Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6

* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
go7007: Convert to the new i2c device binding model

+175 -417
+9 -2
drivers/staging/go7007/go7007-driver.c
··· 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) { ··· 228 226 } 229 227 if (modname != NULL) 230 228 request_module(modname); 231 - if (wis_i2c_probe_device(adapter, id, addr) == 1) 229 + 230 + memset(&info, 0, sizeof(struct i2c_board_info)); 231 + info.addr = addr; 232 + strlcpy(info.type, type, I2C_NAME_SIZE); 233 + if (!i2c_new_device(adapter, &info)) 232 234 return 0; 233 235 if (modname != NULL) 234 236 printk(KERN_INFO ··· 272 266 if (go->i2c_adapter_online) { 273 267 for (i = 0; i < go->board_info->num_i2c_devs; ++i) 274 268 init_i2c_module(&go->i2c_adapter, 269 + go->board_info->i2c_devs[i].type, 275 270 go->board_info->i2c_devs[i].id, 276 271 go->board_info->i2c_devs[i].addr); 277 272 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
-83
drivers/staging/go7007/go7007-i2c.c
··· 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 */ ··· 206 287 207 288 static struct i2c_adapter go7007_adap_templ = { 208 289 .owner = THIS_MODULE, 209 - .class = I2C_CLASS_TV_ANALOG, 210 290 .name = "WIS GO7007SB", 211 - .id = I2C_ALGO_GO7007, 212 291 .algo = &go7007_algo, 213 292 }; 214 293
+1
drivers/staging/go7007/go7007-priv.h
··· 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];
+11 -3
drivers/staging/go7007/go7007-usb.c
··· 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 }, ··· 128 127 .num_i2c_devs = 1, 129 128 .i2c_devs = { 130 129 { 130 + .type = "wis_saa7113", 131 131 .id = I2C_DRIVERID_WIS_SAA7113, 132 132 .addr = 0x25, 133 133 }, ··· 166 164 .num_i2c_devs = 1, 167 165 .i2c_devs = { 168 166 { 167 + .type = "wis_saa7115", 169 168 .id = I2C_DRIVERID_WIS_SAA7115, 170 169 .addr = 0x20, 171 170 }, ··· 212 209 .num_i2c_devs = 3, 213 210 .i2c_devs = { 214 211 { 212 + .type = "wis_saa7115", 215 213 .id = I2C_DRIVERID_WIS_SAA7115, 216 214 .addr = 0x20, 217 215 }, 218 216 { 217 + .type = "wis_uda1342", 219 218 .id = I2C_DRIVERID_WIS_UDA1342, 220 219 .addr = 0x1a, 221 220 }, 222 221 { 222 + .type = "wis_sony_tuner", 223 223 .id = I2C_DRIVERID_WIS_SONY_TUNER, 224 224 .addr = 0x60, 225 225 }, ··· 270 264 .num_i2c_devs = 1, 271 265 .i2c_devs = { 272 266 { 267 + .type = "wis_ov7640", 273 268 .id = I2C_DRIVERID_WIS_OV7640, 274 269 .addr = 0x21, 275 270 }, ··· 303 296 .num_i2c_devs = 1, 304 297 .i2c_devs = { 305 298 { 299 + .type = "wis_tw9903", 306 300 .id = I2C_DRIVERID_WIS_TW9903, 307 301 .addr = 0x44, 308 302 }, ··· 393 385 .num_i2c_devs = 1, 394 386 .i2c_devs = { 395 387 { 388 + .type = "wis_twTW2804", 396 389 .id = I2C_DRIVERID_WIS_TW2804, 397 390 .addr = 0x00, /* yes, really */ 398 391 }, ··· 424 415 .num_i2c_devs = 1, 425 416 .i2c_devs = { 426 417 { 418 + .type = "s2250_board", 427 419 .id = I2C_DRIVERID_S2250, 428 - .addr = 0x34, 420 + .addr = 0x43, 429 421 }, 430 422 }, 431 423 .num_inputs = 2, ··· 953 943 954 944 static struct i2c_adapter go7007_usb_adap_templ = { 955 945 .owner = THIS_MODULE, 956 - .class = I2C_CLASS_TV_ANALOG, 957 946 .name = "WIS GO7007SB EZ-USB", 958 - .id = I2C_ALGO_GO7007_USB, 959 947 .algo = &go7007_usb_algo, 960 948 }; 961 949
+30 -41
drivers/staging/go7007/s2250-board.c
··· 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 ··· 122 123 int hue; 123 124 int reg12b_val; 124 125 int audio_input; 126 + struct i2c_client *audio; 125 127 }; 126 128 127 129 /* from go7007-usb.c which is Copyright (C) 2005-2006 Micronas USA Inc.*/ ··· 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; ··· 476 477 return 0; 477 478 } 478 479 479 - static struct i2c_driver s2250_driver; 480 - 481 - static struct i2c_client s2250_client_templ = { 482 - .name = "Sensoray 2250", 483 - .driver = &s2250_driver, 484 - }; 485 - 486 - static int s2250_detect(struct i2c_adapter *adapter, int addr, int kind) 480 + static int s2250_probe(struct i2c_client *client, 481 + const struct i2c_device_id *id) 487 482 { 488 - struct i2c_client *client; 483 + struct i2c_client *audio; 484 + struct i2c_adapter *adapter = client->adapter; 489 485 struct s2250 *dec; 490 486 u8 *data; 491 487 struct go7007 *go = i2c_get_adapdata(adapter); 492 488 struct go7007_usb *usb = go->hpi_context; 493 489 494 - client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 495 - if (client == NULL) 490 + audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1); 491 + if (audio == NULL) 496 492 return -ENOMEM; 497 - memcpy(client, &s2250_client_templ, 498 - sizeof(s2250_client_templ)); 499 - client->adapter = adapter; 500 493 501 494 dec = kmalloc(sizeof(struct s2250), GFP_KERNEL); 502 495 if (dec == NULL) { 503 - kfree(client); 496 + i2c_unregister_device(audio); 504 497 return -ENOMEM; 505 498 } 506 499 ··· 501 510 dec->contrast = 50; 502 511 dec->saturation = 50; 503 512 dec->hue = 0; 504 - client->addr = TLV320_ADDRESS; 513 + dec->audio = audio; 505 514 i2c_set_clientdata(client, dec); 506 515 507 516 printk(KERN_DEBUG ··· 509 518 adapter->name); 510 519 511 520 /* initialize the audio */ 512 - client->addr = TLV320_ADDRESS; 513 - if (write_regs(client, aud_regs) < 0) { 521 + if (write_regs(audio, aud_regs) < 0) { 514 522 printk(KERN_ERR 515 523 "s2250: error initializing audio\n"); 516 - kfree(client); 524 + i2c_unregister_device(audio); 517 525 kfree(dec); 518 526 return 0; 519 527 } 520 - client->addr = S2250_VIDDEC; 521 - i2c_set_clientdata(client, dec); 522 528 523 529 if (write_regs(client, vid_regs) < 0) { 524 530 printk(KERN_ERR 525 531 "s2250: error initializing decoder\n"); 526 - kfree(client); 532 + i2c_unregister_device(audio); 527 533 kfree(dec); 528 534 return 0; 529 535 } 530 536 if (write_regs_fp(client, vid_regs_fp) < 0) { 531 537 printk(KERN_ERR 532 538 "s2250: error initializing decoder\n"); 533 - kfree(client); 539 + i2c_unregister_device(audio); 534 540 kfree(dec); 535 541 return 0; 536 542 } ··· 563 575 up(&usb->i2c_lock); 564 576 } 565 577 566 - i2c_attach_client(client); 567 578 printk("s2250: initialized successfully\n"); 568 579 return 0; 569 580 } 570 581 571 - static int s2250_detach(struct i2c_client *client) 582 + static int s2250_remove(struct i2c_client *client) 572 583 { 573 584 struct s2250 *dec = i2c_get_clientdata(client); 574 - int r; 575 585 576 - r = i2c_detach_client(client); 577 - if (r < 0) 578 - return r; 579 - 580 - kfree(client); 586 + i2c_set_clientdata(client, NULL); 587 + i2c_unregister_device(dec->audio); 581 588 kfree(dec); 582 589 return 0; 583 590 } 591 + 592 + static struct i2c_device_id s2250_id[] = { 593 + { "s2250_board", 0 }, 594 + { } 595 + }; 584 596 585 597 static struct i2c_driver s2250_driver = { 586 598 .driver = { 587 599 .name = "Sensoray 2250 board driver", 588 600 }, 589 - .id = I2C_DRIVERID_S2250, 590 - .detach_client = s2250_detach, 601 + .probe = s2250_probe, 602 + .remove = s2250_remove, 591 603 .command = s2250_command, 604 + .id_table = s2250_id, 592 605 }; 593 606 594 607 static int __init s2250_init(void) ··· 602 613 603 614 r = i2c_add_driver(&s2250_driver); 604 615 if (r < 0) 605 - return r; 606 - return wis_i2c_add_driver(s2250_driver.id, s2250_detect); 616 + s2250loader_cleanup(); 617 + 618 + return r; 607 619 } 608 620 609 621 static void __exit s2250_cleanup(void) 610 622 { 611 - wis_i2c_del_driver(s2250_detect); 612 623 i2c_del_driver(&s2250_driver); 613 624 614 625 s2250loader_cleanup();
-9
drivers/staging/go7007/wis-i2c.h
··· 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
+16 -38
drivers/staging/go7007/wis-ov7640.c
··· 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 } 79 + 80 + static struct i2c_device_id wis_ov7640_id[] = { 81 + { "wis_ov7640", 0 }, 82 + { } 83 + }; 101 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
+19 -41
drivers/staging/go7007/wis-saa7113.c
··· 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; 278 - 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; 271 + return -ENODEV; 286 272 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; ··· 283 298 284 299 printk(KERN_DEBUG 285 300 "wis-saa7113: initializing SAA7113 at address %d on %s\n", 286 - addr, adapter->name); 301 + client->addr, adapter->name); 287 302 288 303 if (write_regs(client, initial_registers) < 0) { 289 304 printk(KERN_ERR 290 305 "wis-saa7113: error initializing SAA7113\n"); 291 - kfree(client); 292 306 kfree(dec); 293 - return 0; 307 + return -ENODEV; 294 308 } 295 309 296 - i2c_attach_client(client); 297 310 return 0; 298 311 } 299 312 300 - static int wis_saa7113_detach(struct i2c_client *client) 313 + static int wis_saa7113_remove(struct i2c_client *client) 301 314 { 302 315 struct wis_saa7113 *dec = i2c_get_clientdata(client); 303 - int r; 304 316 305 - r = i2c_detach_client(client); 306 - if (r < 0) 307 - return r; 308 - 309 - kfree(client); 317 + i2c_set_clientdata(client, NULL); 310 318 kfree(dec); 311 319 return 0; 312 320 } 321 + 322 + static struct i2c_device_id wis_saa7113_id[] = { 323 + { "wis_saa7113", 0 }, 324 + { } 325 + }; 313 326 314 327 static struct i2c_driver wis_saa7113_driver = { 315 328 .driver = { 316 329 .name = "WIS SAA7113 I2C driver", 317 330 }, 318 - .id = I2C_DRIVERID_WIS_SAA7113, 319 - .detach_client = wis_saa7113_detach, 331 + .probe = wis_saa7113_probe, 332 + .remove = wis_saa7113_remove, 320 333 .command = wis_saa7113_command, 334 + .id_table = wis_saa7113_id, 321 335 }; 322 336 323 337 static int __init wis_saa7113_init(void) 324 338 { 325 - int r; 326 - 327 - r = i2c_add_driver(&wis_saa7113_driver); 328 - if (r < 0) 329 - return r; 330 - return wis_i2c_add_driver(wis_saa7113_driver.id, wis_saa7113_detect); 339 + return i2c_add_driver(&wis_saa7113_driver); 331 340 } 332 341 333 342 static void __exit wis_saa7113_cleanup(void) 334 343 { 335 - wis_i2c_del_driver(wis_saa7113_detect); 336 344 i2c_del_driver(&wis_saa7113_driver); 337 345 } 338 346
+19 -41
drivers/staging/go7007/wis-saa7115.c
··· 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; 411 - 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; 404 + return -ENODEV; 419 405 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; ··· 416 431 417 432 printk(KERN_DEBUG 418 433 "wis-saa7115: initializing SAA7115 at address %d on %s\n", 419 - addr, adapter->name); 434 + client->addr, adapter->name); 420 435 421 436 if (write_regs(client, initial_registers) < 0) { 422 437 printk(KERN_ERR 423 438 "wis-saa7115: error initializing SAA7115\n"); 424 - kfree(client); 425 439 kfree(dec); 426 - return 0; 440 + return -ENODEV; 427 441 } 428 442 429 - i2c_attach_client(client); 430 443 return 0; 431 444 } 432 445 433 - static int wis_saa7115_detach(struct i2c_client *client) 446 + static int wis_saa7115_remove(struct i2c_client *client) 434 447 { 435 448 struct wis_saa7115 *dec = i2c_get_clientdata(client); 436 - int r; 437 449 438 - r = i2c_detach_client(client); 439 - if (r < 0) 440 - return r; 441 - 442 - kfree(client); 450 + i2c_set_clientdata(client, NULL); 443 451 kfree(dec); 444 452 return 0; 445 453 } 454 + 455 + static struct i2c_device_id wis_saa7115_id[] = { 456 + { "wis_saa7115", 0 }, 457 + { } 458 + }; 446 459 447 460 static struct i2c_driver wis_saa7115_driver = { 448 461 .driver = { 449 462 .name = "WIS SAA7115 I2C driver", 450 463 }, 451 - .id = I2C_DRIVERID_WIS_SAA7115, 452 - .detach_client = wis_saa7115_detach, 464 + .probe = wis_saa7115_probe, 465 + .remove = wis_saa7115_remove, 453 466 .command = wis_saa7115_command, 467 + .id_table = wis_saa7115_id, 454 468 }; 455 469 456 470 static int __init wis_saa7115_init(void) 457 471 { 458 - int r; 459 - 460 - r = i2c_add_driver(&wis_saa7115_driver); 461 - if (r < 0) 462 - return r; 463 - return wis_i2c_add_driver(wis_saa7115_driver.id, wis_saa7115_detect); 472 + return i2c_add_driver(&wis_saa7115_driver); 464 473 } 465 474 466 475 static void __exit wis_saa7115_cleanup(void) 467 476 { 468 - wis_i2c_del_driver(wis_saa7115_detect); 469 477 i2c_del_driver(&wis_saa7115_driver); 470 478 } 471 479
+18 -42
drivers/staging/go7007/wis-sony-tuner.c
··· 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; 671 - 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; 663 + return -ENODEV; 679 664 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; ··· 674 690 675 691 printk(KERN_DEBUG 676 692 "wis-sony-tuner: initializing tuner at address %d on %s\n", 677 - addr, adapter->name); 678 - 679 - i2c_attach_client(client); 693 + client->addr, adapter->name); 680 694 681 695 return 0; 682 696 } 683 697 684 - static int wis_sony_tuner_detach(struct i2c_client *client) 698 + static int wis_sony_tuner_remove(struct i2c_client *client) 685 699 { 686 700 struct wis_sony_tuner *t = i2c_get_clientdata(client); 687 - int r; 688 701 689 - r = i2c_detach_client(client); 690 - if (r < 0) 691 - return r; 692 - 702 + i2c_set_clientdata(client, NULL); 693 703 kfree(t); 694 - kfree(client); 695 704 return 0; 696 705 } 706 + 707 + static struct i2c_device_id wis_sony_tuner_id[] = { 708 + { "wis_sony_tuner", 0 }, 709 + { } 710 + }; 697 711 698 712 static struct i2c_driver wis_sony_tuner_driver = { 699 713 .driver = { 700 714 .name = "WIS Sony TV Tuner I2C driver", 701 715 }, 702 - .id = I2C_DRIVERID_WIS_SONY_TUNER, 703 - .detach_client = wis_sony_tuner_detach, 716 + .probe = wis_sony_tuner_probe, 717 + .remove = wis_sony_tuner_remove, 704 718 .command = tuner_command, 719 + .id_table = wis_sony_tuner_id, 705 720 }; 706 721 707 722 static int __init wis_sony_tuner_init(void) 708 723 { 709 - int r; 710 - 711 - r = i2c_add_driver(&wis_sony_tuner_driver); 712 - if (r < 0) 713 - return r; 714 - return wis_i2c_add_driver(wis_sony_tuner_driver.id, 715 - wis_sony_tuner_detect); 724 + return i2c_add_driver(&wis_sony_tuner_driver); 716 725 } 717 726 718 727 static void __exit wis_sony_tuner_cleanup(void) 719 728 { 720 - wis_i2c_del_driver(wis_sony_tuner_detect); 721 729 i2c_del_driver(&wis_sony_tuner_driver); 722 730 } 723 731
+18 -39
drivers/staging/go7007/wis-tw2804.c
··· 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; 308 - 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; 301 + return -ENODEV; 316 302 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; ··· 313 328 i2c_set_clientdata(client, dec); 314 329 315 330 printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n", 316 - addr, adapter->name); 331 + client->addr, adapter->name); 317 332 318 - i2c_attach_client(client); 319 333 return 0; 320 334 } 321 335 322 - static int wis_tw2804_detach(struct i2c_client *client) 336 + static int wis_tw2804_remove(struct i2c_client *client) 323 337 { 324 338 struct wis_tw2804 *dec = i2c_get_clientdata(client); 325 - int r; 326 339 327 - r = i2c_detach_client(client); 328 - if (r < 0) 329 - return r; 330 - 331 - kfree(client); 340 + i2c_set_clientdata(client, NULL); 332 341 kfree(dec); 333 342 return 0; 334 343 } 344 + 345 + static struct i2c_device_id wis_tw2804_id[] = { 346 + { "wis_tw2804", 0 }, 347 + { } 348 + }; 335 349 336 350 static struct i2c_driver wis_tw2804_driver = { 337 351 .driver = { 338 352 .name = "WIS TW2804 I2C driver", 339 353 }, 340 - .id = I2C_DRIVERID_WIS_TW2804, 341 - .detach_client = wis_tw2804_detach, 354 + .probe = wis_tw2804_probe, 355 + .remove = wis_tw2804_remove, 342 356 .command = wis_tw2804_command, 357 + .id_table = wis_tw2804_id, 343 358 }; 344 359 345 360 static int __init wis_tw2804_init(void) 346 361 { 347 - int r; 348 - 349 - r = i2c_add_driver(&wis_tw2804_driver); 350 - if (r < 0) 351 - return r; 352 - return wis_i2c_add_driver(wis_tw2804_driver.id, wis_tw2804_detect); 362 + return i2c_add_driver(&wis_tw2804_driver); 353 363 } 354 364 355 365 static void __exit wis_tw2804_cleanup(void) 356 366 { 357 - wis_i2c_del_driver(wis_tw2804_detect); 358 367 i2c_del_driver(&wis_tw2804_driver); 359 368 } 360 369
+19 -41
drivers/staging/go7007/wis-tw9903.c
··· 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; 284 - 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; 277 + return -ENODEV; 292 278 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; ··· 288 303 289 304 printk(KERN_DEBUG 290 305 "wis-tw9903: initializing TW9903 at address %d on %s\n", 291 - addr, adapter->name); 306 + client->addr, adapter->name); 292 307 293 308 if (write_regs(client, initial_registers) < 0) { 294 309 printk(KERN_ERR "wis-tw9903: error initializing TW9903\n"); 295 - kfree(client); 296 310 kfree(dec); 297 - return 0; 311 + return -ENODEV; 298 312 } 299 313 300 - i2c_attach_client(client); 301 314 return 0; 302 315 } 303 316 304 - static int wis_tw9903_detach(struct i2c_client *client) 317 + static int wis_tw9903_remove(struct i2c_client *client) 305 318 { 306 319 struct wis_tw9903 *dec = i2c_get_clientdata(client); 307 - int r; 308 320 309 - r = i2c_detach_client(client); 310 - if (r < 0) 311 - return r; 312 - 313 - kfree(client); 321 + i2c_set_clientdata(client, NULL); 314 322 kfree(dec); 315 323 return 0; 316 324 } 325 + 326 + static struct i2c_device_id wis_tw9903_id[] = { 327 + { "wis_tw9903", 0 }, 328 + { } 329 + }; 317 330 318 331 static struct i2c_driver wis_tw9903_driver = { 319 332 .driver = { 320 333 .name = "WIS TW9903 I2C driver", 321 334 }, 322 - .id = I2C_DRIVERID_WIS_TW9903, 323 - .detach_client = wis_tw9903_detach, 335 + .probe = wis_tw9903_probe, 336 + .remove = wis_tw9903_remove, 324 337 .command = wis_tw9903_command, 338 + .id_table = wis_tw9903_id, 325 339 }; 326 340 327 341 static int __init wis_tw9903_init(void) 328 342 { 329 - int r; 330 - 331 - r = i2c_add_driver(&wis_tw9903_driver); 332 - if (r < 0) 333 - return r; 334 - return wis_i2c_add_driver(wis_tw9903_driver.id, wis_tw9903_detect); 343 + return i2c_add_driver(&wis_tw9903_driver); 335 344 } 336 345 337 346 static void __exit wis_tw9903_cleanup(void) 338 347 { 339 - wis_i2c_del_driver(wis_tw9903_detect); 340 348 i2c_del_driver(&wis_tw9903_driver); 341 349 } 342 350
+15 -37
drivers/staging/go7007/wis-uda1342.c
··· 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; 75 - 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; 68 + return -ENODEV; 83 69 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 } 84 + 85 + static struct i2c_device_id wis_uda1342_id[] = { 86 + { "wis_uda1342", 0 }, 87 + { } 88 + }; 106 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