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

i2c: Convert most new-style drivers to use module aliasing

Based on earlier work by Jon Smirl and Jochen Friedrich.

Update most new-style i2c drivers to use standard module aliasing
instead of the old driver_name/type driver matching scheme. I've
left the video drivers apart (except for SoC camera drivers) as
they're a bit more diffcult to deal with, they'll have their own
patch later.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jon Smirl <jonsmirl@gmail.com>
Cc: Jochen Friedrich <jochen@scram.de>

authored by

Jean Delvare and committed by
Jean Delvare
3760f736 d2653e92

+211 -247
+1 -2
arch/arm/mach-at91/board-csb337.c
··· 79 79 80 80 static struct i2c_board_info __initdata csb337_i2c_devices[] = { 81 81 { 82 - I2C_BOARD_INFO("rtc-ds1307", 0x68), 83 - .type = "ds1307", 82 + I2C_BOARD_INFO("ds1307", 0x68), 84 83 }, 85 84 }; 86 85
+1 -2
arch/arm/mach-at91/board-dk.c
··· 132 132 I2C_BOARD_INFO("x9429", 0x28), 133 133 }, 134 134 { 135 - I2C_BOARD_INFO("at24c", 0x50), 136 - .type = "24c1024", 135 + I2C_BOARD_INFO("24c1024", 0x50), 137 136 } 138 137 }; 139 138
+1 -2
arch/arm/mach-at91/board-eb9200.c
··· 93 93 94 94 static struct i2c_board_info __initdata eb9200_i2c_devices[] = { 95 95 { 96 - I2C_BOARD_INFO("at24c", 0x50), 97 - .type = "24c512", 96 + I2C_BOARD_INFO("24c512", 0x50), 98 97 }, 99 98 }; 100 99
+1 -2
arch/arm/mach-iop32x/em7210.c
··· 50 50 */ 51 51 static struct i2c_board_info __initdata em7210_i2c_devices[] = { 52 52 { 53 - I2C_BOARD_INFO("rtc-rs5c372", 0x32), 54 - .type = "rs5c372a", 53 + I2C_BOARD_INFO("rs5c372a", 0x32), 55 54 }, 56 55 }; 57 56
+1 -3
arch/arm/mach-iop32x/glantank.c
··· 176 176 177 177 static struct i2c_board_info __initdata glantank_i2c_devices[] = { 178 178 { 179 - I2C_BOARD_INFO("rtc-rs5c372", 0x32), 180 - .type = "rs5c372a", 179 + I2C_BOARD_INFO("rs5c372a", 0x32), 181 180 }, 182 181 { 183 182 I2C_BOARD_INFO("f75375", 0x2e), 184 - .type = "f75375", 185 183 .platform_data = &glantank_f75375s, 186 184 }, 187 185 };
+1 -3
arch/arm/mach-iop32x/n2100.c
··· 208 208 209 209 static struct i2c_board_info __initdata n2100_i2c_devices[] = { 210 210 { 211 - I2C_BOARD_INFO("rtc-rs5c372", 0x32), 212 - .type = "rs5c372b", 211 + I2C_BOARD_INFO("rs5c372b", 0x32), 213 212 }, 214 213 { 215 214 I2C_BOARD_INFO("f75375", 0x2e), 216 - .type = "f75375", 217 215 .platform_data = &n2100_f75375s, 218 216 }, 219 217 };
+1 -1
arch/arm/mach-ixp4xx/dsmg600-setup.c
··· 65 65 66 66 static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = { 67 67 { 68 - I2C_BOARD_INFO("rtc-pcf8563", 0x51), 68 + I2C_BOARD_INFO("pcf8563", 0x51), 69 69 }, 70 70 }; 71 71
+1 -1
arch/arm/mach-ixp4xx/nas100d-setup.c
··· 54 54 55 55 static struct i2c_board_info __initdata nas100d_i2c_board_info [] = { 56 56 { 57 - I2C_BOARD_INFO("rtc-pcf8563", 0x51), 57 + I2C_BOARD_INFO("pcf8563", 0x51), 58 58 }, 59 59 }; 60 60
+1 -1
arch/arm/mach-ixp4xx/nslu2-setup.c
··· 57 57 58 58 static struct i2c_board_info __initdata nslu2_i2c_board_info [] = { 59 59 { 60 - I2C_BOARD_INFO("rtc-x1205", 0x6f), 60 + I2C_BOARD_INFO("x1205", 0x6f), 61 61 }, 62 62 }; 63 63
-2
arch/arm/mach-omap1/board-h2.c
··· 351 351 static struct i2c_board_info __initdata h2_i2c_board_info[] = { 352 352 { 353 353 I2C_BOARD_INFO("tps65010", 0x48), 354 - .type = "tps65010", 355 354 .irq = OMAP_GPIO_IRQ(58), 356 355 }, { 357 356 I2C_BOARD_INFO("isp1301_omap", 0x2d), 358 - .type = "isp1301_omap", 359 357 .irq = OMAP_GPIO_IRQ(2), 360 358 }, 361 359 };
+1 -2
arch/arm/mach-omap1/board-h3.c
··· 473 473 474 474 static struct i2c_board_info __initdata h3_i2c_board_info[] = { 475 475 { 476 - I2C_BOARD_INFO("tps65010", 0x48), 477 - .type = "tps65013", 476 + I2C_BOARD_INFO("tps65013", 0x48), 478 477 /* .irq = OMAP_GPIO_IRQ(??), */ 479 478 }, 480 479 };
-1
arch/arm/mach-omap1/board-osk.c
··· 254 254 static struct i2c_board_info __initdata osk_i2c_board_info[] = { 255 255 { 256 256 I2C_BOARD_INFO("tps65010", 0x48), 257 - .type = "tps65010", 258 257 .irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)), 259 258 .platform_data = &tps_board, 260 259
+1 -3
arch/arm/mach-orion5x/db88f5281-setup.c
··· 292 292 * RTC DS1339 on I2C bus 293 293 ****************************************************************************/ 294 294 static struct i2c_board_info __initdata db88f5281_i2c_rtc = { 295 - .driver_name = "rtc-ds1307", 296 - .type = "ds1339", 297 - .addr = 0x68, 295 + I2C_BOARD_INFO("ds1339", 0x68), 298 296 }; 299 297 300 298 /*****************************************************************************
+2 -5
arch/arm/mach-orion5x/dns323-setup.c
··· 220 220 static struct i2c_board_info __initdata dns323_i2c_devices[] = { 221 221 { 222 222 I2C_BOARD_INFO("g760a", 0x3e), 223 - .type = "g760a", 224 223 }, 225 224 #if 0 226 225 /* this entry requires the new-style driver model lm75 driver, 227 226 * for the meantime "insmod lm75.ko force_lm75=0,0x48" is needed */ 228 227 { 229 - I2C_BOARD_INFO("lm75", 0x48), 230 - .type = "g751", 228 + I2C_BOARD_INFO("g751", 0x48), 231 229 }, 232 230 #endif 233 231 { 234 - I2C_BOARD_INFO("rtc-m41t80", 0x68), 235 - .type = "m41t80", 232 + I2C_BOARD_INFO("m41t80", 0x68), 236 233 } 237 234 }; 238 235
+1 -3
arch/arm/mach-orion5x/kurobox_pro-setup.c
··· 162 162 * RTC 5C372a on I2C bus 163 163 ****************************************************************************/ 164 164 static struct i2c_board_info __initdata kurobox_pro_i2c_rtc = { 165 - .driver_name = "rtc-rs5c372", 166 - .type = "rs5c372a", 167 - .addr = 0x32, 165 + I2C_BOARD_INFO("rs5c372a", 0x32), 168 166 }; 169 167 170 168 /*****************************************************************************
+1 -3
arch/arm/mach-orion5x/rd88f5182-setup.c
··· 224 224 * RTC DS1338 on I2C bus 225 225 ****************************************************************************/ 226 226 static struct i2c_board_info __initdata rd88f5182_i2c_rtc = { 227 - .driver_name = "rtc-ds1307", 228 - .type = "ds1338", 229 - .addr = 0x68, 227 + I2C_BOARD_INFO("ds1338", 0x68), 230 228 }; 231 229 232 230 /*****************************************************************************
+1 -2
arch/arm/mach-orion5x/ts209-setup.c
··· 276 276 #define TS209_RTC_GPIO 3 277 277 278 278 static struct i2c_board_info __initdata qnap_ts209_i2c_rtc = { 279 - .driver_name = "rtc-s35390a", 280 - .addr = 0x30, 279 + I2C_BOARD_INFO("s35390a", 0x30), 281 280 .irq = 0, 282 281 }; 283 282
+1 -4
arch/arm/mach-pxa/pcm990-baseboard.c
··· 320 320 static struct i2c_board_info __initdata pcm990_i2c_devices[] = { 321 321 { 322 322 /* Must initialize before the camera(s) */ 323 - I2C_BOARD_INFO("pca953x", 0x41), 324 - .type = "pca9536", 323 + I2C_BOARD_INFO("pca9536", 0x41), 325 324 .platform_data = &pca9536_data, 326 325 }, { 327 326 I2C_BOARD_INFO("mt9v022", 0x48), 328 - .type = "mt9v022", 329 327 .platform_data = &iclink[0], /* With extender */ 330 328 }, { 331 329 I2C_BOARD_INFO("mt9m001", 0x5d), 332 - .type = "mt9m001", 333 330 .platform_data = &iclink[0], /* With extender */ 334 331 }, 335 332 };
-3
arch/blackfin/mach-bf533/boards/stamp.c
··· 499 499 #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) 500 500 { 501 501 I2C_BOARD_INFO("ad7142_joystick", 0x2C), 502 - .type = "ad7142_joystick", 503 502 .irq = 39, 504 503 }, 505 504 #endif 506 505 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 507 506 { 508 507 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 509 - .type = "pcf8574_lcd", 510 508 }, 511 509 #endif 512 510 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) 513 511 { 514 512 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 515 - .type = "pcf8574_keypad", 516 513 .irq = 39, 517 514 }, 518 515 #endif
-3
arch/blackfin/mach-bf537/boards/stamp.c
··· 751 751 #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) 752 752 { 753 753 I2C_BOARD_INFO("ad7142_joystick", 0x2C), 754 - .type = "ad7142_joystick", 755 754 .irq = 55, 756 755 }, 757 756 #endif 758 757 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 759 758 { 760 759 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 761 - .type = "pcf8574_lcd", 762 760 }, 763 761 #endif 764 762 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) 765 763 { 766 764 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 767 - .type = "pcf8574_keypad", 768 765 .irq = 72, 769 766 }, 770 767 #endif
-2
arch/blackfin/mach-bf548/boards/ezkit.c
··· 641 641 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 642 642 { 643 643 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 644 - .type = "pcf8574_lcd", 645 644 }, 646 645 #endif 647 646 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) 648 647 { 649 648 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 650 - .type = "pcf8574_keypad", 651 649 .irq = 212, 652 650 }, 653 651 #endif
+12 -15
arch/powerpc/sysdev/fsl_soc.c
··· 418 418 #include <linux/i2c.h> 419 419 struct i2c_driver_device { 420 420 char *of_device; 421 - char *i2c_driver; 422 421 char *i2c_type; 423 422 }; 424 423 425 424 static struct i2c_driver_device i2c_devices[] __initdata = { 426 - {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",}, 427 - {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",}, 428 - {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",}, 429 - {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",}, 430 - {"dallas,ds1307", "rtc-ds1307", "ds1307",}, 431 - {"dallas,ds1337", "rtc-ds1307", "ds1337",}, 432 - {"dallas,ds1338", "rtc-ds1307", "ds1338",}, 433 - {"dallas,ds1339", "rtc-ds1307", "ds1339",}, 434 - {"dallas,ds1340", "rtc-ds1307", "ds1340",}, 435 - {"stm,m41t00", "rtc-ds1307", "m41t00"}, 436 - {"dallas,ds1374", "rtc-ds1374", "rtc-ds1374",}, 425 + {"ricoh,rs5c372a", "rs5c372a"}, 426 + {"ricoh,rs5c372b", "rs5c372b"}, 427 + {"ricoh,rv5c386", "rv5c386"}, 428 + {"ricoh,rv5c387a", "rv5c387a"}, 429 + {"dallas,ds1307", "ds1307"}, 430 + {"dallas,ds1337", "ds1337"}, 431 + {"dallas,ds1338", "ds1338"}, 432 + {"dallas,ds1339", "ds1339"}, 433 + {"dallas,ds1340", "ds1340"}, 434 + {"stm,m41t00", "m41t00"}, 435 + {"dallas,ds1374", "rtc-ds1374"}, 437 436 }; 438 437 439 438 static int __init of_find_i2c_driver(struct device_node *node, ··· 443 444 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { 444 445 if (!of_device_is_compatible(node, i2c_devices[i].of_device)) 445 446 continue; 446 - if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver, 447 - KOBJ_NAME_LEN) >= KOBJ_NAME_LEN || 448 - strlcpy(info->type, i2c_devices[i].i2c_type, 447 + if (strlcpy(info->type, i2c_devices[i].i2c_type, 449 448 I2C_NAME_SIZE) >= I2C_NAME_SIZE) 450 449 return -ENOMEM; 451 450 return 0;
+1 -2
arch/sh/boards/renesas/migor/setup.c
··· 199 199 200 200 static struct i2c_board_info __initdata migor_i2c_devices[] = { 201 201 { 202 - I2C_BOARD_INFO("rtc-rs5c372", 0x32), 203 - .type = "rs5c372b", 202 + I2C_BOARD_INFO("rs5c372b", 0x32), 204 203 }, 205 204 { 206 205 I2C_BOARD_INFO("migor_ts", 0x51),
+1 -2
arch/sh/boards/renesas/r7780rp/setup.c
··· 199 199 200 200 static struct i2c_board_info __initdata highlander_i2c_devices[] = { 201 201 { 202 - I2C_BOARD_INFO("rtc-rs5c372", 0x32), 203 - .type = "r2025sd", 202 + I2C_BOARD_INFO("r2025sd", 0x32), 204 203 }, 205 204 }; 206 205
+5 -18
drivers/gpio/pca953x.c
··· 23 23 #define PCA953X_INVERT 2 24 24 #define PCA953X_DIRECTION 3 25 25 26 - /* This is temporary - in 2.6.26 i2c_driver_data should replace it. */ 27 - struct pca953x_desc { 28 - char name[I2C_NAME_SIZE]; 29 - unsigned long driver_data; 30 - }; 31 - 32 - static const struct pca953x_desc pca953x_descs[] = { 26 + static const struct i2c_device_id pca953x_id[] = { 33 27 { "pca9534", 8, }, 34 28 { "pca9535", 16, }, 35 29 { "pca9536", 4, }, ··· 31 37 { "pca9538", 8, }, 32 38 { "pca9539", 16, }, 33 39 /* REVISIT several pca955x parts should work here too */ 40 + { } 34 41 }; 42 + MODULE_DEVICE_TABLE(i2c, pca953x_id); 35 43 36 44 struct pca953x_chip { 37 45 unsigned gpio_start; ··· 189 193 } 190 194 191 195 static int __devinit pca953x_probe(struct i2c_client *client, 192 - const struct i2c_device_id *did) 196 + const struct i2c_device_id *id) 193 197 { 194 198 struct pca953x_platform_data *pdata; 195 199 struct pca953x_chip *chip; 196 200 int ret, i; 197 - const struct pca953x_desc *id = NULL; 198 201 199 202 pdata = client->dev.platform_data; 200 203 if (pdata == NULL) 201 - return -ENODEV; 202 - 203 - /* this loop vanishes when we get i2c_device_id */ 204 - for (i = 0; i < ARRAY_SIZE(pca953x_descs); i++) 205 - if (!strcmp(pca953x_descs[i].name, client->name)) { 206 - id = pca953x_descs + i; 207 - break; 208 - } 209 - if (!id) 210 204 return -ENODEV; 211 205 212 206 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL); ··· 278 292 }, 279 293 .probe = pca953x_probe, 280 294 .remove = pca953x_remove, 295 + .id_table = pca953x_id, 281 296 }; 282 297 283 298 static int __init pca953x_init(void)
+19 -14
drivers/gpio/pcf857x.c
··· 26 26 #include <asm/gpio.h> 27 27 28 28 29 + static const struct i2c_device_id pcf857x_id[] = { 30 + { "pcf8574", 8 }, 31 + { "pca8574", 8 }, 32 + { "pca9670", 8 }, 33 + { "pca9672", 8 }, 34 + { "pca9674", 8 }, 35 + { "pcf8575", 16 }, 36 + { "pca8575", 16 }, 37 + { "pca9671", 16 }, 38 + { "pca9673", 16 }, 39 + { "pca9675", 16 }, 40 + { } 41 + }; 42 + MODULE_DEVICE_TABLE(i2c, pcf857x_id); 43 + 29 44 /* 30 45 * The pcf857x, pca857x, and pca967x chips only expose one read and one 31 46 * write register. Writing a "one" bit (to match the reset state) lets ··· 188 173 * 189 174 * NOTE: we don't distinguish here between *4 and *4a parts. 190 175 */ 191 - if (strcmp(client->name, "pcf8574") == 0 192 - || strcmp(client->name, "pca8574") == 0 193 - || strcmp(client->name, "pca9670") == 0 194 - || strcmp(client->name, "pca9672") == 0 195 - || strcmp(client->name, "pca9674") == 0 196 - ) { 197 - gpio->chip.ngpio = 8; 176 + gpio->chip.ngpio = id->driver_data; 177 + if (gpio->chip.ngpio == 8) { 198 178 gpio->chip.direction_input = pcf857x_input8; 199 179 gpio->chip.get = pcf857x_get8; 200 180 gpio->chip.direction_output = pcf857x_output8; ··· 209 199 * 210 200 * NOTE: we don't distinguish here between '75 and '75c parts. 211 201 */ 212 - } else if (strcmp(client->name, "pcf8575") == 0 213 - || strcmp(client->name, "pca8575") == 0 214 - || strcmp(client->name, "pca9671") == 0 215 - || strcmp(client->name, "pca9673") == 0 216 - || strcmp(client->name, "pca9675") == 0 217 - ) { 218 - gpio->chip.ngpio = 16; 202 + } else if (gpio->chip.ngpio == 16) { 219 203 gpio->chip.direction_input = pcf857x_input16; 220 204 gpio->chip.get = pcf857x_get16; 221 205 gpio->chip.direction_output = pcf857x_output16; ··· 318 314 }, 319 315 .probe = pcf857x_probe, 320 316 .remove = pcf857x_remove, 317 + .id_table = pcf857x_id, 321 318 }; 322 319 323 320 static int __init pcf857x_init(void)
+13 -10
drivers/hwmon/f75375s.c
··· 129 129 .detach_client = f75375_detach_client, 130 130 }; 131 131 132 + static const struct i2c_device_id f75375_id[] = { 133 + { "f75373", f75373 }, 134 + { "f75375", f75375 }, 135 + { } 136 + }; 137 + MODULE_DEVICE_TABLE(i2c, f75375_id); 138 + 132 139 static struct i2c_driver f75375_driver = { 133 140 .driver = { 134 141 .name = "f75375", 135 142 }, 136 143 .probe = f75375_probe, 137 144 .remove = f75375_remove, 145 + .id_table = f75375_id, 138 146 }; 139 147 140 148 static inline int f75375_read8(struct i2c_client *client, u8 reg) ··· 653 645 i2c_set_clientdata(client, data); 654 646 data->client = client; 655 647 mutex_init(&data->update_lock); 656 - 657 - if (strcmp(client->name, "f75375") == 0) 658 - data->kind = f75375; 659 - else if (strcmp(client->name, "f75373") == 0) 660 - data->kind = f75373; 661 - else { 662 - dev_err(&client->dev, "Unsupported device: %s\n", client->name); 663 - return -ENODEV; 664 - } 648 + data->kind = id->driver_data; 665 649 666 650 if ((err = sysfs_create_group(&client->dev.kobj, &f75375_group))) 667 651 goto exit_free; ··· 714 714 u8 version = 0; 715 715 int err = 0; 716 716 const char *name = ""; 717 + struct i2c_device_id id; 717 718 718 719 if (!(client = kzalloc(sizeof(*client), GFP_KERNEL))) { 719 720 err = -ENOMEM; ··· 751 750 if ((err = i2c_attach_client(client))) 752 751 goto exit_free; 753 752 754 - if ((err = f75375_probe(client, NULL)) < 0) 753 + strlcpy(id.name, name, I2C_NAME_SIZE); 754 + id.driver_data = kind; 755 + if ((err = f75375_probe(client, &id)) < 0) 755 756 goto exit_detach; 756 757 757 758 return 0;
+1 -2
drivers/i2c/busses/i2c-taos-evm.c
··· 51 51 /* TAOS TSL2550 EVM */ 52 52 static struct i2c_board_info tsl2550_info = { 53 53 I2C_BOARD_INFO("tsl2550", 0x39), 54 - .type = "tsl2550", 55 54 }; 56 55 57 56 /* Instantiate i2c devices based on the adapter name */ ··· 58 59 { 59 60 if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) { 60 61 dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n", 61 - tsl2550_info.driver_name, tsl2550_info.addr); 62 + tsl2550_info.type, tsl2550_info.addr); 62 63 return i2c_new_device(adapter, &tsl2550_info); 63 64 } 64 65
+7
drivers/i2c/chips/ds1682.c
··· 235 235 return 0; 236 236 } 237 237 238 + static const struct i2c_device_id ds1682_id[] = { 239 + { "ds1682", 0 }, 240 + { } 241 + }; 242 + MODULE_DEVICE_TABLE(i2c, ds1682_id); 243 + 238 244 static struct i2c_driver ds1682_driver = { 239 245 .driver = { 240 246 .name = "ds1682", 241 247 }, 242 248 .probe = ds1682_probe, 243 249 .remove = ds1682_remove, 250 + .id_table = ds1682_id, 244 251 }; 245 252 246 253 static int __init ds1682_init(void)
+7
drivers/i2c/chips/menelaus.c
··· 1243 1243 return 0; 1244 1244 } 1245 1245 1246 + static const struct i2c_device_id menelaus_id[] = { 1247 + { "menelaus", 0 }, 1248 + { } 1249 + }; 1250 + MODULE_DEVICE_TABLE(i2c, menelaus_id); 1251 + 1246 1252 static struct i2c_driver menelaus_i2c_driver = { 1247 1253 .driver = { 1248 1254 .name = DRIVER_NAME, 1249 1255 }, 1250 1256 .probe = menelaus_probe, 1251 1257 .remove = __exit_p(menelaus_remove), 1258 + .id_table = menelaus_id, 1252 1259 }; 1253 1260 1254 1261 static int __init menelaus_init(void)
+11 -18
drivers/i2c/chips/tps65010.c
··· 64 64 * as part of board setup by a bootloader. 65 65 */ 66 66 enum tps_model { 67 - TPS_UNKNOWN = 0, 68 67 TPS65010, 69 68 TPS65011, 70 69 TPS65012, ··· 553 554 mutex_init(&tps->lock); 554 555 INIT_DELAYED_WORK(&tps->work, tps65010_work); 555 556 tps->client = client; 556 - 557 - if (strcmp(client->name, "tps65010") == 0) 558 - tps->model = TPS65010; 559 - else if (strcmp(client->name, "tps65011") == 0) 560 - tps->model = TPS65011; 561 - else if (strcmp(client->name, "tps65012") == 0) 562 - tps->model = TPS65012; 563 - else if (strcmp(client->name, "tps65013") == 0) 564 - tps->model = TPS65013; 565 - else { 566 - dev_warn(&client->dev, "unknown chip '%s'\n", client->name); 567 - status = -ENODEV; 568 - goto fail1; 569 - } 557 + tps->model = id->driver_data; 570 558 571 559 /* the IRQ is active low, but many gpio lines can't support that 572 560 * so this driver uses falling-edge triggers instead. ··· 581 595 case TPS65010: 582 596 case TPS65012: 583 597 tps->por = 1; 584 - break; 585 - case TPS_UNKNOWN: 586 - printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); 587 598 break; 588 599 /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ 589 600 } ··· 668 685 return status; 669 686 } 670 687 688 + static const struct i2c_device_id tps65010_id[] = { 689 + { "tps65010", TPS65010 }, 690 + { "tps65011", TPS65011 }, 691 + { "tps65012", TPS65012 }, 692 + { "tps65013", TPS65013 }, 693 + { } 694 + }; 695 + MODULE_DEVICE_TABLE(i2c, tps65010_id); 696 + 671 697 static struct i2c_driver tps65010_driver = { 672 698 .driver = { 673 699 .name = "tps65010", 674 700 }, 675 701 .probe = tps65010_probe, 676 702 .remove = __exit_p(tps65010_remove), 703 + .id_table = tps65010_id, 677 704 }; 678 705 679 706 /*-------------------------------------------------------------------------*/
+7
drivers/i2c/chips/tsl2550.c
··· 452 452 453 453 #endif /* CONFIG_PM */ 454 454 455 + static const struct i2c_device_id tsl2550_id[] = { 456 + { "tsl2550", 0 }, 457 + { } 458 + }; 459 + MODULE_DEVICE_TABLE(i2c, tsl2550_id); 460 + 455 461 static struct i2c_driver tsl2550_driver = { 456 462 .driver = { 457 463 .name = TSL2550_DRV_NAME, ··· 467 461 .resume = tsl2550_resume, 468 462 .probe = tsl2550_probe, 469 463 .remove = __devexit_p(tsl2550_remove), 464 + .id_table = tsl2550_id, 470 465 }; 471 466 472 467 static int __init tsl2550_init(void)
+7
drivers/media/video/mt9m001.c
··· 697 697 return 0; 698 698 } 699 699 700 + static const struct i2c_device_id mt9m001_id[] = { 701 + { "mt9m001", 0 }, 702 + { } 703 + }; 704 + MODULE_DEVICE_TABLE(i2c, mt9m001_id); 705 + 700 706 static struct i2c_driver mt9m001_i2c_driver = { 701 707 .driver = { 702 708 .name = "mt9m001", 703 709 }, 704 710 .probe = mt9m001_probe, 705 711 .remove = mt9m001_remove, 712 + .id_table = mt9m001_id, 706 713 }; 707 714 708 715 static int __init mt9m001_mod_init(void)
+7
drivers/media/video/mt9v022.c
··· 819 819 return 0; 820 820 } 821 821 822 + static const struct i2c_device_id mt9v022_id[] = { 823 + { "mt9v022", 0 }, 824 + { } 825 + }; 826 + MODULE_DEVICE_TABLE(i2c, mt9v022_id); 827 + 822 828 static struct i2c_driver mt9v022_i2c_driver = { 823 829 .driver = { 824 830 .name = "mt9v022", 825 831 }, 826 832 .probe = mt9v022_probe, 827 833 .remove = mt9v022_remove, 834 + .id_table = mt9v022_id, 828 835 }; 829 836 830 837 static int __init mt9v022_mod_init(void)
+25 -38
drivers/rtc/rtc-ds1307.c
··· 99 99 }; 100 100 101 101 struct chip_desc { 102 - char name[9]; 103 102 unsigned nvram56:1; 104 103 unsigned alarm:1; 105 - enum ds_type type; 106 104 }; 107 105 108 - static const struct chip_desc chips[] = { { 109 - .name = "ds1307", 110 - .type = ds_1307, 106 + static const struct chip_desc chips[] = { 107 + [ds_1307] = { 111 108 .nvram56 = 1, 112 - }, { 113 - .name = "ds1337", 114 - .type = ds_1337, 109 + }, 110 + [ds_1337] = { 115 111 .alarm = 1, 116 - }, { 117 - .name = "ds1338", 118 - .type = ds_1338, 112 + }, 113 + [ds_1338] = { 119 114 .nvram56 = 1, 120 - }, { 121 - .name = "ds1339", 122 - .type = ds_1339, 115 + }, 116 + [ds_1339] = { 123 117 .alarm = 1, 124 - }, { 125 - .name = "ds1340", 126 - .type = ds_1340, 127 - }, { 128 - .name = "m41t00", 129 - .type = m41t00, 118 + }, 119 + [ds_1340] = { 120 + }, 121 + [m41t00] = { 130 122 }, }; 131 123 132 - static inline const struct chip_desc *find_chip(const char *s) 133 - { 134 - unsigned i; 135 - 136 - for (i = 0; i < ARRAY_SIZE(chips); i++) 137 - if (strnicmp(s, chips[i].name, sizeof chips[i].name) == 0) 138 - return &chips[i]; 139 - return NULL; 140 - } 124 + static const struct i2c_device_id ds1307_id[] = { 125 + { "ds1307", ds_1307 }, 126 + { "ds1337", ds_1337 }, 127 + { "ds1338", ds_1338 }, 128 + { "ds1339", ds_1339 }, 129 + { "ds1340", ds_1340 }, 130 + { "m41t00", m41t00 }, 131 + { } 132 + }; 133 + MODULE_DEVICE_TABLE(i2c, ds1307_id); 141 134 142 135 static int ds1307_get_time(struct device *dev, struct rtc_time *t) 143 136 { ··· 325 332 struct ds1307 *ds1307; 326 333 int err = -ENODEV; 327 334 int tmp; 328 - const struct chip_desc *chip; 335 + const struct chip_desc *chip = &chips[id->driver_data]; 329 336 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 330 - 331 - chip = find_chip(client->name); 332 - if (!chip) { 333 - dev_err(&client->dev, "unknown chip type '%s'\n", 334 - client->name); 335 - return -ENODEV; 336 - } 337 337 338 338 if (!i2c_check_functionality(adapter, 339 339 I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) ··· 348 362 ds1307->msg[1].len = sizeof(ds1307->regs); 349 363 ds1307->msg[1].buf = ds1307->regs; 350 364 351 - ds1307->type = chip->type; 365 + ds1307->type = id->driver_data; 352 366 353 367 switch (ds1307->type) { 354 368 case ds_1337: ··· 537 551 }, 538 552 .probe = ds1307_probe, 539 553 .remove = __devexit_p(ds1307_remove), 554 + .id_table = ds1307_id, 540 555 }; 541 556 542 557 static int __init ds1307_init(void)
+7
drivers/rtc/rtc-ds1374.c
··· 41 41 #define DS1374_REG_SR_AF 0x01 /* Alarm Flag */ 42 42 #define DS1374_REG_TCR 0x09 /* Trickle Charge */ 43 43 44 + static const struct i2c_device_id ds1374_id[] = { 45 + { "rtc-ds1374", 0 }, 46 + { } 47 + }; 48 + MODULE_DEVICE_TABLE(i2c, ds1374_id); 49 + 44 50 struct ds1374 { 45 51 struct i2c_client *client; 46 52 struct rtc_device *rtc; ··· 436 430 }, 437 431 .probe = ds1374_probe, 438 432 .remove = __devexit_p(ds1374_remove), 433 + .id_table = ds1374_id, 439 434 }; 440 435 441 436 static int __init ds1374_init(void)
+7
drivers/rtc/rtc-isl1208.c
··· 545 545 return 0; 546 546 } 547 547 548 + static const struct i2c_device_id isl1208_id[] = { 549 + { "isl1208", 0 }, 550 + { } 551 + }; 552 + MODULE_DEVICE_TABLE(i2c, isl1208_id); 553 + 548 554 static struct i2c_driver isl1208_driver = { 549 555 .driver = { 550 556 .name = "rtc-isl1208", 551 557 }, 552 558 .probe = isl1208_probe, 553 559 .remove = isl1208_remove, 560 + .id_table = isl1208_id, 554 561 }; 555 562 556 563 static int __init
+19 -59
drivers/rtc/rtc-m41t80.c
··· 60 60 61 61 #define DRV_VERSION "0.05" 62 62 63 - struct m41t80_chip_info { 64 - const char *name; 65 - u8 features; 63 + static const struct i2c_device_id m41t80_id[] = { 64 + { "m41t80", 0 }, 65 + { "m41t81", M41T80_FEATURE_HT }, 66 + { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 67 + { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 68 + { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 69 + { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 70 + { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 71 + { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 72 + { } 66 73 }; 67 - 68 - static const struct m41t80_chip_info m41t80_chip_info_tbl[] = { 69 - { 70 - .name = "m41t80", 71 - .features = 0, 72 - }, 73 - { 74 - .name = "m41t81", 75 - .features = M41T80_FEATURE_HT, 76 - }, 77 - { 78 - .name = "m41t81s", 79 - .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, 80 - }, 81 - { 82 - .name = "m41t82", 83 - .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, 84 - }, 85 - { 86 - .name = "m41t83", 87 - .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, 88 - }, 89 - { 90 - .name = "m41st84", 91 - .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, 92 - }, 93 - { 94 - .name = "m41st85", 95 - .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, 96 - }, 97 - { 98 - .name = "m41st87", 99 - .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, 100 - }, 101 - }; 74 + MODULE_DEVICE_TABLE(i2c, m41t80_id); 102 75 103 76 struct m41t80_data { 104 - const struct m41t80_chip_info *chip; 77 + u8 features; 105 78 struct rtc_device *rtc; 106 79 }; 107 80 ··· 181 208 struct m41t80_data *clientdata = i2c_get_clientdata(client); 182 209 u8 reg; 183 210 184 - if (clientdata->chip->features & M41T80_FEATURE_BL) { 211 + if (clientdata->features & M41T80_FEATURE_BL) { 185 212 reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); 186 213 seq_printf(seq, "battery\t\t: %s\n", 187 214 (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok"); ··· 732 759 static int m41t80_probe(struct i2c_client *client, 733 760 const struct i2c_device_id *id) 734 761 { 735 - int i, rc = 0; 762 + int rc = 0; 736 763 struct rtc_device *rtc = NULL; 737 764 struct rtc_time tm; 738 - const struct m41t80_chip_info *chip; 739 765 struct m41t80_data *clientdata = NULL; 740 766 741 767 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C ··· 745 773 746 774 dev_info(&client->dev, 747 775 "chip found, driver version " DRV_VERSION "\n"); 748 - 749 - chip = NULL; 750 - for (i = 0; i < ARRAY_SIZE(m41t80_chip_info_tbl); i++) { 751 - if (!strcmp(m41t80_chip_info_tbl[i].name, client->name)) { 752 - chip = &m41t80_chip_info_tbl[i]; 753 - break; 754 - } 755 - } 756 - if (!chip) { 757 - dev_err(&client->dev, "%s is not supported\n", client->name); 758 - rc = -ENODEV; 759 - goto exit; 760 - } 761 776 762 777 clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL); 763 778 if (!clientdata) { ··· 761 802 } 762 803 763 804 clientdata->rtc = rtc; 764 - clientdata->chip = chip; 805 + clientdata->features = id->driver_data; 765 806 i2c_set_clientdata(client, clientdata); 766 807 767 808 /* Make sure HT (Halt Update) bit is cleared */ ··· 770 811 goto ht_err; 771 812 772 813 if (rc & M41T80_ALHOUR_HT) { 773 - if (chip->features & M41T80_FEATURE_HT) { 814 + if (clientdata->features & M41T80_FEATURE_HT) { 774 815 m41t80_get_datetime(client, &tm); 775 816 dev_info(&client->dev, "HT bit was set!\n"); 776 817 dev_info(&client->dev, ··· 802 843 goto exit; 803 844 804 845 #ifdef CONFIG_RTC_DRV_M41T80_WDT 805 - if (chip->features & M41T80_FEATURE_HT) { 846 + if (clientdata->features & M41T80_FEATURE_HT) { 806 847 rc = misc_register(&wdt_dev); 807 848 if (rc) 808 849 goto exit; ··· 838 879 struct rtc_device *rtc = clientdata->rtc; 839 880 840 881 #ifdef CONFIG_RTC_DRV_M41T80_WDT 841 - if (clientdata->chip->features & M41T80_FEATURE_HT) { 882 + if (clientdata->features & M41T80_FEATURE_HT) { 842 883 misc_deregister(&wdt_dev); 843 884 unregister_reboot_notifier(&wdt_notifier); 844 885 } ··· 856 897 }, 857 898 .probe = m41t80_probe, 858 899 .remove = m41t80_remove, 900 + .id_table = m41t80_id, 859 901 }; 860 902 861 903 static int __init m41t80_rtc_init(void)
+7
drivers/rtc/rtc-pcf8563.c
··· 300 300 return 0; 301 301 } 302 302 303 + static const struct i2c_device_id pcf8563_id[] = { 304 + { "pcf8563", 0 }, 305 + { } 306 + }; 307 + MODULE_DEVICE_TABLE(i2c, pcf8563_id); 308 + 303 309 static struct i2c_driver pcf8563_driver = { 304 310 .driver = { 305 311 .name = "rtc-pcf8563", 306 312 }, 307 313 .probe = pcf8563_probe, 308 314 .remove = pcf8563_remove, 315 + .id_table = pcf8563_id, 309 316 }; 310 317 311 318 static int __init pcf8563_init(void)
+11 -13
drivers/rtc/rtc-rs5c372.c
··· 69 69 rtc_rv5c387a, 70 70 }; 71 71 72 + static const struct i2c_device_id rs5c372_id[] = { 73 + { "rs5c372a", rtc_rs5c372a }, 74 + { "rs5c372b", rtc_rs5c372b }, 75 + { "rv5c386", rtc_rv5c386 }, 76 + { "rv5c387a", rtc_rv5c387a }, 77 + { } 78 + }; 79 + MODULE_DEVICE_TABLE(i2c, rs5c372_id); 80 + 72 81 /* REVISIT: this assumes that: 73 82 * - we're in the 21st century, so it's safe to ignore the century 74 83 * bit for rv5c38[67] (REG_MONTH bit 7); ··· 524 515 525 516 rs5c372->client = client; 526 517 i2c_set_clientdata(client, rs5c372); 518 + rs5c372->type = id->driver_data; 527 519 528 520 /* we read registers 0x0f then 0x00-0x0f; skip the first one */ 529 521 rs5c372->regs = &rs5c372->buf[1]; ··· 532 522 err = rs5c_get_regs(rs5c372); 533 523 if (err < 0) 534 524 goto exit_kfree; 535 - 536 - if (strcmp(client->name, "rs5c372a") == 0) 537 - rs5c372->type = rtc_rs5c372a; 538 - else if (strcmp(client->name, "rs5c372b") == 0) 539 - rs5c372->type = rtc_rs5c372b; 540 - else if (strcmp(client->name, "rv5c386") == 0) 541 - rs5c372->type = rtc_rv5c386; 542 - else if (strcmp(client->name, "rv5c387a") == 0) 543 - rs5c372->type = rtc_rv5c387a; 544 - else { 545 - rs5c372->type = rtc_rs5c372b; 546 - dev_warn(&client->dev, "assuming rs5c372b\n"); 547 - } 548 525 549 526 /* clock may be set for am/pm or 24 hr time */ 550 527 switch (rs5c372->type) { ··· 649 652 }, 650 653 .probe = rs5c372_probe, 651 654 .remove = rs5c372_remove, 655 + .id_table = rs5c372_id, 652 656 }; 653 657 654 658 static __init int rs5c372_init(void)
+7
drivers/rtc/rtc-s35390a.c
··· 34 34 #define S35390A_FLAG_RESET 0x80 35 35 #define S35390A_FLAG_TEST 0x01 36 36 37 + static const struct i2c_device_id s35390a_id[] = { 38 + { "s35390a", 0 }, 39 + { } 40 + }; 41 + MODULE_DEVICE_TABLE(i2c, s35390a_id); 42 + 37 43 struct s35390a { 38 44 struct i2c_client *client[8]; 39 45 struct rtc_device *rtc; ··· 303 297 }, 304 298 .probe = s35390a_probe, 305 299 .remove = s35390a_remove, 300 + .id_table = s35390a_id, 306 301 }; 307 302 308 303 static int __init s35390a_rtc_init(void)
+7
drivers/rtc/rtc-x1205.c
··· 553 553 return 0; 554 554 } 555 555 556 + static const struct i2c_device_id x1205_id[] = { 557 + { "x1205", 0 }, 558 + { } 559 + }; 560 + MODULE_DEVICE_TABLE(i2c, x1205_id); 561 + 556 562 static struct i2c_driver x1205_driver = { 557 563 .driver = { 558 564 .name = "rtc-x1205", 559 565 }, 560 566 .probe = x1205_probe, 561 567 .remove = x1205_remove, 568 + .id_table = x1205_id, 562 569 }; 563 570 564 571 static int __init x1205_init(void)
+6 -6
include/linux/i2c.h
··· 229 229 }; 230 230 231 231 /** 232 - * I2C_BOARD_INFO - macro used to list an i2c device and its driver 233 - * @driver: identifies the driver to use with the device 232 + * I2C_BOARD_INFO - macro used to list an i2c device and its address 233 + * @dev_type: identifies the device type 234 234 * @dev_addr: the device's address on the bus. 235 235 * 236 236 * This macro initializes essential fields of a struct i2c_board_info, 237 237 * declaring what has been provided on a particular board. Optional 238 - * fields (such as the chip type, its associated irq, or device-specific 239 - * platform_data) are provided using conventional syntax. 238 + * fields (such as associated irq, or device-specific platform_data) 239 + * are provided using conventional syntax. 240 240 */ 241 - #define I2C_BOARD_INFO(driver,dev_addr) \ 242 - .driver_name = (driver), .addr = (dev_addr) 241 + #define I2C_BOARD_INFO(dev_type,dev_addr) \ 242 + .type = (dev_type), .addr = (dev_addr) 243 243 244 244 245 245 /* Add-on boards should register/unregister their devices; e.g. a board