Skip to content

Commit 7400516

Browse files
author
Jean Delvare
committed
go7007: Convert to the new i2c device binding model
Move the go7007 driver away from the legacy i2c binding model, which is going away really soon now. The I2C addresses of the audio and video chips in s2250-board didn't look quite right, apparently they were left-aligned values when Linux wants right-aligned values, so I fixed them too. Signed-off-by: Jean Delvare <[email protected]> Cc: Greg Kroah-Hartman <[email protected]>
1 parent a939b96 commit 7400516

File tree

13 files changed

+176
-418
lines changed

13 files changed

+176
-418
lines changed

drivers/staging/go7007/go7007-driver.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ int go7007_reset_encoder(struct go7007 *go)
191191
/*
192192
* Attempt to instantiate an I2C client by ID, probably loading a module.
193193
*/
194-
static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr)
194+
static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
195+
int id, int addr)
195196
{
197+
struct i2c_board_info info;
196198
char *modname;
197199

198200
switch (id) {
@@ -226,7 +228,11 @@ static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr)
226228
}
227229
if (modname != NULL)
228230
request_module(modname);
229-
if (wis_i2c_probe_device(adapter, id, addr) == 1)
231+
232+
memset(&info, 0, sizeof(struct i2c_board_info));
233+
info.addr = addr;
234+
strlcpy(info.type, type, I2C_NAME_SIZE);
235+
if (!i2c_new_device(adapter, &info))
230236
return 0;
231237
if (modname != NULL)
232238
printk(KERN_INFO
@@ -266,6 +272,7 @@ int go7007_register_encoder(struct go7007 *go)
266272
if (go->i2c_adapter_online) {
267273
for (i = 0; i < go->board_info->num_i2c_devs; ++i)
268274
init_i2c_module(&go->i2c_adapter,
275+
go->board_info->i2c_devs[i].type,
269276
go->board_info->i2c_devs[i].id,
270277
go->board_info->i2c_devs[i].addr);
271278
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)

drivers/staging/go7007/go7007-i2c.c

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -31,87 +31,6 @@
3131
#include "go7007-priv.h"
3232
#include "wis-i2c.h"
3333

34-
/************** Registration interface for I2C client drivers **************/
35-
36-
/* Since there's no way to auto-probe the I2C devices connected to the I2C
37-
* bus on the go7007, we have this silly little registration system that
38-
* client drivers can use to register their I2C driver ID and their
39-
* detect_client function (the one that's normally passed to i2c_probe).
40-
*
41-
* When a new go7007 device is connected, we can look up in a board info
42-
* table by the USB or PCI vendor/product/revision ID to determine
43-
* which I2C client module to load. The client driver module will register
44-
* itself here, and then we can call the registered detect_client function
45-
* to force-load a new client at the address listed in the board info table.
46-
*
47-
* Really the I2C subsystem should have a way to force-load I2C client
48-
* drivers when we have a priori knowledge of what's on the bus, especially
49-
* since the existing I2C auto-probe mechanism is so hokey, but we'll use
50-
* our own mechanism for the time being. */
51-
52-
struct wis_i2c_client_driver {
53-
unsigned int id;
54-
found_proc found_proc;
55-
struct list_head list;
56-
};
57-
58-
static LIST_HEAD(i2c_client_drivers);
59-
static DECLARE_MUTEX(i2c_client_driver_list_lock);
60-
61-
/* Client drivers register here by their I2C driver ID */
62-
int wis_i2c_add_driver(unsigned int id, found_proc found_proc)
63-
{
64-
struct wis_i2c_client_driver *driver;
65-
66-
driver = kmalloc(sizeof(struct wis_i2c_client_driver), GFP_KERNEL);
67-
if (driver == NULL)
68-
return -ENOMEM;
69-
driver->id = id;
70-
driver->found_proc = found_proc;
71-
72-
down(&i2c_client_driver_list_lock);
73-
list_add_tail(&driver->list, &i2c_client_drivers);
74-
up(&i2c_client_driver_list_lock);
75-
76-
return 0;
77-
}
78-
EXPORT_SYMBOL(wis_i2c_add_driver);
79-
80-
void wis_i2c_del_driver(found_proc found_proc)
81-
{
82-
struct wis_i2c_client_driver *driver, *next;
83-
84-
down(&i2c_client_driver_list_lock);
85-
list_for_each_entry_safe(driver, next, &i2c_client_drivers, list)
86-
if (driver->found_proc == found_proc) {
87-
list_del(&driver->list);
88-
kfree(driver);
89-
}
90-
up(&i2c_client_driver_list_lock);
91-
}
92-
EXPORT_SYMBOL(wis_i2c_del_driver);
93-
94-
/* The main go7007 driver calls this to instantiate a client by driver
95-
* ID and bus address, which are both stored in the board info table */
96-
int wis_i2c_probe_device(struct i2c_adapter *adapter,
97-
unsigned int id, int addr)
98-
{
99-
struct wis_i2c_client_driver *driver;
100-
int found = 0;
101-
102-
if (addr < 0 || addr > 0x7f)
103-
return -1;
104-
down(&i2c_client_driver_list_lock);
105-
list_for_each_entry(driver, &i2c_client_drivers, list)
106-
if (driver->id == id) {
107-
if (driver->found_proc(adapter, addr, 0) == 0)
108-
found = 1;
109-
break;
110-
}
111-
up(&i2c_client_driver_list_lock);
112-
return found;
113-
}
114-
11534
/********************* Driver for on-board I2C adapter *********************/
11635

11736
/* #define GO7007_I2C_DEBUG */
@@ -287,9 +206,7 @@ static struct i2c_algorithm go7007_algo = {
287206

288207
static struct i2c_adapter go7007_adap_templ = {
289208
.owner = THIS_MODULE,
290-
.class = I2C_CLASS_TV_ANALOG,
291209
.name = "WIS GO7007SB",
292-
.id = I2C_ALGO_GO7007,
293210
.algo = &go7007_algo,
294211
};
295212

drivers/staging/go7007/go7007-priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct go7007_board_info {
8787
int audio_main_div;
8888
int num_i2c_devs;
8989
struct {
90+
const char *type;
9091
int id;
9192
int addr;
9293
} i2c_devs[4];

drivers/staging/go7007/go7007-usb.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static struct go7007_usb_board board_matrix_ii = {
9191
.num_i2c_devs = 1,
9292
.i2c_devs = {
9393
{
94+
.type = "wis_saa7115",
9495
.id = I2C_DRIVERID_WIS_SAA7115,
9596
.addr = 0x20,
9697
},
@@ -127,6 +128,7 @@ static struct go7007_usb_board board_matrix_reload = {
127128
.num_i2c_devs = 1,
128129
.i2c_devs = {
129130
{
131+
.type = "wis_saa7113",
130132
.id = I2C_DRIVERID_WIS_SAA7113,
131133
.addr = 0x25,
132134
},
@@ -164,6 +166,7 @@ static struct go7007_usb_board board_star_trek = {
164166
.num_i2c_devs = 1,
165167
.i2c_devs = {
166168
{
169+
.type = "wis_saa7115",
167170
.id = I2C_DRIVERID_WIS_SAA7115,
168171
.addr = 0x20,
169172
},
@@ -209,14 +212,17 @@ static struct go7007_usb_board board_px_tv402u = {
209212
.num_i2c_devs = 3,
210213
.i2c_devs = {
211214
{
215+
.type = "wis_saa7115",
212216
.id = I2C_DRIVERID_WIS_SAA7115,
213217
.addr = 0x20,
214218
},
215219
{
220+
.type = "wis_uda1342",
216221
.id = I2C_DRIVERID_WIS_UDA1342,
217222
.addr = 0x1a,
218223
},
219224
{
225+
.type = "wis_sony_tuner",
220226
.id = I2C_DRIVERID_WIS_SONY_TUNER,
221227
.addr = 0x60,
222228
},
@@ -264,6 +270,7 @@ static struct go7007_usb_board board_xmen = {
264270
.num_i2c_devs = 1,
265271
.i2c_devs = {
266272
{
273+
.type = "wis_ov7640",
267274
.id = I2C_DRIVERID_WIS_OV7640,
268275
.addr = 0x21,
269276
},
@@ -296,6 +303,7 @@ static struct go7007_usb_board board_matrix_revolution = {
296303
.num_i2c_devs = 1,
297304
.i2c_devs = {
298305
{
306+
.type = "wis_tw9903",
299307
.id = I2C_DRIVERID_WIS_TW9903,
300308
.addr = 0x44,
301309
},
@@ -385,6 +393,7 @@ static struct go7007_usb_board board_adlink_mpg24 = {
385393
.num_i2c_devs = 1,
386394
.i2c_devs = {
387395
{
396+
.type = "wis_twTW2804",
388397
.id = I2C_DRIVERID_WIS_TW2804,
389398
.addr = 0x00, /* yes, really */
390399
},
@@ -415,8 +424,9 @@ static struct go7007_usb_board board_sensoray_2250 = {
415424
.num_i2c_devs = 1,
416425
.i2c_devs = {
417426
{
427+
.type = "s2250_board",
418428
.id = I2C_DRIVERID_S2250,
419-
.addr = 0x34,
429+
.addr = 0x43,
420430
},
421431
},
422432
.num_inputs = 2,
@@ -943,9 +953,7 @@ static struct i2c_algorithm go7007_usb_algo = {
943953

944954
static struct i2c_adapter go7007_usb_adap_templ = {
945955
.owner = THIS_MODULE,
946-
.class = I2C_CLASS_TV_ANALOG,
947956
.name = "WIS GO7007SB EZ-USB",
948-
.id = I2C_ALGO_GO7007_USB,
949957
.algo = &go7007_usb_algo,
950958
};
951959

0 commit comments

Comments
 (0)