Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c865534f authored by Ilia Mirkin's avatar Ilia Mirkin Committed by Ben Skeggs
Browse files

drm/nouveau/i2c: pass the function pointers in at creation time

i2c_bit_add_bus can call the pre_xfer function, which expects the func
pointer to be set. Pass in func to the port creation logic so that it is
set before i2c_bit_add_bus.

See https://bugs.freedesktop.org/show_bug.cgi?id=68456



Reported-by: default avatarHans-Peter Deifel <hpdeifel@gmx.de>
Tested-by: default avatarHans-Peter Deifel <hpdeifel@gmx.de>
Signed-off-by: default avatarIlia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent c4a62a76
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@ struct nouveau_i2c_func {
	int  (*drv_ctl)(struct nouveau_i2c_port *, int lane, int sw, int pe);
};

#define nouveau_i2c_port_create(p,e,o,i,a,d)                                   \
	nouveau_i2c_port_create_((p), (e), (o), (i), (a),                      \
#define nouveau_i2c_port_create(p,e,o,i,a,f,d)                                 \
	nouveau_i2c_port_create_((p), (e), (o), (i), (a), (f),                 \
				 sizeof(**d), (void **)d)
#define nouveau_i2c_port_destroy(p) ({                                         \
	struct nouveau_i2c_port *port = (p);                                   \
@@ -53,7 +53,9 @@ struct nouveau_i2c_func {

int nouveau_i2c_port_create_(struct nouveau_object *, struct nouveau_object *,
			     struct nouveau_oclass *, u8,
			     const struct i2c_algorithm *, int, void **);
			     const struct i2c_algorithm *,
			     const struct nouveau_i2c_func *,
			     int, void **);
void _nouveau_i2c_port_dtor(struct nouveau_object *);
#define _nouveau_i2c_port_init nouveau_object_init
#define _nouveau_i2c_port_fini nouveau_object_fini
+4 −6
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ anx9805_aux_chan_ctor(struct nouveau_object *parent,
	int ret;

	ret = nouveau_i2c_port_create(parent, engine, oclass, index,
				     &nouveau_i2c_aux_algo, &chan);
				      &nouveau_i2c_aux_algo, &anx9805_aux_func,
				      &chan);
	*pobject = nv_object(chan);
	if (ret)
		return ret;
@@ -140,8 +141,6 @@ anx9805_aux_chan_ctor(struct nouveau_object *parent,
		struct i2c_algo_bit_data *algo = mast->adapter.algo_data;
		algo->udelay = max(algo->udelay, 40);
	}

	chan->base.func = &anx9805_aux_func;
	return 0;
}

@@ -234,7 +233,8 @@ anx9805_ddc_port_ctor(struct nouveau_object *parent,
	int ret;

	ret = nouveau_i2c_port_create(parent, engine, oclass, index,
				     &anx9805_i2c_algo, &port);
				      &anx9805_i2c_algo, &anx9805_i2c_func,
				      &port);
	*pobject = nv_object(port);
	if (ret)
		return ret;
@@ -256,8 +256,6 @@ anx9805_ddc_port_ctor(struct nouveau_object *parent,
		struct i2c_algo_bit_data *algo = mast->adapter.algo_data;
		algo->udelay = max(algo->udelay, 40);
	}

	port->base.func = &anx9805_i2c_func;
	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,
			 struct nouveau_object *engine,
			 struct nouveau_oclass *oclass, u8 index,
			 const struct i2c_algorithm *algo,
			 const struct nouveau_i2c_func *func,
			 int size, void **pobject)
{
	struct nouveau_device *device = nv_device(parent);
@@ -112,6 +113,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,
	port->adapter.owner = THIS_MODULE;
	port->adapter.dev.parent = &device->pdev->dev;
	port->index = index;
	port->func = func;
	i2c_set_adapdata(&port->adapter, i2c);

	if ( algo == &nouveau_i2c_bit_algo &&
+2 −2
Original line number Diff line number Diff line
@@ -91,12 +91,12 @@ nv04_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
	int ret;

	ret = nouveau_i2c_port_create(parent, engine, oclass, index,
				     &nouveau_i2c_bit_algo, &port);
				      &nouveau_i2c_bit_algo, &nv04_i2c_func,
				      &port);
	*pobject = nv_object(port);
	if (ret)
		return ret;

	port->base.func = &nv04_i2c_func;
	port->drive = info->drive;
	port->sense = info->sense;
	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -84,12 +84,12 @@ nv4e_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
	int ret;

	ret = nouveau_i2c_port_create(parent, engine, oclass, index,
				     &nouveau_i2c_bit_algo, &port);
				      &nouveau_i2c_bit_algo, &nv4e_i2c_func,
				      &port);
	*pobject = nv_object(port);
	if (ret)
		return ret;

	port->base.func = &nv4e_i2c_func;
	port->addr = 0x600800 + info->drive;
	return 0;
}
Loading