diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-08 11:12:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-08 11:12:16 -0500 |
commit | 41440ffe21f29bdb985cab76b2d0b06d83e63b19 (patch) | |
tree | 1d7d1ff6f699ccbabb71c7bc4172f7d15bc4bc45 | |
parent | dad3de7d0090280f44ff27131ed2878f1ab6ddad (diff) | |
parent | 6471b68982d3bb1a593c3e183c804ecf830125d3 (diff) |
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
i2c-stub: Documentation update
i2c-stub: Allow user to disable some commands
i2c-stub: Implement I2C block support
i2c: Refactor for_each callbacks
i2c-i801: Retry on lost arbitration
i2c: Remove big kernel lock from i2cdev_open
ics932s401: Clean up detect function
i2c: Simplify i2c_detect_address
i2c: Drop probe, ignore and force module parameters
i2c: Add missing __devinit markers to old i2c adapter drivers
i2c: Bus drivers don't have to support I2C_M_REV_DIR_ADDR
i2c: Prevent priority inversion on top of bus lock
i2c-voodoo3: Delete
i2c-powermac: Drop temporary name buffer
i2c-powermac: Include the i2c_adapter in struct pmac_i2c_bus
i2c-powermac: Log errors
i2c-powermac: Refactor i2c_powermac_smbus_xfer
i2c-powermac: Reject unsupported I2C transactions
i2c/chips: Move ds1682 to drivers/misc
28 files changed, 248 insertions, 723 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index a004b04ffd3a..591e94448e63 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -407,15 +407,6 @@ Who: Alex Chiang <achiang@hp.com> | |||
407 | 407 | ||
408 | --------------------------- | 408 | --------------------------- |
409 | 409 | ||
410 | What: i2c-voodoo3 driver | ||
411 | When: October 2009 | ||
412 | Why: Superseded by tdfxfb. I2C/DDC support used to live in a separate | ||
413 | driver but this caused driver conflicts. | ||
414 | Who: Jean Delvare <khali@linux-fr.org> | ||
415 | Krzysztof Helt <krzysztof.h1@wp.pl> | ||
416 | |||
417 | --------------------------- | ||
418 | |||
419 | What: CONFIG_RFKILL_INPUT | 410 | What: CONFIG_RFKILL_INPUT |
420 | When: 2.6.33 | 411 | When: 2.6.33 |
421 | Why: Should be implemented in userspace, policy daemon. | 412 | Why: Should be implemented in userspace, policy daemon. |
diff --git a/Documentation/i2c/busses/i2c-voodoo3 b/Documentation/i2c/busses/i2c-voodoo3 deleted file mode 100644 index 62d90a454d39..000000000000 --- a/Documentation/i2c/busses/i2c-voodoo3 +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | Kernel driver i2c-voodoo3 | ||
2 | |||
3 | Supported adapters: | ||
4 | * 3dfx Voodoo3 based cards | ||
5 | * Voodoo Banshee based cards | ||
6 | |||
7 | Authors: | ||
8 | Frodo Looijaard <frodol@dds.nl>, | ||
9 | Philip Edelbrock <phil@netroedge.com>, | ||
10 | Ralph Metzler <rjkm@thp.uni-koeln.de>, | ||
11 | Mark D. Studebaker <mdsxyz123@yahoo.com> | ||
12 | |||
13 | Main contact: Philip Edelbrock <phil@netroedge.com> | ||
14 | |||
15 | The code is based upon Ralph's test code (he did the hard stuff ;') | ||
16 | |||
17 | Description | ||
18 | ----------- | ||
19 | |||
20 | The 3dfx Voodoo3 chip contains two I2C interfaces (aka a I2C 'master' or | ||
21 | 'host'). | ||
22 | |||
23 | The first interface is used for DDC (Data Display Channel) which is a | ||
24 | serial channel through the VGA monitor connector to a DDC-compliant | ||
25 | monitor. This interface is defined by the Video Electronics Standards | ||
26 | Association (VESA). The standards are available for purchase at | ||
27 | http://www.vesa.org . | ||
28 | |||
29 | The second interface is a general-purpose I2C bus. The intent by 3dfx was | ||
30 | to allow manufacturers to add extra chips to the video card such as a | ||
31 | TV-out chip such as the BT869 or possibly even I2C based temperature | ||
32 | sensors like the ADM1021 or LM75. | ||
33 | |||
34 | Stability | ||
35 | --------- | ||
36 | |||
37 | Seems to be stable on the test machine, but needs more testing on other | ||
38 | machines. Simultaneous accesses of the DDC and I2C busses may cause errors. | ||
39 | |||
40 | Supported Devices | ||
41 | ----------------- | ||
42 | |||
43 | Specifically, this driver was written and tested on the '3dfx Voodoo3 AGP | ||
44 | 3000' which has a tv-out feature (s-video or composite). According to the | ||
45 | docs and discussions, this code should work for any Voodoo3 based cards as | ||
46 | well as Voodoo Banshee based cards. The DDC interface has been tested on a | ||
47 | Voodoo Banshee card. | ||
48 | |||
49 | Issues | ||
50 | ------ | ||
51 | |||
52 | Probably many, but it seems to work OK on my system. :') | ||
53 | |||
54 | |||
55 | External Device Connection | ||
56 | -------------------------- | ||
57 | |||
58 | The digital video input jumpers give availability to the I2C bus. | ||
59 | Specifically, pins 13 and 25 (bottom row middle, and bottom right-end) are | ||
60 | the I2C clock and I2C data lines, respectively. +5V and GND are probably | ||
61 | also easily available making the addition of extra I2C/SMBus devices easy | ||
62 | to implement. | ||
diff --git a/Documentation/i2c/i2c-stub b/Documentation/i2c/i2c-stub index 0d8be1c20c16..fa4b669c166b 100644 --- a/Documentation/i2c/i2c-stub +++ b/Documentation/i2c/i2c-stub | |||
@@ -2,9 +2,9 @@ MODULE: i2c-stub | |||
2 | 2 | ||
3 | DESCRIPTION: | 3 | DESCRIPTION: |
4 | 4 | ||
5 | This module is a very simple fake I2C/SMBus driver. It implements four | 5 | This module is a very simple fake I2C/SMBus driver. It implements five |
6 | types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and | 6 | types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w) |
7 | (r/w) word data. | 7 | word data, and (r/w) I2C block data. |
8 | 8 | ||
9 | You need to provide chip addresses as a module parameter when loading this | 9 | You need to provide chip addresses as a module parameter when loading this |
10 | driver, which will then only react to SMBus commands to these addresses. | 10 | driver, which will then only react to SMBus commands to these addresses. |
@@ -21,8 +21,8 @@ EEPROMs, among others. | |||
21 | 21 | ||
22 | The typical use-case is like this: | 22 | The typical use-case is like this: |
23 | 1. load this module | 23 | 1. load this module |
24 | 2. use i2cset (from lm_sensors project) to pre-load some data | 24 | 2. use i2cset (from the i2c-tools project) to pre-load some data |
25 | 3. load the target sensors chip driver module | 25 | 3. load the target chip driver module |
26 | 4. observe its behavior in the kernel log | 26 | 4. observe its behavior in the kernel log |
27 | 27 | ||
28 | There's a script named i2c-stub-from-dump in the i2c-tools package which | 28 | There's a script named i2c-stub-from-dump in the i2c-tools package which |
@@ -33,6 +33,12 @@ PARAMETERS: | |||
33 | int chip_addr[10]: | 33 | int chip_addr[10]: |
34 | The SMBus addresses to emulate chips at. | 34 | The SMBus addresses to emulate chips at. |
35 | 35 | ||
36 | unsigned long functionality: | ||
37 | Functionality override, to disable some commands. See I2C_FUNC_* | ||
38 | constants in <linux/i2c.h> for the suitable values. For example, | ||
39 | value 0x1f0000 would only enable the quick, byte and byte data | ||
40 | commands. | ||
41 | |||
36 | CAVEATS: | 42 | CAVEATS: |
37 | 43 | ||
38 | If your target driver polls some byte or word waiting for it to change, the | 44 | If your target driver polls some byte or word waiting for it to change, the |
diff --git a/Documentation/i2c/old-module-parameters b/Documentation/i2c/old-module-parameters new file mode 100644 index 000000000000..8e2b629d533c --- /dev/null +++ b/Documentation/i2c/old-module-parameters | |||
@@ -0,0 +1,44 @@ | |||
1 | I2C device driver binding control from user-space | ||
2 | ================================================= | ||
3 | |||
4 | Up to kernel 2.6.32, many i2c drivers used helper macros provided by | ||
5 | <linux/i2c.h> which created standard module parameters to let the user | ||
6 | control how the driver would probe i2c buses and attach to devices. These | ||
7 | parameters were known as "probe" (to let the driver probe for an extra | ||
8 | address), "force" (to forcibly attach the driver to a given device) and | ||
9 | "ignore" (to prevent a driver from probing a given address). | ||
10 | |||
11 | With the conversion of the i2c subsystem to the standard device driver | ||
12 | binding model, it became clear that these per-module parameters were no | ||
13 | longer needed, and that a centralized implementation was possible. The new, | ||
14 | sysfs-based interface is described in the documentation file | ||
15 | "instantiating-devices", section "Method 4: Instantiate from user-space". | ||
16 | |||
17 | Below is a mapping from the old module parameters to the new interface. | ||
18 | |||
19 | Attaching a driver to an I2C device | ||
20 | ----------------------------------- | ||
21 | |||
22 | Old method (module parameters): | ||
23 | # modprobe <driver> probe=1,0x2d | ||
24 | # modprobe <driver> force=1,0x2d | ||
25 | # modprobe <driver> force_<device>=1,0x2d | ||
26 | |||
27 | New method (sysfs interface): | ||
28 | # echo <device> 0x2d > /sys/bus/i2c/devices/i2c-1/new_device | ||
29 | |||
30 | Preventing a driver from attaching to an I2C device | ||
31 | --------------------------------------------------- | ||
32 | |||
33 | Old method (module parameters): | ||
34 | # modprobe <driver> ignore=1,0x2f | ||
35 | |||
36 | New method (sysfs interface): | ||
37 | # echo dummy 0x2f > /sys/bus/i2c/devices/i2c-1/new_device | ||
38 | # modprobe <driver> | ||
39 | |||
40 | Of course, it is important to instantiate the "dummy" device before loading | ||
41 | the driver. The dummy device will be handled by i2c-core itself, preventing | ||
42 | other drivers from binding to it later on. If there is a real device at the | ||
43 | problematic address, and you want another driver to bind to it, then simply | ||
44 | pass the name of the device in question instead of "dummy". | ||
diff --git a/arch/powerpc/include/asm/pmac_low_i2c.h b/arch/powerpc/include/asm/pmac_low_i2c.h index 131011bd7e76..01d71826d92f 100644 --- a/arch/powerpc/include/asm/pmac_low_i2c.h +++ b/arch/powerpc/include/asm/pmac_low_i2c.h | |||
@@ -72,11 +72,7 @@ extern int pmac_i2c_get_type(struct pmac_i2c_bus *bus); | |||
72 | extern int pmac_i2c_get_flags(struct pmac_i2c_bus *bus); | 72 | extern int pmac_i2c_get_flags(struct pmac_i2c_bus *bus); |
73 | extern int pmac_i2c_get_channel(struct pmac_i2c_bus *bus); | 73 | extern int pmac_i2c_get_channel(struct pmac_i2c_bus *bus); |
74 | 74 | ||
75 | /* i2c layer adapter attach/detach */ | 75 | /* i2c layer adapter helpers */ |
76 | extern void pmac_i2c_attach_adapter(struct pmac_i2c_bus *bus, | ||
77 | struct i2c_adapter *adapter); | ||
78 | extern void pmac_i2c_detach_adapter(struct pmac_i2c_bus *bus, | ||
79 | struct i2c_adapter *adapter); | ||
80 | extern struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus); | 76 | extern struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus); |
81 | extern struct pmac_i2c_bus *pmac_i2c_adapter_to_bus(struct i2c_adapter *adapter); | 77 | extern struct pmac_i2c_bus *pmac_i2c_adapter_to_bus(struct i2c_adapter *adapter); |
82 | 78 | ||
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c index 414ca9849f23..345e2da56767 100644 --- a/arch/powerpc/platforms/powermac/low_i2c.c +++ b/arch/powerpc/platforms/powermac/low_i2c.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/timer.h> | 43 | #include <linux/timer.h> |
44 | #include <linux/mutex.h> | 44 | #include <linux/mutex.h> |
45 | #include <linux/i2c.h> | ||
45 | #include <asm/keylargo.h> | 46 | #include <asm/keylargo.h> |
46 | #include <asm/uninorth.h> | 47 | #include <asm/uninorth.h> |
47 | #include <asm/io.h> | 48 | #include <asm/io.h> |
@@ -80,7 +81,7 @@ struct pmac_i2c_bus | |||
80 | struct device_node *busnode; | 81 | struct device_node *busnode; |
81 | int type; | 82 | int type; |
82 | int flags; | 83 | int flags; |
83 | struct i2c_adapter *adapter; | 84 | struct i2c_adapter adapter; |
84 | void *hostdata; | 85 | void *hostdata; |
85 | int channel; /* some hosts have multiple */ | 86 | int channel; /* some hosts have multiple */ |
86 | int mode; /* current mode */ | 87 | int mode; /* current mode */ |
@@ -1014,25 +1015,9 @@ int pmac_i2c_get_channel(struct pmac_i2c_bus *bus) | |||
1014 | EXPORT_SYMBOL_GPL(pmac_i2c_get_channel); | 1015 | EXPORT_SYMBOL_GPL(pmac_i2c_get_channel); |
1015 | 1016 | ||
1016 | 1017 | ||
1017 | void pmac_i2c_attach_adapter(struct pmac_i2c_bus *bus, | ||
1018 | struct i2c_adapter *adapter) | ||
1019 | { | ||
1020 | WARN_ON(bus->adapter != NULL); | ||
1021 | bus->adapter = adapter; | ||
1022 | } | ||
1023 | EXPORT_SYMBOL_GPL(pmac_i2c_attach_adapter); | ||
1024 | |||
1025 | void pmac_i2c_detach_adapter(struct pmac_i2c_bus *bus, | ||
1026 | struct i2c_adapter *adapter) | ||
1027 | { | ||
1028 | WARN_ON(bus->adapter != adapter); | ||
1029 | bus->adapter = NULL; | ||
1030 | } | ||
1031 | EXPORT_SYMBOL_GPL(pmac_i2c_detach_adapter); | ||
1032 | |||
1033 | struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus) | 1018 | struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus) |
1034 | { | 1019 | { |
1035 | return bus->adapter; | 1020 | return &bus->adapter; |
1036 | } | 1021 | } |
1037 | EXPORT_SYMBOL_GPL(pmac_i2c_get_adapter); | 1022 | EXPORT_SYMBOL_GPL(pmac_i2c_get_adapter); |
1038 | 1023 | ||
@@ -1041,7 +1026,7 @@ struct pmac_i2c_bus *pmac_i2c_adapter_to_bus(struct i2c_adapter *adapter) | |||
1041 | struct pmac_i2c_bus *bus; | 1026 | struct pmac_i2c_bus *bus; |
1042 | 1027 | ||
1043 | list_for_each_entry(bus, &pmac_i2c_busses, link) | 1028 | list_for_each_entry(bus, &pmac_i2c_busses, link) |
1044 | if (bus->adapter == adapter) | 1029 | if (&bus->adapter == adapter) |
1045 | return bus; | 1030 | return bus; |
1046 | return NULL; | 1031 | return NULL; |
1047 | } | 1032 | } |
@@ -1053,7 +1038,7 @@ int pmac_i2c_match_adapter(struct device_node *dev, struct i2c_adapter *adapter) | |||
1053 | 1038 | ||
1054 | if (bus == NULL) | 1039 | if (bus == NULL) |
1055 | return 0; | 1040 | return 0; |
1056 | return (bus->adapter == adapter); | 1041 | return (&bus->adapter == adapter); |
1057 | } | 1042 | } |
1058 | EXPORT_SYMBOL_GPL(pmac_i2c_match_adapter); | 1043 | EXPORT_SYMBOL_GPL(pmac_i2c_match_adapter); |
1059 | 1044 | ||
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index d7ece131b4f4..8d8a00e5a30e 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig | |||
@@ -5,6 +5,7 @@ | |||
5 | menuconfig I2C | 5 | menuconfig I2C |
6 | tristate "I2C support" | 6 | tristate "I2C support" |
7 | depends on HAS_IOMEM | 7 | depends on HAS_IOMEM |
8 | select RT_MUTEXES | ||
8 | ---help--- | 9 | ---help--- |
9 | I2C (pronounce: I-square-C) is a slow serial bus protocol used in | 10 | I2C (pronounce: I-square-C) is a slow serial bus protocol used in |
10 | many micro controller applications and developed by Philips. SMBus, | 11 | many micro controller applications and developed by Philips. SMBus, |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index e8fe7f169e25..5f318ce29770 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -640,22 +640,6 @@ config I2C_TINY_USB | |||
640 | This driver can also be built as a module. If so, the module | 640 | This driver can also be built as a module. If so, the module |
641 | will be called i2c-tiny-usb. | 641 | will be called i2c-tiny-usb. |
642 | 642 | ||
643 | comment "Graphics adapter I2C/DDC channel drivers" | ||
644 | depends on PCI | ||
645 | |||
646 | config I2C_VOODOO3 | ||
647 | tristate "Voodoo 3 (DEPRECATED)" | ||
648 | depends on PCI | ||
649 | select I2C_ALGOBIT | ||
650 | help | ||
651 | If you say yes to this option, support will be included for the | ||
652 | Voodoo 3 I2C interface. This driver is deprecated and you should | ||
653 | use the tdfxfb driver instead, which additionally provides | ||
654 | framebuffer support. | ||
655 | |||
656 | This driver can also be built as a module. If so, the module | ||
657 | will be called i2c-voodoo3. | ||
658 | |||
659 | comment "Other I2C/SMBus bus drivers" | 643 | comment "Other I2C/SMBus bus drivers" |
660 | 644 | ||
661 | config I2C_ACORN | 645 | config I2C_ACORN |
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index ff937ac69f5b..302c551977bb 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile | |||
@@ -61,9 +61,6 @@ obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o | |||
61 | obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o | 61 | obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o |
62 | obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o | 62 | obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o |
63 | 63 | ||
64 | # Graphics adapter I2C/DDC channel drivers | ||
65 | obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o | ||
66 | |||
67 | # Other I2C/SMBus bus drivers | 64 | # Other I2C/SMBus bus drivers |
68 | obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o | 65 | obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o |
69 | obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o | 66 | obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index d108450df064..8de7d7b87bb0 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -138,7 +138,7 @@ static unsigned short ali1535_smba; | |||
138 | Note the differences between kernels with the old PCI BIOS interface and | 138 | Note the differences between kernels with the old PCI BIOS interface and |
139 | newer kernels with the real PCI interface. In compat.h some things are | 139 | newer kernels with the real PCI interface. In compat.h some things are |
140 | defined to make the transition easier. */ | 140 | defined to make the transition easier. */ |
141 | static int ali1535_setup(struct pci_dev *dev) | 141 | static int __devinit ali1535_setup(struct pci_dev *dev) |
142 | { | 142 | { |
143 | int retval = -ENODEV; | 143 | int retval = -ENODEV; |
144 | unsigned char temp; | 144 | unsigned char temp; |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index d627fceb790b..e7e3205f1286 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -131,7 +131,7 @@ MODULE_PARM_DESC(force_addr, | |||
131 | static struct pci_driver ali15x3_driver; | 131 | static struct pci_driver ali15x3_driver; |
132 | static unsigned short ali15x3_smba; | 132 | static unsigned short ali15x3_smba; |
133 | 133 | ||
134 | static int ali15x3_setup(struct pci_dev *ALI15X3_dev) | 134 | static int __devinit ali15x3_setup(struct pci_dev *ALI15X3_dev) |
135 | { | 135 | { |
136 | u16 a; | 136 | u16 a; |
137 | unsigned char temp; | 137 | unsigned char temp; |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 55edcfe5b851..df6ab553f975 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -767,6 +767,9 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id | |||
767 | /* set up the sysfs linkage to our parent device */ | 767 | /* set up the sysfs linkage to our parent device */ |
768 | i801_adapter.dev.parent = &dev->dev; | 768 | i801_adapter.dev.parent = &dev->dev; |
769 | 769 | ||
770 | /* Retry up to 3 times on lost arbitration */ | ||
771 | i801_adapter.retries = 3; | ||
772 | |||
770 | snprintf(i801_adapter.name, sizeof(i801_adapter.name), | 773 | snprintf(i801_adapter.name, sizeof(i801_adapter.name), |
771 | "SMBus I801 adapter at %04lx", i801_smba); | 774 | "SMBus I801 adapter at %04lx", i801_smba); |
772 | err = i2c_add_adapter(&i801_adapter); | 775 | err = i2c_add_adapter(&i801_adapter); |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index a75c75e77b92..5901707fc66a 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -56,12 +56,6 @@ iic_cook_addr(struct i2c_msg *msg) | |||
56 | if (msg->flags & I2C_M_RD) | 56 | if (msg->flags & I2C_M_RD) |
57 | addr |= 1; | 57 | addr |= 1; |
58 | 58 | ||
59 | /* | ||
60 | * Read or Write? | ||
61 | */ | ||
62 | if (msg->flags & I2C_M_REV_DIR_ADDR) | ||
63 | addr ^= 1; | ||
64 | |||
65 | return addr; | 59 | return addr; |
66 | } | 60 | } |
67 | 61 | ||
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index bbab0e166630..ed387ffa4730 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -338,9 +338,6 @@ mv64xxx_i2c_prepare_for_io(struct mv64xxx_i2c_data *drv_data, | |||
338 | if (msg->flags & I2C_M_RD) | 338 | if (msg->flags & I2C_M_RD) |
339 | dir = 1; | 339 | dir = 1; |
340 | 340 | ||
341 | if (msg->flags & I2C_M_REV_DIR_ADDR) | ||
342 | dir ^= 1; | ||
343 | |||
344 | if (msg->flags & I2C_M_TEN) { | 341 | if (msg->flags & I2C_M_TEN) { |
345 | drv_data->addr1 = 0xf0 | (((u32)msg->addr & 0x300) >> 7) | dir; | 342 | drv_data->addr1 = 0xf0 | (((u32)msg->addr & 0x300) >> 7) | dir; |
346 | drv_data->addr2 = (u32)msg->addr & 0xff; | 343 | drv_data->addr2 = (u32)msg->addr & 0xff; |
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 3c9d71f60187..1c440a70ec61 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -49,48 +49,38 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap, | |||
49 | int rc = 0; | 49 | int rc = 0; |
50 | int read = (read_write == I2C_SMBUS_READ); | 50 | int read = (read_write == I2C_SMBUS_READ); |
51 | int addrdir = (addr << 1) | read; | 51 | int addrdir = (addr << 1) | read; |
52 | int mode, subsize, len; | ||
53 | u32 subaddr; | ||
54 | u8 *buf; | ||
52 | u8 local[2]; | 55 | u8 local[2]; |
53 | 56 | ||
54 | rc = pmac_i2c_open(bus, 0); | 57 | if (size == I2C_SMBUS_QUICK || size == I2C_SMBUS_BYTE) { |
55 | if (rc) | 58 | mode = pmac_i2c_mode_std; |
56 | return rc; | 59 | subsize = 0; |
60 | subaddr = 0; | ||
61 | } else { | ||
62 | mode = read ? pmac_i2c_mode_combined : pmac_i2c_mode_stdsub; | ||
63 | subsize = 1; | ||
64 | subaddr = command; | ||
65 | } | ||
57 | 66 | ||
58 | switch (size) { | 67 | switch (size) { |
59 | case I2C_SMBUS_QUICK: | 68 | case I2C_SMBUS_QUICK: |
60 | rc = pmac_i2c_setmode(bus, pmac_i2c_mode_std); | 69 | buf = NULL; |
61 | if (rc) | 70 | len = 0; |
62 | goto bail; | ||
63 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, NULL, 0); | ||
64 | break; | 71 | break; |
65 | case I2C_SMBUS_BYTE: | 72 | case I2C_SMBUS_BYTE: |
66 | rc = pmac_i2c_setmode(bus, pmac_i2c_mode_std); | ||
67 | if (rc) | ||
68 | goto bail; | ||
69 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, &data->byte, 1); | ||
70 | break; | ||
71 | case I2C_SMBUS_BYTE_DATA: | 73 | case I2C_SMBUS_BYTE_DATA: |
72 | rc = pmac_i2c_setmode(bus, read ? | 74 | buf = &data->byte; |
73 | pmac_i2c_mode_combined : | 75 | len = 1; |
74 | pmac_i2c_mode_stdsub); | ||
75 | if (rc) | ||
76 | goto bail; | ||
77 | rc = pmac_i2c_xfer(bus, addrdir, 1, command, &data->byte, 1); | ||
78 | break; | 76 | break; |
79 | case I2C_SMBUS_WORD_DATA: | 77 | case I2C_SMBUS_WORD_DATA: |
80 | rc = pmac_i2c_setmode(bus, read ? | ||
81 | pmac_i2c_mode_combined : | ||
82 | pmac_i2c_mode_stdsub); | ||
83 | if (rc) | ||
84 | goto bail; | ||
85 | if (!read) { | 78 | if (!read) { |
86 | local[0] = data->word & 0xff; | 79 | local[0] = data->word & 0xff; |
87 | local[1] = (data->word >> 8) & 0xff; | 80 | local[1] = (data->word >> 8) & 0xff; |
88 | } | 81 | } |
89 | rc = pmac_i2c_xfer(bus, addrdir, 1, command, local, 2); | 82 | buf = local; |
90 | if (rc == 0 && read) { | 83 | len = 2; |
91 | data->word = ((u16)local[1]) << 8; | ||
92 | data->word |= local[0]; | ||
93 | } | ||
94 | break; | 84 | break; |
95 | 85 | ||
96 | /* Note that these are broken vs. the expected smbus API where | 86 | /* Note that these are broken vs. the expected smbus API where |
@@ -105,28 +95,44 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap, | |||
105 | * a repeat start/addr phase (but not stop in between) | 95 | * a repeat start/addr phase (but not stop in between) |
106 | */ | 96 | */ |
107 | case I2C_SMBUS_BLOCK_DATA: | 97 | case I2C_SMBUS_BLOCK_DATA: |
108 | rc = pmac_i2c_setmode(bus, read ? | 98 | buf = data->block; |
109 | pmac_i2c_mode_combined : | 99 | len = data->block[0] + 1; |
110 | pmac_i2c_mode_stdsub); | ||
111 | if (rc) | ||
112 | goto bail; | ||
113 | rc = pmac_i2c_xfer(bus, addrdir, 1, command, data->block, | ||
114 | data->block[0] + 1); | ||
115 | |||
116 | break; | 100 | break; |
117 | case I2C_SMBUS_I2C_BLOCK_DATA: | 101 | case I2C_SMBUS_I2C_BLOCK_DATA: |
118 | rc = pmac_i2c_setmode(bus, read ? | 102 | buf = &data->block[1]; |
119 | pmac_i2c_mode_combined : | 103 | len = data->block[0]; |
120 | pmac_i2c_mode_stdsub); | ||
121 | if (rc) | ||
122 | goto bail; | ||
123 | rc = pmac_i2c_xfer(bus, addrdir, 1, command, | ||
124 | &data->block[1], data->block[0]); | ||
125 | break; | 104 | break; |
126 | 105 | ||
127 | default: | 106 | default: |
128 | rc = -EINVAL; | 107 | return -EINVAL; |
108 | } | ||
109 | |||
110 | rc = pmac_i2c_open(bus, 0); | ||
111 | if (rc) { | ||
112 | dev_err(&adap->dev, "Failed to open I2C, err %d\n", rc); | ||
113 | return rc; | ||
114 | } | ||
115 | |||
116 | rc = pmac_i2c_setmode(bus, mode); | ||
117 | if (rc) { | ||
118 | dev_err(&adap->dev, "Failed to set I2C mode %d, err %d\n", | ||
119 | mode, rc); | ||
120 | goto bail; | ||
129 | } | 121 | } |
122 | |||
123 | rc = pmac_i2c_xfer(bus, addrdir, subsize, subaddr, buf, len); | ||
124 | if (rc) { | ||
125 | dev_err(&adap->dev, | ||
126 | "I2C transfer at 0x%02x failed, size %d, err %d\n", | ||
127 | addrdir >> 1, size, rc); | ||
128 | goto bail; | ||
129 | } | ||
130 | |||
131 | if (size == I2C_SMBUS_WORD_DATA && read) { | ||
132 | data->word = ((u16)local[1]) << 8; | ||
133 | data->word |= local[0]; | ||
134 | } | ||
135 | |||
130 | bail: | 136 | bail: |
131 | pmac_i2c_close(bus); | 137 | pmac_i2c_close(bus); |
132 | return rc; | 138 | return rc; |
@@ -146,20 +152,33 @@ static int i2c_powermac_master_xfer( struct i2c_adapter *adap, | |||
146 | int read; | 152 | int read; |
147 | int addrdir; | 153 | int addrdir; |
148 | 154 | ||
155 | if (num != 1) { | ||
156 | dev_err(&adap->dev, | ||
157 | "Multi-message I2C transactions not supported\n"); | ||
158 | return -EOPNOTSUPP; | ||
159 | } | ||
160 | |||
149 | if (msgs->flags & I2C_M_TEN) | 161 | if (msgs->flags & I2C_M_TEN) |
150 | return -EINVAL; | 162 | return -EINVAL; |
151 | read = (msgs->flags & I2C_M_RD) != 0; | 163 | read = (msgs->flags & I2C_M_RD) != 0; |
152 | addrdir = (msgs->addr << 1) | read; | 164 | addrdir = (msgs->addr << 1) | read; |
153 | if (msgs->flags & I2C_M_REV_DIR_ADDR) | ||
154 | addrdir ^= 1; | ||
155 | 165 | ||
156 | rc = pmac_i2c_open(bus, 0); | 166 | rc = pmac_i2c_open(bus, 0); |
157 | if (rc) | 167 | if (rc) { |
168 | dev_err(&adap->dev, "Failed to open I2C, err %d\n", rc); | ||
158 | return rc; | 169 | return rc; |
170 | } | ||
159 | rc = pmac_i2c_setmode(bus, pmac_i2c_mode_std); | 171 | rc = pmac_i2c_setmode(bus, pmac_i2c_mode_std); |
160 | if (rc) | 172 | if (rc) { |
173 | dev_err(&adap->dev, "Failed to set I2C mode %d, err %d\n", | ||
174 | pmac_i2c_mode_std, rc); | ||
161 | goto bail; | 175 | goto bail; |
176 | } | ||
162 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len); | 177 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len); |
178 | if (rc < 0) | ||
179 | dev_err(&adap->dev, "I2C %s 0x%02x failed, err %d\n", | ||
180 | addrdir & 1 ? "read from" : "write to", addrdir >> 1, | ||
181 | rc); | ||
163 | bail: | 182 | bail: |
164 | pmac_i2c_close(bus); | 183 | pmac_i2c_close(bus); |
165 | return rc < 0 ? rc : 1; | 184 | return rc < 0 ? rc : 1; |
@@ -183,19 +202,16 @@ static const struct i2c_algorithm i2c_powermac_algorithm = { | |||
183 | static int __devexit i2c_powermac_remove(struct platform_device *dev) | 202 | static int __devexit i2c_powermac_remove(struct platform_device *dev) |
184 | { | 203 | { |
185 | struct i2c_adapter *adapter = platform_get_drvdata(dev); | 204 | struct i2c_adapter *adapter = platform_get_drvdata(dev); |
186 | struct pmac_i2c_bus *bus = i2c_get_adapdata(adapter); | ||
187 | int rc; | 205 | int rc; |
188 | 206 | ||
189 | rc = i2c_del_adapter(adapter); | 207 | rc = i2c_del_adapter(adapter); |
190 | pmac_i2c_detach_adapter(bus, adapter); | ||
191 | i2c_set_adapdata(adapter, NULL); | ||
192 | /* We aren't that prepared to deal with this... */ | 208 | /* We aren't that prepared to deal with this... */ |
193 | if (rc) | 209 | if (rc) |
194 | printk(KERN_WARNING | 210 | printk(KERN_WARNING |
195 | "i2c-powermac.c: Failed to remove bus %s !\n", | 211 | "i2c-powermac.c: Failed to remove bus %s !\n", |
196 | adapter->name); | 212 | adapter->name); |
197 | platform_set_drvdata(dev, NULL); | 213 | platform_set_drvdata(dev, NULL); |
198 | kfree(adapter); | 214 | memset(adapter, 0, sizeof(*adapter)); |
199 | 215 | ||
200 | return 0; | 216 | return 0; |
201 | } | 217 | } |
@@ -206,12 +222,12 @@ static int __devinit i2c_powermac_probe(struct platform_device *dev) | |||
206 | struct pmac_i2c_bus *bus = dev->dev.platform_data; | 222 | struct pmac_i2c_bus *bus = dev->dev.platform_data; |
207 | struct device_node *parent = NULL; | 223 | struct device_node *parent = NULL; |
208 | struct i2c_adapter *adapter; | 224 | struct i2c_adapter *adapter; |
209 | char name[32]; | ||
210 | const char *basename; | 225 | const char *basename; |
211 | int rc; | 226 | int rc; |
212 | 227 | ||
213 | if (bus == NULL) | 228 | if (bus == NULL) |
214 | return -EINVAL; | 229 | return -EINVAL; |
230 | adapter = pmac_i2c_get_adapter(bus); | ||
215 | 231 | ||
216 | /* Ok, now we need to make up a name for the interface that will | 232 | /* Ok, now we need to make up a name for the interface that will |
217 | * match what we used to do in the past, that is basically the | 233 | * match what we used to do in the past, that is basically the |
@@ -237,29 +253,22 @@ static int __devinit i2c_powermac_probe(struct platform_device *dev) | |||
237 | default: | 253 | default: |
238 | return -EINVAL; | 254 | return -EINVAL; |
239 | } | 255 | } |
240 | snprintf(name, 32, "%s %d", basename, pmac_i2c_get_channel(bus)); | 256 | snprintf(adapter->name, sizeof(adapter->name), "%s %d", basename, |
257 | pmac_i2c_get_channel(bus)); | ||
241 | of_node_put(parent); | 258 | of_node_put(parent); |
242 | 259 | ||
243 | adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); | ||
244 | if (adapter == NULL) { | ||
245 | printk(KERN_ERR "i2c-powermac: can't allocate inteface !\n"); | ||
246 | return -ENOMEM; | ||
247 | } | ||
248 | platform_set_drvdata(dev, adapter); | 260 | platform_set_drvdata(dev, adapter); |
249 | strcpy(adapter->name, name); | ||
250 | adapter->algo = &i2c_powermac_algorithm; | 261 | adapter->algo = &i2c_powermac_algorithm; |
251 | i2c_set_adapdata(adapter, bus); | 262 | i2c_set_adapdata(adapter, bus); |
252 | adapter->dev.parent = &dev->dev; | 263 | adapter->dev.parent = &dev->dev; |
253 | pmac_i2c_attach_adapter(bus, adapter); | ||
254 | rc = i2c_add_adapter(adapter); | 264 | rc = i2c_add_adapter(adapter); |
255 | if (rc) { | 265 | if (rc) { |
256 | printk(KERN_ERR "i2c-powermac: Adapter %s registration " | 266 | printk(KERN_ERR "i2c-powermac: Adapter %s registration " |
257 | "failed\n", name); | 267 | "failed\n", adapter->name); |
258 | i2c_set_adapdata(adapter, NULL); | 268 | memset(adapter, 0, sizeof(*adapter)); |
259 | pmac_i2c_detach_adapter(bus, adapter); | ||
260 | } | 269 | } |
261 | 270 | ||
262 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); | 271 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", adapter->name); |
263 | 272 | ||
264 | if (!strncmp(basename, "uni-n", 5)) { | 273 | if (!strncmp(basename, "uni-n", 5)) { |
265 | struct device_node *np; | 274 | struct device_node *np; |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 139f0c7f12a4..844569f7d8b7 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -142,7 +142,7 @@ static void sis5595_write(u8 reg, u8 data) | |||
142 | outb(data, sis5595_base + SMB_DAT); | 142 | outb(data, sis5595_base + SMB_DAT); |
143 | } | 143 | } |
144 | 144 | ||
145 | static int sis5595_setup(struct pci_dev *SIS5595_dev) | 145 | static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev) |
146 | { | 146 | { |
147 | u16 a; | 147 | u16 a; |
148 | u8 val; | 148 | u8 val; |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 70ca41e90e58..68cff7af7013 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -389,7 +389,7 @@ static u32 sis630_func(struct i2c_adapter *adapter) | |||
389 | I2C_FUNC_SMBUS_BLOCK_DATA; | 389 | I2C_FUNC_SMBUS_BLOCK_DATA; |
390 | } | 390 | } |
391 | 391 | ||
392 | static int sis630_setup(struct pci_dev *sis630_dev) | 392 | static int __devinit sis630_setup(struct pci_dev *sis630_dev) |
393 | { | 393 | { |
394 | unsigned char b; | 394 | unsigned char b; |
395 | struct pci_dev *dummy = NULL; | 395 | struct pci_dev *dummy = NULL; |
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 1b7b2af94036..0c770eabe85e 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -35,6 +35,10 @@ 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)"); | 36 | "Chip addresses (up to 10, between 0x03 and 0x77)"); |
37 | 37 | ||
38 | static unsigned long functionality = ~0UL; | ||
39 | module_param(functionality, ulong, S_IRUGO | S_IWUSR); | ||
40 | MODULE_PARM_DESC(functionality, "Override functionality bitfield"); | ||
41 | |||
38 | struct stub_chip { | 42 | struct stub_chip { |
39 | u8 pointer; | 43 | u8 pointer; |
40 | u16 words[256]; /* Byte operations use the LSB as per SMBus | 44 | u16 words[256]; /* Byte operations use the LSB as per SMBus |
@@ -48,7 +52,7 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, | |||
48 | char read_write, u8 command, int size, union i2c_smbus_data * data) | 52 | char read_write, u8 command, int size, union i2c_smbus_data * data) |
49 | { | 53 | { |
50 | s32 ret; | 54 | s32 ret; |
51 | int i; | 55 | int i, len; |
52 | struct stub_chip *chip = NULL; | 56 | struct stub_chip *chip = NULL; |
53 | 57 | ||
54 | /* Search for the right chip */ | 58 | /* Search for the right chip */ |
@@ -118,6 +122,29 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, | |||
118 | ret = 0; | 122 | ret = 0; |
119 | break; | 123 | break; |
120 | 124 | ||
125 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
126 | len = data->block[0]; | ||
127 | if (read_write == I2C_SMBUS_WRITE) { | ||
128 | for (i = 0; i < len; i++) { | ||
129 | chip->words[command + i] &= 0xff00; | ||
130 | chip->words[command + i] |= data->block[1 + i]; | ||
131 | } | ||
132 | dev_dbg(&adap->dev, "i2c block data - addr 0x%02x, " | ||
133 | "wrote %d bytes at 0x%02x.\n", | ||
134 | addr, len, command); | ||
135 | } else { | ||
136 | for (i = 0; i < len; i++) { | ||
137 | data->block[1 + i] = | ||
138 | chip->words[command + i] & 0xff; | ||
139 | } | ||
140 | dev_dbg(&adap->dev, "i2c block data - addr 0x%02x, " | ||
141 | "read %d bytes at 0x%02x.\n", | ||
142 | addr, len, command); | ||
143 | } | ||
144 | |||
145 | ret = 0; | ||
146 | break; | ||
147 | |||
121 | default: | 148 | default: |
122 | dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n"); | 149 | dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n"); |
123 | ret = -EOPNOTSUPP; | 150 | ret = -EOPNOTSUPP; |
@@ -129,8 +156,9 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, | |||
129 | 156 | ||
130 | static u32 stub_func(struct i2c_adapter *adapter) | 157 | static u32 stub_func(struct i2c_adapter *adapter) |
131 | { | 158 | { |
132 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 159 | return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
133 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; | 160 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
161 | I2C_FUNC_SMBUS_I2C_BLOCK) & functionality; | ||
134 | } | 162 | } |
135 | 163 | ||
136 | static const struct i2c_algorithm smbus_algorithm = { | 164 | static const struct i2c_algorithm smbus_algorithm = { |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c deleted file mode 100644 index 7663d57833a0..000000000000 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ /dev/null | |||
@@ -1,248 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>, | ||
3 | Philip Edelbrock <phil@netroedge.com>, | ||
4 | Ralph Metzler <rjkm@thp.uni-koeln.de>, and | ||
5 | Mark D. Studebaker <mdsxyz123@yahoo.com> | ||
6 | |||
7 | Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and | ||
8 | Simon Vogl | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to | ||
26 | the BT869 and possibly other I2C devices. */ | ||
27 | |||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/module.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/pci.h> | ||
32 | #include <linux/i2c.h> | ||
33 | #include <linux/i2c-algo-bit.h> | ||
34 | #include <asm/io.h> | ||
35 | |||
36 | /* the only registers we use */ | ||
37 | #define REG 0x78 | ||
38 | #define REG2 0x70 | ||
39 | |||
40 | /* bit locations in the register */ | ||
41 | #define DDC_ENAB 0x00040000 | ||
42 | #define DDC_SCL_OUT 0x00080000 | ||
43 | #define DDC_SDA_OUT 0x00100000 | ||
44 | #define DDC_SCL_IN 0x00200000 | ||
45 | #define DDC_SDA_IN 0x00400000 | ||
46 | #define I2C_ENAB 0x00800000 | ||
47 | #define I2C_SCL_OUT 0x01000000 | ||
48 | #define I2C_SDA_OUT 0x02000000 | ||
49 | #define I2C_SCL_IN 0x04000000 | ||
50 | #define I2C_SDA_IN 0x08000000 | ||
51 | |||
52 | /* initialization states */ | ||
53 | #define INIT2 0x2 | ||
54 | #define INIT3 0x4 | ||
55 | |||
56 | /* delays */ | ||
57 | #define CYCLE_DELAY 10 | ||
58 | #define TIMEOUT (HZ / 2) | ||
59 | |||
60 | |||
61 | static void __iomem *ioaddr; | ||
62 | |||
63 | /* The voo GPIO registers don't have individual masks for each bit | ||
64 | so we always have to read before writing. */ | ||
65 | |||
66 | static void bit_vooi2c_setscl(void *data, int val) | ||
67 | { | ||
68 | unsigned int r; | ||
69 | r = readl(ioaddr + REG); | ||
70 | if (val) | ||
71 | r |= I2C_SCL_OUT; | ||
72 | else | ||
73 | r &= ~I2C_SCL_OUT; | ||
74 | writel(r, ioaddr + REG); | ||
75 | readl(ioaddr + REG); /* flush posted write */ | ||
76 | } | ||
77 | |||
78 | static void bit_vooi2c_setsda(void *data, int val) | ||
79 | { | ||
80 | unsigned int r; | ||
81 | r = readl(ioaddr + REG); | ||
82 | if (val) | ||
83 | r |= I2C_SDA_OUT; | ||
84 | else | ||
85 | r &= ~I2C_SDA_OUT; | ||
86 | writel(r, ioaddr + REG); | ||
87 | readl(ioaddr + REG); /* flush posted write */ | ||
88 | } | ||
89 | |||
90 | /* The GPIO pins are open drain, so the pins always remain outputs. | ||
91 | We rely on the i2c-algo-bit routines to set the pins high before | ||
92 | reading the input from other chips. */ | ||
93 | |||
94 | static int bit_vooi2c_getscl(void *data) | ||
95 | { | ||
96 | return (0 != (readl(ioaddr + REG) & I2C_SCL_IN)); | ||
97 | } | ||
98 | |||
99 | static int bit_vooi2c_getsda(void *data) | ||
100 | { | ||
101 | return (0 != (readl(ioaddr + REG) & I2C_SDA_IN)); | ||
102 | } | ||
103 | |||
104 | static void bit_vooddc_setscl(void *data, int val) | ||
105 | { | ||
106 | unsigned int r; | ||
107 | r = readl(ioaddr + REG); | ||
108 | if (val) | ||
109 | r |= DDC_SCL_OUT; | ||
110 | else | ||
111 | r &= ~DDC_SCL_OUT; | ||
112 | writel(r, ioaddr + REG); | ||
113 | readl(ioaddr + REG); /* flush posted write */ | ||
114 | } | ||
115 | |||
116 | static void bit_vooddc_setsda(void *data, int val) | ||
117 | { | ||
118 | unsigned int r; | ||
119 | r = readl(ioaddr + REG); | ||
120 | if (val) | ||
121 | r |= DDC_SDA_OUT; | ||
122 | else | ||
123 | r &= ~DDC_SDA_OUT; | ||
124 | writel(r, ioaddr + REG); | ||
125 | readl(ioaddr + REG); /* flush posted write */ | ||
126 | } | ||
127 | |||
128 | static int bit_vooddc_getscl(void *data) | ||
129 | { | ||
130 | return (0 != (readl(ioaddr + REG) & DDC_SCL_IN)); | ||
131 | } | ||
132 | |||
133 | static int bit_vooddc_getsda(void *data) | ||
134 | { | ||
135 | return (0 != (readl(ioaddr + REG) & DDC_SDA_IN)); | ||
136 | } | ||
137 | |||
138 | static int config_v3(struct pci_dev *dev) | ||
139 | { | ||
140 | unsigned long cadr; | ||
141 | |||
142 | /* map Voodoo3 memory */ | ||
143 | cadr = dev->resource[0].start; | ||
144 | cadr &= PCI_BASE_ADDRESS_MEM_MASK; | ||
145 | ioaddr = ioremap_nocache(cadr, 0x1000); | ||
146 | if (ioaddr) { | ||
147 | writel(0x8160, ioaddr + REG2); | ||
148 | writel(0xcffc0020, ioaddr + REG); | ||
149 | dev_info(&dev->dev, "Using Banshee/Voodoo3 I2C device at %p\n", ioaddr); | ||
150 | return 0; | ||
151 | } | ||
152 | return -ENODEV; | ||
153 | } | ||
154 | |||
155 | static struct i2c_algo_bit_data voo_i2c_bit_data = { | ||
156 | .setsda = bit_vooi2c_setsda, | ||
157 | .setscl = bit_vooi2c_setscl, | ||
158 | .getsda = bit_vooi2c_getsda, | ||
159 | .getscl = bit_vooi2c_getscl, | ||
160 | .udelay = CYCLE_DELAY, | ||
161 | .timeout = TIMEOUT | ||
162 | }; | ||
163 | |||
164 | static struct i2c_adapter voodoo3_i2c_adapter = { | ||
165 | .owner = THIS_MODULE, | ||
166 | .name = "I2C Voodoo3/Banshee adapter", | ||
167 | .algo_data = &voo_i2c_bit_data, | ||
168 | }; | ||
169 | |||
170 | static struct i2c_algo_bit_data voo_ddc_bit_data = { | ||
171 | .setsda = bit_vooddc_setsda, | ||
172 | .setscl = bit_vooddc_setscl, | ||
173 | .getsda = bit_vooddc_getsda, | ||
174 | .getscl = bit_vooddc_getscl, | ||
175 | .udelay = CYCLE_DELAY, | ||
176 | .timeout = TIMEOUT | ||
177 | }; | ||
178 | |||
179 | static struct i2c_adapter voodoo3_ddc_adapter = { | ||
180 | .owner = THIS_MODULE, | ||
181 | .class = I2C_CLASS_DDC, | ||
182 | .name = "DDC Voodoo3/Banshee adapter", | ||
183 | .algo_data = &voo_ddc_bit_data, | ||
184 | }; | ||
185 | |||
186 | static struct pci_device_id voodoo3_ids[] __devinitdata = { | ||
187 | { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3) }, | ||
188 | { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE) }, | ||
189 | { 0, } | ||
190 | }; | ||
191 | |||
192 | MODULE_DEVICE_TABLE (pci, voodoo3_ids); | ||
193 | |||
194 | static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_id *id) | ||
195 | { | ||
196 | int retval; | ||
197 | |||
198 | retval = config_v3(dev); | ||
199 | if (retval) | ||
200 | return retval; | ||
201 | |||
202 | /* set up the sysfs linkage to our parent device */ | ||
203 | voodoo3_i2c_adapter.dev.parent = &dev->dev; | ||
204 | voodoo3_ddc_adapter.dev.parent = &dev->dev; | ||
205 | |||
206 | retval = i2c_bit_add_bus(&voodoo3_i2c_adapter); | ||
207 | if (retval) | ||
208 | return retval; | ||
209 | retval = i2c_bit_add_bus(&voodoo3_ddc_adapter); | ||
210 | if (retval) | ||
211 | i2c_del_adapter(&voodoo3_i2c_adapter); | ||
212 | return retval; | ||
213 | } | ||
214 | |||
215 | static void __devexit voodoo3_remove(struct pci_dev *dev) | ||
216 | { | ||
217 | i2c_del_adapter(&voodoo3_i2c_adapter); | ||
218 | i2c_del_adapter(&voodoo3_ddc_adapter); | ||
219 | iounmap(ioaddr); | ||
220 | } | ||
221 | |||
222 | static struct pci_driver voodoo3_driver = { | ||
223 | .name = "voodoo3_smbus", | ||
224 | .id_table = voodoo3_ids, | ||
225 | .probe = voodoo3_probe, | ||
226 | .remove = __devexit_p(voodoo3_remove), | ||
227 | }; | ||
228 | |||
229 | static int __init i2c_voodoo3_init(void) | ||
230 | { | ||
231 | return pci_register_driver(&voodoo3_driver); | ||
232 | } | ||
233 | |||
234 | static void __exit i2c_voodoo3_exit(void) | ||
235 | { | ||
236 | pci_unregister_driver(&voodoo3_driver); | ||
237 | } | ||
238 | |||
239 | |||
240 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, " | ||
241 | "Philip Edelbrock <phil@netroedge.com>, " | ||
242 | "Ralph Metzler <rjkm@thp.uni-koeln.de>, " | ||
243 | "and Mark D. Studebaker <mdsxyz123@yahoo.com>"); | ||
244 | MODULE_DESCRIPTION("Voodoo3 I2C/SMBus driver"); | ||
245 | MODULE_LICENSE("GPL"); | ||
246 | |||
247 | module_init(i2c_voodoo3_init); | ||
248 | module_exit(i2c_voodoo3_exit); | ||
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index f9618f4d4e47..ae4539d99bef 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -6,16 +6,6 @@ | |||
6 | 6 | ||
7 | menu "Miscellaneous I2C Chip support" | 7 | menu "Miscellaneous I2C Chip support" |
8 | 8 | ||
9 | config DS1682 | ||
10 | tristate "Dallas DS1682 Total Elapsed Time Recorder with Alarm" | ||
11 | depends on EXPERIMENTAL | ||
12 | help | ||
13 | If you say yes here you get support for Dallas Semiconductor | ||
14 | DS1682 Total Elapsed Time Recorder. | ||
15 | |||
16 | This driver can also be built as a module. If so, the module | ||
17 | will be called ds1682. | ||
18 | |||
19 | config SENSORS_TSL2550 | 9 | config SENSORS_TSL2550 |
20 | tristate "Taos TSL2550 ambient light sensor" | 10 | tristate "Taos TSL2550 ambient light sensor" |
21 | depends on EXPERIMENTAL | 11 | depends on EXPERIMENTAL |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 749cf3606294..fe0af0f81f2d 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
@@ -10,7 +10,6 @@ | |||
10 | # * I/O expander drivers go to drivers/gpio | 10 | # * I/O expander drivers go to drivers/gpio |
11 | # | 11 | # |
12 | 12 | ||
13 | obj-$(CONFIG_DS1682) += ds1682.o | ||
14 | obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o | 13 | obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o |
15 | 14 | ||
16 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 15 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 296504355142..4f34823e86b1 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -558,11 +558,9 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter) | |||
558 | up_read(&__i2c_board_lock); | 558 | up_read(&__i2c_board_lock); |
559 | } | 559 | } |
560 | 560 | ||
561 | static int i2c_do_add_adapter(struct device_driver *d, void *data) | 561 | static int i2c_do_add_adapter(struct i2c_driver *driver, |
562 | struct i2c_adapter *adap) | ||
562 | { | 563 | { |
563 | struct i2c_driver *driver = to_i2c_driver(d); | ||
564 | struct i2c_adapter *adap = data; | ||
565 | |||
566 | /* Detect supported devices on that bus, and instantiate them */ | 564 | /* Detect supported devices on that bus, and instantiate them */ |
567 | i2c_detect(adap, driver); | 565 | i2c_detect(adap, driver); |
568 | 566 | ||
@@ -574,6 +572,11 @@ static int i2c_do_add_adapter(struct device_driver *d, void *data) | |||
574 | return 0; | 572 | return 0; |
575 | } | 573 | } |
576 | 574 | ||
575 | static int __process_new_adapter(struct device_driver *d, void *data) | ||
576 | { | ||
577 | return i2c_do_add_adapter(to_i2c_driver(d), data); | ||
578 | } | ||
579 | |||
577 | static int i2c_register_adapter(struct i2c_adapter *adap) | 580 | static int i2c_register_adapter(struct i2c_adapter *adap) |
578 | { | 581 | { |
579 | int res = 0, dummy; | 582 | int res = 0, dummy; |
@@ -584,7 +587,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
584 | goto out_list; | 587 | goto out_list; |
585 | } | 588 | } |
586 | 589 | ||
587 | mutex_init(&adap->bus_lock); | 590 | rt_mutex_init(&adap->bus_lock); |
588 | 591 | ||
589 | /* Set default timeout to 1 second if not already set */ | 592 | /* Set default timeout to 1 second if not already set */ |
590 | if (adap->timeout == 0) | 593 | if (adap->timeout == 0) |
@@ -614,7 +617,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
614 | /* Notify drivers */ | 617 | /* Notify drivers */ |
615 | mutex_lock(&core_lock); | 618 | mutex_lock(&core_lock); |
616 | dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, | 619 | dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, |
617 | i2c_do_add_adapter); | 620 | __process_new_adapter); |
618 | mutex_unlock(&core_lock); | 621 | mutex_unlock(&core_lock); |
619 | 622 | ||
620 | return 0; | 623 | return 0; |
@@ -715,10 +718,9 @@ retry: | |||
715 | } | 718 | } |
716 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); | 719 | EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); |
717 | 720 | ||
718 | static int i2c_do_del_adapter(struct device_driver *d, void *data) | 721 | static int i2c_do_del_adapter(struct i2c_driver *driver, |
722 | struct i2c_adapter *adapter) | ||
719 | { | 723 | { |
720 | struct i2c_driver *driver = to_i2c_driver(d); | ||
721 | struct i2c_adapter *adapter = data; | ||
722 | struct i2c_client *client, *_n; | 724 | struct i2c_client *client, *_n; |
723 | int res; | 725 | int res; |
724 | 726 | ||
@@ -750,6 +752,11 @@ static int __unregister_client(struct device *dev, void *dummy) | |||
750 | return 0; | 752 | return 0; |
751 | } | 753 | } |
752 | 754 | ||
755 | static int __process_removed_adapter(struct device_driver *d, void *data) | ||
756 | { | ||
757 | return i2c_do_del_adapter(to_i2c_driver(d), data); | ||
758 | } | ||
759 | |||
753 | /** | 760 | /** |
754 | * i2c_del_adapter - unregister I2C adapter | 761 | * i2c_del_adapter - unregister I2C adapter |
755 | * @adap: the adapter being unregistered | 762 | * @adap: the adapter being unregistered |
@@ -777,7 +784,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
777 | /* Tell drivers about this removal */ | 784 | /* Tell drivers about this removal */ |
778 | mutex_lock(&core_lock); | 785 | mutex_lock(&core_lock); |
779 | res = bus_for_each_drv(&i2c_bus_type, NULL, adap, | 786 | res = bus_for_each_drv(&i2c_bus_type, NULL, adap, |
780 | i2c_do_del_adapter); | 787 | __process_removed_adapter); |
781 | mutex_unlock(&core_lock); | 788 | mutex_unlock(&core_lock); |
782 | if (res) | 789 | if (res) |
783 | return res; | 790 | return res; |
@@ -826,22 +833,11 @@ EXPORT_SYMBOL(i2c_del_adapter); | |||
826 | 833 | ||
827 | /* ------------------------------------------------------------------------- */ | 834 | /* ------------------------------------------------------------------------- */ |
828 | 835 | ||
829 | static int __attach_adapter(struct device *dev, void *data) | 836 | static int __process_new_driver(struct device *dev, void *data) |
830 | { | 837 | { |
831 | struct i2c_adapter *adapter; | ||
832 | struct i2c_driver *driver = data; | ||
833 | |||
834 | if (dev->type != &i2c_adapter_type) | 838 | if (dev->type != &i2c_adapter_type) |
835 | return 0; | 839 | return 0; |
836 | adapter = to_i2c_adapter(dev); | 840 | return i2c_do_add_adapter(data, to_i2c_adapter(dev)); |
837 | |||
838 | i2c_detect(adapter, driver); | ||
839 | |||
840 | /* Legacy drivers scan i2c busses directly */ | ||
841 | if (driver->attach_adapter) | ||
842 | driver->attach_adapter(adapter); | ||
843 | |||
844 | return 0; | ||
845 | } | 841 | } |
846 | 842 | ||
847 | /* | 843 | /* |
@@ -873,40 +869,18 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
873 | INIT_LIST_HEAD(&driver->clients); | 869 | INIT_LIST_HEAD(&driver->clients); |
874 | /* Walk the adapters that are already present */ | 870 | /* Walk the adapters that are already present */ |
875 | mutex_lock(&core_lock); | 871 | mutex_lock(&core_lock); |
876 | bus_for_each_dev(&i2c_bus_type, NULL, driver, __attach_adapter); | 872 | bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_new_driver); |
877 | mutex_unlock(&core_lock); | 873 | mutex_unlock(&core_lock); |
878 | 874 | ||
879 | return 0; | 875 | return 0; |
880 | } | 876 | } |
881 | EXPORT_SYMBOL(i2c_register_driver); | 877 | EXPORT_SYMBOL(i2c_register_driver); |
882 | 878 | ||
883 | static int __detach_adapter(struct device *dev, void *data) | 879 | static int __process_removed_driver(struct device *dev, void *data) |
884 | { | 880 | { |
885 | struct i2c_adapter *adapter; | ||
886 | struct i2c_driver *driver = data; | ||
887 | struct i2c_client *client, *_n; | ||
888 | |||
889 | if (dev->type != &i2c_adapter_type) | 881 | if (dev->type != &i2c_adapter_type) |
890 | return 0; | 882 | return 0; |
891 | adapter = to_i2c_adapter(dev); | 883 | return i2c_do_del_adapter(data, to_i2c_adapter(dev)); |
892 | |||
893 | /* Remove the devices we created ourselves as the result of hardware | ||
894 | * probing (using a driver's detect method) */ | ||
895 | list_for_each_entry_safe(client, _n, &driver->clients, detected) { | ||
896 | dev_dbg(&adapter->dev, "Removing %s at 0x%x\n", | ||
897 | client->name, client->addr); | ||
898 | list_del(&client->detected); | ||
899 | i2c_unregister_device(client); | ||
900 | } | ||
901 | |||
902 | if (driver->detach_adapter) { | ||
903 | if (driver->detach_adapter(adapter)) | ||
904 | dev_err(&adapter->dev, | ||
905 | "detach_adapter failed for driver [%s]\n", | ||
906 | driver->driver.name); | ||
907 | } | ||
908 | |||
909 | return 0; | ||
910 | } | 884 | } |
911 | 885 | ||
912 | /** | 886 | /** |
@@ -917,7 +891,7 @@ static int __detach_adapter(struct device *dev, void *data) | |||
917 | void i2c_del_driver(struct i2c_driver *driver) | 891 | void i2c_del_driver(struct i2c_driver *driver) |
918 | { | 892 | { |
919 | mutex_lock(&core_lock); | 893 | mutex_lock(&core_lock); |
920 | bus_for_each_dev(&i2c_bus_type, NULL, driver, __detach_adapter); | 894 | bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_removed_driver); |
921 | mutex_unlock(&core_lock); | 895 | mutex_unlock(&core_lock); |
922 | 896 | ||
923 | driver_unregister(&driver->driver); | 897 | driver_unregister(&driver->driver); |
@@ -1092,12 +1066,12 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1092 | #endif | 1066 | #endif |
1093 | 1067 | ||
1094 | if (in_atomic() || irqs_disabled()) { | 1068 | if (in_atomic() || irqs_disabled()) { |
1095 | ret = mutex_trylock(&adap->bus_lock); | 1069 | ret = rt_mutex_trylock(&adap->bus_lock); |
1096 | if (!ret) | 1070 | if (!ret) |
1097 | /* I2C activity is ongoing. */ | 1071 | /* I2C activity is ongoing. */ |
1098 | return -EAGAIN; | 1072 | return -EAGAIN; |
1099 | } else { | 1073 | } else { |
1100 | mutex_lock_nested(&adap->bus_lock, adap->level); | 1074 | rt_mutex_lock(&adap->bus_lock); |
1101 | } | 1075 | } |
1102 | 1076 | ||
1103 | /* Retry automatically on arbitration loss */ | 1077 | /* Retry automatically on arbitration loss */ |
@@ -1109,7 +1083,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1109 | if (time_after(jiffies, orig_jiffies + adap->timeout)) | 1083 | if (time_after(jiffies, orig_jiffies + adap->timeout)) |
1110 | break; | 1084 | break; |
1111 | } | 1085 | } |
1112 | mutex_unlock(&adap->bus_lock); | 1086 | rt_mutex_unlock(&adap->bus_lock); |
1113 | 1087 | ||
1114 | return ret; | 1088 | return ret; |
1115 | } else { | 1089 | } else { |
@@ -1180,7 +1154,7 @@ EXPORT_SYMBOL(i2c_master_recv); | |||
1180 | * ---------------------------------------------------- | 1154 | * ---------------------------------------------------- |
1181 | */ | 1155 | */ |
1182 | 1156 | ||
1183 | static int i2c_detect_address(struct i2c_client *temp_client, int kind, | 1157 | static int i2c_detect_address(struct i2c_client *temp_client, |
1184 | struct i2c_driver *driver) | 1158 | struct i2c_driver *driver) |
1185 | { | 1159 | { |
1186 | struct i2c_board_info info; | 1160 | struct i2c_board_info info; |
@@ -1199,22 +1173,18 @@ static int i2c_detect_address(struct i2c_client *temp_client, int kind, | |||
1199 | if (i2c_check_addr(adapter, addr)) | 1173 | if (i2c_check_addr(adapter, addr)) |
1200 | return 0; | 1174 | return 0; |
1201 | 1175 | ||
1202 | /* Make sure there is something at this address, unless forced */ | 1176 | /* Make sure there is something at this address */ |
1203 | if (kind < 0) { | 1177 | if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) < 0) |
1204 | if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, | 1178 | return 0; |
1205 | I2C_SMBUS_QUICK, NULL) < 0) | ||
1206 | return 0; | ||
1207 | 1179 | ||
1208 | /* prevent 24RF08 corruption */ | 1180 | /* Prevent 24RF08 corruption */ |
1209 | if ((addr & ~0x0f) == 0x50) | 1181 | if ((addr & ~0x0f) == 0x50) |
1210 | i2c_smbus_xfer(adapter, addr, 0, 0, 0, | 1182 | i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL); |
1211 | I2C_SMBUS_QUICK, NULL); | ||
1212 | } | ||
1213 | 1183 | ||
1214 | /* Finally call the custom detection function */ | 1184 | /* Finally call the custom detection function */ |
1215 | memset(&info, 0, sizeof(struct i2c_board_info)); | 1185 | memset(&info, 0, sizeof(struct i2c_board_info)); |
1216 | info.addr = addr; | 1186 | info.addr = addr; |
1217 | err = driver->detect(temp_client, kind, &info); | 1187 | err = driver->detect(temp_client, -1, &info); |
1218 | if (err) { | 1188 | if (err) { |
1219 | /* -ENODEV is returned if the detection fails. We catch it | 1189 | /* -ENODEV is returned if the detection fails. We catch it |
1220 | here as this isn't an error. */ | 1190 | here as this isn't an error. */ |
@@ -1259,40 +1229,13 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) | |||
1259 | return -ENOMEM; | 1229 | return -ENOMEM; |
1260 | temp_client->adapter = adapter; | 1230 | temp_client->adapter = adapter; |
1261 | 1231 | ||
1262 | /* Force entries are done first, and are not affected by ignore | ||
1263 | entries */ | ||
1264 | if (address_data->forces) { | ||
1265 | const unsigned short * const *forces = address_data->forces; | ||
1266 | int kind; | ||
1267 | |||
1268 | for (kind = 0; forces[kind]; kind++) { | ||
1269 | for (i = 0; forces[kind][i] != I2C_CLIENT_END; | ||
1270 | i += 2) { | ||
1271 | if (forces[kind][i] == adap_id | ||
1272 | || forces[kind][i] == ANY_I2C_BUS) { | ||
1273 | dev_dbg(&adapter->dev, "found force " | ||
1274 | "parameter for adapter %d, " | ||
1275 | "addr 0x%02x, kind %d\n", | ||
1276 | adap_id, forces[kind][i + 1], | ||
1277 | kind); | ||
1278 | temp_client->addr = forces[kind][i + 1]; | ||
1279 | err = i2c_detect_address(temp_client, | ||
1280 | kind, driver); | ||
1281 | if (err) | ||
1282 | goto exit_free; | ||
1283 | } | ||
1284 | } | ||
1285 | } | ||
1286 | } | ||
1287 | |||
1288 | /* Stop here if the classes do not match */ | 1232 | /* Stop here if the classes do not match */ |
1289 | if (!(adapter->class & driver->class)) | 1233 | if (!(adapter->class & driver->class)) |
1290 | goto exit_free; | 1234 | goto exit_free; |
1291 | 1235 | ||
1292 | /* Stop here if we can't use SMBUS_QUICK */ | 1236 | /* Stop here if we can't use SMBUS_QUICK */ |
1293 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { | 1237 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { |
1294 | if (address_data->probe[0] == I2C_CLIENT_END | 1238 | if (address_data->normal_i2c[0] == I2C_CLIENT_END) |
1295 | && address_data->normal_i2c[0] == I2C_CLIENT_END) | ||
1296 | goto exit_free; | 1239 | goto exit_free; |
1297 | 1240 | ||
1298 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " | 1241 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " |
@@ -1301,48 +1244,12 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) | |||
1301 | goto exit_free; | 1244 | goto exit_free; |
1302 | } | 1245 | } |
1303 | 1246 | ||
1304 | /* Probe entries are done second, and are not affected by ignore | ||
1305 | entries either */ | ||
1306 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { | ||
1307 | if (address_data->probe[i] == adap_id | ||
1308 | || address_data->probe[i] == ANY_I2C_BUS) { | ||
1309 | dev_dbg(&adapter->dev, "found probe parameter for " | ||
1310 | "adapter %d, addr 0x%02x\n", adap_id, | ||
1311 | address_data->probe[i + 1]); | ||
1312 | temp_client->addr = address_data->probe[i + 1]; | ||
1313 | err = i2c_detect_address(temp_client, -1, driver); | ||
1314 | if (err) | ||
1315 | goto exit_free; | ||
1316 | } | ||
1317 | } | ||
1318 | |||
1319 | /* Normal entries are done last, unless shadowed by an ignore entry */ | ||
1320 | for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { | 1247 | for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { |
1321 | int j, ignore; | ||
1322 | |||
1323 | ignore = 0; | ||
1324 | for (j = 0; address_data->ignore[j] != I2C_CLIENT_END; | ||
1325 | j += 2) { | ||
1326 | if ((address_data->ignore[j] == adap_id || | ||
1327 | address_data->ignore[j] == ANY_I2C_BUS) | ||
1328 | && address_data->ignore[j + 1] | ||
1329 | == address_data->normal_i2c[i]) { | ||
1330 | dev_dbg(&adapter->dev, "found ignore " | ||
1331 | "parameter for adapter %d, " | ||
1332 | "addr 0x%02x\n", adap_id, | ||
1333 | address_data->ignore[j + 1]); | ||
1334 | ignore = 1; | ||
1335 | break; | ||
1336 | } | ||
1337 | } | ||
1338 | if (ignore) | ||
1339 | continue; | ||
1340 | |||
1341 | dev_dbg(&adapter->dev, "found normal entry for adapter %d, " | 1248 | dev_dbg(&adapter->dev, "found normal entry for adapter %d, " |
1342 | "addr 0x%02x\n", adap_id, | 1249 | "addr 0x%02x\n", adap_id, |
1343 | address_data->normal_i2c[i]); | 1250 | address_data->normal_i2c[i]); |
1344 | temp_client->addr = address_data->normal_i2c[i]; | 1251 | temp_client->addr = address_data->normal_i2c[i]; |
1345 | err = i2c_detect_address(temp_client, -1, driver); | 1252 | err = i2c_detect_address(temp_client, driver); |
1346 | if (err) | 1253 | if (err) |
1347 | goto exit_free; | 1254 | goto exit_free; |
1348 | } | 1255 | } |
@@ -1913,7 +1820,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, | |||
1913 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 1820 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; |
1914 | 1821 | ||
1915 | if (adapter->algo->smbus_xfer) { | 1822 | if (adapter->algo->smbus_xfer) { |
1916 | mutex_lock(&adapter->bus_lock); | 1823 | rt_mutex_lock(&adapter->bus_lock); |
1917 | 1824 | ||
1918 | /* Retry automatically on arbitration loss */ | 1825 | /* Retry automatically on arbitration loss */ |
1919 | orig_jiffies = jiffies; | 1826 | orig_jiffies = jiffies; |
@@ -1927,7 +1834,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, | |||
1927 | orig_jiffies + adapter->timeout)) | 1834 | orig_jiffies + adapter->timeout)) |
1928 | break; | 1835 | break; |
1929 | } | 1836 | } |
1930 | mutex_unlock(&adapter->bus_lock); | 1837 | rt_mutex_unlock(&adapter->bus_lock); |
1931 | } else | 1838 | } else |
1932 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1839 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, |
1933 | command, protocol, data); | 1840 | command, protocol, data); |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 7e13d2df9af3..f4110aa49600 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
37 | #include <linux/smp_lock.h> | ||
38 | #include <linux/jiffies.h> | 37 | #include <linux/jiffies.h> |
39 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
40 | 39 | ||
@@ -445,20 +444,14 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
445 | struct i2c_client *client; | 444 | struct i2c_client *client; |
446 | struct i2c_adapter *adap; | 445 | struct i2c_adapter *adap; |
447 | struct i2c_dev *i2c_dev; | 446 | struct i2c_dev *i2c_dev; |
448 | int ret = 0; | ||
449 | 447 | ||
450 | lock_kernel(); | ||
451 | i2c_dev = i2c_dev_get_by_minor(minor); | 448 | i2c_dev = i2c_dev_get_by_minor(minor); |
452 | if (!i2c_dev) { | 449 | if (!i2c_dev) |
453 | ret = -ENODEV; | 450 | return -ENODEV; |
454 | goto out; | ||
455 | } | ||
456 | 451 | ||
457 | adap = i2c_get_adapter(i2c_dev->adap->nr); | 452 | adap = i2c_get_adapter(i2c_dev->adap->nr); |
458 | if (!adap) { | 453 | if (!adap) |
459 | ret = -ENODEV; | 454 | return -ENODEV; |
460 | goto out; | ||
461 | } | ||
462 | 455 | ||
463 | /* This creates an anonymous i2c_client, which may later be | 456 | /* This creates an anonymous i2c_client, which may later be |
464 | * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. | 457 | * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. |
@@ -470,8 +463,7 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
470 | client = kzalloc(sizeof(*client), GFP_KERNEL); | 463 | client = kzalloc(sizeof(*client), GFP_KERNEL); |
471 | if (!client) { | 464 | if (!client) { |
472 | i2c_put_adapter(adap); | 465 | i2c_put_adapter(adap); |
473 | ret = -ENOMEM; | 466 | return -ENOMEM; |
474 | goto out; | ||
475 | } | 467 | } |
476 | snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); | 468 | snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); |
477 | client->driver = &i2cdev_driver; | 469 | client->driver = &i2cdev_driver; |
@@ -479,9 +471,7 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
479 | client->adapter = adap; | 471 | client->adapter = adap; |
480 | file->private_data = client; | 472 | file->private_data = client; |
481 | 473 | ||
482 | out: | 474 | return 0; |
483 | unlock_kernel(); | ||
484 | return ret; | ||
485 | } | 475 | } |
486 | 476 | ||
487 | static int i2cdev_release(struct inode *inode, struct file *file) | 477 | static int i2cdev_release(struct inode *inode, struct file *file) |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a2ea383105a6..2c16ca6501d5 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -246,6 +246,16 @@ config EP93XX_PWM | |||
246 | To compile this driver as a module, choose M here: the module will | 246 | To compile this driver as a module, choose M here: the module will |
247 | be called ep93xx_pwm. | 247 | be called ep93xx_pwm. |
248 | 248 | ||
249 | config DS1682 | ||
250 | tristate "Dallas DS1682 Total Elapsed Time Recorder with Alarm" | ||
251 | depends on I2C && EXPERIMENTAL | ||
252 | help | ||
253 | If you say yes here you get support for Dallas Semiconductor | ||
254 | DS1682 Total Elapsed Time Recorder. | ||
255 | |||
256 | This driver can also be built as a module. If so, the module | ||
257 | will be called ds1682. | ||
258 | |||
249 | source "drivers/misc/c2port/Kconfig" | 259 | source "drivers/misc/c2port/Kconfig" |
250 | source "drivers/misc/eeprom/Kconfig" | 260 | source "drivers/misc/eeprom/Kconfig" |
251 | source "drivers/misc/cb710/Kconfig" | 261 | source "drivers/misc/cb710/Kconfig" |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e311267a355f..906a0edcea40 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -20,6 +20,7 @@ obj-$(CONFIG_SGI_GRU) += sgi-gru/ | |||
20 | obj-$(CONFIG_HP_ILO) += hpilo.o | 20 | obj-$(CONFIG_HP_ILO) += hpilo.o |
21 | obj-$(CONFIG_ISL29003) += isl29003.o | 21 | obj-$(CONFIG_ISL29003) += isl29003.o |
22 | obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o | 22 | obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o |
23 | obj-$(CONFIG_DS1682) += ds1682.o | ||
23 | obj-$(CONFIG_C2PORT) += c2port/ | 24 | obj-$(CONFIG_C2PORT) += c2port/ |
24 | obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ | 25 | obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ |
25 | obj-y += eeprom/ | 26 | obj-y += eeprom/ |
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/misc/ds1682.c index f3ee4a1abb77..f3ee4a1abb77 100644 --- a/drivers/i2c/chips/ds1682.c +++ b/drivers/misc/ds1682.c | |||
diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c index 6e43ab4231ae..4bb7a3af9ad9 100644 --- a/drivers/misc/ics932s401.c +++ b/drivers/misc/ics932s401.c | |||
@@ -417,32 +417,25 @@ static int ics932s401_detect(struct i2c_client *client, int kind, | |||
417 | struct i2c_board_info *info) | 417 | struct i2c_board_info *info) |
418 | { | 418 | { |
419 | struct i2c_adapter *adapter = client->adapter; | 419 | struct i2c_adapter *adapter = client->adapter; |
420 | int vendor, device, revision; | ||
420 | 421 | ||
421 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 422 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
422 | return -ENODEV; | 423 | return -ENODEV; |
423 | 424 | ||
424 | if (kind <= 0) { | 425 | vendor = i2c_smbus_read_word_data(client, ICS932S401_REG_VENDOR_REV); |
425 | int vendor, device, revision; | 426 | vendor >>= 8; |
426 | 427 | revision = vendor >> ICS932S401_REV_SHIFT; | |
427 | vendor = i2c_smbus_read_word_data(client, | 428 | vendor &= ICS932S401_VENDOR_MASK; |
428 | ICS932S401_REG_VENDOR_REV); | 429 | if (vendor != ICS932S401_VENDOR) |
429 | vendor >>= 8; | 430 | return -ENODEV; |
430 | revision = vendor >> ICS932S401_REV_SHIFT; | 431 | |
431 | vendor &= ICS932S401_VENDOR_MASK; | 432 | device = i2c_smbus_read_word_data(client, ICS932S401_REG_DEVICE); |
432 | if (vendor != ICS932S401_VENDOR) | 433 | device >>= 8; |
433 | return -ENODEV; | 434 | if (device != ICS932S401_DEVICE) |
434 | 435 | return -ENODEV; | |
435 | device = i2c_smbus_read_word_data(client, | 436 | |
436 | ICS932S401_REG_DEVICE); | 437 | if (revision != ICS932S401_REV) |
437 | device >>= 8; | 438 | dev_info(&adapter->dev, "Unknown revision %d\n", revision); |
438 | if (device != ICS932S401_DEVICE) | ||
439 | return -ENODEV; | ||
440 | |||
441 | if (revision != ICS932S401_REV) | ||
442 | dev_info(&adapter->dev, "Unknown revision %d\n", | ||
443 | revision); | ||
444 | } else | ||
445 | dev_dbg(&adapter->dev, "detection forced\n"); | ||
446 | 439 | ||
447 | strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); | 440 | strlcpy(info->type, "ics932s401", I2C_NAME_SIZE); |
448 | 441 | ||
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 7b40cda57a70..419ab546b266 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -110,7 +110,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, | |||
110 | * @driver: Device driver model driver | 110 | * @driver: Device driver model driver |
111 | * @id_table: List of I2C devices supported by this driver | 111 | * @id_table: List of I2C devices supported by this driver |
112 | * @detect: Callback for device detection | 112 | * @detect: Callback for device detection |
113 | * @address_data: The I2C addresses to probe, ignore or force (for detect) | 113 | * @address_data: The I2C addresses to probe (for detect) |
114 | * @clients: List of detected clients we created (for i2c-core use only) | 114 | * @clients: List of detected clients we created (for i2c-core use only) |
115 | * | 115 | * |
116 | * The driver.owner field should be set to the module owner of this driver. | 116 | * The driver.owner field should be set to the module owner of this driver. |
@@ -338,8 +338,7 @@ struct i2c_adapter { | |||
338 | void *algo_data; | 338 | void *algo_data; |
339 | 339 | ||
340 | /* data fields that are valid for all devices */ | 340 | /* data fields that are valid for all devices */ |
341 | u8 level; /* nesting level for lockdep */ | 341 | struct rt_mutex bus_lock; |
342 | struct mutex bus_lock; | ||
343 | 342 | ||
344 | int timeout; /* in jiffies */ | 343 | int timeout; /* in jiffies */ |
345 | int retries; | 344 | int retries; |
@@ -367,7 +366,7 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data) | |||
367 | */ | 366 | */ |
368 | static inline void i2c_lock_adapter(struct i2c_adapter *adapter) | 367 | static inline void i2c_lock_adapter(struct i2c_adapter *adapter) |
369 | { | 368 | { |
370 | mutex_lock(&adapter->bus_lock); | 369 | rt_mutex_lock(&adapter->bus_lock); |
371 | } | 370 | } |
372 | 371 | ||
373 | /** | 372 | /** |
@@ -376,7 +375,7 @@ static inline void i2c_lock_adapter(struct i2c_adapter *adapter) | |||
376 | */ | 375 | */ |
377 | static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) | 376 | static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) |
378 | { | 377 | { |
379 | mutex_unlock(&adapter->bus_lock); | 378 | rt_mutex_unlock(&adapter->bus_lock); |
380 | } | 379 | } |
381 | 380 | ||
382 | /*flags for the client struct: */ | 381 | /*flags for the client struct: */ |
@@ -398,9 +397,6 @@ static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) | |||
398 | */ | 397 | */ |
399 | struct i2c_client_address_data { | 398 | struct i2c_client_address_data { |
400 | const unsigned short *normal_i2c; | 399 | const unsigned short *normal_i2c; |
401 | const unsigned short *probe; | ||
402 | const unsigned short *ignore; | ||
403 | const unsigned short * const *forces; | ||
404 | }; | 400 | }; |
405 | 401 | ||
406 | /* Internal numbers to terminate lists */ | 402 | /* Internal numbers to terminate lists */ |
@@ -614,134 +610,48 @@ union i2c_smbus_data { | |||
614 | module_param_array(var, short, &var##_num, 0); \ | 610 | module_param_array(var, short, &var##_num, 0); \ |
615 | MODULE_PARM_DESC(var, desc) | 611 | MODULE_PARM_DESC(var, desc) |
616 | 612 | ||
617 | #define I2C_CLIENT_MODULE_PARM_FORCE(name) \ | ||
618 | I2C_CLIENT_MODULE_PARM(force_##name, \ | ||
619 | "List of adapter,address pairs which are " \ | ||
620 | "unquestionably assumed to contain a `" \ | ||
621 | # name "' chip") | ||
622 | |||
623 | |||
624 | #define I2C_CLIENT_INSMOD_COMMON \ | 613 | #define I2C_CLIENT_INSMOD_COMMON \ |
625 | I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \ | ||
626 | "additionally"); \ | ||
627 | I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ | ||
628 | "scan"); \ | ||
629 | static const struct i2c_client_address_data addr_data = { \ | 614 | static const struct i2c_client_address_data addr_data = { \ |
630 | .normal_i2c = normal_i2c, \ | 615 | .normal_i2c = normal_i2c, \ |
631 | .probe = probe, \ | ||
632 | .ignore = ignore, \ | ||
633 | .forces = forces, \ | ||
634 | } | 616 | } |
635 | 617 | ||
636 | #define I2C_CLIENT_FORCE_TEXT \ | ||
637 | "List of adapter,address pairs to boldly assume to be present" | ||
638 | |||
639 | /* These are the ones you want to use in your own drivers. Pick the one | 618 | /* These are the ones you want to use in your own drivers. Pick the one |
640 | which matches the number of devices the driver differenciates between. */ | 619 | which matches the number of devices the driver differenciates between. */ |
641 | #define I2C_CLIENT_INSMOD \ | 620 | #define I2C_CLIENT_INSMOD \ |
642 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
643 | static const unsigned short * const forces[] = { force, NULL }; \ | ||
644 | I2C_CLIENT_INSMOD_COMMON | 621 | I2C_CLIENT_INSMOD_COMMON |
645 | 622 | ||
646 | #define I2C_CLIENT_INSMOD_1(chip1) \ | 623 | #define I2C_CLIENT_INSMOD_1(chip1) \ |
647 | enum chips { any_chip, chip1 }; \ | 624 | enum chips { any_chip, chip1 }; \ |
648 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
649 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
650 | static const unsigned short * const forces[] = { force, \ | ||
651 | force_##chip1, NULL }; \ | ||
652 | I2C_CLIENT_INSMOD_COMMON | 625 | I2C_CLIENT_INSMOD_COMMON |
653 | 626 | ||
654 | #define I2C_CLIENT_INSMOD_2(chip1, chip2) \ | 627 | #define I2C_CLIENT_INSMOD_2(chip1, chip2) \ |
655 | enum chips { any_chip, chip1, chip2 }; \ | 628 | enum chips { any_chip, chip1, chip2 }; \ |
656 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
657 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
658 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
659 | static const unsigned short * const forces[] = { force, \ | ||
660 | force_##chip1, force_##chip2, NULL }; \ | ||
661 | I2C_CLIENT_INSMOD_COMMON | 629 | I2C_CLIENT_INSMOD_COMMON |
662 | 630 | ||
663 | #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ | 631 | #define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ |
664 | enum chips { any_chip, chip1, chip2, chip3 }; \ | 632 | enum chips { any_chip, chip1, chip2, chip3 }; \ |
665 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
666 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
667 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
668 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
669 | static const unsigned short * const forces[] = { force, \ | ||
670 | force_##chip1, force_##chip2, force_##chip3, NULL }; \ | ||
671 | I2C_CLIENT_INSMOD_COMMON | 633 | I2C_CLIENT_INSMOD_COMMON |
672 | 634 | ||
673 | #define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \ | 635 | #define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \ |
674 | enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ | 636 | enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ |
675 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
676 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
677 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
678 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
679 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
680 | static const unsigned short * const forces[] = { force, \ | ||
681 | force_##chip1, force_##chip2, force_##chip3, \ | ||
682 | force_##chip4, NULL}; \ | ||
683 | I2C_CLIENT_INSMOD_COMMON | 637 | I2C_CLIENT_INSMOD_COMMON |
684 | 638 | ||
685 | #define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \ | 639 | #define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \ |
686 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ | 640 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ |
687 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
688 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
689 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
690 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
691 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
692 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
693 | static const unsigned short * const forces[] = { force, \ | ||
694 | force_##chip1, force_##chip2, force_##chip3, \ | ||
695 | force_##chip4, force_##chip5, NULL }; \ | ||
696 | I2C_CLIENT_INSMOD_COMMON | 641 | I2C_CLIENT_INSMOD_COMMON |
697 | 642 | ||
698 | #define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \ | 643 | #define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \ |
699 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ | 644 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ |
700 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
701 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
702 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
703 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
704 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
705 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
706 | I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ | ||
707 | static const unsigned short * const forces[] = { force, \ | ||
708 | force_##chip1, force_##chip2, force_##chip3, \ | ||
709 | force_##chip4, force_##chip5, force_##chip6, NULL }; \ | ||
710 | I2C_CLIENT_INSMOD_COMMON | 645 | I2C_CLIENT_INSMOD_COMMON |
711 | 646 | ||
712 | #define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ | 647 | #define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ |
713 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ | 648 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ |
714 | chip7 }; \ | 649 | chip7 }; \ |
715 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
716 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
717 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
718 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
719 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
720 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
721 | I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ | ||
722 | I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ | ||
723 | static const unsigned short * const forces[] = { force, \ | ||
724 | force_##chip1, force_##chip2, force_##chip3, \ | ||
725 | force_##chip4, force_##chip5, force_##chip6, \ | ||
726 | force_##chip7, NULL }; \ | ||
727 | I2C_CLIENT_INSMOD_COMMON | 650 | I2C_CLIENT_INSMOD_COMMON |
728 | 651 | ||
729 | #define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ | 652 | #define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ |
730 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ | 653 | enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ |
731 | chip7, chip8 }; \ | 654 | chip7, chip8 }; \ |
732 | I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ | ||
733 | I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ | ||
734 | I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ | ||
735 | I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ | ||
736 | I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ | ||
737 | I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ | ||
738 | I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ | ||
739 | I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ | ||
740 | I2C_CLIENT_MODULE_PARM_FORCE(chip8); \ | ||
741 | static const unsigned short * const forces[] = { force, \ | ||
742 | force_##chip1, force_##chip2, force_##chip3, \ | ||
743 | force_##chip4, force_##chip5, force_##chip6, \ | ||
744 | force_##chip7, force_##chip8, NULL }; \ | ||
745 | I2C_CLIENT_INSMOD_COMMON | 655 | I2C_CLIENT_INSMOD_COMMON |
746 | #endif /* __KERNEL__ */ | 656 | #endif /* __KERNEL__ */ |
747 | #endif /* _LINUX_I2C_H */ | 657 | #endif /* _LINUX_I2C_H */ |