Commit 7400516ab40d8fe55031dc8d614e2b365bd95f1c

Authored by Jean Delvare
1 parent a939b96ccc

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 <khali@linux-fr.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>

Showing 13 changed files with 176 additions and 418 deletions Side-by-side Diff

drivers/staging/go7007/go7007-driver.c
... ... @@ -191,8 +191,10 @@
191 191 /*
192 192 * Attempt to instantiate an I2C client by ID, probably loading a module.
193 193 */
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)
195 196 {
  197 + struct i2c_board_info info;
196 198 char *modname;
197 199  
198 200 switch (id) {
... ... @@ -226,7 +228,11 @@
226 228 }
227 229 if (modname != NULL)
228 230 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))
230 236 return 0;
231 237 if (modname != NULL)
232 238 printk(KERN_INFO
... ... @@ -266,6 +272,7 @@
266 272 if (go->i2c_adapter_online) {
267 273 for (i = 0; i < go->board_info->num_i2c_devs; ++i)
268 274 init_i2c_module(&go->i2c_adapter,
  275 + go->board_info->i2c_devs[i].type,
269 276 go->board_info->i2c_devs[i].id,
270 277 go->board_info->i2c_devs[i].addr);
271 278 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
drivers/staging/go7007/go7007-i2c.c
... ... @@ -31,87 +31,6 @@
31 31 #include "go7007-priv.h"
32 32 #include "wis-i2c.h"
33 33  
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   -
115 34 /********************* Driver for on-board I2C adapter *********************/
116 35  
117 36 /* #define GO7007_I2C_DEBUG */
118 37  
... ... @@ -287,9 +206,7 @@
287 206  
288 207 static struct i2c_adapter go7007_adap_templ = {
289 208 .owner = THIS_MODULE,
290   - .class = I2C_CLASS_TV_ANALOG,
291 209 .name = "WIS GO7007SB",
292   - .id = I2C_ALGO_GO7007,
293 210 .algo = &go7007_algo,
294 211 };
295 212  
drivers/staging/go7007/go7007-priv.h
... ... @@ -87,6 +87,7 @@
87 87 int audio_main_div;
88 88 int num_i2c_devs;
89 89 struct {
  90 + const char *type;
90 91 int id;
91 92 int addr;
92 93 } i2c_devs[4];
drivers/staging/go7007/go7007-usb.c
... ... @@ -91,6 +91,7 @@
91 91 .num_i2c_devs = 1,
92 92 .i2c_devs = {
93 93 {
  94 + .type = "wis_saa7115",
94 95 .id = I2C_DRIVERID_WIS_SAA7115,
95 96 .addr = 0x20,
96 97 },
... ... @@ -127,6 +128,7 @@
127 128 .num_i2c_devs = 1,
128 129 .i2c_devs = {
129 130 {
  131 + .type = "wis_saa7113",
130 132 .id = I2C_DRIVERID_WIS_SAA7113,
131 133 .addr = 0x25,
132 134 },
... ... @@ -164,6 +166,7 @@
164 166 .num_i2c_devs = 1,
165 167 .i2c_devs = {
166 168 {
  169 + .type = "wis_saa7115",
167 170 .id = I2C_DRIVERID_WIS_SAA7115,
168 171 .addr = 0x20,
169 172 },
170 173  
171 174  
... ... @@ -209,14 +212,17 @@
209 212 .num_i2c_devs = 3,
210 213 .i2c_devs = {
211 214 {
  215 + .type = "wis_saa7115",
212 216 .id = I2C_DRIVERID_WIS_SAA7115,
213 217 .addr = 0x20,
214 218 },
215 219 {
  220 + .type = "wis_uda1342",
216 221 .id = I2C_DRIVERID_WIS_UDA1342,
217 222 .addr = 0x1a,
218 223 },
219 224 {
  225 + .type = "wis_sony_tuner",
220 226 .id = I2C_DRIVERID_WIS_SONY_TUNER,
221 227 .addr = 0x60,
222 228 },
... ... @@ -264,6 +270,7 @@
264 270 .num_i2c_devs = 1,
265 271 .i2c_devs = {
266 272 {
  273 + .type = "wis_ov7640",
267 274 .id = I2C_DRIVERID_WIS_OV7640,
268 275 .addr = 0x21,
269 276 },
... ... @@ -296,6 +303,7 @@
296 303 .num_i2c_devs = 1,
297 304 .i2c_devs = {
298 305 {
  306 + .type = "wis_tw9903",
299 307 .id = I2C_DRIVERID_WIS_TW9903,
300 308 .addr = 0x44,
301 309 },
... ... @@ -385,6 +393,7 @@
385 393 .num_i2c_devs = 1,
386 394 .i2c_devs = {
387 395 {
  396 + .type = "wis_twTW2804",
388 397 .id = I2C_DRIVERID_WIS_TW2804,
389 398 .addr = 0x00, /* yes, really */
390 399 },
391 400  
... ... @@ -415,8 +424,9 @@
415 424 .num_i2c_devs = 1,
416 425 .i2c_devs = {
417 426 {
  427 + .type = "s2250_board",
418 428 .id = I2C_DRIVERID_S2250,
419   - .addr = 0x34,
  429 + .addr = 0x43,
420 430 },
421 431 },
422 432 .num_inputs = 2,
423 433  
... ... @@ -943,9 +953,7 @@
943 953  
944 954 static struct i2c_adapter go7007_usb_adap_templ = {
945 955 .owner = THIS_MODULE,
946   - .class = I2C_CLASS_TV_ANALOG,
947 956 .name = "WIS GO7007SB EZ-USB",
948   - .id = I2C_ALGO_GO7007_USB,
949 957 .algo = &go7007_usb_algo,
950 958 };
951 959  
drivers/staging/go7007/s2250-board.c
... ... @@ -28,7 +28,6 @@
28 28 extern void s2250loader_cleanup(void);
29 29  
30 30 #define TLV320_ADDRESS 0x34
31   -#define S2250_VIDDEC 0x86
32 31 #define VPX322_ADDR_ANALOGCONTROL1 0x02
33 32 #define VPX322_ADDR_BRIGHTNESS0 0x0127
34 33 #define VPX322_ADDR_BRIGHTNESS1 0x0131
... ... @@ -123,6 +122,7 @@
123 122 int hue;
124 123 int reg12b_val;
125 124 int audio_input;
  125 + struct i2c_client *audio;
126 126 };
127 127  
128 128 /* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/
129 129  
130 130  
131 131  
... ... @@ -452,16 +452,15 @@
452 452 {
453 453 struct v4l2_audio *audio = arg;
454 454  
455   - client->addr = TLV320_ADDRESS;
456 455 switch (audio->index) {
457 456 case 0:
458   - write_reg(client, 0x08, 0x02); /* Line In */
  457 + write_reg(dec->audio, 0x08, 0x02); /* Line In */
459 458 break;
460 459 case 1:
461   - write_reg(client, 0x08, 0x04); /* Mic */
  460 + write_reg(dec->audio, 0x08, 0x04); /* Mic */
462 461 break;
463 462 case 2:
464   - write_reg(client, 0x08, 0x05); /* Mic Boost */
  463 + write_reg(dec->audio, 0x08, 0x05); /* Mic Boost */
465 464 break;
466 465 default:
467 466 return -EINVAL;
468 467  
469 468  
470 469  
471 470  
... ... @@ -477,31 +476,23 @@
477 476 return 0;
478 477 }
479 478  
480   -static struct i2c_driver s2250_driver;
481   -
482   -static struct i2c_client s2250_client_templ = {
483   - .name = "Sensoray 2250",
484   - .driver = &s2250_driver,
485   -};
486   -
487   -static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind)
  479 +static int s2250_probe(struct i2c_client *client,
  480 + const struct i2c_device_id *id)
488 481 {
489   - struct i2c_client *client;
  482 + struct i2c_client *audio;
  483 + struct i2c_adapter *adapter = client->adapter;
490 484 struct s2250 *dec;
491 485 u8 *data;
492 486 struct go7007 *go = i2c_get_adapdata(adapter);
493 487 struct go7007_usb *usb = go->hpi_context;
494 488  
495   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
496   - if (client == NULL)
  489 + audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1);
  490 + if (audio == NULL)
497 491 return -ENOMEM;
498   - memcpy(client, &s2250_client_templ,
499   - sizeof(s2250_client_templ));
500   - client->adapter = adapter;
501 492  
502 493 dec = kmalloc(sizeof(struct s2250), GFP_KERNEL);
503 494 if (dec == NULL) {
504   - kfree(client);
  495 + i2c_unregister_device(audio);
505 496 return -ENOMEM;
506 497 }
507 498  
... ... @@ -510,7 +501,7 @@
510 501 dec->contrast = 50;
511 502 dec->saturation = 50;
512 503 dec->hue = 0;
513   - client->addr = TLV320_ADDRESS;
  504 + dec->audio = audio;
514 505 i2c_set_clientdata(client, dec);
515 506  
516 507 printk(KERN_DEBUG
517 508  
518 509  
519 510  
520 511  
... ... @@ -518,28 +509,25 @@
518 509 adapter->name);
519 510  
520 511 /* initialize the audio */
521   - client->addr = TLV320_ADDRESS;
522   - if (write_regs(client, aud_regs) < 0) {
  512 + if (write_regs(audio, aud_regs) < 0) {
523 513 printk(KERN_ERR
524 514 "s2250: error initializing audio\n");
525   - kfree(client);
  515 + i2c_unregister_device(audio);
526 516 kfree(dec);
527 517 return 0;
528 518 }
529   - client->addr = S2250_VIDDEC;
530   - i2c_set_clientdata(client, dec);
531 519  
532 520 if (write_regs(client, vid_regs) < 0) {
533 521 printk(KERN_ERR
534 522 "s2250: error initializing decoder\n");
535   - kfree(client);
  523 + i2c_unregister_device(audio);
536 524 kfree(dec);
537 525 return 0;
538 526 }
539 527 if (write_regs_fp(client, vid_regs_fp) < 0) {
540 528 printk(KERN_ERR
541 529 "s2250: error initializing decoder\n");
542   - kfree(client);
  530 + i2c_unregister_device(audio);
543 531 kfree(dec);
544 532 return 0;
545 533 }
546 534  
547 535  
548 536  
549 537  
550 538  
551 539  
... ... @@ -575,32 +563,33 @@
575 563 up(&usb->i2c_lock);
576 564 }
577 565  
578   - i2c_attach_client(client);
579 566 printk("s2250: initialized successfully\n");
580 567 return 0;
581 568 }
582 569  
583   -static int s2250_detach(struct i2c_client *client)
  570 +static int s2250_remove(struct i2c_client *client)
584 571 {
585 572 struct s2250 *dec = i2c_get_clientdata(client);
586   - int r;
587 573  
588   - r = i2c_detach_client(client);
589   - if (r < 0)
590   - return r;
591   -
592   - kfree(client);
  574 + i2c_set_clientdata(client, NULL);
  575 + i2c_unregister_device(dec->audio);
593 576 kfree(dec);
594 577 return 0;
595 578 }
596 579  
  580 +static struct i2c_device_id s2250_id[] = {
  581 + { "s2250_board", 0 },
  582 + { }
  583 +};
  584 +
597 585 static struct i2c_driver s2250_driver = {
598 586 .driver = {
599 587 .name = "Sensoray 2250 board driver",
600 588 },
601   - .id = I2C_DRIVERID_S2250,
602   - .detach_client = s2250_detach,
  589 + .probe = s2250_probe,
  590 + .remove = s2250_remove,
603 591 .command = s2250_command,
  592 + .id_table = s2250_id,
604 593 };
605 594  
606 595 static int __init s2250_init(void)
607 596  
... ... @@ -613,13 +602,13 @@
613 602  
614 603 r = i2c_add_driver(&s2250_driver);
615 604 if (r < 0)
616   - return r;
617   - return wis_i2c_add_driver(s2250_driver.id, s2250_detect);
  605 + s2250loader_cleanup();
  606 +
  607 + return r;
618 608 }
619 609  
620 610 static void __exit s2250_cleanup(void)
621 611 {
622   - wis_i2c_del_driver(s2250_detect);
623 612 i2c_del_driver(&s2250_driver);
624 613  
625 614 s2250loader_cleanup();
drivers/staging/go7007/wis-i2c.h
... ... @@ -24,20 +24,11 @@
24 24 #define I2C_DRIVERID_WIS_OV7640 0xf0f5
25 25 #define I2C_DRIVERID_WIS_TW2804 0xf0f6
26 26 #define I2C_DRIVERID_S2250 0xf0f7
27   -#define I2C_ALGO_GO7007 0xf00000
28   -#define I2C_ALGO_GO7007_USB 0xf10000
29 27  
30 28 /* Flag to indicate that the client needs to be accessed with SCCB semantics */
31 29 /* We re-use the I2C_M_TEN value so the flag passes through the masks in the
32 30 * core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */
33 31 #define I2C_CLIENT_SCCB 0x10
34   -
35   -typedef int (*found_proc) (struct i2c_adapter *, int, int);
36   -int wis_i2c_add_driver(unsigned int id, found_proc found_proc);
37   -void wis_i2c_del_driver(found_proc found_proc);
38   -
39   -int wis_i2c_probe_device(struct i2c_adapter *adapter,
40   - unsigned int id, int addr);
41 32  
42 33 /* Definitions for new video decoder commands */
43 34  
drivers/staging/go7007/wis-ov7640.c
... ... @@ -50,76 +50,54 @@
50 50 return 0;
51 51 }
52 52  
53   -static struct i2c_driver wis_ov7640_driver;
54   -
55   -static struct i2c_client wis_ov7640_client_templ = {
56   - .name = "OV7640 (WIS)",
57   - .driver = &wis_ov7640_driver,
58   -};
59   -
60   -static int wis_ov7640_detect(struct i2c_adapter *adapter, int addr, int kind)
  53 +static int wis_ov7640_probe(struct i2c_client *client,
  54 + const struct i2c_device_id *id)
61 55 {
62   - struct i2c_client *client;
  56 + struct i2c_adapter *adapter = client->adapter;
63 57  
64 58 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
65   - return 0;
  59 + return -ENODEV;
66 60  
67   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
68   - if (client == NULL)
69   - return -ENOMEM;
70   - memcpy(client, &wis_ov7640_client_templ,
71   - sizeof(wis_ov7640_client_templ));
72   - client->adapter = adapter;
73   - client->addr = addr;
74 61 client->flags = I2C_CLIENT_SCCB;
75 62  
76 63 printk(KERN_DEBUG
77 64 "wis-ov7640: initializing OV7640 at address %d on %s\n",
78   - addr, adapter->name);
  65 + client->addr, adapter->name);
79 66  
80 67 if (write_regs(client, initial_registers) < 0) {
81 68 printk(KERN_ERR "wis-ov7640: error initializing OV7640\n");
82   - kfree(client);
83   - return 0;
  69 + return -ENODEV;
84 70 }
85 71  
86   - i2c_attach_client(client);
87 72 return 0;
88 73 }
89 74  
90   -static int wis_ov7640_detach(struct i2c_client *client)
  75 +static int wis_ov7640_remove(struct i2c_client *client)
91 76 {
92   - int r;
93   -
94   - r = i2c_detach_client(client);
95   - if (r < 0)
96   - return r;
97   -
98   - kfree(client);
99 77 return 0;
100 78 }
101 79  
  80 +static struct i2c_device_id wis_ov7640_id[] = {
  81 + { "wis_ov7640", 0 },
  82 + { }
  83 +};
  84 +
102 85 static struct i2c_driver wis_ov7640_driver = {
103 86 .driver = {
104 87 .name = "WIS OV7640 I2C driver",
105 88 },
106   - .id = I2C_DRIVERID_WIS_OV7640,
107   - .detach_client = wis_ov7640_detach,
  89 + .probe = wis_ov7640_probe,
  90 + .remove = wis_ov7640_remove,
  91 + .id_table = wis_ov7640_id,
108 92 };
109 93  
110 94 static int __init wis_ov7640_init(void)
111 95 {
112   - int r;
113   -
114   - r = i2c_add_driver(&wis_ov7640_driver);
115   - if (r < 0)
116   - return r;
117   - return wis_i2c_add_driver(wis_ov7640_driver.id, wis_ov7640_detect);
  96 + return i2c_add_driver(&wis_ov7640_driver);
118 97 }
119 98  
120 99 static void __exit wis_ov7640_cleanup(void)
121 100 {
122   - wis_i2c_del_driver(wis_ov7640_detect);
123 101 i2c_del_driver(&wis_ov7640_driver);
124 102 }
125 103  
drivers/staging/go7007/wis-saa7113.c
... ... @@ -261,34 +261,19 @@
261 261 return 0;
262 262 }
263 263  
264   -static struct i2c_driver wis_saa7113_driver;
265   -
266   -static struct i2c_client wis_saa7113_client_templ = {
267   - .name = "SAA7113 (WIS)",
268   - .driver = &wis_saa7113_driver,
269   -};
270   -
271   -static int wis_saa7113_detect(struct i2c_adapter *adapter, int addr, int kind)
  264 +static int wis_saa7113_probe(struct i2c_client *client,
  265 + const struct i2c_device_id *id)
272 266 {
273   - struct i2c_client *client;
  267 + struct i2c_adapter *adapter = client->adapter;
274 268 struct wis_saa7113 *dec;
275 269  
276 270 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
277   - return 0;
  271 + return -ENODEV;
278 272  
279   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
280   - if (client == NULL)
281   - return -ENOMEM;
282   - memcpy(client, &wis_saa7113_client_templ,
283   - sizeof(wis_saa7113_client_templ));
284   - client->adapter = adapter;
285   - client->addr = addr;
286   -
287 273 dec = kmalloc(sizeof(struct wis_saa7113), GFP_KERNEL);
288   - if (dec == NULL) {
289   - kfree(client);
  274 + if (dec == NULL)
290 275 return -ENOMEM;
291   - }
  276 +
292 277 dec->norm = V4L2_STD_NTSC;
293 278 dec->brightness = 128;
294 279 dec->contrast = 71;
295 280  
296 281  
297 282  
298 283  
299 284  
300 285  
301 286  
302 287  
303 288  
304 289  
305 290  
... ... @@ -298,56 +283,49 @@
298 283  
299 284 printk(KERN_DEBUG
300 285 "wis-saa7113: initializing SAA7113 at address %d on %s\n",
301   - addr, adapter->name);
  286 + client->addr, adapter->name);
302 287  
303 288 if (write_regs(client, initial_registers) < 0) {
304 289 printk(KERN_ERR
305 290 "wis-saa7113: error initializing SAA7113\n");
306   - kfree(client);
307 291 kfree(dec);
308   - return 0;
  292 + return -ENODEV;
309 293 }
310 294  
311   - i2c_attach_client(client);
312 295 return 0;
313 296 }
314 297  
315   -static int wis_saa7113_detach(struct i2c_client *client)
  298 +static int wis_saa7113_remove(struct i2c_client *client)
316 299 {
317 300 struct wis_saa7113 *dec = i2c_get_clientdata(client);
318   - int r;
319 301  
320   - r = i2c_detach_client(client);
321   - if (r < 0)
322   - return r;
323   -
324   - kfree(client);
  302 + i2c_set_clientdata(client, NULL);
325 303 kfree(dec);
326 304 return 0;
327 305 }
328 306  
  307 +static struct i2c_device_id wis_saa7113_id[] = {
  308 + { "wis_saa7113", 0 },
  309 + { }
  310 +};
  311 +
329 312 static struct i2c_driver wis_saa7113_driver = {
330 313 .driver = {
331 314 .name = "WIS SAA7113 I2C driver",
332 315 },
333   - .id = I2C_DRIVERID_WIS_SAA7113,
334   - .detach_client = wis_saa7113_detach,
  316 + .probe = wis_saa7113_probe,
  317 + .remove = wis_saa7113_remove,
335 318 .command = wis_saa7113_command,
  319 + .id_table = wis_saa7113_id,
336 320 };
337 321  
338 322 static int __init wis_saa7113_init(void)
339 323 {
340   - int r;
341   -
342   - r = i2c_add_driver(&wis_saa7113_driver);
343   - if (r < 0)
344   - return r;
345   - return wis_i2c_add_driver(wis_saa7113_driver.id, wis_saa7113_detect);
  324 + return i2c_add_driver(&wis_saa7113_driver);
346 325 }
347 326  
348 327 static void __exit wis_saa7113_cleanup(void)
349 328 {
350   - wis_i2c_del_driver(wis_saa7113_detect);
351 329 i2c_del_driver(&wis_saa7113_driver);
352 330 }
353 331  
drivers/staging/go7007/wis-saa7115.c
... ... @@ -394,34 +394,19 @@
394 394 return 0;
395 395 }
396 396  
397   -static struct i2c_driver wis_saa7115_driver;
398   -
399   -static struct i2c_client wis_saa7115_client_templ = {
400   - .name = "SAA7115 (WIS)",
401   - .driver = &wis_saa7115_driver,
402   -};
403   -
404   -static int wis_saa7115_detect(struct i2c_adapter *adapter, int addr, int kind)
  397 +static int wis_saa7115_probe(struct i2c_client *client,
  398 + const struct i2c_device_id *id)
405 399 {
406   - struct i2c_client *client;
  400 + struct i2c_adapter *adapter = client->adapter;
407 401 struct wis_saa7115 *dec;
408 402  
409 403 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
410   - return 0;
  404 + return -ENODEV;
411 405  
412   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
413   - if (client == NULL)
414   - return -ENOMEM;
415   - memcpy(client, &wis_saa7115_client_templ,
416   - sizeof(wis_saa7115_client_templ));
417   - client->adapter = adapter;
418   - client->addr = addr;
419   -
420 406 dec = kmalloc(sizeof(struct wis_saa7115), GFP_KERNEL);
421   - if (dec == NULL) {
422   - kfree(client);
  407 + if (dec == NULL)
423 408 return -ENOMEM;
424   - }
  409 +
425 410 dec->norm = V4L2_STD_NTSC;
426 411 dec->brightness = 128;
427 412 dec->contrast = 64;
428 413  
429 414  
430 415  
431 416  
432 417  
433 418  
434 419  
435 420  
436 421  
437 422  
438 423  
... ... @@ -431,56 +416,49 @@
431 416  
432 417 printk(KERN_DEBUG
433 418 "wis-saa7115: initializing SAA7115 at address %d on %s\n",
434   - addr, adapter->name);
  419 + client->addr, adapter->name);
435 420  
436 421 if (write_regs(client, initial_registers) < 0) {
437 422 printk(KERN_ERR
438 423 "wis-saa7115: error initializing SAA7115\n");
439   - kfree(client);
440 424 kfree(dec);
441   - return 0;
  425 + return -ENODEV;
442 426 }
443 427  
444   - i2c_attach_client(client);
445 428 return 0;
446 429 }
447 430  
448   -static int wis_saa7115_detach(struct i2c_client *client)
  431 +static int wis_saa7115_remove(struct i2c_client *client)
449 432 {
450 433 struct wis_saa7115 *dec = i2c_get_clientdata(client);
451   - int r;
452 434  
453   - r = i2c_detach_client(client);
454   - if (r < 0)
455   - return r;
456   -
457   - kfree(client);
  435 + i2c_set_clientdata(client, NULL);
458 436 kfree(dec);
459 437 return 0;
460 438 }
461 439  
  440 +static struct i2c_device_id wis_saa7115_id[] = {
  441 + { "wis_saa7115", 0 },
  442 + { }
  443 +};
  444 +
462 445 static struct i2c_driver wis_saa7115_driver = {
463 446 .driver = {
464 447 .name = "WIS SAA7115 I2C driver",
465 448 },
466   - .id = I2C_DRIVERID_WIS_SAA7115,
467   - .detach_client = wis_saa7115_detach,
  449 + .probe = wis_saa7115_probe,
  450 + .remove = wis_saa7115_remove,
468 451 .command = wis_saa7115_command,
  452 + .id_table = wis_saa7115_id,
469 453 };
470 454  
471 455 static int __init wis_saa7115_init(void)
472 456 {
473   - int r;
474   -
475   - r = i2c_add_driver(&wis_saa7115_driver);
476   - if (r < 0)
477   - return r;
478   - return wis_i2c_add_driver(wis_saa7115_driver.id, wis_saa7115_detect);
  457 + return i2c_add_driver(&wis_saa7115_driver);
479 458 }
480 459  
481 460 static void __exit wis_saa7115_cleanup(void)
482 461 {
483   - wis_i2c_del_driver(wis_saa7115_detect);
484 462 i2c_del_driver(&wis_saa7115_driver);
485 463 }
486 464  
drivers/staging/go7007/wis-sony-tuner.c
... ... @@ -653,35 +653,19 @@
653 653 return 0;
654 654 }
655 655  
656   -static struct i2c_driver wis_sony_tuner_driver;
657   -
658   -static struct i2c_client wis_sony_tuner_client_templ = {
659   - .name = "Sony TV Tuner (WIS)",
660   - .driver = &wis_sony_tuner_driver,
661   -};
662   -
663   -static int wis_sony_tuner_detect(struct i2c_adapter *adapter,
664   - int addr, int kind)
  656 +static int wis_sony_tuner_probe(struct i2c_client *client,
  657 + const struct i2c_device_id *id)
665 658 {
666   - struct i2c_client *client;
  659 + struct i2c_adapter *adapter = client->adapter;
667 660 struct wis_sony_tuner *t;
668 661  
669 662 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
670   - return 0;
  663 + return -ENODEV;
671 664  
672   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
673   - if (client == NULL)
674   - return -ENOMEM;
675   - memcpy(client, &wis_sony_tuner_client_templ,
676   - sizeof(wis_sony_tuner_client_templ));
677   - client->adapter = adapter;
678   - client->addr = addr;
679   -
680 665 t = kmalloc(sizeof(struct wis_sony_tuner), GFP_KERNEL);
681   - if (t == NULL) {
682   - kfree(client);
  666 + if (t == NULL)
683 667 return -ENOMEM;
684   - }
  668 +
685 669 t->type = -1;
686 670 t->freq = 0;
687 671 t->mpxmode = 0;
688 672  
689 673  
690 674  
691 675  
692 676  
693 677  
694 678  
695 679  
696 680  
697 681  
... ... @@ -690,50 +674,42 @@
690 674  
691 675 printk(KERN_DEBUG
692 676 "wis-sony-tuner: initializing tuner at address %d on %s\n",
693   - addr, adapter->name);
  677 + client->addr, adapter->name);
694 678  
695   - i2c_attach_client(client);
696   -
697 679 return 0;
698 680 }
699 681  
700   -static int wis_sony_tuner_detach(struct i2c_client *client)
  682 +static int wis_sony_tuner_remove(struct i2c_client *client)
701 683 {
702 684 struct wis_sony_tuner *t = i2c_get_clientdata(client);
703   - int r;
704 685  
705   - r = i2c_detach_client(client);
706   - if (r < 0)
707   - return r;
708   -
  686 + i2c_set_clientdata(client, NULL);
709 687 kfree(t);
710   - kfree(client);
711 688 return 0;
712 689 }
713 690  
  691 +static struct i2c_device_id wis_sony_tuner_id[] = {
  692 + { "wis_sony_tuner", 0 },
  693 + { }
  694 +};
  695 +
714 696 static struct i2c_driver wis_sony_tuner_driver = {
715 697 .driver = {
716 698 .name = "WIS Sony TV Tuner I2C driver",
717 699 },
718   - .id = I2C_DRIVERID_WIS_SONY_TUNER,
719   - .detach_client = wis_sony_tuner_detach,
  700 + .probe = wis_sony_tuner_probe,
  701 + .remove = wis_sony_tuner_remove,
720 702 .command = tuner_command,
  703 + .id_table = wis_sony_tuner_id,
721 704 };
722 705  
723 706 static int __init wis_sony_tuner_init(void)
724 707 {
725   - int r;
726   -
727   - r = i2c_add_driver(&wis_sony_tuner_driver);
728   - if (r < 0)
729   - return r;
730   - return wis_i2c_add_driver(wis_sony_tuner_driver.id,
731   - wis_sony_tuner_detect);
  708 + return i2c_add_driver(&wis_sony_tuner_driver);
732 709 }
733 710  
734 711 static void __exit wis_sony_tuner_cleanup(void)
735 712 {
736   - wis_i2c_del_driver(wis_sony_tuner_detect);
737 713 i2c_del_driver(&wis_sony_tuner_driver);
738 714 }
739 715  
drivers/staging/go7007/wis-tw2804.c
... ... @@ -291,34 +291,19 @@
291 291 return 0;
292 292 }
293 293  
294   -static struct i2c_driver wis_tw2804_driver;
295   -
296   -static struct i2c_client wis_tw2804_client_templ = {
297   - .name = "TW2804 (WIS)",
298   - .driver = &wis_tw2804_driver,
299   -};
300   -
301   -static int wis_tw2804_detect(struct i2c_adapter *adapter, int addr, int kind)
  294 +static int wis_tw2804_probe(struct i2c_client *client,
  295 + const struct i2c_device_id *id)
302 296 {
303   - struct i2c_client *client;
  297 + struct i2c_adapter *adapter = client->adapter;
304 298 struct wis_tw2804 *dec;
305 299  
306 300 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
307   - return 0;
  301 + return -ENODEV;
308 302  
309   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
310   - if (client == NULL)
311   - return -ENOMEM;
312   - memcpy(client, &wis_tw2804_client_templ,
313   - sizeof(wis_tw2804_client_templ));
314   - client->adapter = adapter;
315   - client->addr = addr;
316   -
317 303 dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL);
318   - if (dec == NULL) {
319   - kfree(client);
  304 + if (dec == NULL)
320 305 return -ENOMEM;
321   - }
  306 +
322 307 dec->channel = -1;
323 308 dec->norm = V4L2_STD_NTSC;
324 309 dec->brightness = 128;
325 310  
326 311  
327 312  
328 313  
329 314  
330 315  
331 316  
332 317  
333 318  
... ... @@ -328,48 +313,42 @@
328 313 i2c_set_clientdata(client, dec);
329 314  
330 315 printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n",
331   - addr, adapter->name);
  316 + client->addr, adapter->name);
332 317  
333   - i2c_attach_client(client);
334 318 return 0;
335 319 }
336 320  
337   -static int wis_tw2804_detach(struct i2c_client *client)
  321 +static int wis_tw2804_remove(struct i2c_client *client)
338 322 {
339 323 struct wis_tw2804 *dec = i2c_get_clientdata(client);
340   - int r;
341 324  
342   - r = i2c_detach_client(client);
343   - if (r < 0)
344   - return r;
345   -
346   - kfree(client);
  325 + i2c_set_clientdata(client, NULL);
347 326 kfree(dec);
348 327 return 0;
349 328 }
350 329  
  330 +static struct i2c_device_id wis_tw2804_id[] = {
  331 + { "wis_tw2804", 0 },
  332 + { }
  333 +};
  334 +
351 335 static struct i2c_driver wis_tw2804_driver = {
352 336 .driver = {
353 337 .name = "WIS TW2804 I2C driver",
354 338 },
355   - .id = I2C_DRIVERID_WIS_TW2804,
356   - .detach_client = wis_tw2804_detach,
  339 + .probe = wis_tw2804_probe,
  340 + .remove = wis_tw2804_remove,
357 341 .command = wis_tw2804_command,
  342 + .id_table = wis_tw2804_id,
358 343 };
359 344  
360 345 static int __init wis_tw2804_init(void)
361 346 {
362   - int r;
363   -
364   - r = i2c_add_driver(&wis_tw2804_driver);
365   - if (r < 0)
366   - return r;
367   - return wis_i2c_add_driver(wis_tw2804_driver.id, wis_tw2804_detect);
  347 + return i2c_add_driver(&wis_tw2804_driver);
368 348 }
369 349  
370 350 static void __exit wis_tw2804_cleanup(void)
371 351 {
372   - wis_i2c_del_driver(wis_tw2804_detect);
373 352 i2c_del_driver(&wis_tw2804_driver);
374 353 }
375 354  
drivers/staging/go7007/wis-tw9903.c
... ... @@ -267,34 +267,19 @@
267 267 return 0;
268 268 }
269 269  
270   -static struct i2c_driver wis_tw9903_driver;
271   -
272   -static struct i2c_client wis_tw9903_client_templ = {
273   - .name = "TW9903 (WIS)",
274   - .driver = &wis_tw9903_driver,
275   -};
276   -
277   -static int wis_tw9903_detect(struct i2c_adapter *adapter, int addr, int kind)
  270 +static int wis_tw9903_probe(struct i2c_client *client,
  271 + const struct i2c_device_id *id)
278 272 {
279   - struct i2c_client *client;
  273 + struct i2c_adapter *adapter = client->adapter;
280 274 struct wis_tw9903 *dec;
281 275  
282 276 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
283   - return 0;
  277 + return -ENODEV;
284 278  
285   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
286   - if (client == NULL)
287   - return -ENOMEM;
288   - memcpy(client, &wis_tw9903_client_templ,
289   - sizeof(wis_tw9903_client_templ));
290   - client->adapter = adapter;
291   - client->addr = addr;
292   -
293 279 dec = kmalloc(sizeof(struct wis_tw9903), GFP_KERNEL);
294   - if (dec == NULL) {
295   - kfree(client);
  280 + if (dec == NULL)
296 281 return -ENOMEM;
297   - }
  282 +
298 283 dec->norm = V4L2_STD_NTSC;
299 284 dec->brightness = 0;
300 285 dec->contrast = 0x60;
301 286  
302 287  
303 288  
304 289  
305 290  
306 291  
307 292  
308 293  
309 294  
310 295  
311 296  
... ... @@ -303,55 +288,48 @@
303 288  
304 289 printk(KERN_DEBUG
305 290 "wis-tw9903: initializing TW9903 at address %d on %s\n",
306   - addr, adapter->name);
  291 + client->addr, adapter->name);
307 292  
308 293 if (write_regs(client, initial_registers) < 0) {
309 294 printk(KERN_ERR "wis-tw9903: error initializing TW9903\n");
310   - kfree(client);
311 295 kfree(dec);
312   - return 0;
  296 + return -ENODEV;
313 297 }
314 298  
315   - i2c_attach_client(client);
316 299 return 0;
317 300 }
318 301  
319   -static int wis_tw9903_detach(struct i2c_client *client)
  302 +static int wis_tw9903_remove(struct i2c_client *client)
320 303 {
321 304 struct wis_tw9903 *dec = i2c_get_clientdata(client);
322   - int r;
323 305  
324   - r = i2c_detach_client(client);
325   - if (r < 0)
326   - return r;
327   -
328   - kfree(client);
  306 + i2c_set_clientdata(client, NULL);
329 307 kfree(dec);
330 308 return 0;
331 309 }
332 310  
  311 +static struct i2c_device_id wis_tw9903_id[] = {
  312 + { "wis_tw9903", 0 },
  313 + { }
  314 +};
  315 +
333 316 static struct i2c_driver wis_tw9903_driver = {
334 317 .driver = {
335 318 .name = "WIS TW9903 I2C driver",
336 319 },
337   - .id = I2C_DRIVERID_WIS_TW9903,
338   - .detach_client = wis_tw9903_detach,
  320 + .probe = wis_tw9903_probe,
  321 + .remove = wis_tw9903_remove,
339 322 .command = wis_tw9903_command,
  323 + .id_table = wis_tw9903_id,
340 324 };
341 325  
342 326 static int __init wis_tw9903_init(void)
343 327 {
344   - int r;
345   -
346   - r = i2c_add_driver(&wis_tw9903_driver);
347   - if (r < 0)
348   - return r;
349   - return wis_i2c_add_driver(wis_tw9903_driver.id, wis_tw9903_detect);
  328 + return i2c_add_driver(&wis_tw9903_driver);
350 329 }
351 330  
352 331 static void __exit wis_tw9903_cleanup(void)
353 332 {
354   - wis_i2c_del_driver(wis_tw9903_detect);
355 333 i2c_del_driver(&wis_tw9903_driver);
356 334 }
357 335  
drivers/staging/go7007/wis-uda1342.c
... ... @@ -59,73 +59,51 @@
59 59 return 0;
60 60 }
61 61  
62   -static struct i2c_driver wis_uda1342_driver;
63   -
64   -static struct i2c_client wis_uda1342_client_templ = {
65   - .name = "UDA1342 (WIS)",
66   - .driver = &wis_uda1342_driver,
67   -};
68   -
69   -static int wis_uda1342_detect(struct i2c_adapter *adapter, int addr, int kind)
  62 +static int wis_uda1342_probe(struct i2c_client *client,
  63 + const struct i2c_device_id *id)
70 64 {
71   - struct i2c_client *client;
  65 + struct i2c_adapter *adapter = client->adapter;
72 66  
73 67 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
74   - return 0;
  68 + return -ENODEV;
75 69  
76   - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
77   - if (client == NULL)
78   - return -ENOMEM;
79   - memcpy(client, &wis_uda1342_client_templ,
80   - sizeof(wis_uda1342_client_templ));
81   - client->adapter = adapter;
82   - client->addr = addr;
83   -
84 70 printk(KERN_DEBUG
85 71 "wis-uda1342: initializing UDA1342 at address %d on %s\n",
86   - addr, adapter->name);
  72 + client->addr, adapter->name);
87 73  
88 74 write_reg(client, 0x00, 0x8000); /* reset registers */
89 75 write_reg(client, 0x00, 0x1241); /* select input 1 */
90 76  
91   - i2c_attach_client(client);
92 77 return 0;
93 78 }
94 79  
95   -static int wis_uda1342_detach(struct i2c_client *client)
  80 +static int wis_uda1342_remove(struct i2c_client *client)
96 81 {
97   - int r;
98   -
99   - r = i2c_detach_client(client);
100   - if (r < 0)
101   - return r;
102   -
103   - kfree(client);
104 82 return 0;
105 83 }
106 84  
  85 +static struct i2c_device_id wis_uda1342_id[] = {
  86 + { "wis_uda1342", 0 },
  87 + { }
  88 +};
  89 +
107 90 static struct i2c_driver wis_uda1342_driver = {
108 91 .driver = {
109 92 .name = "WIS UDA1342 I2C driver",
110 93 },
111   - .id = I2C_DRIVERID_WIS_UDA1342,
112   - .detach_client = wis_uda1342_detach,
  94 + .probe = wis_uda1342_probe,
  95 + .remove = wis_uda1342_remove,
113 96 .command = wis_uda1342_command,
  97 + .id_table = wis_uda1342_id,
114 98 };
115 99  
116 100 static int __init wis_uda1342_init(void)
117 101 {
118   - int r;
119   -
120   - r = i2c_add_driver(&wis_uda1342_driver);
121   - if (r < 0)
122   - return r;
123   - return wis_i2c_add_driver(wis_uda1342_driver.id, wis_uda1342_detect);
  102 + return i2c_add_driver(&wis_uda1342_driver);
124 103 }
125 104  
126 105 static void __exit wis_uda1342_cleanup(void)
127 106 {
128   - wis_i2c_del_driver(wis_uda1342_detect);
129 107 i2c_del_driver(&wis_uda1342_driver);
130 108 }
131 109