Skip to content

Commit c865534

Browse files
imirkinBen Skeggs
authored andcommitted
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: Hans-Peter Deifel <[email protected]> Tested-by: Hans-Peter Deifel <[email protected]> Signed-off-by: Ilia Mirkin <[email protected]> Signed-off-by: Ben Skeggs <[email protected]>
1 parent c4a62a7 commit c865534

File tree

8 files changed

+23
-21
lines changed

8 files changed

+23
-21
lines changed

drivers/gpu/drm/nouveau/core/include/subdev/i2c.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ struct nouveau_i2c_func {
3939
int (*drv_ctl)(struct nouveau_i2c_port *, int lane, int sw, int pe);
4040
};
4141

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

5454
int nouveau_i2c_port_create_(struct nouveau_object *, struct nouveau_object *,
5555
struct nouveau_oclass *, u8,
56-
const struct i2c_algorithm *, int, void **);
56+
const struct i2c_algorithm *,
57+
const struct nouveau_i2c_func *,
58+
int, void **);
5759
void _nouveau_i2c_port_dtor(struct nouveau_object *);
5860
#define _nouveau_i2c_port_init nouveau_object_init
5961
#define _nouveau_i2c_port_fini nouveau_object_fini

drivers/gpu/drm/nouveau/core/subdev/i2c/anx9805.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ anx9805_aux_chan_ctor(struct nouveau_object *parent,
118118
int ret;
119119

120120
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
121-
&nouveau_i2c_aux_algo, &chan);
121+
&nouveau_i2c_aux_algo, &anx9805_aux_func,
122+
&chan);
122123
*pobject = nv_object(chan);
123124
if (ret)
124125
return ret;
@@ -140,8 +141,6 @@ anx9805_aux_chan_ctor(struct nouveau_object *parent,
140141
struct i2c_algo_bit_data *algo = mast->adapter.algo_data;
141142
algo->udelay = max(algo->udelay, 40);
142143
}
143-
144-
chan->base.func = &anx9805_aux_func;
145144
return 0;
146145
}
147146

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

236235
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
237-
&anx9805_i2c_algo, &port);
236+
&anx9805_i2c_algo, &anx9805_i2c_func,
237+
&port);
238238
*pobject = nv_object(port);
239239
if (ret)
240240
return ret;
@@ -256,8 +256,6 @@ anx9805_ddc_port_ctor(struct nouveau_object *parent,
256256
struct i2c_algo_bit_data *algo = mast->adapter.algo_data;
257257
algo->udelay = max(algo->udelay, 40);
258258
}
259-
260-
port->base.func = &anx9805_i2c_func;
261259
return 0;
262260
}
263261

drivers/gpu/drm/nouveau/core/subdev/i2c/base.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,
9595
struct nouveau_object *engine,
9696
struct nouveau_oclass *oclass, u8 index,
9797
const struct i2c_algorithm *algo,
98+
const struct nouveau_i2c_func *func,
9899
int size, void **pobject)
99100
{
100101
struct nouveau_device *device = nv_device(parent);
@@ -112,6 +113,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,
112113
port->adapter.owner = THIS_MODULE;
113114
port->adapter.dev.parent = &device->pdev->dev;
114115
port->index = index;
116+
port->func = func;
115117
i2c_set_adapdata(&port->adapter, i2c);
116118

117119
if ( algo == &nouveau_i2c_bit_algo &&

drivers/gpu/drm/nouveau/core/subdev/i2c/nv04.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ nv04_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
9191
int ret;
9292

9393
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
94-
&nouveau_i2c_bit_algo, &port);
94+
&nouveau_i2c_bit_algo, &nv04_i2c_func,
95+
&port);
9596
*pobject = nv_object(port);
9697
if (ret)
9798
return ret;
9899

99-
port->base.func = &nv04_i2c_func;
100100
port->drive = info->drive;
101101
port->sense = info->sense;
102102
return 0;

drivers/gpu/drm/nouveau/core/subdev/i2c/nv4e.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ nv4e_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
8484
int ret;
8585

8686
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
87-
&nouveau_i2c_bit_algo, &port);
87+
&nouveau_i2c_bit_algo, &nv4e_i2c_func,
88+
&port);
8889
*pobject = nv_object(port);
8990
if (ret)
9091
return ret;
9192

92-
port->base.func = &nv4e_i2c_func;
9393
port->addr = 0x600800 + info->drive;
9494
return 0;
9595
}

drivers/gpu/drm/nouveau/core/subdev/i2c/nv50.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ nv50_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
8585
int ret;
8686

8787
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
88-
&nouveau_i2c_bit_algo, &port);
88+
&nouveau_i2c_bit_algo, &nv50_i2c_func,
89+
&port);
8990
*pobject = nv_object(port);
9091
if (ret)
9192
return ret;
9293

9394
if (info->drive >= nv50_i2c_addr_nr)
9495
return -EINVAL;
9596

96-
port->base.func = &nv50_i2c_func;
9797
port->state = 0x00000007;
9898
port->addr = nv50_i2c_addr[info->drive];
9999
return 0;

drivers/gpu/drm/nouveau/core/subdev/i2c/nv94.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ nv94_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
186186
int ret;
187187

188188
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
189-
&nouveau_i2c_bit_algo, &port);
189+
&nouveau_i2c_bit_algo, &nv94_i2c_func,
190+
&port);
190191
*pobject = nv_object(port);
191192
if (ret)
192193
return ret;
193194

194195
if (info->drive >= nv50_i2c_addr_nr)
195196
return -EINVAL;
196197

197-
port->base.func = &nv94_i2c_func;
198198
port->state = 7;
199199
port->addr = nv50_i2c_addr[info->drive];
200200
if (info->share != DCB_I2C_UNUSED) {
@@ -221,12 +221,12 @@ nv94_aux_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
221221
int ret;
222222

223223
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
224-
&nouveau_i2c_aux_algo, &port);
224+
&nouveau_i2c_aux_algo, &nv94_aux_func,
225+
&port);
225226
*pobject = nv_object(port);
226227
if (ret)
227228
return ret;
228229

229-
port->base.func = &nv94_aux_func;
230230
port->addr = info->drive;
231231
if (info->share != DCB_I2C_UNUSED) {
232232
port->ctrl = 0x00e500 + (info->drive * 0x50);

drivers/gpu/drm/nouveau/core/subdev/i2c/nvd0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ nvd0_i2c_port_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
6060
int ret;
6161

6262
ret = nouveau_i2c_port_create(parent, engine, oclass, index,
63-
&nouveau_i2c_bit_algo, &port);
63+
&nouveau_i2c_bit_algo, &nvd0_i2c_func,
64+
&port);
6465
*pobject = nv_object(port);
6566
if (ret)
6667
return ret;
6768

68-
port->base.func = &nvd0_i2c_func;
6969
port->state = 0x00000007;
7070
port->addr = 0x00d014 + (info->drive * 0x20);
7171
if (info->share != DCB_I2C_UNUSED) {

0 commit comments

Comments
 (0)