diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 17:48:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 17:48:31 -0400 |
commit | b57ab7632b8fc1eef139bbbb7a89002be61f99e1 (patch) | |
tree | 19d4eeea0dbf721312c4e33a423ed29ff70aff88 /drivers/i2c | |
parent | f12c03722045882a50c270f6332cf2c7b16a83d2 (diff) | |
parent | 3760f736716f74bdc62a4ba5406934338da93eb2 (diff) |
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:
i2c: Convert most new-style drivers to use module aliasing
i2c: Add support for device alias names
i2c-amd756-s4882: Fix an error path
i2c: Drop unused RTC driver IDs
i2c/tps65010: Add missing intialization of client data
i2c-sis5595: Minor cleanups in sis5595_access
i2c-piix4: Minor cleanups
i2c: Spelling fix (successful)
i2c-stub: No newline in parameter description
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-amd756-s4882.c | 5 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-piix4.c | 10 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sis5595.c | 14 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sis630.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-stub.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-taos-evm.c | 3 | ||||
-rw-r--r-- | drivers/i2c/chips/ds1682.c | 10 | ||||
-rw-r--r-- | drivers/i2c/chips/menelaus.c | 10 | ||||
-rw-r--r-- | drivers/i2c/chips/tps65010.c | 34 | ||||
-rw-r--r-- | drivers/i2c/chips/tsl2550.c | 10 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 51 |
11 files changed, 95 insertions, 56 deletions
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index e5e96c817566..c38a0a112208 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * i2c-amd756-s4882.c - i2c-amd756 extras for the Tyan S4882 motherboard | 2 | * i2c-amd756-s4882.c - i2c-amd756 extras for the Tyan S4882 motherboard |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2004, 2008 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -231,7 +231,8 @@ ERROR2: | |||
231 | kfree(s4882_adapter); | 231 | kfree(s4882_adapter); |
232 | s4882_adapter = NULL; | 232 | s4882_adapter = NULL; |
233 | ERROR1: | 233 | ERROR1: |
234 | i2c_del_adapter(&amd756_smbus); | 234 | /* Restore physical bus */ |
235 | i2c_add_adapter(&amd756_smbus); | ||
235 | ERROR0: | 236 | ERROR0: |
236 | return error; | 237 | return error; |
237 | } | 238 | } |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 9bbe96cef719..fdc9ad805e35 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/ioport.h> | 38 | #include <linux/ioport.h> |
39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/apm_bios.h> | ||
42 | #include <linux/dmi.h> | 41 | #include <linux/dmi.h> |
43 | #include <asm/io.h> | 42 | #include <asm/io.h> |
44 | 43 | ||
@@ -223,7 +222,7 @@ static int piix4_transaction(void) | |||
223 | dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); | 222 | dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); |
224 | return -1; | 223 | return -1; |
225 | } else { | 224 | } else { |
226 | dev_dbg(&piix4_adapter.dev, "Successfull!\n"); | 225 | dev_dbg(&piix4_adapter.dev, "Successful!\n"); |
227 | } | 226 | } |
228 | } | 227 | } |
229 | 228 | ||
@@ -343,12 +342,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, | |||
343 | 342 | ||
344 | 343 | ||
345 | switch (size) { | 344 | switch (size) { |
346 | case PIIX4_BYTE: /* Where is the result put? I assume here it is in | 345 | case PIIX4_BYTE: |
347 | SMBHSTDAT0 but it might just as well be in the | ||
348 | SMBHSTCMD. No clue in the docs */ | ||
349 | |||
350 | data->byte = inb_p(SMBHSTDAT0); | ||
351 | break; | ||
352 | case PIIX4_BYTE_DATA: | 346 | case PIIX4_BYTE_DATA: |
353 | data->byte = inb_p(SMBHSTDAT0); | 347 | data->byte = inb_p(SMBHSTDAT0); |
354 | break; | 348 | break; |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 283769cecee2..9ca8f9155f95 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -238,7 +238,7 @@ static int sis5595_transaction(struct i2c_adapter *adap) | |||
238 | dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); | 238 | dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); |
239 | return -1; | 239 | return -1; |
240 | } else { | 240 | } else { |
241 | dev_dbg(&adap->dev, "Successfull!\n"); | 241 | dev_dbg(&adap->dev, "Successful!\n"); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
@@ -316,14 +316,8 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, | |||
316 | } | 316 | } |
317 | size = (size == I2C_SMBUS_PROC_CALL) ? SIS5595_PROC_CALL : SIS5595_WORD_DATA; | 317 | size = (size == I2C_SMBUS_PROC_CALL) ? SIS5595_PROC_CALL : SIS5595_WORD_DATA; |
318 | break; | 318 | break; |
319 | /* | ||
320 | case I2C_SMBUS_BLOCK_DATA: | ||
321 | printk(KERN_WARNING "sis5595.o: Block data not yet implemented!\n"); | ||
322 | return -1; | ||
323 | break; | ||
324 | */ | ||
325 | default: | 319 | default: |
326 | printk(KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size); | 320 | dev_warn(&adap->dev, "Unsupported transaction %d\n", size); |
327 | return -1; | 321 | return -1; |
328 | } | 322 | } |
329 | 323 | ||
@@ -338,9 +332,7 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, | |||
338 | 332 | ||
339 | 333 | ||
340 | switch (size) { | 334 | switch (size) { |
341 | case SIS5595_BYTE: /* Where is the result put? I assume here it is in | 335 | case SIS5595_BYTE: |
342 | SMB_DATA but it might just as well be in the | ||
343 | SMB_CMD. No clue in the docs */ | ||
344 | case SIS5595_BYTE_DATA: | 336 | case SIS5595_BYTE_DATA: |
345 | data->byte = sis5595_read(SMB_BYTE); | 337 | data->byte = sis5595_read(SMB_BYTE); |
346 | break; | 338 | break; |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 5fd734f99ee9..3765dd7f450f 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -136,7 +136,7 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc | |||
136 | dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); | 136 | dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); |
137 | return -1; | 137 | return -1; |
138 | } else { | 138 | } else { |
139 | dev_dbg(&adap->dev, "Successfull!\n"); | 139 | dev_dbg(&adap->dev, "Successful!\n"); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index c2a9f8c94f5e..d08eeec53913 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -33,7 +33,7 @@ | |||
33 | static unsigned short chip_addr[MAX_CHIPS]; | 33 | static unsigned short chip_addr[MAX_CHIPS]; |
34 | module_param_array(chip_addr, ushort, NULL, S_IRUGO); | 34 | module_param_array(chip_addr, ushort, NULL, S_IRUGO); |
35 | MODULE_PARM_DESC(chip_addr, | 35 | MODULE_PARM_DESC(chip_addr, |
36 | "Chip addresses (up to 10, between 0x03 and 0x77)\n"); | 36 | "Chip addresses (up to 10, between 0x03 and 0x77)"); |
37 | 37 | ||
38 | struct stub_chip { | 38 | struct stub_chip { |
39 | u8 pointer; | 39 | u8 pointer; |
diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c index 1b0cfd5472fd..de9db49e54d9 100644 --- a/drivers/i2c/busses/i2c-taos-evm.c +++ b/drivers/i2c/busses/i2c-taos-evm.c | |||
@@ -51,7 +51,6 @@ struct taos_data { | |||
51 | /* TAOS TSL2550 EVM */ | 51 | /* TAOS TSL2550 EVM */ |
52 | static struct i2c_board_info tsl2550_info = { | 52 | static struct i2c_board_info tsl2550_info = { |
53 | I2C_BOARD_INFO("tsl2550", 0x39), | 53 | I2C_BOARD_INFO("tsl2550", 0x39), |
54 | .type = "tsl2550", | ||
55 | }; | 54 | }; |
56 | 55 | ||
57 | /* Instantiate i2c devices based on the adapter name */ | 56 | /* Instantiate i2c devices based on the adapter name */ |
@@ -59,7 +58,7 @@ static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter) | |||
59 | { | 58 | { |
60 | if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) { | 59 | if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) { |
61 | dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n", | 60 | dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n", |
62 | tsl2550_info.driver_name, tsl2550_info.addr); | 61 | tsl2550_info.type, tsl2550_info.addr); |
63 | return i2c_new_device(adapter, &tsl2550_info); | 62 | return i2c_new_device(adapter, &tsl2550_info); |
64 | } | 63 | } |
65 | 64 | ||
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c index 9e94542c18a2..23be4d42cb02 100644 --- a/drivers/i2c/chips/ds1682.c +++ b/drivers/i2c/chips/ds1682.c | |||
@@ -200,7 +200,8 @@ static struct bin_attribute ds1682_eeprom_attr = { | |||
200 | /* | 200 | /* |
201 | * Called when a ds1682 device is matched with this driver | 201 | * Called when a ds1682 device is matched with this driver |
202 | */ | 202 | */ |
203 | static int ds1682_probe(struct i2c_client *client) | 203 | static int ds1682_probe(struct i2c_client *client, |
204 | const struct i2c_device_id *id) | ||
204 | { | 205 | { |
205 | int rc; | 206 | int rc; |
206 | 207 | ||
@@ -234,12 +235,19 @@ static int ds1682_remove(struct i2c_client *client) | |||
234 | return 0; | 235 | return 0; |
235 | } | 236 | } |
236 | 237 | ||
238 | static const struct i2c_device_id ds1682_id[] = { | ||
239 | { "ds1682", 0 }, | ||
240 | { } | ||
241 | }; | ||
242 | MODULE_DEVICE_TABLE(i2c, ds1682_id); | ||
243 | |||
237 | static struct i2c_driver ds1682_driver = { | 244 | static struct i2c_driver ds1682_driver = { |
238 | .driver = { | 245 | .driver = { |
239 | .name = "ds1682", | 246 | .name = "ds1682", |
240 | }, | 247 | }, |
241 | .probe = ds1682_probe, | 248 | .probe = ds1682_probe, |
242 | .remove = ds1682_remove, | 249 | .remove = ds1682_remove, |
250 | .id_table = ds1682_id, | ||
243 | }; | 251 | }; |
244 | 252 | ||
245 | static int __init ds1682_init(void) | 253 | static int __init ds1682_init(void) |
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c index 2dea0123a958..b36db1797c11 100644 --- a/drivers/i2c/chips/menelaus.c +++ b/drivers/i2c/chips/menelaus.c | |||
@@ -1149,7 +1149,8 @@ static inline void menelaus_rtc_init(struct menelaus_chip *m) | |||
1149 | 1149 | ||
1150 | static struct i2c_driver menelaus_i2c_driver; | 1150 | static struct i2c_driver menelaus_i2c_driver; |
1151 | 1151 | ||
1152 | static int menelaus_probe(struct i2c_client *client) | 1152 | static int menelaus_probe(struct i2c_client *client, |
1153 | const struct i2c_device_id *id) | ||
1153 | { | 1154 | { |
1154 | struct menelaus_chip *menelaus; | 1155 | struct menelaus_chip *menelaus; |
1155 | int rev = 0, val; | 1156 | int rev = 0, val; |
@@ -1242,12 +1243,19 @@ static int __exit menelaus_remove(struct i2c_client *client) | |||
1242 | return 0; | 1243 | return 0; |
1243 | } | 1244 | } |
1244 | 1245 | ||
1246 | static const struct i2c_device_id menelaus_id[] = { | ||
1247 | { "menelaus", 0 }, | ||
1248 | { } | ||
1249 | }; | ||
1250 | MODULE_DEVICE_TABLE(i2c, menelaus_id); | ||
1251 | |||
1245 | static struct i2c_driver menelaus_i2c_driver = { | 1252 | static struct i2c_driver menelaus_i2c_driver = { |
1246 | .driver = { | 1253 | .driver = { |
1247 | .name = DRIVER_NAME, | 1254 | .name = DRIVER_NAME, |
1248 | }, | 1255 | }, |
1249 | .probe = menelaus_probe, | 1256 | .probe = menelaus_probe, |
1250 | .remove = __exit_p(menelaus_remove), | 1257 | .remove = __exit_p(menelaus_remove), |
1258 | .id_table = menelaus_id, | ||
1251 | }; | 1259 | }; |
1252 | 1260 | ||
1253 | static int __init menelaus_init(void) | 1261 | static int __init menelaus_init(void) |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index b67f69c2e7f3..85949685191b 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -64,7 +64,6 @@ static struct i2c_driver tps65010_driver; | |||
64 | * as part of board setup by a bootloader. | 64 | * as part of board setup by a bootloader. |
65 | */ | 65 | */ |
66 | enum tps_model { | 66 | enum tps_model { |
67 | TPS_UNKNOWN = 0, | ||
68 | TPS65010, | 67 | TPS65010, |
69 | TPS65011, | 68 | TPS65011, |
70 | TPS65012, | 69 | TPS65012, |
@@ -527,11 +526,13 @@ static int __exit tps65010_remove(struct i2c_client *client) | |||
527 | flush_scheduled_work(); | 526 | flush_scheduled_work(); |
528 | debugfs_remove(tps->file); | 527 | debugfs_remove(tps->file); |
529 | kfree(tps); | 528 | kfree(tps); |
529 | i2c_set_clientdata(client, NULL); | ||
530 | the_tps = NULL; | 530 | the_tps = NULL; |
531 | return 0; | 531 | return 0; |
532 | } | 532 | } |
533 | 533 | ||
534 | static int tps65010_probe(struct i2c_client *client) | 534 | static int tps65010_probe(struct i2c_client *client, |
535 | const struct i2c_device_id *id) | ||
535 | { | 536 | { |
536 | struct tps65010 *tps; | 537 | struct tps65010 *tps; |
537 | int status; | 538 | int status; |
@@ -552,20 +553,7 @@ static int tps65010_probe(struct i2c_client *client) | |||
552 | mutex_init(&tps->lock); | 553 | mutex_init(&tps->lock); |
553 | INIT_DELAYED_WORK(&tps->work, tps65010_work); | 554 | INIT_DELAYED_WORK(&tps->work, tps65010_work); |
554 | tps->client = client; | 555 | tps->client = client; |
555 | 556 | tps->model = id->driver_data; | |
556 | if (strcmp(client->name, "tps65010") == 0) | ||
557 | tps->model = TPS65010; | ||
558 | else if (strcmp(client->name, "tps65011") == 0) | ||
559 | tps->model = TPS65011; | ||
560 | else if (strcmp(client->name, "tps65012") == 0) | ||
561 | tps->model = TPS65012; | ||
562 | else if (strcmp(client->name, "tps65013") == 0) | ||
563 | tps->model = TPS65013; | ||
564 | else { | ||
565 | dev_warn(&client->dev, "unknown chip '%s'\n", client->name); | ||
566 | status = -ENODEV; | ||
567 | goto fail1; | ||
568 | } | ||
569 | 557 | ||
570 | /* the IRQ is active low, but many gpio lines can't support that | 558 | /* the IRQ is active low, but many gpio lines can't support that |
571 | * so this driver uses falling-edge triggers instead. | 559 | * so this driver uses falling-edge triggers instead. |
@@ -594,9 +582,6 @@ static int tps65010_probe(struct i2c_client *client) | |||
594 | case TPS65012: | 582 | case TPS65012: |
595 | tps->por = 1; | 583 | tps->por = 1; |
596 | break; | 584 | break; |
597 | case TPS_UNKNOWN: | ||
598 | printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); | ||
599 | break; | ||
600 | /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ | 585 | /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ |
601 | } | 586 | } |
602 | tps->chgconf = i2c_smbus_read_byte_data(client, TPS_CHGCONFIG); | 587 | tps->chgconf = i2c_smbus_read_byte_data(client, TPS_CHGCONFIG); |
@@ -615,6 +600,7 @@ static int tps65010_probe(struct i2c_client *client) | |||
615 | i2c_smbus_read_byte_data(client, TPS_DEFGPIO), | 600 | i2c_smbus_read_byte_data(client, TPS_DEFGPIO), |
616 | i2c_smbus_read_byte_data(client, TPS_MASK3)); | 601 | i2c_smbus_read_byte_data(client, TPS_MASK3)); |
617 | 602 | ||
603 | i2c_set_clientdata(client, tps); | ||
618 | the_tps = tps; | 604 | the_tps = tps; |
619 | 605 | ||
620 | #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) | 606 | #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) |
@@ -682,12 +668,22 @@ fail1: | |||
682 | return status; | 668 | return status; |
683 | } | 669 | } |
684 | 670 | ||
671 | static const struct i2c_device_id tps65010_id[] = { | ||
672 | { "tps65010", TPS65010 }, | ||
673 | { "tps65011", TPS65011 }, | ||
674 | { "tps65012", TPS65012 }, | ||
675 | { "tps65013", TPS65013 }, | ||
676 | { } | ||
677 | }; | ||
678 | MODULE_DEVICE_TABLE(i2c, tps65010_id); | ||
679 | |||
685 | static struct i2c_driver tps65010_driver = { | 680 | static struct i2c_driver tps65010_driver = { |
686 | .driver = { | 681 | .driver = { |
687 | .name = "tps65010", | 682 | .name = "tps65010", |
688 | }, | 683 | }, |
689 | .probe = tps65010_probe, | 684 | .probe = tps65010_probe, |
690 | .remove = __exit_p(tps65010_remove), | 685 | .remove = __exit_p(tps65010_remove), |
686 | .id_table = tps65010_id, | ||
691 | }; | 687 | }; |
692 | 688 | ||
693 | /*-------------------------------------------------------------------------*/ | 689 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c index a10fd2791a69..1a9cc135219f 100644 --- a/drivers/i2c/chips/tsl2550.c +++ b/drivers/i2c/chips/tsl2550.c | |||
@@ -364,7 +364,8 @@ static int tsl2550_init_client(struct i2c_client *client) | |||
364 | */ | 364 | */ |
365 | 365 | ||
366 | static struct i2c_driver tsl2550_driver; | 366 | static struct i2c_driver tsl2550_driver; |
367 | static int __devinit tsl2550_probe(struct i2c_client *client) | 367 | static int __devinit tsl2550_probe(struct i2c_client *client, |
368 | const struct i2c_device_id *id) | ||
368 | { | 369 | { |
369 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 370 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
370 | struct tsl2550_data *data; | 371 | struct tsl2550_data *data; |
@@ -451,6 +452,12 @@ static int tsl2550_resume(struct i2c_client *client) | |||
451 | 452 | ||
452 | #endif /* CONFIG_PM */ | 453 | #endif /* CONFIG_PM */ |
453 | 454 | ||
455 | static const struct i2c_device_id tsl2550_id[] = { | ||
456 | { "tsl2550", 0 }, | ||
457 | { } | ||
458 | }; | ||
459 | MODULE_DEVICE_TABLE(i2c, tsl2550_id); | ||
460 | |||
454 | static struct i2c_driver tsl2550_driver = { | 461 | static struct i2c_driver tsl2550_driver = { |
455 | .driver = { | 462 | .driver = { |
456 | .name = TSL2550_DRV_NAME, | 463 | .name = TSL2550_DRV_NAME, |
@@ -460,6 +467,7 @@ static struct i2c_driver tsl2550_driver = { | |||
460 | .resume = tsl2550_resume, | 467 | .resume = tsl2550_resume, |
461 | .probe = tsl2550_probe, | 468 | .probe = tsl2550_probe, |
462 | .remove = __devexit_p(tsl2550_remove), | 469 | .remove = __devexit_p(tsl2550_remove), |
470 | .id_table = tsl2550_id, | ||
463 | }; | 471 | }; |
464 | 472 | ||
465 | static int __init tsl2550_init(void) | 473 | static int __init tsl2550_init(void) |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 6c7fa8d53c0e..26384daccb96 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -48,6 +48,17 @@ static DEFINE_IDR(i2c_adapter_idr); | |||
48 | 48 | ||
49 | /* ------------------------------------------------------------------------- */ | 49 | /* ------------------------------------------------------------------------- */ |
50 | 50 | ||
51 | static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, | ||
52 | const struct i2c_client *client) | ||
53 | { | ||
54 | while (id->name[0]) { | ||
55 | if (strcmp(client->name, id->name) == 0) | ||
56 | return id; | ||
57 | id++; | ||
58 | } | ||
59 | return NULL; | ||
60 | } | ||
61 | |||
51 | static int i2c_device_match(struct device *dev, struct device_driver *drv) | 62 | static int i2c_device_match(struct device *dev, struct device_driver *drv) |
52 | { | 63 | { |
53 | struct i2c_client *client = to_i2c_client(dev); | 64 | struct i2c_client *client = to_i2c_client(dev); |
@@ -59,6 +70,10 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) | |||
59 | if (!is_newstyle_driver(driver)) | 70 | if (!is_newstyle_driver(driver)) |
60 | return 0; | 71 | return 0; |
61 | 72 | ||
73 | /* match on an id table if there is one */ | ||
74 | if (driver->id_table) | ||
75 | return i2c_match_id(driver->id_table, client) != NULL; | ||
76 | |||
62 | /* new style drivers use the same kind of driver matching policy | 77 | /* new style drivers use the same kind of driver matching policy |
63 | * as platform devices or SPI: compare device and driver IDs. | 78 | * as platform devices or SPI: compare device and driver IDs. |
64 | */ | 79 | */ |
@@ -73,11 +88,17 @@ static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
73 | struct i2c_client *client = to_i2c_client(dev); | 88 | struct i2c_client *client = to_i2c_client(dev); |
74 | 89 | ||
75 | /* by definition, legacy drivers can't hotplug */ | 90 | /* by definition, legacy drivers can't hotplug */ |
76 | if (dev->driver || !client->driver_name) | 91 | if (dev->driver) |
77 | return 0; | 92 | return 0; |
78 | 93 | ||
79 | if (add_uevent_var(env, "MODALIAS=%s", client->driver_name)) | 94 | if (client->driver_name[0]) { |
80 | return -ENOMEM; | 95 | if (add_uevent_var(env, "MODALIAS=%s", client->driver_name)) |
96 | return -ENOMEM; | ||
97 | } else { | ||
98 | if (add_uevent_var(env, "MODALIAS=%s%s", | ||
99 | I2C_MODULE_PREFIX, client->name)) | ||
100 | return -ENOMEM; | ||
101 | } | ||
81 | dev_dbg(dev, "uevent\n"); | 102 | dev_dbg(dev, "uevent\n"); |
82 | return 0; | 103 | return 0; |
83 | } | 104 | } |
@@ -90,13 +111,19 @@ static int i2c_device_probe(struct device *dev) | |||
90 | { | 111 | { |
91 | struct i2c_client *client = to_i2c_client(dev); | 112 | struct i2c_client *client = to_i2c_client(dev); |
92 | struct i2c_driver *driver = to_i2c_driver(dev->driver); | 113 | struct i2c_driver *driver = to_i2c_driver(dev->driver); |
114 | const struct i2c_device_id *id; | ||
93 | int status; | 115 | int status; |
94 | 116 | ||
95 | if (!driver->probe) | 117 | if (!driver->probe) |
96 | return -ENODEV; | 118 | return -ENODEV; |
97 | client->driver = driver; | 119 | client->driver = driver; |
98 | dev_dbg(dev, "probe\n"); | 120 | dev_dbg(dev, "probe\n"); |
99 | status = driver->probe(client); | 121 | |
122 | if (driver->id_table) | ||
123 | id = i2c_match_id(driver->id_table, client); | ||
124 | else | ||
125 | id = NULL; | ||
126 | status = driver->probe(client, id); | ||
100 | if (status) | 127 | if (status) |
101 | client->driver = NULL; | 128 | client->driver = NULL; |
102 | return status; | 129 | return status; |
@@ -179,9 +206,9 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att | |||
179 | static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) | 206 | static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) |
180 | { | 207 | { |
181 | struct i2c_client *client = to_i2c_client(dev); | 208 | struct i2c_client *client = to_i2c_client(dev); |
182 | return client->driver_name | 209 | return client->driver_name[0] |
183 | ? sprintf(buf, "%s\n", client->driver_name) | 210 | ? sprintf(buf, "%s\n", client->driver_name) |
184 | : 0; | 211 | : sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name); |
185 | } | 212 | } |
186 | 213 | ||
187 | static struct device_attribute i2c_dev_attrs[] = { | 214 | static struct device_attribute i2c_dev_attrs[] = { |
@@ -300,15 +327,21 @@ void i2c_unregister_device(struct i2c_client *client) | |||
300 | EXPORT_SYMBOL_GPL(i2c_unregister_device); | 327 | EXPORT_SYMBOL_GPL(i2c_unregister_device); |
301 | 328 | ||
302 | 329 | ||
303 | static int dummy_nop(struct i2c_client *client) | 330 | static int dummy_probe(struct i2c_client *client, |
331 | const struct i2c_device_id *id) | ||
332 | { | ||
333 | return 0; | ||
334 | } | ||
335 | |||
336 | static int dummy_remove(struct i2c_client *client) | ||
304 | { | 337 | { |
305 | return 0; | 338 | return 0; |
306 | } | 339 | } |
307 | 340 | ||
308 | static struct i2c_driver dummy_driver = { | 341 | static struct i2c_driver dummy_driver = { |
309 | .driver.name = "dummy", | 342 | .driver.name = "dummy", |
310 | .probe = dummy_nop, | 343 | .probe = dummy_probe, |
311 | .remove = dummy_nop, | 344 | .remove = dummy_remove, |
312 | }; | 345 | }; |
313 | 346 | ||
314 | /** | 347 | /** |