aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/hwmon/lm787
-rw-r--r--Documentation/hwmon/w83792d174
-rw-r--r--Documentation/i2c/chips/max687594
-rw-r--r--Documentation/i2c/functionality2
-rw-r--r--Documentation/i2c/porting-clients25
-rw-r--r--Documentation/i2c/writing-clients114
-rw-r--r--MAINTAINERS9
-rw-r--r--drivers/hwmon/Kconfig72
-rw-r--r--drivers/hwmon/Makefile4
-rw-r--r--drivers/hwmon/adm1021.c35
-rw-r--r--drivers/hwmon/adm1025.c31
-rw-r--r--drivers/hwmon/adm1026.c25
-rw-r--r--drivers/hwmon/adm1031.c24
-rw-r--r--drivers/hwmon/adm9240.c33
-rw-r--r--drivers/hwmon/asb100.c56
-rw-r--r--drivers/hwmon/atxp1.c26
-rw-r--r--drivers/hwmon/ds1621.c29
-rw-r--r--drivers/hwmon/fscher.c27
-rw-r--r--drivers/hwmon/fscpos.c27
-rw-r--r--drivers/hwmon/gl518sm.c28
-rw-r--r--drivers/hwmon/gl520sm.c31
-rw-r--r--drivers/hwmon/hwmon-vid.c189
-rw-r--r--drivers/hwmon/hwmon.c98
-rw-r--r--drivers/hwmon/it87.c76
-rw-r--r--drivers/hwmon/lm63.c27
-rw-r--r--drivers/hwmon/lm75.c41
-rw-r--r--drivers/hwmon/lm75.h2
-rw-r--r--drivers/hwmon/lm77.c24
-rw-r--r--drivers/hwmon/lm78.c84
-rw-r--r--drivers/hwmon/lm80.c27
-rw-r--r--drivers/hwmon/lm83.c27
-rw-r--r--drivers/hwmon/lm85.c39
-rw-r--r--drivers/hwmon/lm87.c31
-rw-r--r--drivers/hwmon/lm90.c27
-rw-r--r--drivers/hwmon/lm92.c28
-rw-r--r--drivers/hwmon/max1619.c28
-rw-r--r--drivers/hwmon/pc87360.c852
-rw-r--r--drivers/hwmon/sis5595.c70
-rw-r--r--drivers/hwmon/smsc47b397.c74
-rw-r--r--drivers/hwmon/smsc47m1.c70
-rw-r--r--drivers/hwmon/via686a.c76
-rw-r--r--drivers/hwmon/w83627ehf.c64
-rw-r--r--drivers/hwmon/w83627hf.c80
-rw-r--r--drivers/hwmon/w83781d.c90
-rw-r--r--drivers/hwmon/w83792d.c1649
-rw-r--r--drivers/hwmon/w83l785ts.c27
-rw-r--r--drivers/i2c/Makefile4
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c4
-rw-r--r--drivers/i2c/algos/i2c-algo-ite.c4
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c16
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c4
-rw-r--r--drivers/i2c/algos/i2c-algo-sgi.c5
-rw-r--r--drivers/i2c/algos/i2c-algo-sibyte.c4
-rw-r--r--drivers/i2c/busses/Kconfig8
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c2
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c2
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c2
-rw-r--r--drivers/i2c/busses/i2c-amd756.c2
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c2
-rw-r--r--drivers/i2c/busses/i2c-au1550.c2
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c4
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-isa.c161
-rw-r--r--drivers/i2c/busses/i2c-keywest.c15
-rw-r--r--drivers/i2c/busses/i2c-mpc.c4
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c12
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c33
-rw-r--r--drivers/i2c/busses/i2c-piix4.c2
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c1
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c2
-rw-r--r--drivers/i2c/busses/i2c-sis630.c2
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c2
-rw-r--r--drivers/i2c/busses/i2c-stub.c2
-rw-r--r--drivers/i2c/busses/i2c-viapro.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c4
-rw-r--r--drivers/i2c/chips/Kconfig10
-rw-r--r--drivers/i2c/chips/ds1337.c11
-rw-r--r--drivers/i2c/chips/ds1374.c3
-rw-r--r--drivers/i2c/chips/eeprom.c17
-rw-r--r--drivers/i2c/chips/m41t00.c3
-rw-r--r--drivers/i2c/chips/max6875.c462
-rw-r--r--drivers/i2c/chips/pca9539.c12
-rw-r--r--drivers/i2c/chips/pcf8574.c13
-rw-r--r--drivers/i2c/chips/pcf8591.c13
-rw-r--r--drivers/i2c/chips/rtc8564.c1
-rw-r--r--drivers/i2c/i2c-core.c256
-rw-r--r--drivers/i2c/i2c-dev.c5
-rw-r--r--drivers/i2c/i2c-sensor-detect.c145
-rw-r--r--drivers/i2c/i2c-sensor-vid.c98
-rw-r--r--drivers/ieee1394/pcilynx.c20
-rw-r--r--drivers/media/common/saa7146_i2c.c4
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c3
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c2
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c1
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c1
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c3
-rw-r--r--drivers/media/video/adv7170.c1
-rw-r--r--drivers/media/video/adv7175.c1
-rw-r--r--drivers/media/video/bt819.c1
-rw-r--r--drivers/media/video/bt832.c4
-rw-r--r--drivers/media/video/bt856.c1
-rw-r--r--drivers/media/video/bttv-i2c.c12
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c8
-rw-r--r--drivers/media/video/ir-kbd-i2c.c6
-rw-r--r--drivers/media/video/msp3400.c4
-rw-r--r--drivers/media/video/ovcamchip/ov6x20.c6
-rw-r--r--drivers/media/video/ovcamchip/ov6x30.c4
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_core.c14
-rw-r--r--drivers/media/video/saa7110.c1
-rw-r--r--drivers/media/video/saa7111.c1
-rw-r--r--drivers/media/video/saa7114.c1
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c10
-rw-r--r--drivers/media/video/saa7185.c1
-rw-r--r--drivers/media/video/tda7432.c4
-rw-r--r--drivers/media/video/tda9840.c4
-rw-r--r--drivers/media/video/tda9875.c4
-rw-r--r--drivers/media/video/tda9887.c8
-rw-r--r--drivers/media/video/tea6415c.c4
-rw-r--r--drivers/media/video/tea6420.c4
-rw-r--r--drivers/media/video/tuner-3036.c3
-rw-r--r--drivers/media/video/tuner-core.c2
-rw-r--r--drivers/media/video/tvaudio.c51
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/tvmixer.c14
-rw-r--r--drivers/media/video/vpx3220.c1
-rw-r--r--drivers/media/video/zoran_card.c2
-rw-r--r--drivers/usb/media/w9968cf.c12
-rw-r--r--drivers/video/aty/radeon_i2c.c2
-rw-r--r--drivers/video/matrox/matroxfb_maven.c2
-rw-r--r--drivers/video/nvidia/nv_i2c.c3
-rw-r--r--drivers/video/riva/rivafb-i2c.c3
-rw-r--r--drivers/video/savage/savagefb-i2c.c3
-rw-r--r--include/linux/hwmon-sysfs.h15
-rw-r--r--include/linux/hwmon-vid.h45
-rw-r--r--include/linux/hwmon.h35
-rw-r--r--include/linux/i2c-id.h192
-rw-r--r--include/linux/i2c-isa.h36
-rw-r--r--include/linux/i2c-sensor.h263
-rw-r--r--include/linux/i2c-vid.h111
-rw-r--r--include/linux/i2c.h206
-rw-r--r--include/media/id.h5
145 files changed, 4433 insertions, 2752 deletions
diff --git a/Documentation/hwmon/lm78 b/Documentation/hwmon/lm78
index 357086ed7f64..fd5dc7a19f0e 100644
--- a/Documentation/hwmon/lm78
+++ b/Documentation/hwmon/lm78
@@ -2,16 +2,11 @@ Kernel driver lm78
2================== 2==================
3 3
4Supported chips: 4Supported chips:
5 * National Semiconductor LM78 5 * National Semiconductor LM78 / LM78-J
6 Prefix: 'lm78' 6 Prefix: 'lm78'
7 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 7 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
8 Datasheet: Publicly available at the National Semiconductor website 8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/ 9 http://www.national.com/
10 * National Semiconductor LM78-J
11 Prefix: 'lm78-j'
12 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
13 Datasheet: Publicly available at the National Semiconductor website
14 http://www.national.com/
15 * National Semiconductor LM79 10 * National Semiconductor LM79
16 Prefix: 'lm79' 11 Prefix: 'lm79'
17 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 12 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
diff --git a/Documentation/hwmon/w83792d b/Documentation/hwmon/w83792d
new file mode 100644
index 000000000000..8171c285bb55
--- /dev/null
+++ b/Documentation/hwmon/w83792d
@@ -0,0 +1,174 @@
1Kernel driver w83792d
2=====================
3
4Supported chips:
5 * Winbond W83792D
6 Prefix: 'w83792d'
7 Addresses scanned: I2C 0x2c - 0x2f
8 Datasheet: http://www.winbond.com.tw/E-WINBONDHTM/partner/PDFresult.asp?Pname=1035
9
10Author: Chunhao Huang
11Contact: DZShen <DZShen@Winbond.com.tw>
12
13
14Module Parameters
15-----------------
16
17* init int
18 (default 1)
19 Use 'init=0' to bypass initializing the chip.
20 Try this if your computer crashes when you load the module.
21
22* force_subclients=bus,caddr,saddr,saddr
23 This is used to force the i2c addresses for subclients of
24 a certain chip. Example usage is `force_subclients=0,0x2f,0x4a,0x4b'
25 to force the subclients of chip 0x2f on bus 0 to i2c addresses
26 0x4a and 0x4b.
27
28
29Description
30-----------
31
32This driver implements support for the Winbond W83792AD/D.
33
34Detection of the chip can sometimes be foiled because it can be in an
35internal state that allows no clean access (Bank with ID register is not
36currently selected). If you know the address of the chip, use a 'force'
37parameter; this will put it into a more well-behaved state first.
38
39The driver implements three temperature sensors, seven fan rotation speed
40sensors, nine voltage sensors, and two automatic fan regulation
41strategies called: Smart Fan I (Thermal Cruise mode) and Smart Fan II.
42Automatic fan control mode is possible only for fan1-fan3. Fan4-fan7 can run
43synchronized with selected fan (fan1-fan3). This functionality and manual PWM
44control for fan4-fan7 is not yet implemented.
45
46Temperatures are measured in degrees Celsius and measurement resolution is 1
47degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when
48the temperature gets higher than the Overtemperature Shutdown value; it stays
49on until the temperature falls below the Hysteresis value.
50
51Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
52triggered if the rotation speed has dropped below a programmable limit. Fan
53readings can be divided by a programmable divider (1, 2, 4, 8, 16, 32, 64 or
54128) to give the readings more range or accuracy.
55
56Voltage sensors (also known as IN sensors) report their values in millivolts.
57An alarm is triggered if the voltage has crossed a programmable minimum
58or maximum limit.
59
60Alarms are provided as output from "realtime status register". Following bits
61are defined:
62
63bit - alarm on:
640 - in0
651 - in1
662 - temp1
673 - temp2
684 - temp3
695 - fan1
706 - fan2
717 - fan3
728 - in2
739 - in3
7410 - in4
7511 - in5
7612 - in6
7713 - VID change
7814 - chassis
7915 - fan7
8016 - tart1
8117 - tart2
8218 - tart3
8319 - in7
8420 - in8
8521 - fan4
8622 - fan5
8723 - fan6
88
89Tart will be asserted while target temperature cannot be achieved after 3 minutes
90of full speed rotation of corresponding fan.
91
92In addition to the alarms described above, there is a CHAS alarm on the chips
93which triggers if your computer case is open (This one is latched, contrary
94to realtime alarms).
95
96The chips only update values each 3 seconds; reading them more often will
97do no harm, but will return 'old' values.
98
99
100W83792D PROBLEMS
101----------------
102Known problems:
103 - This driver is only for Winbond W83792D C version device, there
104 are also some motherboards with B version W83792D device. The
105 calculation method to in6-in7(measured value, limits) is a little
106 different between C and B version. C or B version can be identified
107 by CR[0x49h].
108 - The function of vid and vrm has not been finished, because I'm NOT
109 very familiar with them. Adding support is welcome.
110  - The function of chassis open detection needs more tests.
111 - If you have ASUS server board and chip was not found: Then you will
112 need to upgrade to latest (or beta) BIOS. If it does not help please
113 contact us.
114
115Fan control
116-----------
117
118Manual mode
119-----------
120
121Works as expected. You just need to specify desired PWM/DC value (fan speed)
122in appropriate pwm# file.
123
124Thermal cruise
125--------------
126
127In this mode, W83792D provides the Smart Fan system to automatically control
128fan speed to keep the temperatures of CPU and the system within specific
129range. At first a wanted temperature and interval must be set. This is done
130via thermal_cruise# file. The tolerance# file serves to create T +- tolerance
131interval. The fan speed will be lowered as long as the current temperature
132remains below the thermal_cruise# +- tolerance# value. Once the temperature
133exceeds the high limit (T+tolerance), the fan will be turned on with a
134specific speed set by pwm# and automatically controlled its PWM duty cycle
135with the temperature varying. Three conditions may occur:
136
137(1) If the temperature still exceeds the high limit, PWM duty
138cycle will increase slowly.
139
140(2) If the temperature goes below the high limit, but still above the low
141limit (T-tolerance), the fan speed will be fixed at the current speed because
142the temperature is in the target range.
143
144(3) If the temperature goes below the low limit, PWM duty cycle will decrease
145slowly to 0 or a preset stop value until the temperature exceeds the low
146limit. (The preset stop value handling is not yet implemented in driver)
147
148Smart Fan II
149------------
150
151W83792D also provides a special mode for fan. Four temperature points are
152available. When related temperature sensors detects the temperature in preset
153temperature region (sf2_point@_fan# +- tolerance#) it will cause fans to run
154on programmed value from sf2_level@_fan#. You need to set four temperatures
155for each fan.
156
157
158/sys files
159----------
160
161pwm[1-3] - this file stores PWM duty cycle or DC value (fan speed) in range:
162 0 (stop) to 255 (full)
163pwm[1-3]_enable - this file controls mode of fan/temperature control:
164 * 0 Disabled
165 * 1 Manual mode
166 * 2 Smart Fan II
167 * 3 Thermal Cruise
168pwm[1-3]_mode - Select PWM of DC mode
169 * 0 DC
170 * 1 PWM
171thermal_cruise[1-3] - Selects the desired temperature for cruise (degC)
172tolerance[1-3] - Value in degrees of Celsius (degC) for +- T
173sf2_point[1-4]_fan[1-3] - four temperature points for each fan for Smart Fan II
174sf2_level[1-3]_fan[1-3] - three PWM/DC levels for each fan for Smart Fan II
diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875
index b02002898a09..96fec562a8e9 100644
--- a/Documentation/i2c/chips/max6875
+++ b/Documentation/i2c/chips/max6875
@@ -4,22 +4,13 @@ Kernel driver max6875
4Supported chips: 4Supported chips:
5 * Maxim MAX6874, MAX6875 5 * Maxim MAX6874, MAX6875
6 Prefix: 'max6875' 6 Prefix: 'max6875'
7 Addresses scanned: 0x50, 0x52 7 Addresses scanned: None (see below)
8 Datasheet: 8 Datasheet:
9 http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf 9 http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
10 10
11Author: Ben Gardner <bgardner@wabtec.com> 11Author: Ben Gardner <bgardner@wabtec.com>
12 12
13 13
14Module Parameters
15-----------------
16
17* allow_write int
18 Set to non-zero to enable write permission:
19 *0: Read only
20 1: Read and write
21
22
23Description 14Description
24----------- 15-----------
25 16
@@ -33,34 +24,85 @@ registers.
33 24
34The Maxim MAX6874 is a similar, mostly compatible device, with more intputs 25The Maxim MAX6874 is a similar, mostly compatible device, with more intputs
35and outputs: 26and outputs:
36
37 vin gpi vout 27 vin gpi vout
38MAX6874 6 4 8 28MAX6874 6 4 8
39MAX6875 4 3 5 29MAX6875 4 3 5
40 30
41MAX6874 chips can have four different addresses (as opposed to only two for 31See the datasheet for more information.
42the MAX6875). The additional addresses (0x54 and 0x56) are not probed by
43this driver by default, but the probe module parameter can be used if
44needed.
45
46See the datasheet for details on how to program the EEPROM.
47 32
48 33
49Sysfs entries 34Sysfs entries
50------------- 35-------------
51 36
52eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if 37eeprom - 512 bytes of user-defined EEPROM space.
53 allow_write was set and register 0x43 is 0.
54
55eeprom_config - 70 bytes of config EEPROM. Note that changes will not get
56 loaded into register space until a power cycle or device reset.
57
58reg_config - 70 bytes of register space. Any changes take affect immediately.
59 38
60 39
61General Remarks 40General Remarks
62--------------- 41---------------
63 42
64A typical application will require that the EEPROMs be programmed once and 43Valid addresses for the MAX6875 are 0x50 and 0x52.
65never altered afterwards. 44Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56.
45The driver does not probe any address, so you must force the address.
46
47Example:
48$ modprobe max6875 force=0,0x50
49
50The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple
51addresses. For example, for address 0x50, it also reserves 0x51.
52The even-address instance is called 'max6875', the odd one is 'max6875 subclient'.
53
54
55Programming the chip using i2c-dev
56----------------------------------
57
58Use the i2c-dev interface to access and program the chips.
59Reads and writes are performed differently depending on the address range.
60
61The configuration registers are at addresses 0x00 - 0x45.
62Use i2c_smbus_write_byte_data() to write a register and
63i2c_smbus_read_byte_data() to read a register.
64The command is the register number.
65
66Examples:
67To write a 1 to register 0x45:
68 i2c_smbus_write_byte_data(fd, 0x45, 1);
69
70To read register 0x45:
71 value = i2c_smbus_read_byte_data(fd, 0x45);
72
73
74The configuration EEPROM is at addresses 0x8000 - 0x8045.
75The user EEPROM is at addresses 0x8100 - 0x82ff.
76
77Use i2c_smbus_write_word_data() to write a byte to EEPROM.
78
79The command is the upper byte of the address: 0x80, 0x81, or 0x82.
80The data word is the lower part of the address or'd with data << 8.
81 cmd = address >> 8;
82 val = (address & 0xff) | (data << 8);
83
84Example:
85To write 0x5a to address 0x8003:
86 i2c_smbus_write_word_data(fd, 0x80, 0x5a03);
87
88
89Reading data from the EEPROM is a little more complicated.
90Use i2c_smbus_write_byte_data() to set the read address and then
91i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data.
92
93Example:
94To read data starting at offset 0x8100, first set the address:
95 i2c_smbus_write_byte_data(fd, 0x81, 0x00);
96
97And then read the data
98 value = i2c_smbus_read_byte(fd);
99
100 or
101
102 count = i2c_smbus_read_i2c_block_data(fd, 0x84, buffer);
103
104The block read should read 16 bytes.
1050x84 is the block read command.
106
107See the datasheet for more details.
66 108
diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality
index 8a78a95ae04e..41ffefbdc60c 100644
--- a/Documentation/i2c/functionality
+++ b/Documentation/i2c/functionality
@@ -115,7 +115,7 @@ CHECKING THROUGH /DEV
115If you try to access an adapter from a userspace program, you will have 115If you try to access an adapter from a userspace program, you will have
116to use the /dev interface. You will still have to check whether the 116to use the /dev interface. You will still have to check whether the
117functionality you need is supported, of course. This is done using 117functionality you need is supported, of course. This is done using
118the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2c_detect 118the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2cdetect
119program, is below: 119program, is below:
120 120
121 int file; 121 int file;
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index a7adbdd9ea8a..4849dfd6961c 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -1,4 +1,4 @@
1Revision 4, 2004-03-30 1Revision 5, 2005-07-29
2Jean Delvare <khali@linux-fr.org> 2Jean Delvare <khali@linux-fr.org>
3Greg KH <greg@kroah.com> 3Greg KH <greg@kroah.com>
4 4
@@ -17,20 +17,22 @@ yours for best results.
17 17
18Technical changes: 18Technical changes:
19 19
20* [Includes] Get rid of "version.h". Replace <linux/i2c-proc.h> with 20* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>.
21 <linux/i2c-sensor.h>. Includes typically look like that: 21 Includes typically look like that:
22 #include <linux/module.h> 22 #include <linux/module.h>
23 #include <linux/init.h> 23 #include <linux/init.h>
24 #include <linux/slab.h> 24 #include <linux/slab.h>
25 #include <linux/i2c.h> 25 #include <linux/i2c.h>
26 #include <linux/i2c-sensor.h> 26 #include <linux/hwmon.h> /* for hardware monitoring drivers */
27 #include <linux/i2c-vid.h> /* if you need VRM support */ 27 #include <linux/hwmon-sysfs.h>
28 #include <linux/hwmon-vid.h> /* if you need VRM support */
28 #include <asm/io.h> /* if you have I/O operations */ 29 #include <asm/io.h> /* if you have I/O operations */
29 Please respect this inclusion order. Some extra headers may be 30 Please respect this inclusion order. Some extra headers may be
30 required for a given driver (e.g. "lm75.h"). 31 required for a given driver (e.g. "lm75.h").
31 32
32* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, SENSORS_ISA_END 33* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses
33 becomes I2C_CLIENT_ISA_END. 34 are no more handled by the i2c core.
35 SENSORS_INSMOD_<n> becomes I2C_CLIENT_INSMOD_<n>.
34 36
35* [Client data] Get rid of sysctl_id. Try using standard names for 37* [Client data] Get rid of sysctl_id. Try using standard names for
36 register values (for example, temp_os becomes temp_max). You're 38 register values (for example, temp_os becomes temp_max). You're
@@ -66,13 +68,15 @@ Technical changes:
66 if (!(adapter->class & I2C_CLASS_HWMON)) 68 if (!(adapter->class & I2C_CLASS_HWMON))
67 return 0; 69 return 0;
68 ISA-only drivers of course don't need this. 70 ISA-only drivers of course don't need this.
71 Call i2c_probe() instead of i2c_detect().
69 72
70* [Detect] As mentioned earlier, the flags parameter is gone. 73* [Detect] As mentioned earlier, the flags parameter is gone.
71 The type_name and client_name strings are replaced by a single 74 The type_name and client_name strings are replaced by a single
72 name string, which will be filled with a lowercase, short string 75 name string, which will be filled with a lowercase, short string
73 (typically the driver name, e.g. "lm75"). 76 (typically the driver name, e.g. "lm75").
74 In i2c-only drivers, drop the i2c_is_isa_adapter check, it's 77 In i2c-only drivers, drop the i2c_is_isa_adapter check, it's
75 useless. 78 useless. Same for isa-only drivers, as the test would always be
79 true. Only hybrid drivers (which are quite rare) still need it.
76 The errorN labels are reduced to the number needed. If that number 80 The errorN labels are reduced to the number needed. If that number
77 is 2 (i2c-only drivers), it is advised that the labels are named 81 is 2 (i2c-only drivers), it is advised that the labels are named
78 exit and exit_free. For i2c+isa drivers, labels should be named 82 exit and exit_free. For i2c+isa drivers, labels should be named
@@ -86,6 +90,8 @@ Technical changes:
86 device_create_file. Move the driver initialization before any 90 device_create_file. Move the driver initialization before any
87 sysfs file creation. 91 sysfs file creation.
88 Drop client->id. 92 Drop client->id.
93 Drop any 24RF08 corruption prevention you find, as this is now done
94 at the i2c-core level, and doing it twice voids it.
89 95
90* [Init] Limits must not be set by the driver (can be done later in 96* [Init] Limits must not be set by the driver (can be done later in
91 user-space). Chip should not be reset default (although a module 97 user-space). Chip should not be reset default (although a module
@@ -93,7 +99,8 @@ Technical changes:
93 limited to the strictly necessary steps. 99 limited to the strictly necessary steps.
94 100
95* [Detach] Get rid of data, remove the call to 101* [Detach] Get rid of data, remove the call to
96 i2c_deregister_entry. 102 i2c_deregister_entry. Do not log an error message if
103 i2c_detach_client fails, as i2c-core will now do it for you.
97 104
98* [Update] Don't access client->data directly, use 105* [Update] Don't access client->data directly, use
99 i2c_get_clientdata(client) instead. 106 i2c_get_clientdata(client) instead.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 91664be91ffc..077275722a7c 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -148,15 +148,15 @@ are defined in i2c.h to help you support them, as well as a generic
148detection algorithm. 148detection algorithm.
149 149
150You do not have to use this parameter interface; but don't try to use 150You do not have to use this parameter interface; but don't try to use
151function i2c_probe() (or i2c_detect()) if you don't. 151function i2c_probe() if you don't.
152 152
153NOTE: If you want to write a `sensors' driver, the interface is slightly 153NOTE: If you want to write a `sensors' driver, the interface is slightly
154 different! See below. 154 different! See below.
155 155
156 156
157 157
158Probing classes (i2c) 158Probing classes
159--------------------- 159---------------
160 160
161All parameters are given as lists of unsigned 16-bit integers. Lists are 161All parameters are given as lists of unsigned 16-bit integers. Lists are
162terminated by I2C_CLIENT_END. 162terminated by I2C_CLIENT_END.
@@ -171,12 +171,18 @@ The following lists are used internally:
171 ignore: insmod parameter. 171 ignore: insmod parameter.
172 A list of pairs. The first value is a bus number (-1 for any I2C bus), 172 A list of pairs. The first value is a bus number (-1 for any I2C bus),
173 the second is the I2C address. These addresses are never probed. 173 the second is the I2C address. These addresses are never probed.
174 This parameter overrules 'normal' and 'probe', but not the 'force' lists. 174 This parameter overrules the 'normal_i2c' list only.
175 force: insmod parameter. 175 force: insmod parameter.
176 A list of pairs. The first value is a bus number (-1 for any I2C bus), 176 A list of pairs. The first value is a bus number (-1 for any I2C bus),
177 the second is the I2C address. A device is blindly assumed to be on 177 the second is the I2C address. A device is blindly assumed to be on
178 the given address, no probing is done. 178 the given address, no probing is done.
179 179
180Additionally, kind-specific force lists may optionally be defined if
181the driver supports several chip kinds. They are grouped in a
182NULL-terminated list of pointers named forces, those first element if the
183generic force list mentioned above. Each additional list correspond to an
184insmod parameter of the form force_<kind>.
185
180Fortunately, as a module writer, you just have to define the `normal_i2c' 186Fortunately, as a module writer, you just have to define the `normal_i2c'
181parameter. The complete declaration could look like this: 187parameter. The complete declaration could look like this:
182 188
@@ -186,66 +192,17 @@ parameter. The complete declaration could look like this:
186 192
187 /* Magic definition of all other variables and things */ 193 /* Magic definition of all other variables and things */
188 I2C_CLIENT_INSMOD; 194 I2C_CLIENT_INSMOD;
195 /* Or, if your driver supports, say, 2 kind of devices: */
196 I2C_CLIENT_INSMOD_2(foo, bar);
197
198If you use the multi-kind form, an enum will be defined for you:
199 enum chips { any_chip, foo, bar, ... }
200You can then (and certainly should) use it in the driver code.
189 201
190Note that you *have* to call the defined variable `normal_i2c', 202Note that you *have* to call the defined variable `normal_i2c',
191without any prefix! 203without any prefix!
192 204
193 205
194Probing classes (sensors)
195-------------------------
196
197If you write a `sensors' driver, you use a slightly different interface.
198As well as I2C addresses, we have to cope with ISA addresses. Also, we
199use a enum of chip types. Don't forget to include `sensors.h'.
200
201The following lists are used internally. They are all lists of integers.
202
203 normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.
204 A list of I2C addresses which should normally be examined.
205 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
206 A list of ISA addresses which should normally be examined.
207 probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.
208 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
209 the ISA bus, -1 for any I2C bus), the second is the address. These
210 addresses are also probed, as if they were in the 'normal' list.
211 ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values.
212 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
213 the ISA bus, -1 for any I2C bus), the second is the I2C address. These
214 addresses are never probed. This parameter overrules 'normal' and
215 'probe', but not the 'force' lists.
216
217Also used is a list of pointers to sensors_force_data structures:
218 force_data: insmod parameters. A list, ending with an element of which
219 the force field is NULL.
220 Each element contains the type of chip and a list of pairs.
221 The first value is a bus number (SENSORS_ISA_BUS for the ISA bus,
222 -1 for any I2C bus), the second is the address.
223 These are automatically translated to insmod variables of the form
224 force_foo.
225
226So we have a generic insmod variabled `force', and chip-specific variables
227`force_CHIPNAME'.
228
229Fortunately, as a module writer, you just have to define the `normal_i2c'
230and `normal_isa' parameters, and define what chip names are used.
231The complete declaration could look like this:
232 /* Scan i2c addresses 0x37, and 0x48 to 0x4f */
233 static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
234 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
235 /* Scan ISA address 0x290 */
236 static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END};
237
238 /* Define chips foo and bar, as well as all module parameters and things */
239 SENSORS_INSMOD_2(foo,bar);
240
241If you have one chip, you use macro SENSORS_INSMOD_1(chip), if you have 2
242you use macro SENSORS_INSMOD_2(chip1,chip2), etc. If you do not want to
243bother with chip types, you can use SENSORS_INSMOD_0.
244
245A enum is automatically defined as follows:
246 enum chips { any_chip, chip1, chip2, ... }
247
248
249Attaching to an adapter 206Attaching to an adapter
250----------------------- 207-----------------------
251 208
@@ -264,17 +221,10 @@ detected at a specific address, another callback is called.
264 return i2c_probe(adapter,&addr_data,&foo_detect_client); 221 return i2c_probe(adapter,&addr_data,&foo_detect_client);
265 } 222 }
266 223
267For `sensors' drivers, use the i2c_detect function instead:
268
269 int foo_attach_adapter(struct i2c_adapter *adapter)
270 {
271 return i2c_detect(adapter,&addr_data,&foo_detect_client);
272 }
273
274Remember, structure `addr_data' is defined by the macros explained above, 224Remember, structure `addr_data' is defined by the macros explained above,
275so you do not have to define it yourself. 225so you do not have to define it yourself.
276 226
277The i2c_probe or i2c_detect function will call the foo_detect_client 227The i2c_probe function will call the foo_detect_client
278function only for those i2c addresses that actually have a device on 228function only for those i2c addresses that actually have a device on
279them (unless a `force' parameter was used). In addition, addresses that 229them (unless a `force' parameter was used). In addition, addresses that
280are already in use (by some other registered client) are skipped. 230are already in use (by some other registered client) are skipped.
@@ -283,19 +233,18 @@ are already in use (by some other registered client) are skipped.
283The detect client function 233The detect client function
284-------------------------- 234--------------------------
285 235
286The detect client function is called by i2c_probe or i2c_detect. 236The detect client function is called by i2c_probe. The `kind' parameter
287The `kind' parameter contains 0 if this call is due to a `force' 237contains -1 for a probed detection, 0 for a forced detection, or a positive
288parameter, and -1 otherwise (for i2c_detect, it contains 0 if 238number for a forced detection with a chip type forced.
289this call is due to the generic `force' parameter, and the chip type
290number if it is due to a specific `force' parameter).
291 239
292Below, some things are only needed if this is a `sensors' driver. Those 240Below, some things are only needed if this is a `sensors' driver. Those
293parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */ 241parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */
294markers. 242markers.
295 243
296This function should only return an error (any value != 0) if there is 244Returning an error different from -ENODEV in a detect function will cause
297some reason why no more detection should be done anymore. If the 245the detection to stop: other addresses and adapters won't be scanned.
298detection just fails for this address, return 0. 246This should only be done on fatal or internal errors, such as a memory
247shortage or i2c_attach_client failing.
299 248
300For now, you can ignore the `flags' parameter. It is there for future use. 249For now, you can ignore the `flags' parameter. It is there for future use.
301 250
@@ -320,11 +269,10 @@ For now, you can ignore the `flags' parameter. It is there for future use.
320 const char *type_name = ""; 269 const char *type_name = "";
321 int is_isa = i2c_is_isa_adapter(adapter); 270 int is_isa = i2c_is_isa_adapter(adapter);
322 271
323 if (is_isa) { 272 /* Do this only if the chip can additionally be found on the ISA bus
273 (hybrid chip). */
324 274
325 /* If this client can't be on the ISA bus at all, we can stop now 275 if (is_isa) {
326 (call `goto ERROR0'). But for kicks, we will assume it is all
327 right. */
328 276
329 /* Discard immediately if this ISA range is already used */ 277 /* Discard immediately if this ISA range is already used */
330 if (check_region(address,FOO_EXTENT)) 278 if (check_region(address,FOO_EXTENT))
@@ -495,15 +443,13 @@ much simpler than the attachment code, fortunately!
495 /* SENSORS ONLY END */ 443 /* SENSORS ONLY END */
496 444
497 /* Try to detach the client from i2c space */ 445 /* Try to detach the client from i2c space */
498 if ((err = i2c_detach_client(client))) { 446 if ((err = i2c_detach_client(client)))
499 printk("foo.o: Client deregistration failed, client not detached.\n");
500 return err; 447 return err;
501 }
502 448
503 /* SENSORS ONLY START */ 449 /* HYBRID SENSORS CHIP ONLY START */
504 if i2c_is_isa_client(client) 450 if i2c_is_isa_client(client)
505 release_region(client->addr,LM78_EXTENT); 451 release_region(client->addr,LM78_EXTENT);
506 /* SENSORS ONLY END */ 452 /* HYBRID SENSORS CHIP ONLY END */
507 453
508 kfree(client); /* Frees client data too, if allocated at the same time */ 454 kfree(client); /* Frees client data too, if allocated at the same time */
509 return 0; 455 return 0;
diff --git a/MAINTAINERS b/MAINTAINERS
index 5899ec1504f3..7e1f67130a16 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -933,6 +933,13 @@ M: khc@pm.waw.pl
933W: http://www.kernel.org/pub/linux/utils/net/hdlc/ 933W: http://www.kernel.org/pub/linux/utils/net/hdlc/
934S: Maintained 934S: Maintained
935 935
936HARDWARE MONITORING
937P: Jean Delvare
938M: khali@linux-fr.org
939L: lm-sensors@lm-sensors.org
940W: http://www.lm-sensors.nu/
941S: Maintained
942
936HARMONY SOUND DRIVER 943HARMONY SOUND DRIVER
937P: Kyle McMartin 944P: Kyle McMartin
938M: kyle@parisc-linux.org 945M: kyle@parisc-linux.org
@@ -1014,7 +1021,7 @@ P: William Irwin
1014M: wli@holomorphy.com 1021M: wli@holomorphy.com
1015S: Maintained 1022S: Maintained
1016 1023
1017I2C AND SENSORS DRIVERS 1024I2C SUBSYSTEM
1018P: Greg Kroah-Hartman 1025P: Greg Kroah-Hartman
1019M: greg@kroah.com 1026M: greg@kroah.com
1020P: Jean Delvare 1027P: Jean Delvare
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 140d5f851a5b..138dc50270e3 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -12,12 +12,20 @@ config HWMON
12 of a system. Most modern motherboards include such a device. It 12 of a system. Most modern motherboards include such a device. It
13 can include temperature sensors, voltage sensors, fan speed 13 can include temperature sensors, voltage sensors, fan speed
14 sensors and various additional features such as the ability to 14 sensors and various additional features such as the ability to
15 control the speed of the fans. 15 control the speed of the fans. If you want this support you
16 should say Y here and also to the specific driver(s) for your
17 sensors chip(s) below.
18
19 This support can also be built as a module. If so, the module
20 will be called hwmon.
21
22config HWMON_VID
23 tristate
24 default n
16 25
17config SENSORS_ADM1021 26config SENSORS_ADM1021
18 tristate "Analog Devices ADM1021 and compatibles" 27 tristate "Analog Devices ADM1021 and compatibles"
19 depends on HWMON && I2C 28 depends on HWMON && I2C
20 select I2C_SENSOR
21 help 29 help
22 If you say yes here you get support for Analog Devices ADM1021 30 If you say yes here you get support for Analog Devices ADM1021
23 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, 31 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
@@ -30,7 +38,7 @@ config SENSORS_ADM1021
30config SENSORS_ADM1025 38config SENSORS_ADM1025
31 tristate "Analog Devices ADM1025 and compatibles" 39 tristate "Analog Devices ADM1025 and compatibles"
32 depends on HWMON && I2C && EXPERIMENTAL 40 depends on HWMON && I2C && EXPERIMENTAL
33 select I2C_SENSOR 41 select HWMON_VID
34 help 42 help
35 If you say yes here you get support for Analog Devices ADM1025 43 If you say yes here you get support for Analog Devices ADM1025
36 and Philips NE1619 sensor chips. 44 and Philips NE1619 sensor chips.
@@ -41,7 +49,7 @@ config SENSORS_ADM1025
41config SENSORS_ADM1026 49config SENSORS_ADM1026
42 tristate "Analog Devices ADM1026 and compatibles" 50 tristate "Analog Devices ADM1026 and compatibles"
43 depends on HWMON && I2C && EXPERIMENTAL 51 depends on HWMON && I2C && EXPERIMENTAL
44 select I2C_SENSOR 52 select HWMON_VID
45 help 53 help
46 If you say yes here you get support for Analog Devices ADM1026 54 If you say yes here you get support for Analog Devices ADM1026
47 sensor chip. 55 sensor chip.
@@ -52,7 +60,6 @@ config SENSORS_ADM1026
52config SENSORS_ADM1031 60config SENSORS_ADM1031
53 tristate "Analog Devices ADM1031 and compatibles" 61 tristate "Analog Devices ADM1031 and compatibles"
54 depends on HWMON && I2C && EXPERIMENTAL 62 depends on HWMON && I2C && EXPERIMENTAL
55 select I2C_SENSOR
56 help 63 help
57 If you say yes here you get support for Analog Devices ADM1031 64 If you say yes here you get support for Analog Devices ADM1031
58 and ADM1030 sensor chips. 65 and ADM1030 sensor chips.
@@ -63,7 +70,7 @@ config SENSORS_ADM1031
63config SENSORS_ADM9240 70config SENSORS_ADM9240
64 tristate "Analog Devices ADM9240 and compatibles" 71 tristate "Analog Devices ADM9240 and compatibles"
65 depends on HWMON && I2C && EXPERIMENTAL 72 depends on HWMON && I2C && EXPERIMENTAL
66 select I2C_SENSOR 73 select HWMON_VID
67 help 74 help
68 If you say yes here you get support for Analog Devices ADM9240, 75 If you say yes here you get support for Analog Devices ADM9240,
69 Dallas DS1780, National Semiconductor LM81 sensor chips. 76 Dallas DS1780, National Semiconductor LM81 sensor chips.
@@ -74,7 +81,7 @@ config SENSORS_ADM9240
74config SENSORS_ASB100 81config SENSORS_ASB100
75 tristate "Asus ASB100 Bach" 82 tristate "Asus ASB100 Bach"
76 depends on HWMON && I2C && EXPERIMENTAL 83 depends on HWMON && I2C && EXPERIMENTAL
77 select I2C_SENSOR 84 select HWMON_VID
78 help 85 help
79 If you say yes here you get support for the ASB100 Bach sensor 86 If you say yes here you get support for the ASB100 Bach sensor
80 chip found on some Asus mainboards. 87 chip found on some Asus mainboards.
@@ -85,7 +92,7 @@ config SENSORS_ASB100
85config SENSORS_ATXP1 92config SENSORS_ATXP1
86 tristate "Attansic ATXP1 VID controller" 93 tristate "Attansic ATXP1 VID controller"
87 depends on HWMON && I2C && EXPERIMENTAL 94 depends on HWMON && I2C && EXPERIMENTAL
88 select I2C_SENSOR 95 select HWMON_VID
89 help 96 help
90 If you say yes here you get support for the Attansic ATXP1 VID 97 If you say yes here you get support for the Attansic ATXP1 VID
91 controller. 98 controller.
@@ -99,7 +106,6 @@ config SENSORS_ATXP1
99config SENSORS_DS1621 106config SENSORS_DS1621
100 tristate "Dallas Semiconductor DS1621 and DS1625" 107 tristate "Dallas Semiconductor DS1621 and DS1625"
101 depends on HWMON && I2C && EXPERIMENTAL 108 depends on HWMON && I2C && EXPERIMENTAL
102 select I2C_SENSOR
103 help 109 help
104 If you say yes here you get support for Dallas Semiconductor 110 If you say yes here you get support for Dallas Semiconductor
105 DS1621 and DS1625 sensor chips. 111 DS1621 and DS1625 sensor chips.
@@ -110,7 +116,6 @@ config SENSORS_DS1621
110config SENSORS_FSCHER 116config SENSORS_FSCHER
111 tristate "FSC Hermes" 117 tristate "FSC Hermes"
112 depends on HWMON && I2C && EXPERIMENTAL 118 depends on HWMON && I2C && EXPERIMENTAL
113 select I2C_SENSOR
114 help 119 help
115 If you say yes here you get support for Fujitsu Siemens 120 If you say yes here you get support for Fujitsu Siemens
116 Computers Hermes sensor chips. 121 Computers Hermes sensor chips.
@@ -121,7 +126,6 @@ config SENSORS_FSCHER
121config SENSORS_FSCPOS 126config SENSORS_FSCPOS
122 tristate "FSC Poseidon" 127 tristate "FSC Poseidon"
123 depends on HWMON && I2C && EXPERIMENTAL 128 depends on HWMON && I2C && EXPERIMENTAL
124 select I2C_SENSOR
125 help 129 help
126 If you say yes here you get support for Fujitsu Siemens 130 If you say yes here you get support for Fujitsu Siemens
127 Computers Poseidon sensor chips. 131 Computers Poseidon sensor chips.
@@ -132,7 +136,6 @@ config SENSORS_FSCPOS
132config SENSORS_GL518SM 136config SENSORS_GL518SM
133 tristate "Genesys Logic GL518SM" 137 tristate "Genesys Logic GL518SM"
134 depends on HWMON && I2C 138 depends on HWMON && I2C
135 select I2C_SENSOR
136 help 139 help
137 If you say yes here you get support for Genesys Logic GL518SM 140 If you say yes here you get support for Genesys Logic GL518SM
138 sensor chips. 141 sensor chips.
@@ -143,7 +146,7 @@ config SENSORS_GL518SM
143config SENSORS_GL520SM 146config SENSORS_GL520SM
144 tristate "Genesys Logic GL520SM" 147 tristate "Genesys Logic GL520SM"
145 depends on HWMON && I2C && EXPERIMENTAL 148 depends on HWMON && I2C && EXPERIMENTAL
146 select I2C_SENSOR 149 select HWMON_VID
147 help 150 help
148 If you say yes here you get support for Genesys Logic GL520SM 151 If you say yes here you get support for Genesys Logic GL520SM
149 sensor chips. 152 sensor chips.
@@ -154,7 +157,8 @@ config SENSORS_GL520SM
154config SENSORS_IT87 157config SENSORS_IT87
155 tristate "ITE IT87xx and compatibles" 158 tristate "ITE IT87xx and compatibles"
156 depends on HWMON && I2C 159 depends on HWMON && I2C
157 select I2C_SENSOR 160 select I2C_ISA
161 select HWMON_VID
158 help 162 help
159 If you say yes here you get support for ITE IT87xx sensor chips 163 If you say yes here you get support for ITE IT87xx sensor chips
160 and clones: SiS960. 164 and clones: SiS960.
@@ -165,7 +169,6 @@ config SENSORS_IT87
165config SENSORS_LM63 169config SENSORS_LM63
166 tristate "National Semiconductor LM63" 170 tristate "National Semiconductor LM63"
167 depends on HWMON && I2C && EXPERIMENTAL 171 depends on HWMON && I2C && EXPERIMENTAL
168 select I2C_SENSOR
169 help 172 help
170 If you say yes here you get support for the National Semiconductor 173 If you say yes here you get support for the National Semiconductor
171 LM63 remote diode digital temperature sensor with integrated fan 174 LM63 remote diode digital temperature sensor with integrated fan
@@ -178,7 +181,6 @@ config SENSORS_LM63
178config SENSORS_LM75 181config SENSORS_LM75
179 tristate "National Semiconductor LM75 and compatibles" 182 tristate "National Semiconductor LM75 and compatibles"
180 depends on HWMON && I2C 183 depends on HWMON && I2C
181 select I2C_SENSOR
182 help 184 help
183 If you say yes here you get support for National Semiconductor LM75 185 If you say yes here you get support for National Semiconductor LM75
184 sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in 186 sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
@@ -194,7 +196,6 @@ config SENSORS_LM75
194config SENSORS_LM77 196config SENSORS_LM77
195 tristate "National Semiconductor LM77" 197 tristate "National Semiconductor LM77"
196 depends on HWMON && I2C && EXPERIMENTAL 198 depends on HWMON && I2C && EXPERIMENTAL
197 select I2C_SENSOR
198 help 199 help
199 If you say yes here you get support for National Semiconductor LM77 200 If you say yes here you get support for National Semiconductor LM77
200 sensor chips. 201 sensor chips.
@@ -205,7 +206,8 @@ config SENSORS_LM77
205config SENSORS_LM78 206config SENSORS_LM78
206 tristate "National Semiconductor LM78 and compatibles" 207 tristate "National Semiconductor LM78 and compatibles"
207 depends on HWMON && I2C && EXPERIMENTAL 208 depends on HWMON && I2C && EXPERIMENTAL
208 select I2C_SENSOR 209 select I2C_ISA
210 select HWMON_VID
209 help 211 help
210 If you say yes here you get support for National Semiconductor LM78, 212 If you say yes here you get support for National Semiconductor LM78,
211 LM78-J and LM79. 213 LM78-J and LM79.
@@ -216,7 +218,6 @@ config SENSORS_LM78
216config SENSORS_LM80 218config SENSORS_LM80
217 tristate "National Semiconductor LM80" 219 tristate "National Semiconductor LM80"
218 depends on HWMON && I2C && EXPERIMENTAL 220 depends on HWMON && I2C && EXPERIMENTAL
219 select I2C_SENSOR
220 help 221 help
221 If you say yes here you get support for National Semiconductor 222 If you say yes here you get support for National Semiconductor
222 LM80 sensor chips. 223 LM80 sensor chips.
@@ -227,7 +228,6 @@ config SENSORS_LM80
227config SENSORS_LM83 228config SENSORS_LM83
228 tristate "National Semiconductor LM83" 229 tristate "National Semiconductor LM83"
229 depends on HWMON && I2C 230 depends on HWMON && I2C
230 select I2C_SENSOR
231 help 231 help
232 If you say yes here you get support for National Semiconductor 232 If you say yes here you get support for National Semiconductor
233 LM83 sensor chips. 233 LM83 sensor chips.
@@ -238,7 +238,7 @@ config SENSORS_LM83
238config SENSORS_LM85 238config SENSORS_LM85
239 tristate "National Semiconductor LM85 and compatibles" 239 tristate "National Semiconductor LM85 and compatibles"
240 depends on HWMON && I2C && EXPERIMENTAL 240 depends on HWMON && I2C && EXPERIMENTAL
241 select I2C_SENSOR 241 select HWMON_VID
242 help 242 help
243 If you say yes here you get support for National Semiconductor LM85 243 If you say yes here you get support for National Semiconductor LM85
244 sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027. 244 sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
@@ -249,7 +249,7 @@ config SENSORS_LM85
249config SENSORS_LM87 249config SENSORS_LM87
250 tristate "National Semiconductor LM87" 250 tristate "National Semiconductor LM87"
251 depends on HWMON && I2C && EXPERIMENTAL 251 depends on HWMON && I2C && EXPERIMENTAL
252 select I2C_SENSOR 252 select HWMON_VID
253 help 253 help
254 If you say yes here you get support for National Semiconductor LM87 254 If you say yes here you get support for National Semiconductor LM87
255 sensor chips. 255 sensor chips.
@@ -260,7 +260,6 @@ config SENSORS_LM87
260config SENSORS_LM90 260config SENSORS_LM90
261 tristate "National Semiconductor LM90 and compatibles" 261 tristate "National Semiconductor LM90 and compatibles"
262 depends on HWMON && I2C 262 depends on HWMON && I2C
263 select I2C_SENSOR
264 help 263 help
265 If you say yes here you get support for National Semiconductor LM90, 264 If you say yes here you get support for National Semiconductor LM90,
266 LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and 265 LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
@@ -275,7 +274,6 @@ config SENSORS_LM90
275config SENSORS_LM92 274config SENSORS_LM92
276 tristate "National Semiconductor LM92 and compatibles" 275 tristate "National Semiconductor LM92 and compatibles"
277 depends on HWMON && I2C && EXPERIMENTAL 276 depends on HWMON && I2C && EXPERIMENTAL
278 select I2C_SENSOR
279 help 277 help
280 If you say yes here you get support for National Semiconductor LM92 278 If you say yes here you get support for National Semiconductor LM92
281 and Maxim MAX6635 sensor chips. 279 and Maxim MAX6635 sensor chips.
@@ -286,7 +284,6 @@ config SENSORS_LM92
286config SENSORS_MAX1619 284config SENSORS_MAX1619
287 tristate "Maxim MAX1619 sensor chip" 285 tristate "Maxim MAX1619 sensor chip"
288 depends on HWMON && I2C && EXPERIMENTAL 286 depends on HWMON && I2C && EXPERIMENTAL
289 select I2C_SENSOR
290 help 287 help
291 If you say yes here you get support for MAX1619 sensor chip. 288 If you say yes here you get support for MAX1619 sensor chip.
292 289
@@ -296,8 +293,8 @@ config SENSORS_MAX1619
296config SENSORS_PC87360 293config SENSORS_PC87360
297 tristate "National Semiconductor PC87360 family" 294 tristate "National Semiconductor PC87360 family"
298 depends on HWMON && I2C && EXPERIMENTAL 295 depends on HWMON && I2C && EXPERIMENTAL
299 select I2C_SENSOR
300 select I2C_ISA 296 select I2C_ISA
297 select HWMON_VID
301 help 298 help
302 If you say yes here you get access to the hardware monitoring 299 If you say yes here you get access to the hardware monitoring
303 functions of the National Semiconductor PC8736x Super-I/O chips. 300 functions of the National Semiconductor PC8736x Super-I/O chips.
@@ -311,7 +308,6 @@ config SENSORS_PC87360
311config SENSORS_SIS5595 308config SENSORS_SIS5595
312 tristate "Silicon Integrated Systems Corp. SiS5595" 309 tristate "Silicon Integrated Systems Corp. SiS5595"
313 depends on HWMON && I2C && PCI && EXPERIMENTAL 310 depends on HWMON && I2C && PCI && EXPERIMENTAL
314 select I2C_SENSOR
315 select I2C_ISA 311 select I2C_ISA
316 help 312 help
317 If you say yes here you get support for the integrated sensors in 313 If you say yes here you get support for the integrated sensors in
@@ -323,7 +319,6 @@ config SENSORS_SIS5595
323config SENSORS_SMSC47M1 319config SENSORS_SMSC47M1
324 tristate "SMSC LPC47M10x and compatibles" 320 tristate "SMSC LPC47M10x and compatibles"
325 depends on HWMON && I2C && EXPERIMENTAL 321 depends on HWMON && I2C && EXPERIMENTAL
326 select I2C_SENSOR
327 select I2C_ISA 322 select I2C_ISA
328 help 323 help
329 If you say yes here you get support for the integrated fan 324 If you say yes here you get support for the integrated fan
@@ -336,7 +331,6 @@ config SENSORS_SMSC47M1
336config SENSORS_SMSC47B397 331config SENSORS_SMSC47B397
337 tristate "SMSC LPC47B397-NC" 332 tristate "SMSC LPC47B397-NC"
338 depends on HWMON && I2C && EXPERIMENTAL 333 depends on HWMON && I2C && EXPERIMENTAL
339 select I2C_SENSOR
340 select I2C_ISA 334 select I2C_ISA
341 help 335 help
342 If you say yes here you get support for the SMSC LPC47B397-NC 336 If you say yes here you get support for the SMSC LPC47B397-NC
@@ -348,7 +342,6 @@ config SENSORS_SMSC47B397
348config SENSORS_VIA686A 342config SENSORS_VIA686A
349 tristate "VIA686A" 343 tristate "VIA686A"
350 depends on HWMON && I2C && PCI 344 depends on HWMON && I2C && PCI
351 select I2C_SENSOR
352 select I2C_ISA 345 select I2C_ISA
353 help 346 help
354 If you say yes here you get support for the integrated sensors in 347 If you say yes here you get support for the integrated sensors in
@@ -360,7 +353,8 @@ config SENSORS_VIA686A
360config SENSORS_W83781D 353config SENSORS_W83781D
361 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" 354 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
362 depends on HWMON && I2C 355 depends on HWMON && I2C
363 select I2C_SENSOR 356 select I2C_ISA
357 select HWMON_VID
364 help 358 help
365 If you say yes here you get support for the Winbond W8378x series 359 If you say yes here you get support for the Winbond W8378x series
366 of sensor chips: the W83781D, W83782D, W83783S and W83627HF, 360 of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
@@ -369,10 +363,18 @@ config SENSORS_W83781D
369 This driver can also be built as a module. If so, the module 363 This driver can also be built as a module. If so, the module
370 will be called w83781d. 364 will be called w83781d.
371 365
366config SENSORS_W83792D
367 tristate "Winbond W83792D"
368 depends on HWMON && I2C && EXPERIMENTAL
369 help
370 If you say yes here you get support for the Winbond W83792D chip.
371
372 This driver can also be built as a module. If so, the module
373 will be called w83792d.
374
372config SENSORS_W83L785TS 375config SENSORS_W83L785TS
373 tristate "Winbond W83L785TS-S" 376 tristate "Winbond W83L785TS-S"
374 depends on HWMON && I2C && EXPERIMENTAL 377 depends on HWMON && I2C && EXPERIMENTAL
375 select I2C_SENSOR
376 help 378 help
377 If you say yes here you get support for the Winbond W83L785TS-S 379 If you say yes here you get support for the Winbond W83L785TS-S
378 sensor chip, which is used on the Asus A7N8X, among other 380 sensor chip, which is used on the Asus A7N8X, among other
@@ -384,8 +386,8 @@ config SENSORS_W83L785TS
384config SENSORS_W83627HF 386config SENSORS_W83627HF
385 tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF" 387 tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
386 depends on HWMON && I2C && EXPERIMENTAL 388 depends on HWMON && I2C && EXPERIMENTAL
387 select I2C_SENSOR
388 select I2C_ISA 389 select I2C_ISA
390 select HWMON_VID
389 help 391 help
390 If you say yes here you get support for the Winbond W836X7 series 392 If you say yes here you get support for the Winbond W836X7 series
391 of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF 393 of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
@@ -396,7 +398,6 @@ config SENSORS_W83627HF
396config SENSORS_W83627EHF 398config SENSORS_W83627EHF
397 tristate "Winbond W83627EHF" 399 tristate "Winbond W83627EHF"
398 depends on HWMON && I2C && EXPERIMENTAL 400 depends on HWMON && I2C && EXPERIMENTAL
399 select I2C_SENSOR
400 select I2C_ISA 401 select I2C_ISA
401 help 402 help
402 If you say yes here you get preliminary support for the hardware 403 If you say yes here you get preliminary support for the hardware
@@ -404,6 +405,9 @@ config SENSORS_W83627EHF
404 Only fan and temperature inputs are supported at the moment, while 405 Only fan and temperature inputs are supported at the moment, while
405 the chip does much more than that. 406 the chip does much more than that.
406 407
408 This driver also supports the W83627EHG, which is the lead-free
409 version of the W83627EHF.
410
407 This driver can also be built as a module. If so, the module 411 This driver can also be built as a module. If so, the module
408 will be called w83627ehf. 412 will be called w83627ehf.
409 413
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 2781403a0236..381f1bf04cc5 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -2,9 +2,13 @@
2# Makefile for sensor chip drivers. 2# Makefile for sensor chip drivers.
3# 3#
4 4
5obj-$(CONFIG_HWMON) += hwmon.o
6obj-$(CONFIG_HWMON_VID) += hwmon-vid.o
7
5# asb100, then w83781d go first, as they can override other drivers' addresses. 8# asb100, then w83781d go first, as they can override other drivers' addresses.
6obj-$(CONFIG_SENSORS_ASB100) += asb100.o 9obj-$(CONFIG_SENSORS_ASB100) += asb100.o
7obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o 10obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
11obj-$(CONFIG_SENSORS_W83792D) += w83792d.o
8obj-$(CONFIG_SENSORS_W83781D) += w83781d.o 12obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
9 13
10obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o 14obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index d2c774c32f45..e928cdb041cb 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -24,7 +24,8 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/i2c-sensor.h> 27#include <linux/hwmon.h>
28#include <linux/err.h>
28 29
29 30
30/* Addresses to scan */ 31/* Addresses to scan */
@@ -32,10 +33,9 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
32 0x29, 0x2a, 0x2b, 33 0x29, 0x2a, 0x2b,
33 0x4c, 0x4d, 0x4e, 34 0x4c, 0x4d, 0x4e,
34 I2C_CLIENT_END }; 35 I2C_CLIENT_END };
35static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
36 36
37/* Insmod parameters */ 37/* Insmod parameters */
38SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); 38I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
39 39
40/* adm1021 constants specified below */ 40/* adm1021 constants specified below */
41 41
@@ -89,6 +89,7 @@ clearing it. Weird, ey? --Phil */
89/* Each client has this additional data */ 89/* Each client has this additional data */
90struct adm1021_data { 90struct adm1021_data {
91 struct i2c_client client; 91 struct i2c_client client;
92 struct class_device *class_dev;
92 enum chips type; 93 enum chips type;
93 94
94 struct semaphore update_lock; 95 struct semaphore update_lock;
@@ -185,7 +186,7 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter)
185{ 186{
186 if (!(adapter->class & I2C_CLASS_HWMON)) 187 if (!(adapter->class & I2C_CLASS_HWMON))
187 return 0; 188 return 0;
188 return i2c_detect(adapter, &addr_data, adm1021_detect); 189 return i2c_probe(adapter, &addr_data, adm1021_detect);
189} 190}
190 191
191static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) 192static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -196,15 +197,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
196 int err = 0; 197 int err = 0;
197 const char *type_name = ""; 198 const char *type_name = "";
198 199
199 /* Make sure we aren't probing the ISA bus!! This is just a safety check
200 at this moment; i2c_detect really won't call us. */
201#ifdef DEBUG
202 if (i2c_is_isa_adapter(adapter)) {
203 dev_dbg(&adapter->dev, "adm1021_detect called for an ISA bus adapter?!?\n");
204 return 0;
205 }
206#endif
207
208 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 200 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
209 goto error0; 201 goto error0;
210 202
@@ -295,6 +287,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
295 adm1021_init_client(new_client); 287 adm1021_init_client(new_client);
296 288
297 /* Register sysfs hooks */ 289 /* Register sysfs hooks */
290 data->class_dev = hwmon_device_register(&new_client->dev);
291 if (IS_ERR(data->class_dev)) {
292 err = PTR_ERR(data->class_dev);
293 goto error2;
294 }
295
298 device_create_file(&new_client->dev, &dev_attr_temp1_max); 296 device_create_file(&new_client->dev, &dev_attr_temp1_max);
299 device_create_file(&new_client->dev, &dev_attr_temp1_min); 297 device_create_file(&new_client->dev, &dev_attr_temp1_min);
300 device_create_file(&new_client->dev, &dev_attr_temp1_input); 298 device_create_file(&new_client->dev, &dev_attr_temp1_input);
@@ -305,6 +303,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
305 303
306 return 0; 304 return 0;
307 305
306error2:
307 i2c_detach_client(new_client);
308error1: 308error1:
309 kfree(data); 309 kfree(data);
310error0: 310error0:
@@ -322,14 +322,15 @@ static void adm1021_init_client(struct i2c_client *client)
322 322
323static int adm1021_detach_client(struct i2c_client *client) 323static int adm1021_detach_client(struct i2c_client *client)
324{ 324{
325 struct adm1021_data *data = i2c_get_clientdata(client);
325 int err; 326 int err;
326 327
327 if ((err = i2c_detach_client(client))) { 328 hwmon_device_unregister(data->class_dev);
328 dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); 329
330 if ((err = i2c_detach_client(client)))
329 return err; 331 return err;
330 }
331 332
332 kfree(i2c_get_clientdata(client)); 333 kfree(data);
333 return 0; 334 return 0;
334} 335}
335 336
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index e452d0daf906..526b7ff179eb 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -50,8 +50,9 @@
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <linux/jiffies.h> 51#include <linux/jiffies.h>
52#include <linux/i2c.h> 52#include <linux/i2c.h>
53#include <linux/i2c-sensor.h> 53#include <linux/hwmon.h>
54#include <linux/i2c-vid.h> 54#include <linux/hwmon-vid.h>
55#include <linux/err.h>
55 56
56/* 57/*
57 * Addresses to scan 58 * Addresses to scan
@@ -60,13 +61,12 @@
60 */ 61 */
61 62
62static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 63static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
63static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
64 64
65/* 65/*
66 * Insmod parameters 66 * Insmod parameters
67 */ 67 */
68 68
69SENSORS_INSMOD_2(adm1025, ne1619); 69I2C_CLIENT_INSMOD_2(adm1025, ne1619);
70 70
71/* 71/*
72 * The ADM1025 registers 72 * The ADM1025 registers
@@ -132,6 +132,7 @@ static struct i2c_driver adm1025_driver = {
132 132
133struct adm1025_data { 133struct adm1025_data {
134 struct i2c_client client; 134 struct i2c_client client;
135 struct class_device *class_dev;
135 struct semaphore update_lock; 136 struct semaphore update_lock;
136 char valid; /* zero until following fields are valid */ 137 char valid; /* zero until following fields are valid */
137 unsigned long last_updated; /* in jiffies */ 138 unsigned long last_updated; /* in jiffies */
@@ -312,7 +313,7 @@ static int adm1025_attach_adapter(struct i2c_adapter *adapter)
312{ 313{
313 if (!(adapter->class & I2C_CLASS_HWMON)) 314 if (!(adapter->class & I2C_CLASS_HWMON))
314 return 0; 315 return 0;
315 return i2c_detect(adapter, &addr_data, adm1025_detect); 316 return i2c_probe(adapter, &addr_data, adm1025_detect);
316} 317}
317 318
318/* 319/*
@@ -416,6 +417,12 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
416 adm1025_init_client(new_client); 417 adm1025_init_client(new_client);
417 418
418 /* Register sysfs hooks */ 419 /* Register sysfs hooks */
420 data->class_dev = hwmon_device_register(&new_client->dev);
421 if (IS_ERR(data->class_dev)) {
422 err = PTR_ERR(data->class_dev);
423 goto exit_detach;
424 }
425
419 device_create_file(&new_client->dev, &dev_attr_in0_input); 426 device_create_file(&new_client->dev, &dev_attr_in0_input);
420 device_create_file(&new_client->dev, &dev_attr_in1_input); 427 device_create_file(&new_client->dev, &dev_attr_in1_input);
421 device_create_file(&new_client->dev, &dev_attr_in2_input); 428 device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -452,6 +459,8 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
452 459
453 return 0; 460 return 0;
454 461
462exit_detach:
463 i2c_detach_client(new_client);
455exit_free: 464exit_free:
456 kfree(data); 465 kfree(data);
457exit: 466exit:
@@ -464,7 +473,7 @@ static void adm1025_init_client(struct i2c_client *client)
464 struct adm1025_data *data = i2c_get_clientdata(client); 473 struct adm1025_data *data = i2c_get_clientdata(client);
465 int i; 474 int i;
466 475
467 data->vrm = i2c_which_vrm(); 476 data->vrm = vid_which_vrm();
468 477
469 /* 478 /*
470 * Set high limits 479 * Set high limits
@@ -502,15 +511,15 @@ static void adm1025_init_client(struct i2c_client *client)
502 511
503static int adm1025_detach_client(struct i2c_client *client) 512static int adm1025_detach_client(struct i2c_client *client)
504{ 513{
514 struct adm1025_data *data = i2c_get_clientdata(client);
505 int err; 515 int err;
506 516
507 if ((err = i2c_detach_client(client))) { 517 hwmon_device_unregister(data->class_dev);
508 dev_err(&client->dev, "Client deregistration failed, " 518
509 "client not detached.\n"); 519 if ((err = i2c_detach_client(client)))
510 return err; 520 return err;
511 }
512 521
513 kfree(i2c_get_clientdata(client)); 522 kfree(data);
514 return 0; 523 return 0;
515} 524}
516 525
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index c8a7f47911f9..625158110fd4 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -28,16 +28,16 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/jiffies.h> 29#include <linux/jiffies.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/i2c-sensor.h> 31#include <linux/hwmon.h>
32#include <linux/i2c-vid.h>
33#include <linux/hwmon-sysfs.h> 32#include <linux/hwmon-sysfs.h>
33#include <linux/hwmon-vid.h>
34#include <linux/err.h>
34 35
35/* Addresses to scan */ 36/* Addresses to scan */
36static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
37static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
38 38
39/* Insmod parameters */ 39/* Insmod parameters */
40SENSORS_INSMOD_1(adm1026); 40I2C_CLIENT_INSMOD_1(adm1026);
41 41
42static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, 42static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
43 -1, -1, -1, -1, -1, -1, -1, -1 }; 43 -1, -1, -1, -1, -1, -1, -1, -1 };
@@ -259,6 +259,7 @@ struct pwm_data {
259 259
260struct adm1026_data { 260struct adm1026_data {
261 struct i2c_client client; 261 struct i2c_client client;
262 struct class_device *class_dev;
262 struct semaphore lock; 263 struct semaphore lock;
263 enum chips type; 264 enum chips type;
264 265
@@ -319,13 +320,15 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter)
319 if (!(adapter->class & I2C_CLASS_HWMON)) { 320 if (!(adapter->class & I2C_CLASS_HWMON)) {
320 return 0; 321 return 0;
321 } 322 }
322 return i2c_detect(adapter, &addr_data, adm1026_detect); 323 return i2c_probe(adapter, &addr_data, adm1026_detect);
323} 324}
324 325
325int adm1026_detach_client(struct i2c_client *client) 326int adm1026_detach_client(struct i2c_client *client)
326{ 327{
328 struct adm1026_data *data = i2c_get_clientdata(client);
329 hwmon_device_unregister(data->class_dev);
327 i2c_detach_client(client); 330 i2c_detach_client(client);
328 kfree(i2c_get_clientdata(client)); 331 kfree(data);
329 return 0; 332 return 0;
330} 333}
331 334
@@ -1549,12 +1552,18 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1549 goto exitfree; 1552 goto exitfree;
1550 1553
1551 /* Set the VRM version */ 1554 /* Set the VRM version */
1552 data->vrm = i2c_which_vrm(); 1555 data->vrm = vid_which_vrm();
1553 1556
1554 /* Initialize the ADM1026 chip */ 1557 /* Initialize the ADM1026 chip */
1555 adm1026_init_client(new_client); 1558 adm1026_init_client(new_client);
1556 1559
1557 /* Register sysfs hooks */ 1560 /* Register sysfs hooks */
1561 data->class_dev = hwmon_device_register(&new_client->dev);
1562 if (IS_ERR(data->class_dev)) {
1563 err = PTR_ERR(data->class_dev);
1564 goto exitdetach;
1565 }
1566
1558 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); 1567 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
1559 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); 1568 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
1560 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); 1569 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
@@ -1690,6 +1699,8 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1690 return 0; 1699 return 0;
1691 1700
1692 /* Error out and cleanup code */ 1701 /* Error out and cleanup code */
1702exitdetach:
1703 i2c_detach_client(new_client);
1693exitfree: 1704exitfree:
1694 kfree(data); 1705 kfree(data);
1695exit: 1706exit:
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index 936250957270..58338ed7c8a1 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -26,7 +26,8 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/hwmon.h>
30#include <linux/err.h>
30 31
31/* Following macros takes channel parameter starting from 0 to 2 */ 32/* Following macros takes channel parameter starting from 0 to 2 */
32#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) 33#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr))
@@ -59,16 +60,16 @@
59 60
60/* Addresses to scan */ 61/* Addresses to scan */
61static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 62static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
62static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
63 63
64/* Insmod parameters */ 64/* Insmod parameters */
65SENSORS_INSMOD_2(adm1030, adm1031); 65I2C_CLIENT_INSMOD_2(adm1030, adm1031);
66 66
67typedef u8 auto_chan_table_t[8][2]; 67typedef u8 auto_chan_table_t[8][2];
68 68
69/* Each client has this additional data */ 69/* Each client has this additional data */
70struct adm1031_data { 70struct adm1031_data {
71 struct i2c_client client; 71 struct i2c_client client;
72 struct class_device *class_dev;
72 struct semaphore update_lock; 73 struct semaphore update_lock;
73 int chip_type; 74 int chip_type;
74 char valid; /* !=0 if following fields are valid */ 75 char valid; /* !=0 if following fields are valid */
@@ -725,10 +726,10 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter)
725{ 726{
726 if (!(adapter->class & I2C_CLASS_HWMON)) 727 if (!(adapter->class & I2C_CLASS_HWMON))
727 return 0; 728 return 0;
728 return i2c_detect(adapter, &addr_data, adm1031_detect); 729 return i2c_probe(adapter, &addr_data, adm1031_detect);
729} 730}
730 731
731/* This function is called by i2c_detect */ 732/* This function is called by i2c_probe */
732static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) 733static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
733{ 734{
734 struct i2c_client *new_client; 735 struct i2c_client *new_client;
@@ -788,6 +789,12 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
788 adm1031_init_client(new_client); 789 adm1031_init_client(new_client);
789 790
790 /* Register sysfs hooks */ 791 /* Register sysfs hooks */
792 data->class_dev = hwmon_device_register(&new_client->dev);
793 if (IS_ERR(data->class_dev)) {
794 err = PTR_ERR(data->class_dev);
795 goto exit_detach;
796 }
797
791 device_create_file(&new_client->dev, &dev_attr_fan1_input); 798 device_create_file(&new_client->dev, &dev_attr_fan1_input);
792 device_create_file(&new_client->dev, &dev_attr_fan1_div); 799 device_create_file(&new_client->dev, &dev_attr_fan1_div);
793 device_create_file(&new_client->dev, &dev_attr_fan1_min); 800 device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -833,6 +840,8 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
833 840
834 return 0; 841 return 0;
835 842
843exit_detach:
844 i2c_detach_client(new_client);
836exit_free: 845exit_free:
837 kfree(data); 846 kfree(data);
838exit: 847exit:
@@ -841,11 +850,14 @@ exit:
841 850
842static int adm1031_detach_client(struct i2c_client *client) 851static int adm1031_detach_client(struct i2c_client *client)
843{ 852{
853 struct adm1031_data *data = i2c_get_clientdata(client);
844 int ret; 854 int ret;
855
856 hwmon_device_unregister(data->class_dev);
845 if ((ret = i2c_detach_client(client)) != 0) { 857 if ((ret = i2c_detach_client(client)) != 0) {
846 return ret; 858 return ret;
847 } 859 }
848 kfree(i2c_get_clientdata(client)); 860 kfree(data);
849 return 0; 861 return 0;
850} 862}
851 863
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index ce2a6eb93f6e..bc7faef162f7 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -45,17 +45,16 @@
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/i2c.h> 47#include <linux/i2c.h>
48#include <linux/i2c-sensor.h> 48#include <linux/hwmon.h>
49#include <linux/i2c-vid.h> 49#include <linux/hwmon-vid.h>
50#include <linux/err.h>
50 51
51/* Addresses to scan */ 52/* Addresses to scan */
52static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 53static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
53 I2C_CLIENT_END }; 54 I2C_CLIENT_END };
54 55
55static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
56
57/* Insmod parameters */ 56/* Insmod parameters */
58SENSORS_INSMOD_3(adm9240, ds1780, lm81); 57I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81);
59 58
60/* ADM9240 registers */ 59/* ADM9240 registers */
61#define ADM9240_REG_MAN_ID 0x3e 60#define ADM9240_REG_MAN_ID 0x3e
@@ -150,6 +149,7 @@ static struct i2c_driver adm9240_driver = {
150struct adm9240_data { 149struct adm9240_data {
151 enum chips type; 150 enum chips type;
152 struct i2c_client client; 151 struct i2c_client client;
152 struct class_device *class_dev;
153 struct semaphore update_lock; 153 struct semaphore update_lock;
154 char valid; 154 char valid;
155 unsigned long last_updated_measure; 155 unsigned long last_updated_measure;
@@ -582,6 +582,12 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
582 adm9240_init_client(new_client); 582 adm9240_init_client(new_client);
583 583
584 /* populate sysfs filesystem */ 584 /* populate sysfs filesystem */
585 data->class_dev = hwmon_device_register(&new_client->dev);
586 if (IS_ERR(data->class_dev)) {
587 err = PTR_ERR(data->class_dev);
588 goto exit_detach;
589 }
590
585 device_create_file(&new_client->dev, &dev_attr_in0_input); 591 device_create_file(&new_client->dev, &dev_attr_in0_input);
586 device_create_file(&new_client->dev, &dev_attr_in0_min); 592 device_create_file(&new_client->dev, &dev_attr_in0_min);
587 device_create_file(&new_client->dev, &dev_attr_in0_max); 593 device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -615,6 +621,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
615 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 621 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
616 622
617 return 0; 623 return 0;
624
625exit_detach:
626 i2c_detach_client(new_client);
618exit_free: 627exit_free:
619 kfree(data); 628 kfree(data);
620exit: 629exit:
@@ -625,20 +634,20 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter)
625{ 634{
626 if (!(adapter->class & I2C_CLASS_HWMON)) 635 if (!(adapter->class & I2C_CLASS_HWMON))
627 return 0; 636 return 0;
628 return i2c_detect(adapter, &addr_data, adm9240_detect); 637 return i2c_probe(adapter, &addr_data, adm9240_detect);
629} 638}
630 639
631static int adm9240_detach_client(struct i2c_client *client) 640static int adm9240_detach_client(struct i2c_client *client)
632{ 641{
642 struct adm9240_data *data = i2c_get_clientdata(client);
633 int err; 643 int err;
634 644
635 if ((err = i2c_detach_client(client))) { 645 hwmon_device_unregister(data->class_dev);
636 dev_err(&client->dev, "Client deregistration failed, " 646
637 "client not detached.\n"); 647 if ((err = i2c_detach_client(client)))
638 return err; 648 return err;
639 }
640 649
641 kfree(i2c_get_clientdata(client)); 650 kfree(data);
642 return 0; 651 return 0;
643} 652}
644 653
@@ -648,7 +657,7 @@ static void adm9240_init_client(struct i2c_client *client)
648 u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); 657 u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG);
649 u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; 658 u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3;
650 659
651 data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ 660 data->vrm = vid_which_vrm(); /* need this to report vid as mV */
652 661
653 dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, 662 dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10,
654 data->vrm % 10); 663 data->vrm % 10);
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 70d996d6fe0a..8e34855a6274 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -39,8 +39,9 @@
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/i2c.h> 41#include <linux/i2c.h>
42#include <linux/i2c-sensor.h> 42#include <linux/hwmon.h>
43#include <linux/i2c-vid.h> 43#include <linux/hwmon-vid.h>
44#include <linux/err.h>
44#include <linux/init.h> 45#include <linux/init.h>
45#include <linux/jiffies.h> 46#include <linux/jiffies.h>
46#include "lm75.h" 47#include "lm75.h"
@@ -54,11 +55,8 @@
54/* I2C addresses to scan */ 55/* I2C addresses to scan */
55static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; 56static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
56 57
57/* ISA addresses to scan (none) */
58static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
59
60/* Insmod parameters */ 58/* Insmod parameters */
61SENSORS_INSMOD_1(asb100); 59I2C_CLIENT_INSMOD_1(asb100);
62I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 60I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
63 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 61 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
64 62
@@ -183,6 +181,7 @@ static u8 DIV_TO_REG(long val)
183 dynamically allocated, at the same time the client itself is allocated. */ 181 dynamically allocated, at the same time the client itself is allocated. */
184struct asb100_data { 182struct asb100_data {
185 struct i2c_client client; 183 struct i2c_client client;
184 struct class_device *class_dev;
186 struct semaphore lock; 185 struct semaphore lock;
187 enum chips type; 186 enum chips type;
188 187
@@ -621,7 +620,7 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter)
621{ 620{
622 if (!(adapter->class & I2C_CLASS_HWMON)) 621 if (!(adapter->class & I2C_CLASS_HWMON))
623 return 0; 622 return 0;
624 return i2c_detect(adapter, &addr_data, asb100_detect); 623 return i2c_probe(adapter, &addr_data, asb100_detect);
625} 624}
626 625
627static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, 626static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
@@ -714,14 +713,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
714 struct i2c_client *new_client; 713 struct i2c_client *new_client;
715 struct asb100_data *data; 714 struct asb100_data *data;
716 715
717 /* asb100 is SMBus only */
718 if (i2c_is_isa_adapter(adapter)) {
719 pr_debug("asb100.o: detect failed, "
720 "cannot attach to legacy adapter!\n");
721 err = -ENODEV;
722 goto ERROR0;
723 }
724
725 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 716 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
726 pr_debug("asb100.o: detect failed, " 717 pr_debug("asb100.o: detect failed, "
727 "smbus byte data not supported!\n"); 718 "smbus byte data not supported!\n");
@@ -821,6 +812,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
821 data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2)); 812 data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2));
822 813
823 /* Register sysfs hooks */ 814 /* Register sysfs hooks */
815 data->class_dev = hwmon_device_register(&new_client->dev);
816 if (IS_ERR(data->class_dev)) {
817 err = PTR_ERR(data->class_dev);
818 goto ERROR3;
819 }
820
824 device_create_file_in(new_client, 0); 821 device_create_file_in(new_client, 0);
825 device_create_file_in(new_client, 1); 822 device_create_file_in(new_client, 1);
826 device_create_file_in(new_client, 2); 823 device_create_file_in(new_client, 2);
@@ -847,6 +844,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
847 844
848 return 0; 845 return 0;
849 846
847ERROR3:
848 i2c_detach_client(data->lm75[1]);
849 i2c_detach_client(data->lm75[0]);
850 kfree(data->lm75[1]);
851 kfree(data->lm75[0]);
850ERROR2: 852ERROR2:
851 i2c_detach_client(new_client); 853 i2c_detach_client(new_client);
852ERROR1: 854ERROR1:
@@ -857,21 +859,23 @@ ERROR0:
857 859
858static int asb100_detach_client(struct i2c_client *client) 860static int asb100_detach_client(struct i2c_client *client)
859{ 861{
862 struct asb100_data *data = i2c_get_clientdata(client);
860 int err; 863 int err;
861 864
862 if ((err = i2c_detach_client(client))) { 865 /* main client */
863 dev_err(&client->dev, "client deregistration failed; " 866 if (data)
864 "client not detached.\n"); 867 hwmon_device_unregister(data->class_dev);
868
869 if ((err = i2c_detach_client(client)))
865 return err; 870 return err;
866 }
867 871
868 if (i2c_get_clientdata(client)==NULL) { 872 /* main client */
869 /* subclients */ 873 if (data)
874 kfree(data);
875
876 /* subclient */
877 else
870 kfree(client); 878 kfree(client);
871 } else {
872 /* main client */
873 kfree(i2c_get_clientdata(client));
874 }
875 879
876 return 0; 880 return 0;
877} 881}
@@ -969,7 +973,7 @@ static void asb100_init_client(struct i2c_client *client)
969 973
970 vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f; 974 vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f;
971 vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4; 975 vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4;
972 data->vrm = i2c_which_vrm(); 976 data->vrm = vid_which_vrm();
973 vid = vid_from_reg(vid, data->vrm); 977 vid = vid_from_reg(vid, data->vrm);
974 978
975 /* Start monitoring */ 979 /* Start monitoring */
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index fca3fc1cef72..deb4d34c9539 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -23,8 +23,9 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/jiffies.h> 24#include <linux/jiffies.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/i2c-sensor.h> 26#include <linux/hwmon.h>
27#include <linux/i2c-vid.h> 27#include <linux/hwmon-vid.h>
28#include <linux/err.h>
28 29
29MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
30MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); 31MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -40,9 +41,8 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
40#define ATXP1_GPIO1MASK 0x0f 41#define ATXP1_GPIO1MASK 0x0f
41 42
42static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; 43static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
43static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
44 44
45SENSORS_INSMOD_1(atxp1); 45I2C_CLIENT_INSMOD_1(atxp1);
46 46
47static int atxp1_attach_adapter(struct i2c_adapter * adapter); 47static int atxp1_attach_adapter(struct i2c_adapter * adapter);
48static int atxp1_detach_client(struct i2c_client * client); 48static int atxp1_detach_client(struct i2c_client * client);
@@ -59,6 +59,7 @@ static struct i2c_driver atxp1_driver = {
59 59
60struct atxp1_data { 60struct atxp1_data {
61 struct i2c_client client; 61 struct i2c_client client;
62 struct class_device *class_dev;
62 struct semaphore update_lock; 63 struct semaphore update_lock;
63 unsigned long last_updated; 64 unsigned long last_updated;
64 u8 valid; 65 u8 valid;
@@ -252,7 +253,7 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
252 253
253static int atxp1_attach_adapter(struct i2c_adapter *adapter) 254static int atxp1_attach_adapter(struct i2c_adapter *adapter)
254{ 255{
255 return i2c_detect(adapter, &addr_data, &atxp1_detect); 256 return i2c_probe(adapter, &addr_data, &atxp1_detect);
256}; 257};
257 258
258static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) 259static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -295,7 +296,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
295 } 296 }
296 297
297 /* Get VRM */ 298 /* Get VRM */
298 data->vrm = i2c_which_vrm(); 299 data->vrm = vid_which_vrm();
299 300
300 if ((data->vrm != 90) && (data->vrm != 91)) { 301 if ((data->vrm != 90) && (data->vrm != 91)) {
301 dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", 302 dev_err(&new_client->dev, "Not supporting VRM %d.%d\n",
@@ -317,6 +318,12 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
317 goto exit_free; 318 goto exit_free;
318 } 319 }
319 320
321 data->class_dev = hwmon_device_register(&new_client->dev);
322 if (IS_ERR(data->class_dev)) {
323 err = PTR_ERR(data->class_dev);
324 goto exit_detach;
325 }
326
320 device_create_file(&new_client->dev, &dev_attr_gpio1); 327 device_create_file(&new_client->dev, &dev_attr_gpio1);
321 device_create_file(&new_client->dev, &dev_attr_gpio2); 328 device_create_file(&new_client->dev, &dev_attr_gpio2);
322 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 329 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
@@ -326,6 +333,8 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
326 333
327 return 0; 334 return 0;
328 335
336exit_detach:
337 i2c_detach_client(new_client);
329exit_free: 338exit_free:
330 kfree(data); 339 kfree(data);
331exit: 340exit:
@@ -334,14 +343,17 @@ exit:
334 343
335static int atxp1_detach_client(struct i2c_client * client) 344static int atxp1_detach_client(struct i2c_client * client)
336{ 345{
346 struct atxp1_data * data = i2c_get_clientdata(client);
337 int err; 347 int err;
338 348
349 hwmon_device_unregister(data->class_dev);
350
339 err = i2c_detach_client(client); 351 err = i2c_detach_client(client);
340 352
341 if (err) 353 if (err)
342 dev_err(&client->dev, "Failed to detach client.\n"); 354 dev_err(&client->dev, "Failed to detach client.\n");
343 else 355 else
344 kfree(i2c_get_clientdata(client)); 356 kfree(data);
345 357
346 return err; 358 return err;
347}; 359};
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 5360d58804f6..b0199e063d0e 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -26,16 +26,16 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/hwmon.h>
30#include <linux/err.h>
30#include "lm75.h" 31#include "lm75.h"
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
33static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 34static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
34 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 35 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
35static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
36 36
37/* Insmod parameters */ 37/* Insmod parameters */
38SENSORS_INSMOD_1(ds1621); 38I2C_CLIENT_INSMOD_1(ds1621);
39static int polarity = -1; 39static int polarity = -1;
40module_param(polarity, int, 0); 40module_param(polarity, int, 0);
41MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low"); 41MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low");
@@ -71,6 +71,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
71/* Each client has this additional data */ 71/* Each client has this additional data */
72struct ds1621_data { 72struct ds1621_data {
73 struct i2c_client client; 73 struct i2c_client client;
74 struct class_device *class_dev;
74 struct semaphore update_lock; 75 struct semaphore update_lock;
75 char valid; /* !=0 if following fields are valid */ 76 char valid; /* !=0 if following fields are valid */
76 unsigned long last_updated; /* In jiffies */ 77 unsigned long last_updated; /* In jiffies */
@@ -179,10 +180,10 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
179 180
180static int ds1621_attach_adapter(struct i2c_adapter *adapter) 181static int ds1621_attach_adapter(struct i2c_adapter *adapter)
181{ 182{
182 return i2c_detect(adapter, &addr_data, ds1621_detect); 183 return i2c_probe(adapter, &addr_data, ds1621_detect);
183} 184}
184 185
185/* This function is called by i2c_detect */ 186/* This function is called by i2c_probe */
186int ds1621_detect(struct i2c_adapter *adapter, int address, 187int ds1621_detect(struct i2c_adapter *adapter, int address,
187 int kind) 188 int kind)
188{ 189{
@@ -250,6 +251,12 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
250 ds1621_init_client(new_client); 251 ds1621_init_client(new_client);
251 252
252 /* Register sysfs hooks */ 253 /* Register sysfs hooks */
254 data->class_dev = hwmon_device_register(&new_client->dev);
255 if (IS_ERR(data->class_dev)) {
256 err = PTR_ERR(data->class_dev);
257 goto exit_detach;
258 }
259
253 device_create_file(&new_client->dev, &dev_attr_alarms); 260 device_create_file(&new_client->dev, &dev_attr_alarms);
254 device_create_file(&new_client->dev, &dev_attr_temp1_input); 261 device_create_file(&new_client->dev, &dev_attr_temp1_input);
255 device_create_file(&new_client->dev, &dev_attr_temp1_min); 262 device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -259,6 +266,8 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
259 266
260/* OK, this is not exactly good programming practice, usually. But it is 267/* OK, this is not exactly good programming practice, usually. But it is
261 very code-efficient in this case. */ 268 very code-efficient in this case. */
269 exit_detach:
270 i2c_detach_client(new_client);
262 exit_free: 271 exit_free:
263 kfree(data); 272 kfree(data);
264 exit: 273 exit:
@@ -267,15 +276,15 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
267 276
268static int ds1621_detach_client(struct i2c_client *client) 277static int ds1621_detach_client(struct i2c_client *client)
269{ 278{
279 struct ds1621_data *data = i2c_get_clientdata(client);
270 int err; 280 int err;
271 281
272 if ((err = i2c_detach_client(client))) { 282 hwmon_device_unregister(data->class_dev);
273 dev_err(&client->dev, "Client deregistration failed, " 283
274 "client not detached.\n"); 284 if ((err = i2c_detach_client(client)))
275 return err; 285 return err;
276 }
277 286
278 kfree(i2c_get_clientdata(client)); 287 kfree(data);
279 288
280 return 0; 289 return 0;
281} 290}
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index da411741c2c5..eef6061d786b 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -31,20 +31,20 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-sensor.h> 34#include <linux/hwmon.h>
35#include <linux/err.h>
35 36
36/* 37/*
37 * Addresses to scan 38 * Addresses to scan
38 */ 39 */
39 40
40static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 41static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
41static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
42 42
43/* 43/*
44 * Insmod parameters 44 * Insmod parameters
45 */ 45 */
46 46
47SENSORS_INSMOD_1(fscher); 47I2C_CLIENT_INSMOD_1(fscher);
48 48
49/* 49/*
50 * The FSCHER registers 50 * The FSCHER registers
@@ -132,6 +132,7 @@ static struct i2c_driver fscher_driver = {
132 132
133struct fscher_data { 133struct fscher_data {
134 struct i2c_client client; 134 struct i2c_client client;
135 struct class_device *class_dev;
135 struct semaphore update_lock; 136 struct semaphore update_lock;
136 char valid; /* zero until following fields are valid */ 137 char valid; /* zero until following fields are valid */
137 unsigned long last_updated; /* in jiffies */ 138 unsigned long last_updated; /* in jiffies */
@@ -287,7 +288,7 @@ static int fscher_attach_adapter(struct i2c_adapter *adapter)
287{ 288{
288 if (!(adapter->class & I2C_CLASS_HWMON)) 289 if (!(adapter->class & I2C_CLASS_HWMON))
289 return 0; 290 return 0;
290 return i2c_detect(adapter, &addr_data, fscher_detect); 291 return i2c_probe(adapter, &addr_data, fscher_detect);
291} 292}
292 293
293static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) 294static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -341,6 +342,12 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
341 fscher_init_client(new_client); 342 fscher_init_client(new_client);
342 343
343 /* Register sysfs hooks */ 344 /* Register sysfs hooks */
345 data->class_dev = hwmon_device_register(&new_client->dev);
346 if (IS_ERR(data->class_dev)) {
347 err = PTR_ERR(data->class_dev);
348 goto exit_detach;
349 }
350
344 device_create_file_revision(new_client); 351 device_create_file_revision(new_client);
345 device_create_file_alarms(new_client); 352 device_create_file_alarms(new_client);
346 device_create_file_control(new_client); 353 device_create_file_control(new_client);
@@ -360,6 +367,8 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
360 367
361 return 0; 368 return 0;
362 369
370exit_detach:
371 i2c_detach_client(new_client);
363exit_free: 372exit_free:
364 kfree(data); 373 kfree(data);
365exit: 374exit:
@@ -368,15 +377,15 @@ exit:
368 377
369static int fscher_detach_client(struct i2c_client *client) 378static int fscher_detach_client(struct i2c_client *client)
370{ 379{
380 struct fscher_data *data = i2c_get_clientdata(client);
371 int err; 381 int err;
372 382
373 if ((err = i2c_detach_client(client))) { 383 hwmon_device_unregister(data->class_dev);
374 dev_err(&client->dev, "Client deregistration failed, " 384
375 "client not detached.\n"); 385 if ((err = i2c_detach_client(client)))
376 return err; 386 return err;
377 }
378 387
379 kfree(i2c_get_clientdata(client)); 388 kfree(data);
380 return 0; 389 return 0;
381} 390}
382 391
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index 301ae98bd0ad..5fc77a5fed07 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -34,19 +34,19 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/jiffies.h> 35#include <linux/jiffies.h>
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/i2c-sensor.h>
38#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/hwmon.h>
39#include <linux/err.h>
39 40
40/* 41/*
41 * Addresses to scan 42 * Addresses to scan
42 */ 43 */
43static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 44static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
44static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
45 45
46/* 46/*
47 * Insmod parameters 47 * Insmod parameters
48 */ 48 */
49SENSORS_INSMOD_1(fscpos); 49I2C_CLIENT_INSMOD_1(fscpos);
50 50
51/* 51/*
52 * The FSCPOS registers 52 * The FSCPOS registers
@@ -113,6 +113,7 @@ static struct i2c_driver fscpos_driver = {
113 */ 113 */
114struct fscpos_data { 114struct fscpos_data {
115 struct i2c_client client; 115 struct i2c_client client;
116 struct class_device *class_dev;
116 struct semaphore update_lock; 117 struct semaphore update_lock;
117 char valid; /* 0 until following fields are valid */ 118 char valid; /* 0 until following fields are valid */
118 unsigned long last_updated; /* In jiffies */ 119 unsigned long last_updated; /* In jiffies */
@@ -434,7 +435,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter)
434{ 435{
435 if (!(adapter->class & I2C_CLASS_HWMON)) 436 if (!(adapter->class & I2C_CLASS_HWMON))
436 return 0; 437 return 0;
437 return i2c_detect(adapter, &addr_data, fscpos_detect); 438 return i2c_probe(adapter, &addr_data, fscpos_detect);
438} 439}
439 440
440int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) 441int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -496,6 +497,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
496 dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision); 497 dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision);
497 498
498 /* Register sysfs hooks */ 499 /* Register sysfs hooks */
500 data->class_dev = hwmon_device_register(&new_client->dev);
501 if (IS_ERR(data->class_dev)) {
502 err = PTR_ERR(data->class_dev);
503 goto exit_detach;
504 }
505
499 device_create_file(&new_client->dev, &dev_attr_event); 506 device_create_file(&new_client->dev, &dev_attr_event);
500 device_create_file(&new_client->dev, &dev_attr_in0_input); 507 device_create_file(&new_client->dev, &dev_attr_in0_input);
501 device_create_file(&new_client->dev, &dev_attr_in1_input); 508 device_create_file(&new_client->dev, &dev_attr_in1_input);
@@ -526,6 +533,8 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
526 533
527 return 0; 534 return 0;
528 535
536exit_detach:
537 i2c_detach_client(new_client);
529exit_free: 538exit_free:
530 kfree(data); 539 kfree(data);
531exit: 540exit:
@@ -534,14 +543,14 @@ exit:
534 543
535static int fscpos_detach_client(struct i2c_client *client) 544static int fscpos_detach_client(struct i2c_client *client)
536{ 545{
546 struct fscpos_data *data = i2c_get_clientdata(client);
537 int err; 547 int err;
538 548
539 if ((err = i2c_detach_client(client))) { 549 hwmon_device_unregister(data->class_dev);
540 dev_err(&client->dev, "Client deregistration failed, client" 550
541 " not detached.\n"); 551 if ((err = i2c_detach_client(client)))
542 return err; 552 return err;
543 } 553 kfree(data);
544 kfree(i2c_get_clientdata(client));
545 return 0; 554 return 0;
546} 555}
547 556
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 6bedf729dcf5..256b9323c84b 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -41,14 +41,14 @@
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/jiffies.h> 42#include <linux/jiffies.h>
43#include <linux/i2c.h> 43#include <linux/i2c.h>
44#include <linux/i2c-sensor.h> 44#include <linux/hwmon.h>
45#include <linux/err.h>
45 46
46/* Addresses to scan */ 47/* Addresses to scan */
47static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 48static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
48static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
49 49
50/* Insmod parameters */ 50/* Insmod parameters */
51SENSORS_INSMOD_2(gl518sm_r00, gl518sm_r80); 51I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80);
52 52
53/* Many GL518 constants specified below */ 53/* Many GL518 constants specified below */
54 54
@@ -117,6 +117,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
117/* Each client has this additional data */ 117/* Each client has this additional data */
118struct gl518_data { 118struct gl518_data {
119 struct i2c_client client; 119 struct i2c_client client;
120 struct class_device *class_dev;
120 enum chips type; 121 enum chips type;
121 122
122 struct semaphore update_lock; 123 struct semaphore update_lock;
@@ -346,7 +347,7 @@ static int gl518_attach_adapter(struct i2c_adapter *adapter)
346{ 347{
347 if (!(adapter->class & I2C_CLASS_HWMON)) 348 if (!(adapter->class & I2C_CLASS_HWMON))
348 return 0; 349 return 0;
349 return i2c_detect(adapter, &addr_data, gl518_detect); 350 return i2c_probe(adapter, &addr_data, gl518_detect);
350} 351}
351 352
352static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) 353static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -419,6 +420,12 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
419 gl518_init_client((struct i2c_client *) new_client); 420 gl518_init_client((struct i2c_client *) new_client);
420 421
421 /* Register sysfs hooks */ 422 /* Register sysfs hooks */
423 data->class_dev = hwmon_device_register(&new_client->dev);
424 if (IS_ERR(data->class_dev)) {
425 err = PTR_ERR(data->class_dev);
426 goto exit_detach;
427 }
428
422 device_create_file(&new_client->dev, &dev_attr_in0_input); 429 device_create_file(&new_client->dev, &dev_attr_in0_input);
423 device_create_file(&new_client->dev, &dev_attr_in1_input); 430 device_create_file(&new_client->dev, &dev_attr_in1_input);
424 device_create_file(&new_client->dev, &dev_attr_in2_input); 431 device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -450,6 +457,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
450/* OK, this is not exactly good programming practice, usually. But it is 457/* OK, this is not exactly good programming practice, usually. But it is
451 very code-efficient in this case. */ 458 very code-efficient in this case. */
452 459
460exit_detach:
461 i2c_detach_client(new_client);
453exit_free: 462exit_free:
454 kfree(data); 463 kfree(data);
455exit: 464exit:
@@ -477,16 +486,15 @@ static void gl518_init_client(struct i2c_client *client)
477 486
478static int gl518_detach_client(struct i2c_client *client) 487static int gl518_detach_client(struct i2c_client *client)
479{ 488{
489 struct gl518_data *data = i2c_get_clientdata(client);
480 int err; 490 int err;
481 491
482 if ((err = i2c_detach_client(client))) { 492 hwmon_device_unregister(data->class_dev);
483 dev_err(&client->dev, "Client deregistration failed, "
484 "client not detached.\n");
485 return err;
486 }
487 493
488 kfree(i2c_get_clientdata(client)); 494 if ((err = i2c_detach_client(client)))
495 return err;
489 496
497 kfree(data);
490 return 0; 498 return 0;
491} 499}
492 500
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index 80ae8d30c2af..12fd757066fc 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -26,8 +26,9 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/hwmon.h>
30#include <linux/i2c-vid.h> 30#include <linux/hwmon-vid.h>
31#include <linux/err.h>
31 32
32/* Type of the extra sensor */ 33/* Type of the extra sensor */
33static unsigned short extra_sensor_type; 34static unsigned short extra_sensor_type;
@@ -36,10 +37,9 @@ MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=tempe
36 37
37/* Addresses to scan */ 38/* Addresses to scan */
38static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 39static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
39static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
40 40
41/* Insmod parameters */ 41/* Insmod parameters */
42SENSORS_INSMOD_1(gl520sm); 42I2C_CLIENT_INSMOD_1(gl520sm);
43 43
44/* Many GL520 constants specified below 44/* Many GL520 constants specified below
45One of the inputs can be configured as either temp or voltage. 45One of the inputs can be configured as either temp or voltage.
@@ -120,6 +120,7 @@ static struct i2c_driver gl520_driver = {
120/* Client data */ 120/* Client data */
121struct gl520_data { 121struct gl520_data {
122 struct i2c_client client; 122 struct i2c_client client;
123 struct class_device *class_dev;
123 struct semaphore update_lock; 124 struct semaphore update_lock;
124 char valid; /* zero until the following fields are valid */ 125 char valid; /* zero until the following fields are valid */
125 unsigned long last_updated; /* in jiffies */ 126 unsigned long last_updated; /* in jiffies */
@@ -518,7 +519,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter)
518{ 519{
519 if (!(adapter->class & I2C_CLASS_HWMON)) 520 if (!(adapter->class & I2C_CLASS_HWMON))
520 return 0; 521 return 0;
521 return i2c_detect(adapter, &addr_data, gl520_detect); 522 return i2c_probe(adapter, &addr_data, gl520_detect);
522} 523}
523 524
524static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) 525static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -571,6 +572,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
571 gl520_init_client(new_client); 572 gl520_init_client(new_client);
572 573
573 /* Register sysfs hooks */ 574 /* Register sysfs hooks */
575 data->class_dev = hwmon_device_register(&new_client->dev);
576 if (IS_ERR(data->class_dev)) {
577 err = PTR_ERR(data->class_dev);
578 goto exit_detach;
579 }
580
574 device_create_file_vid(new_client, 0); 581 device_create_file_vid(new_client, 0);
575 582
576 device_create_file_in(new_client, 0); 583 device_create_file_in(new_client, 0);
@@ -592,6 +599,8 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
592 599
593 return 0; 600 return 0;
594 601
602exit_detach:
603 i2c_detach_client(new_client);
595exit_free: 604exit_free:
596 kfree(data); 605 kfree(data);
597exit: 606exit:
@@ -608,7 +617,7 @@ static void gl520_init_client(struct i2c_client *client)
608 conf = oldconf = gl520_read_value(client, GL520_REG_CONF); 617 conf = oldconf = gl520_read_value(client, GL520_REG_CONF);
609 618
610 data->alarm_mask = 0xff; 619 data->alarm_mask = 0xff;
611 data->vrm = i2c_which_vrm(); 620 data->vrm = vid_which_vrm();
612 621
613 if (extra_sensor_type == 1) 622 if (extra_sensor_type == 1)
614 conf &= ~0x10; 623 conf &= ~0x10;
@@ -639,15 +648,15 @@ static void gl520_init_client(struct i2c_client *client)
639 648
640static int gl520_detach_client(struct i2c_client *client) 649static int gl520_detach_client(struct i2c_client *client)
641{ 650{
651 struct gl520_data *data = i2c_get_clientdata(client);
642 int err; 652 int err;
643 653
644 if ((err = i2c_detach_client(client))) { 654 hwmon_device_unregister(data->class_dev);
645 dev_err(&client->dev, "Client deregistration failed, " 655
646 "client not detached.\n"); 656 if ((err = i2c_detach_client(client)))
647 return err; 657 return err;
648 }
649 658
650 kfree(i2c_get_clientdata(client)); 659 kfree(data);
651 return 0; 660 return 0;
652} 661}
653 662
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c
new file mode 100644
index 000000000000..312769ad4dab
--- /dev/null
+++ b/drivers/hwmon/hwmon-vid.c
@@ -0,0 +1,189 @@
1/*
2 hwmon-vid.c - VID/VRM/VRD voltage conversions
3
4 Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
5
6 Partly imported from i2c-vid.h of the lm_sensors project
7 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
8 With assistance from Trent Piepho <xyzzy@speakeasy.org>
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#include <linux/config.h>
26#include <linux/module.h>
27#include <linux/kernel.h>
28#include <linux/hwmon-vid.h>
29
30/*
31 Common code for decoding VID pins.
32
33 References:
34
35 For VRM 8.4 to 9.1, "VRM x.y DC-DC Converter Design Guidelines",
36 available at http://developer.intel.com/.
37
38 For VRD 10.0 and up, "VRD x.y Design Guide",
39 available at http://developer.intel.com/.
40
41 AMD Opteron processors don't follow the Intel specifications.
42 I'm going to "make up" 2.4 as the spec number for the Opterons.
43 No good reason just a mnemonic for the 24x Opteron processor
44 series.
45
46 Opteron VID encoding is:
47 00000 = 1.550 V
48 00001 = 1.525 V
49 . . . .
50 11110 = 0.800 V
51 11111 = 0.000 V (off)
52*/
53
54/* vrm is the VRM/VRD document version multiplied by 10.
55 val is the 4-, 5- or 6-bit VID code.
56 Returned value is in mV to avoid floating point in the kernel. */
57int vid_from_reg(int val, int vrm)
58{
59 int vid;
60
61 switch(vrm) {
62
63 case 0:
64 return 0;
65
66 case 100: /* VRD 10.0 */
67 if((val & 0x1f) == 0x1f)
68 return 0;
69 if((val & 0x1f) <= 0x09 || val == 0x0a)
70 vid = 10875 - (val & 0x1f) * 250;
71 else
72 vid = 18625 - (val & 0x1f) * 250;
73 if(val & 0x20)
74 vid -= 125;
75 vid /= 10; /* only return 3 dec. places for now */
76 return vid;
77
78 case 24: /* Opteron processor */
79 return(val == 0x1f ? 0 : 1550 - val * 25);
80
81 case 91: /* VRM 9.1 */
82 case 90: /* VRM 9.0 */
83 return(val == 0x1f ? 0 :
84 1850 - val * 25);
85
86 case 85: /* VRM 8.5 */
87 return((val & 0x10 ? 25 : 0) +
88 ((val & 0x0f) > 0x04 ? 2050 : 1250) -
89 ((val & 0x0f) * 50));
90
91 case 84: /* VRM 8.4 */
92 val &= 0x0f;
93 /* fall through */
94 default: /* VRM 8.2 */
95 return(val == 0x1f ? 0 :
96 val & 0x10 ? 5100 - (val) * 100 :
97 2050 - (val) * 50);
98 }
99}
100
101
102/*
103 After this point is the code to automatically determine which
104 VRM/VRD specification should be used depending on the CPU.
105*/
106
107struct vrm_model {
108 u8 vendor;
109 u8 eff_family;
110 u8 eff_model;
111 int vrm_type;
112};
113
114#define ANY 0xFF
115
116#ifdef CONFIG_X86
117
118static struct vrm_model vrm_models[] = {
119 {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */
120 {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */
121 {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */
122 {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* Tualatin */
123 {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */
124 {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */
125 {X86_VENDOR_INTEL, 0xF, 0x0, 90}, /* P4 */
126 {X86_VENDOR_INTEL, 0xF, 0x1, 90}, /* P4 Willamette */
127 {X86_VENDOR_INTEL, 0xF, 0x2, 90}, /* P4 Northwood */
128 {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */
129 {X86_VENDOR_INTEL, 0xF, 0x4, 100}, /* P4 Prescott */
130 {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */
131 {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */
132};
133
134static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
135{
136 int i = 0;
137
138 while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) {
139 if (vrm_models[i].vendor==vendor)
140 if ((vrm_models[i].eff_family==eff_family)
141 && ((vrm_models[i].eff_model==eff_model) ||
142 (vrm_models[i].eff_model==ANY)))
143 return vrm_models[i].vrm_type;
144 i++;
145 }
146
147 return 0;
148}
149
150int vid_which_vrm(void)
151{
152 struct cpuinfo_x86 *c = cpu_data;
153 u32 eax;
154 u8 eff_family, eff_model;
155 int vrm_ret;
156
157 if (c->x86 < 6) /* Any CPU with family lower than 6 */
158 return 0; /* doesn't have VID and/or CPUID */
159
160 eax = cpuid_eax(1);
161 eff_family = ((eax & 0x00000F00)>>8);
162 eff_model = ((eax & 0x000000F0)>>4);
163 if (eff_family == 0xF) { /* use extended model & family */
164 eff_family += ((eax & 0x00F00000)>>20);
165 eff_model += ((eax & 0x000F0000)>>16)<<4;
166 }
167 vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
168 if (vrm_ret == 0)
169 printk(KERN_INFO "hwmon-vid: Unknown VRM version of your "
170 "x86 CPU\n");
171 return vrm_ret;
172}
173
174/* and now something completely different for the non-x86 world */
175#else
176int vid_which_vrm(void)
177{
178 printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n");
179 return 0;
180}
181#endif
182
183EXPORT_SYMBOL(vid_from_reg);
184EXPORT_SYMBOL(vid_which_vrm);
185
186MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>");
187
188MODULE_DESCRIPTION("hwmon-vid driver");
189MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
new file mode 100644
index 000000000000..9b41c9bd805f
--- /dev/null
+++ b/drivers/hwmon/hwmon.c
@@ -0,0 +1,98 @@
1/*
2 hwmon.c - part of lm_sensors, Linux kernel modules for hardware monitoring
3
4 This file defines the sysfs class "hwmon", for use by sensors drivers.
5
6 Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; version 2 of the License.
11*/
12
13#include <linux/module.h>
14#include <linux/device.h>
15#include <linux/err.h>
16#include <linux/kdev_t.h>
17#include <linux/idr.h>
18#include <linux/hwmon.h>
19
20#define HWMON_ID_PREFIX "hwmon"
21#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
22
23static struct class *hwmon_class;
24
25static DEFINE_IDR(hwmon_idr);
26
27/**
28 * hwmon_device_register - register w/ hwmon sysfs class
29 * @dev: the device to register
30 *
31 * hwmon_device_unregister() must be called when the class device is no
32 * longer needed.
33 *
34 * Returns the pointer to the new struct class device.
35 */
36struct class_device *hwmon_device_register(struct device *dev)
37{
38 struct class_device *cdev;
39 int id;
40
41 if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)
42 return ERR_PTR(-ENOMEM);
43
44 if (idr_get_new(&hwmon_idr, NULL, &id) < 0)
45 return ERR_PTR(-ENOMEM);
46
47 id = id & MAX_ID_MASK;
48 cdev = class_device_create(hwmon_class, MKDEV(0,0), dev,
49 HWMON_ID_FORMAT, id);
50
51 if (IS_ERR(cdev))
52 idr_remove(&hwmon_idr, id);
53
54 return cdev;
55}
56
57/**
58 * hwmon_device_unregister - removes the previously registered class device
59 *
60 * @cdev: the class device to destroy
61 */
62void hwmon_device_unregister(struct class_device *cdev)
63{
64 int id;
65
66 if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) {
67 class_device_unregister(cdev);
68 idr_remove(&hwmon_idr, id);
69 } else
70 dev_dbg(cdev->dev,
71 "hwmon_device_unregister() failed: bad class ID!\n");
72}
73
74static int __init hwmon_init(void)
75{
76 hwmon_class = class_create(THIS_MODULE, "hwmon");
77 if (IS_ERR(hwmon_class)) {
78 printk(KERN_ERR "hwmon.c: couldn't create sysfs class\n");
79 return PTR_ERR(hwmon_class);
80 }
81 return 0;
82}
83
84static void __exit hwmon_exit(void)
85{
86 class_destroy(hwmon_class);
87}
88
89module_init(hwmon_init);
90module_exit(hwmon_exit);
91
92EXPORT_SYMBOL_GPL(hwmon_device_register);
93EXPORT_SYMBOL_GPL(hwmon_device_unregister);
94
95MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
96MODULE_DESCRIPTION("hardware monitoring sysfs/class support");
97MODULE_LICENSE("GPL");
98
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index db20c9e47393..53cc2b6d6385 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -36,19 +36,21 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c-sensor.h> 39#include <linux/i2c-isa.h>
40#include <linux/i2c-vid.h> 40#include <linux/hwmon.h>
41#include <linux/hwmon-sysfs.h> 41#include <linux/hwmon-sysfs.h>
42#include <linux/hwmon-vid.h>
43#include <linux/err.h>
42#include <asm/io.h> 44#include <asm/io.h>
43 45
44 46
45/* Addresses to scan */ 47/* Addresses to scan */
46static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 48static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
47 0x2e, 0x2f, I2C_CLIENT_END }; 49 0x2e, 0x2f, I2C_CLIENT_END };
48static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; 50static unsigned short isa_address = 0x290;
49 51
50/* Insmod parameters */ 52/* Insmod parameters */
51SENSORS_INSMOD_2(it87, it8712); 53I2C_CLIENT_INSMOD_2(it87, it8712);
52 54
53#define REG 0x2e /* The register to read/write */ 55#define REG 0x2e /* The register to read/write */
54#define DEV 0x07 /* Register: Logical device select */ 56#define DEV 0x07 /* Register: Logical device select */
@@ -192,6 +194,7 @@ static int DIV_TO_REG(int val)
192 allocated. */ 194 allocated. */
193struct it87_data { 195struct it87_data {
194 struct i2c_client client; 196 struct i2c_client client;
197 struct class_device *class_dev;
195 struct semaphore lock; 198 struct semaphore lock;
196 enum chips type; 199 enum chips type;
197 200
@@ -218,7 +221,7 @@ struct it87_data {
218 221
219 222
220static int it87_attach_adapter(struct i2c_adapter *adapter); 223static int it87_attach_adapter(struct i2c_adapter *adapter);
221static int it87_find(int *address); 224static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
222static int it87_detect(struct i2c_adapter *adapter, int address, int kind); 225static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
223static int it87_detach_client(struct i2c_client *client); 226static int it87_detach_client(struct i2c_client *client);
224 227
@@ -239,6 +242,14 @@ static struct i2c_driver it87_driver = {
239 .detach_client = it87_detach_client, 242 .detach_client = it87_detach_client,
240}; 243};
241 244
245static struct i2c_driver it87_isa_driver = {
246 .owner = THIS_MODULE,
247 .name = "it87-isa",
248 .attach_adapter = it87_isa_attach_adapter,
249 .detach_client = it87_detach_client,
250};
251
252
242static ssize_t show_in(struct device *dev, struct device_attribute *attr, 253static ssize_t show_in(struct device *dev, struct device_attribute *attr,
243 char *buf) 254 char *buf)
244{ 255{
@@ -686,11 +697,16 @@ static int it87_attach_adapter(struct i2c_adapter *adapter)
686{ 697{
687 if (!(adapter->class & I2C_CLASS_HWMON)) 698 if (!(adapter->class & I2C_CLASS_HWMON))
688 return 0; 699 return 0;
689 return i2c_detect(adapter, &addr_data, it87_detect); 700 return i2c_probe(adapter, &addr_data, it87_detect);
690} 701}
691 702
692/* SuperIO detection - will change normal_isa[0] if a chip is found */ 703static int it87_isa_attach_adapter(struct i2c_adapter *adapter)
693static int it87_find(int *address) 704{
705 return it87_detect(adapter, isa_address, -1);
706}
707
708/* SuperIO detection - will change isa_address if a chip is found */
709static int __init it87_find(int *address)
694{ 710{
695 int err = -ENODEV; 711 int err = -ENODEV;
696 712
@@ -721,7 +737,7 @@ exit:
721 return err; 737 return err;
722} 738}
723 739
724/* This function is called by i2c_detect */ 740/* This function is called by i2c_probe */
725int it87_detect(struct i2c_adapter *adapter, int address, int kind) 741int it87_detect(struct i2c_adapter *adapter, int address, int kind)
726{ 742{
727 int i; 743 int i;
@@ -738,7 +754,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
738 754
739 /* Reserve the ISA region */ 755 /* Reserve the ISA region */
740 if (is_isa) 756 if (is_isa)
741 if (!request_region(address, IT87_EXTENT, it87_driver.name)) 757 if (!request_region(address, IT87_EXTENT, it87_isa_driver.name))
742 goto ERROR0; 758 goto ERROR0;
743 759
744 /* Probe whether there is anything available on this address. Already 760 /* Probe whether there is anything available on this address. Already
@@ -784,7 +800,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
784 i2c_set_clientdata(new_client, data); 800 i2c_set_clientdata(new_client, data);
785 new_client->addr = address; 801 new_client->addr = address;
786 new_client->adapter = adapter; 802 new_client->adapter = adapter;
787 new_client->driver = &it87_driver; 803 new_client->driver = is_isa ? &it87_isa_driver : &it87_driver;
788 new_client->flags = 0; 804 new_client->flags = 0;
789 805
790 /* Now, we do the remaining detection. */ 806 /* Now, we do the remaining detection. */
@@ -840,6 +856,12 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
840 it87_init_client(new_client, data); 856 it87_init_client(new_client, data);
841 857
842 /* Register sysfs hooks */ 858 /* Register sysfs hooks */
859 data->class_dev = hwmon_device_register(&new_client->dev);
860 if (IS_ERR(data->class_dev)) {
861 err = PTR_ERR(data->class_dev);
862 goto ERROR3;
863 }
864
843 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); 865 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
844 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); 866 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
845 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); 867 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
@@ -897,13 +919,15 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
897 } 919 }
898 920
899 if (data->type == it8712) { 921 if (data->type == it8712) {
900 data->vrm = i2c_which_vrm(); 922 data->vrm = vid_which_vrm();
901 device_create_file_vrm(new_client); 923 device_create_file_vrm(new_client);
902 device_create_file_vid(new_client); 924 device_create_file_vid(new_client);
903 } 925 }
904 926
905 return 0; 927 return 0;
906 928
929ERROR3:
930 i2c_detach_client(new_client);
907ERROR2: 931ERROR2:
908 kfree(data); 932 kfree(data);
909ERROR1: 933ERROR1:
@@ -915,17 +939,17 @@ ERROR0:
915 939
916static int it87_detach_client(struct i2c_client *client) 940static int it87_detach_client(struct i2c_client *client)
917{ 941{
942 struct it87_data *data = i2c_get_clientdata(client);
918 int err; 943 int err;
919 944
920 if ((err = i2c_detach_client(client))) { 945 hwmon_device_unregister(data->class_dev);
921 dev_err(&client->dev, 946
922 "Client deregistration failed, client not detached.\n"); 947 if ((err = i2c_detach_client(client)))
923 return err; 948 return err;
924 }
925 949
926 if(i2c_is_isa_client(client)) 950 if(i2c_is_isa_client(client))
927 release_region(client->addr, IT87_EXTENT); 951 release_region(client->addr, IT87_EXTENT);
928 kfree(i2c_get_clientdata(client)); 952 kfree(data);
929 953
930 return 0; 954 return 0;
931} 955}
@@ -1158,16 +1182,28 @@ static struct it87_data *it87_update_device(struct device *dev)
1158 1182
1159static int __init sm_it87_init(void) 1183static int __init sm_it87_init(void)
1160{ 1184{
1161 int addr; 1185 int addr, res;
1162 1186
1163 if (!it87_find(&addr)) { 1187 if (!it87_find(&addr)) {
1164 normal_isa[0] = addr; 1188 isa_address = addr;
1189 }
1190
1191 res = i2c_add_driver(&it87_driver);
1192 if (res)
1193 return res;
1194
1195 res = i2c_isa_add_driver(&it87_isa_driver);
1196 if (res) {
1197 i2c_del_driver(&it87_driver);
1198 return res;
1165 } 1199 }
1166 return i2c_add_driver(&it87_driver); 1200
1201 return 0;
1167} 1202}
1168 1203
1169static void __exit sm_it87_exit(void) 1204static void __exit sm_it87_exit(void)
1170{ 1205{
1206 i2c_isa_del_driver(&it87_isa_driver);
1171 i2c_del_driver(&it87_driver); 1207 i2c_del_driver(&it87_driver);
1172} 1208}
1173 1209
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 7c6f9ea5a254..be5c7095ecbb 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -42,8 +42,9 @@
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/jiffies.h> 43#include <linux/jiffies.h>
44#include <linux/i2c.h> 44#include <linux/i2c.h>
45#include <linux/i2c-sensor.h>
46#include <linux/hwmon-sysfs.h> 45#include <linux/hwmon-sysfs.h>
46#include <linux/hwmon.h>
47#include <linux/err.h>
47 48
48/* 49/*
49 * Addresses to scan 50 * Addresses to scan
@@ -51,13 +52,12 @@
51 */ 52 */
52 53
53static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; 54static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
54static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
55 55
56/* 56/*
57 * Insmod parameters 57 * Insmod parameters
58 */ 58 */
59 59
60SENSORS_INSMOD_1(lm63); 60I2C_CLIENT_INSMOD_1(lm63);
61 61
62/* 62/*
63 * The LM63 registers 63 * The LM63 registers
@@ -152,6 +152,7 @@ static struct i2c_driver lm63_driver = {
152 152
153struct lm63_data { 153struct lm63_data {
154 struct i2c_client client; 154 struct i2c_client client;
155 struct class_device *class_dev;
155 struct semaphore update_lock; 156 struct semaphore update_lock;
156 char valid; /* zero until following fields are valid */ 157 char valid; /* zero until following fields are valid */
157 unsigned long last_updated; /* in jiffies */ 158 unsigned long last_updated; /* in jiffies */
@@ -358,7 +359,7 @@ static int lm63_attach_adapter(struct i2c_adapter *adapter)
358{ 359{
359 if (!(adapter->class & I2C_CLASS_HWMON)) 360 if (!(adapter->class & I2C_CLASS_HWMON))
360 return 0; 361 return 0;
361 return i2c_detect(adapter, &addr_data, lm63_detect); 362 return i2c_probe(adapter, &addr_data, lm63_detect);
362} 363}
363 364
364/* 365/*
@@ -437,6 +438,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
437 lm63_init_client(new_client); 438 lm63_init_client(new_client);
438 439
439 /* Register sysfs hooks */ 440 /* Register sysfs hooks */
441 data->class_dev = hwmon_device_register(&new_client->dev);
442 if (IS_ERR(data->class_dev)) {
443 err = PTR_ERR(data->class_dev);
444 goto exit_detach;
445 }
446
440 if (data->config & 0x04) { /* tachometer enabled */ 447 if (data->config & 0x04) { /* tachometer enabled */
441 device_create_file(&new_client->dev, 448 device_create_file(&new_client->dev,
442 &sensor_dev_attr_fan1_input.dev_attr); 449 &sensor_dev_attr_fan1_input.dev_attr);
@@ -462,6 +469,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
462 469
463 return 0; 470 return 0;
464 471
472exit_detach:
473 i2c_detach_client(new_client);
465exit_free: 474exit_free:
466 kfree(data); 475 kfree(data);
467exit: 476exit:
@@ -505,15 +514,15 @@ static void lm63_init_client(struct i2c_client *client)
505 514
506static int lm63_detach_client(struct i2c_client *client) 515static int lm63_detach_client(struct i2c_client *client)
507{ 516{
517 struct lm63_data *data = i2c_get_clientdata(client);
508 int err; 518 int err;
509 519
510 if ((err = i2c_detach_client(client))) { 520 hwmon_device_unregister(data->class_dev);
511 dev_err(&client->dev, "Client deregistration failed, " 521
512 "client not detached\n"); 522 if ((err = i2c_detach_client(client)))
513 return err; 523 return err;
514 }
515 524
516 kfree(i2c_get_clientdata(client)); 525 kfree(data);
517 return 0; 526 return 0;
518} 527}
519 528
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 5be164ed278e..9a3ebdf583f4 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -23,17 +23,17 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/jiffies.h> 24#include <linux/jiffies.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/i2c-sensor.h> 26#include <linux/hwmon.h>
27#include <linux/err.h>
27#include "lm75.h" 28#include "lm75.h"
28 29
29 30
30/* Addresses to scan */ 31/* Addresses to scan */
31static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 32static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
32 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 33 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
33static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
34 34
35/* Insmod parameters */ 35/* Insmod parameters */
36SENSORS_INSMOD_1(lm75); 36I2C_CLIENT_INSMOD_1(lm75);
37 37
38/* Many LM75 constants specified below */ 38/* Many LM75 constants specified below */
39 39
@@ -46,6 +46,7 @@ SENSORS_INSMOD_1(lm75);
46/* Each client has this additional data */ 46/* Each client has this additional data */
47struct lm75_data { 47struct lm75_data {
48 struct i2c_client client; 48 struct i2c_client client;
49 struct class_device *class_dev;
49 struct semaphore update_lock; 50 struct semaphore update_lock;
50 char valid; /* !=0 if following fields are valid */ 51 char valid; /* !=0 if following fields are valid */
51 unsigned long last_updated; /* In jiffies */ 52 unsigned long last_updated; /* In jiffies */
@@ -107,10 +108,10 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter)
107{ 108{
108 if (!(adapter->class & I2C_CLASS_HWMON)) 109 if (!(adapter->class & I2C_CLASS_HWMON))
109 return 0; 110 return 0;
110 return i2c_detect(adapter, &addr_data, lm75_detect); 111 return i2c_probe(adapter, &addr_data, lm75_detect);
111} 112}
112 113
113/* This function is called by i2c_detect */ 114/* This function is called by i2c_probe */
114static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) 115static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
115{ 116{
116 int i; 117 int i;
@@ -119,16 +120,6 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
119 int err = 0; 120 int err = 0;
120 const char *name = ""; 121 const char *name = "";
121 122
122 /* Make sure we aren't probing the ISA bus!! This is just a safety check
123 at this moment; i2c_detect really won't call us. */
124#ifdef DEBUG
125 if (i2c_is_isa_adapter(adapter)) {
126 dev_dbg(&adapter->dev,
127 "lm75_detect called for an ISA bus adapter?!?\n");
128 goto exit;
129 }
130#endif
131
132 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | 123 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
133 I2C_FUNC_SMBUS_WORD_DATA)) 124 I2C_FUNC_SMBUS_WORD_DATA))
134 goto exit; 125 goto exit;
@@ -208,12 +199,20 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
208 lm75_init_client(new_client); 199 lm75_init_client(new_client);
209 200
210 /* Register sysfs hooks */ 201 /* Register sysfs hooks */
202 data->class_dev = hwmon_device_register(&new_client->dev);
203 if (IS_ERR(data->class_dev)) {
204 err = PTR_ERR(data->class_dev);
205 goto exit_detach;
206 }
207
211 device_create_file(&new_client->dev, &dev_attr_temp1_max); 208 device_create_file(&new_client->dev, &dev_attr_temp1_max);
212 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 209 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
213 device_create_file(&new_client->dev, &dev_attr_temp1_input); 210 device_create_file(&new_client->dev, &dev_attr_temp1_input);
214 211
215 return 0; 212 return 0;
216 213
214exit_detach:
215 i2c_detach_client(new_client);
217exit_free: 216exit_free:
218 kfree(data); 217 kfree(data);
219exit: 218exit:
@@ -222,8 +221,10 @@ exit:
222 221
223static int lm75_detach_client(struct i2c_client *client) 222static int lm75_detach_client(struct i2c_client *client)
224{ 223{
224 struct lm75_data *data = i2c_get_clientdata(client);
225 hwmon_device_unregister(data->class_dev);
225 i2c_detach_client(client); 226 i2c_detach_client(client);
226 kfree(i2c_get_clientdata(client)); 227 kfree(data);
227 return 0; 228 return 0;
228} 229}
229 230
@@ -251,8 +252,12 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
251 252
252static void lm75_init_client(struct i2c_client *client) 253static void lm75_init_client(struct i2c_client *client)
253{ 254{
254 /* Initialize the LM75 chip */ 255 int reg;
255 lm75_write_value(client, LM75_REG_CONF, 0); 256
257 /* Enable if in shutdown mode */
258 reg = lm75_read_value(client, LM75_REG_CONF);
259 if (reg >= 0 && (reg & 0x01))
260 lm75_write_value(client, LM75_REG_CONF, reg & 0xfe);
256} 261}
257 262
258static struct lm75_data *lm75_update_device(struct device *dev) 263static struct lm75_data *lm75_update_device(struct device *dev)
diff --git a/drivers/hwmon/lm75.h b/drivers/hwmon/lm75.h
index 63e3f2fb4c21..af7dc650ee15 100644
--- a/drivers/hwmon/lm75.h
+++ b/drivers/hwmon/lm75.h
@@ -25,7 +25,7 @@
25 which contains this code, we don't worry about the wasted space. 25 which contains this code, we don't worry about the wasted space.
26*/ 26*/
27 27
28#include <linux/i2c-sensor.h> 28#include <linux/hwmon.h>
29 29
30/* straight from the datasheet */ 30/* straight from the datasheet */
31#define LM75_TEMP_MIN (-55000) 31#define LM75_TEMP_MIN (-55000)
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index b98f44952997..866eab96a6f6 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -30,15 +30,14 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/jiffies.h> 31#include <linux/jiffies.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-sensor.h> 33#include <linux/hwmon.h>
34 34#include <linux/err.h>
35 35
36/* Addresses to scan */ 36/* Addresses to scan */
37static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; 37static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
38static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
39 38
40/* Insmod parameters */ 39/* Insmod parameters */
41SENSORS_INSMOD_1(lm77); 40I2C_CLIENT_INSMOD_1(lm77);
42 41
43/* The LM77 registers */ 42/* The LM77 registers */
44#define LM77_REG_TEMP 0x00 43#define LM77_REG_TEMP 0x00
@@ -51,6 +50,7 @@ SENSORS_INSMOD_1(lm77);
51/* Each client has this additional data */ 50/* Each client has this additional data */
52struct lm77_data { 51struct lm77_data {
53 struct i2c_client client; 52 struct i2c_client client;
53 struct class_device *class_dev;
54 struct semaphore update_lock; 54 struct semaphore update_lock;
55 char valid; 55 char valid;
56 unsigned long last_updated; /* In jiffies */ 56 unsigned long last_updated; /* In jiffies */
@@ -208,10 +208,10 @@ static int lm77_attach_adapter(struct i2c_adapter *adapter)
208{ 208{
209 if (!(adapter->class & I2C_CLASS_HWMON)) 209 if (!(adapter->class & I2C_CLASS_HWMON))
210 return 0; 210 return 0;
211 return i2c_detect(adapter, &addr_data, lm77_detect); 211 return i2c_probe(adapter, &addr_data, lm77_detect);
212} 212}
213 213
214/* This function is called by i2c_detect */ 214/* This function is called by i2c_probe */
215static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) 215static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
216{ 216{
217 struct i2c_client *new_client; 217 struct i2c_client *new_client;
@@ -317,6 +317,12 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
317 lm77_init_client(new_client); 317 lm77_init_client(new_client);
318 318
319 /* Register sysfs hooks */ 319 /* Register sysfs hooks */
320 data->class_dev = hwmon_device_register(&new_client->dev);
321 if (IS_ERR(data->class_dev)) {
322 err = PTR_ERR(data->class_dev);
323 goto exit_detach;
324 }
325
320 device_create_file(&new_client->dev, &dev_attr_temp1_input); 326 device_create_file(&new_client->dev, &dev_attr_temp1_input);
321 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 327 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
322 device_create_file(&new_client->dev, &dev_attr_temp1_min); 328 device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -327,6 +333,8 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
327 device_create_file(&new_client->dev, &dev_attr_alarms); 333 device_create_file(&new_client->dev, &dev_attr_alarms);
328 return 0; 334 return 0;
329 335
336exit_detach:
337 i2c_detach_client(new_client);
330exit_free: 338exit_free:
331 kfree(data); 339 kfree(data);
332exit: 340exit:
@@ -335,8 +343,10 @@ exit:
335 343
336static int lm77_detach_client(struct i2c_client *client) 344static int lm77_detach_client(struct i2c_client *client)
337{ 345{
346 struct lm77_data *data = i2c_get_clientdata(client);
347 hwmon_device_unregister(data->class_dev);
338 i2c_detach_client(client); 348 i2c_detach_client(client);
339 kfree(i2c_get_clientdata(client)); 349 kfree(data);
340 return 0; 350 return 0;
341} 351}
342 352
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 29241469dcba..f6730dc3573b 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -23,7 +23,10 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/jiffies.h> 24#include <linux/jiffies.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/i2c-sensor.h> 26#include <linux/i2c-isa.h>
27#include <linux/hwmon.h>
28#include <linux/hwmon-vid.h>
29#include <linux/err.h>
27#include <asm/io.h> 30#include <asm/io.h>
28 31
29/* Addresses to scan */ 32/* Addresses to scan */
@@ -31,10 +34,10 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
31 0x25, 0x26, 0x27, 0x28, 0x29, 34 0x25, 0x26, 0x27, 0x28, 0x29,
32 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 35 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
33 0x2f, I2C_CLIENT_END }; 36 0x2f, I2C_CLIENT_END };
34static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; 37static unsigned short isa_address = 0x290;
35 38
36/* Insmod parameters */ 39/* Insmod parameters */
37SENSORS_INSMOD_3(lm78, lm78j, lm79); 40I2C_CLIENT_INSMOD_2(lm78, lm79);
38 41
39/* Many LM78 constants specified below */ 42/* Many LM78 constants specified below */
40 43
@@ -104,13 +107,6 @@ static inline int TEMP_FROM_REG(s8 val)
104 return val * 1000; 107 return val * 1000;
105} 108}
106 109
107/* VID: mV
108 REG: (see doc/vid) */
109static inline int VID_FROM_REG(u8 val)
110{
111 return val==0x1f ? 0 : val>=0x10 ? 5100-val*100 : 2050-val*50;
112}
113
114#define DIV_FROM_REG(val) (1 << (val)) 110#define DIV_FROM_REG(val) (1 << (val))
115 111
116/* There are some complications in a module like this. First off, LM78 chips 112/* There are some complications in a module like this. First off, LM78 chips
@@ -134,6 +130,7 @@ static inline int VID_FROM_REG(u8 val)
134 allocated. */ 130 allocated. */
135struct lm78_data { 131struct lm78_data {
136 struct i2c_client client; 132 struct i2c_client client;
133 struct class_device *class_dev;
137 struct semaphore lock; 134 struct semaphore lock;
138 enum chips type; 135 enum chips type;
139 136
@@ -156,6 +153,7 @@ struct lm78_data {
156 153
157 154
158static int lm78_attach_adapter(struct i2c_adapter *adapter); 155static int lm78_attach_adapter(struct i2c_adapter *adapter);
156static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
159static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); 157static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
160static int lm78_detach_client(struct i2c_client *client); 158static int lm78_detach_client(struct i2c_client *client);
161 159
@@ -174,6 +172,14 @@ static struct i2c_driver lm78_driver = {
174 .detach_client = lm78_detach_client, 172 .detach_client = lm78_detach_client,
175}; 173};
176 174
175static struct i2c_driver lm78_isa_driver = {
176 .owner = THIS_MODULE,
177 .name = "lm78-isa",
178 .attach_adapter = lm78_isa_attach_adapter,
179 .detach_client = lm78_detach_client,
180};
181
182
177/* 7 Voltages */ 183/* 7 Voltages */
178static ssize_t show_in(struct device *dev, char *buf, int nr) 184static ssize_t show_in(struct device *dev, char *buf, int nr)
179{ 185{
@@ -445,7 +451,7 @@ static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL);
445static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 451static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
446{ 452{
447 struct lm78_data *data = lm78_update_device(dev); 453 struct lm78_data *data = lm78_update_device(dev);
448 return sprintf(buf, "%d\n", VID_FROM_REG(data->vid)); 454 return sprintf(buf, "%d\n", vid_from_reg(82, data->vid));
449} 455}
450static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 456static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
451 457
@@ -465,10 +471,15 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter)
465{ 471{
466 if (!(adapter->class & I2C_CLASS_HWMON)) 472 if (!(adapter->class & I2C_CLASS_HWMON))
467 return 0; 473 return 0;
468 return i2c_detect(adapter, &addr_data, lm78_detect); 474 return i2c_probe(adapter, &addr_data, lm78_detect);
475}
476
477static int lm78_isa_attach_adapter(struct i2c_adapter *adapter)
478{
479 return lm78_detect(adapter, isa_address, -1);
469} 480}
470 481
471/* This function is called by i2c_detect */ 482/* This function is called by i2c_probe */
472int lm78_detect(struct i2c_adapter *adapter, int address, int kind) 483int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
473{ 484{
474 int i, err; 485 int i, err;
@@ -485,7 +496,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
485 496
486 /* Reserve the ISA region */ 497 /* Reserve the ISA region */
487 if (is_isa) 498 if (is_isa)
488 if (!request_region(address, LM78_EXTENT, lm78_driver.name)) { 499 if (!request_region(address, LM78_EXTENT,
500 lm78_isa_driver.name)) {
489 err = -EBUSY; 501 err = -EBUSY;
490 goto ERROR0; 502 goto ERROR0;
491 } 503 }
@@ -540,7 +552,7 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
540 i2c_set_clientdata(new_client, data); 552 i2c_set_clientdata(new_client, data);
541 new_client->addr = address; 553 new_client->addr = address;
542 new_client->adapter = adapter; 554 new_client->adapter = adapter;
543 new_client->driver = &lm78_driver; 555 new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver;
544 new_client->flags = 0; 556 new_client->flags = 0;
545 557
546 /* Now, we do the remaining detection. */ 558 /* Now, we do the remaining detection. */
@@ -559,10 +571,9 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
559 /* Determine the chip type. */ 571 /* Determine the chip type. */
560 if (kind <= 0) { 572 if (kind <= 0) {
561 i = lm78_read_value(new_client, LM78_REG_CHIPID); 573 i = lm78_read_value(new_client, LM78_REG_CHIPID);
562 if (i == 0x00 || i == 0x20) 574 if (i == 0x00 || i == 0x20 /* LM78 */
575 || i == 0x40) /* LM78-J */
563 kind = lm78; 576 kind = lm78;
564 else if (i == 0x40)
565 kind = lm78j;
566 else if ((i & 0xfe) == 0xc0) 577 else if ((i & 0xfe) == 0xc0)
567 kind = lm79; 578 kind = lm79;
568 else { 579 else {
@@ -578,8 +589,6 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
578 589
579 if (kind == lm78) { 590 if (kind == lm78) {
580 client_name = "lm78"; 591 client_name = "lm78";
581 } else if (kind == lm78j) {
582 client_name = "lm78-j";
583 } else if (kind == lm79) { 592 } else if (kind == lm79) {
584 client_name = "lm79"; 593 client_name = "lm79";
585 } 594 }
@@ -605,6 +614,12 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
605 } 614 }
606 615
607 /* Register sysfs hooks */ 616 /* Register sysfs hooks */
617 data->class_dev = hwmon_device_register(&new_client->dev);
618 if (IS_ERR(data->class_dev)) {
619 err = PTR_ERR(data->class_dev);
620 goto ERROR3;
621 }
622
608 device_create_file(&new_client->dev, &dev_attr_in0_input); 623 device_create_file(&new_client->dev, &dev_attr_in0_input);
609 device_create_file(&new_client->dev, &dev_attr_in0_min); 624 device_create_file(&new_client->dev, &dev_attr_in0_min);
610 device_create_file(&new_client->dev, &dev_attr_in0_max); 625 device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -643,6 +658,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
643 658
644 return 0; 659 return 0;
645 660
661ERROR3:
662 i2c_detach_client(new_client);
646ERROR2: 663ERROR2:
647 kfree(data); 664 kfree(data);
648ERROR1: 665ERROR1:
@@ -654,18 +671,18 @@ ERROR0:
654 671
655static int lm78_detach_client(struct i2c_client *client) 672static int lm78_detach_client(struct i2c_client *client)
656{ 673{
674 struct lm78_data *data = i2c_get_clientdata(client);
657 int err; 675 int err;
658 676
659 if ((err = i2c_detach_client(client))) { 677 hwmon_device_unregister(data->class_dev);
660 dev_err(&client->dev, 678
661 "Client deregistration failed, client not detached.\n"); 679 if ((err = i2c_detach_client(client)))
662 return err; 680 return err;
663 }
664 681
665 if(i2c_is_isa_client(client)) 682 if(i2c_is_isa_client(client))
666 release_region(client->addr, LM78_EXTENT); 683 release_region(client->addr, LM78_EXTENT);
667 684
668 kfree(i2c_get_clientdata(client)); 685 kfree(data);
669 686
670 return 0; 687 return 0;
671} 688}
@@ -777,18 +794,31 @@ static struct lm78_data *lm78_update_device(struct device *dev)
777 794
778static int __init sm_lm78_init(void) 795static int __init sm_lm78_init(void)
779{ 796{
780 return i2c_add_driver(&lm78_driver); 797 int res;
798
799 res = i2c_add_driver(&lm78_driver);
800 if (res)
801 return res;
802
803 res = i2c_isa_add_driver(&lm78_isa_driver);
804 if (res) {
805 i2c_del_driver(&lm78_driver);
806 return res;
807 }
808
809 return 0;
781} 810}
782 811
783static void __exit sm_lm78_exit(void) 812static void __exit sm_lm78_exit(void)
784{ 813{
814 i2c_isa_del_driver(&lm78_isa_driver);
785 i2c_del_driver(&lm78_driver); 815 i2c_del_driver(&lm78_driver);
786} 816}
787 817
788 818
789 819
790MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); 820MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
791MODULE_DESCRIPTION("LM78, LM78-J and LM79 driver"); 821MODULE_DESCRIPTION("LM78/LM79 driver");
792MODULE_LICENSE("GPL"); 822MODULE_LICENSE("GPL");
793 823
794module_init(sm_lm78_init); 824module_init(sm_lm78_init);
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 8100595feb44..83af8b3a0cac 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -26,15 +26,15 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/hwmon.h>
30#include <linux/err.h>
30 31
31/* Addresses to scan */ 32/* Addresses to scan */
32static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 33static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
33 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; 34 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
34static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
35 35
36/* Insmod parameters */ 36/* Insmod parameters */
37SENSORS_INSMOD_1(lm80); 37I2C_CLIENT_INSMOD_1(lm80);
38 38
39/* Many LM80 constants specified below */ 39/* Many LM80 constants specified below */
40 40
@@ -107,6 +107,7 @@ static inline long TEMP_FROM_REG(u16 temp)
107 107
108struct lm80_data { 108struct lm80_data {
109 struct i2c_client client; 109 struct i2c_client client;
110 struct class_device *class_dev;
110 struct semaphore update_lock; 111 struct semaphore update_lock;
111 char valid; /* !=0 if following fields are valid */ 112 char valid; /* !=0 if following fields are valid */
112 unsigned long last_updated; /* In jiffies */ 113 unsigned long last_updated; /* In jiffies */
@@ -389,7 +390,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter)
389{ 390{
390 if (!(adapter->class & I2C_CLASS_HWMON)) 391 if (!(adapter->class & I2C_CLASS_HWMON))
391 return 0; 392 return 0;
392 return i2c_detect(adapter, &addr_data, lm80_detect); 393 return i2c_probe(adapter, &addr_data, lm80_detect);
393} 394}
394 395
395int lm80_detect(struct i2c_adapter *adapter, int address, int kind) 396int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -451,6 +452,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
451 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); 452 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2));
452 453
453 /* Register sysfs hooks */ 454 /* Register sysfs hooks */
455 data->class_dev = hwmon_device_register(&new_client->dev);
456 if (IS_ERR(data->class_dev)) {
457 err = PTR_ERR(data->class_dev);
458 goto error_detach;
459 }
460
454 device_create_file(&new_client->dev, &dev_attr_in0_min); 461 device_create_file(&new_client->dev, &dev_attr_in0_min);
455 device_create_file(&new_client->dev, &dev_attr_in1_min); 462 device_create_file(&new_client->dev, &dev_attr_in1_min);
456 device_create_file(&new_client->dev, &dev_attr_in2_min); 463 device_create_file(&new_client->dev, &dev_attr_in2_min);
@@ -487,6 +494,8 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
487 494
488 return 0; 495 return 0;
489 496
497error_detach:
498 i2c_detach_client(new_client);
490error_free: 499error_free:
491 kfree(data); 500 kfree(data);
492exit: 501exit:
@@ -495,15 +504,15 @@ exit:
495 504
496static int lm80_detach_client(struct i2c_client *client) 505static int lm80_detach_client(struct i2c_client *client)
497{ 506{
507 struct lm80_data *data = i2c_get_clientdata(client);
498 int err; 508 int err;
499 509
500 if ((err = i2c_detach_client(client))) { 510 hwmon_device_unregister(data->class_dev);
501 dev_err(&client->dev, "Client deregistration failed, " 511
502 "client not detached.\n"); 512 if ((err = i2c_detach_client(client)))
503 return err; 513 return err;
504 }
505 514
506 kfree(i2c_get_clientdata(client)); 515 kfree(data);
507 return 0; 516 return 0;
508} 517}
509 518
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index a49008b444c8..d74b2c20c719 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -32,8 +32,9 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/jiffies.h> 33#include <linux/jiffies.h>
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/i2c-sensor.h>
36#include <linux/hwmon-sysfs.h> 35#include <linux/hwmon-sysfs.h>
36#include <linux/hwmon.h>
37#include <linux/err.h>
37 38
38/* 39/*
39 * Addresses to scan 40 * Addresses to scan
@@ -45,13 +46,12 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
45 0x29, 0x2a, 0x2b, 46 0x29, 0x2a, 0x2b,
46 0x4c, 0x4d, 0x4e, 47 0x4c, 0x4d, 0x4e,
47 I2C_CLIENT_END }; 48 I2C_CLIENT_END };
48static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
49 49
50/* 50/*
51 * Insmod parameters 51 * Insmod parameters
52 */ 52 */
53 53
54SENSORS_INSMOD_1(lm83); 54I2C_CLIENT_INSMOD_1(lm83);
55 55
56/* 56/*
57 * The LM83 registers 57 * The LM83 registers
@@ -138,6 +138,7 @@ static struct i2c_driver lm83_driver = {
138 138
139struct lm83_data { 139struct lm83_data {
140 struct i2c_client client; 140 struct i2c_client client;
141 struct class_device *class_dev;
141 struct semaphore update_lock; 142 struct semaphore update_lock;
142 char valid; /* zero until following fields are valid */ 143 char valid; /* zero until following fields are valid */
143 unsigned long last_updated; /* in jiffies */ 144 unsigned long last_updated; /* in jiffies */
@@ -212,7 +213,7 @@ static int lm83_attach_adapter(struct i2c_adapter *adapter)
212{ 213{
213 if (!(adapter->class & I2C_CLASS_HWMON)) 214 if (!(adapter->class & I2C_CLASS_HWMON))
214 return 0; 215 return 0;
215 return i2c_detect(adapter, &addr_data, lm83_detect); 216 return i2c_probe(adapter, &addr_data, lm83_detect);
216} 217}
217 218
218/* 219/*
@@ -312,6 +313,12 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
312 */ 313 */
313 314
314 /* Register sysfs hooks */ 315 /* Register sysfs hooks */
316 data->class_dev = hwmon_device_register(&new_client->dev);
317 if (IS_ERR(data->class_dev)) {
318 err = PTR_ERR(data->class_dev);
319 goto exit_detach;
320 }
321
315 device_create_file(&new_client->dev, 322 device_create_file(&new_client->dev,
316 &sensor_dev_attr_temp1_input.dev_attr); 323 &sensor_dev_attr_temp1_input.dev_attr);
317 device_create_file(&new_client->dev, 324 device_create_file(&new_client->dev,
@@ -340,6 +347,8 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
340 347
341 return 0; 348 return 0;
342 349
350exit_detach:
351 i2c_detach_client(new_client);
343exit_free: 352exit_free:
344 kfree(data); 353 kfree(data);
345exit: 354exit:
@@ -348,15 +357,15 @@ exit:
348 357
349static int lm83_detach_client(struct i2c_client *client) 358static int lm83_detach_client(struct i2c_client *client)
350{ 359{
360 struct lm83_data *data = i2c_get_clientdata(client);
351 int err; 361 int err;
352 362
353 if ((err = i2c_detach_client(client))) { 363 hwmon_device_unregister(data->class_dev);
354 dev_err(&client->dev, 364
355 "Client deregistration failed, client not detached.\n"); 365 if ((err = i2c_detach_client(client)))
356 return err; 366 return err;
357 }
358 367
359 kfree(i2c_get_clientdata(client)); 368 kfree(data);
360 return 0; 369 return 0;
361} 370}
362 371
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index b4d7fd418264..ab214df9624b 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -28,15 +28,15 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/jiffies.h> 29#include <linux/jiffies.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/i2c-sensor.h> 31#include <linux/hwmon.h>
32#include <linux/i2c-vid.h> 32#include <linux/hwmon-vid.h>
33#include <linux/err.h>
33 34
34/* Addresses to scan */ 35/* Addresses to scan */
35static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 36static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
36static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
37 37
38/* Insmod parameters */ 38/* Insmod parameters */
39SENSORS_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); 39I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
40 40
41/* The LM85 registers */ 41/* The LM85 registers */
42 42
@@ -281,15 +281,6 @@ static int ZONE_TO_REG( int zone )
281#define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) 281#define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2))
282#define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) 282#define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1)
283 283
284/* i2c-vid.h defines vid_from_reg() */
285#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm)))
286
287/* Unlike some other drivers we DO NOT set initial limits. Use
288 * the config file to set limits. Some users have reported
289 * motherboards shutting down when we set limits in a previous
290 * version of the driver.
291 */
292
293/* Chip sampling rates 284/* Chip sampling rates
294 * 285 *
295 * Some sensors are not updated more frequently than once per second 286 * Some sensors are not updated more frequently than once per second
@@ -339,6 +330,7 @@ struct lm85_autofan {
339 330
340struct lm85_data { 331struct lm85_data {
341 struct i2c_client client; 332 struct i2c_client client;
333 struct class_device *class_dev;
342 struct semaphore lock; 334 struct semaphore lock;
343 enum chips type; 335 enum chips type;
344 336
@@ -1019,7 +1011,7 @@ int lm85_attach_adapter(struct i2c_adapter *adapter)
1019{ 1011{
1020 if (!(adapter->class & I2C_CLASS_HWMON)) 1012 if (!(adapter->class & I2C_CLASS_HWMON))
1021 return 0; 1013 return 0;
1022 return i2c_detect(adapter, &addr_data, lm85_detect); 1014 return i2c_probe(adapter, &addr_data, lm85_detect);
1023} 1015}
1024 1016
1025int lm85_detect(struct i2c_adapter *adapter, int address, 1017int lm85_detect(struct i2c_adapter *adapter, int address,
@@ -1031,11 +1023,6 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1031 int err = 0; 1023 int err = 0;
1032 const char *type_name = ""; 1024 const char *type_name = "";
1033 1025
1034 if (i2c_is_isa_adapter(adapter)) {
1035 /* This chip has no ISA interface */
1036 goto ERROR0 ;
1037 };
1038
1039 if (!i2c_check_functionality(adapter, 1026 if (!i2c_check_functionality(adapter,
1040 I2C_FUNC_SMBUS_BYTE_DATA)) { 1027 I2C_FUNC_SMBUS_BYTE_DATA)) {
1041 /* We need to be able to do byte I/O */ 1028 /* We need to be able to do byte I/O */
@@ -1160,12 +1147,18 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1160 goto ERROR1; 1147 goto ERROR1;
1161 1148
1162 /* Set the VRM version */ 1149 /* Set the VRM version */
1163 data->vrm = i2c_which_vrm(); 1150 data->vrm = vid_which_vrm();
1164 1151
1165 /* Initialize the LM85 chip */ 1152 /* Initialize the LM85 chip */
1166 lm85_init_client(new_client); 1153 lm85_init_client(new_client);
1167 1154
1168 /* Register sysfs hooks */ 1155 /* Register sysfs hooks */
1156 data->class_dev = hwmon_device_register(&new_client->dev);
1157 if (IS_ERR(data->class_dev)) {
1158 err = PTR_ERR(data->class_dev);
1159 goto ERROR2;
1160 }
1161
1169 device_create_file(&new_client->dev, &dev_attr_fan1_input); 1162 device_create_file(&new_client->dev, &dev_attr_fan1_input);
1170 device_create_file(&new_client->dev, &dev_attr_fan2_input); 1163 device_create_file(&new_client->dev, &dev_attr_fan2_input);
1171 device_create_file(&new_client->dev, &dev_attr_fan3_input); 1164 device_create_file(&new_client->dev, &dev_attr_fan3_input);
@@ -1235,6 +1228,8 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1235 return 0; 1228 return 0;
1236 1229
1237 /* Error out and cleanup code */ 1230 /* Error out and cleanup code */
1231 ERROR2:
1232 i2c_detach_client(new_client);
1238 ERROR1: 1233 ERROR1:
1239 kfree(data); 1234 kfree(data);
1240 ERROR0: 1235 ERROR0:
@@ -1243,8 +1238,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1243 1238
1244int lm85_detach_client(struct i2c_client *client) 1239int lm85_detach_client(struct i2c_client *client)
1245{ 1240{
1241 struct lm85_data *data = i2c_get_clientdata(client);
1242 hwmon_device_unregister(data->class_dev);
1246 i2c_detach_client(client); 1243 i2c_detach_client(client);
1247 kfree(i2c_get_clientdata(client)); 1244 kfree(data);
1248 return 0; 1245 return 0;
1249} 1246}
1250 1247
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 1921ed1af182..dca996de4c33 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -57,8 +57,9 @@
57#include <linux/slab.h> 57#include <linux/slab.h>
58#include <linux/jiffies.h> 58#include <linux/jiffies.h>
59#include <linux/i2c.h> 59#include <linux/i2c.h>
60#include <linux/i2c-sensor.h> 60#include <linux/hwmon.h>
61#include <linux/i2c-vid.h> 61#include <linux/hwmon-vid.h>
62#include <linux/err.h>
62 63
63/* 64/*
64 * Addresses to scan 65 * Addresses to scan
@@ -66,13 +67,12 @@
66 */ 67 */
67 68
68static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 69static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
69static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
70 70
71/* 71/*
72 * Insmod parameters 72 * Insmod parameters
73 */ 73 */
74 74
75SENSORS_INSMOD_1(lm87); 75I2C_CLIENT_INSMOD_1(lm87);
76 76
77/* 77/*
78 * The LM87 registers 78 * The LM87 registers
@@ -175,6 +175,7 @@ static struct i2c_driver lm87_driver = {
175 175
176struct lm87_data { 176struct lm87_data {
177 struct i2c_client client; 177 struct i2c_client client;
178 struct class_device *class_dev;
178 struct semaphore update_lock; 179 struct semaphore update_lock;
179 char valid; /* zero until following fields are valid */ 180 char valid; /* zero until following fields are valid */
180 unsigned long last_updated; /* In jiffies */ 181 unsigned long last_updated; /* In jiffies */
@@ -537,7 +538,7 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter)
537{ 538{
538 if (!(adapter->class & I2C_CLASS_HWMON)) 539 if (!(adapter->class & I2C_CLASS_HWMON))
539 return 0; 540 return 0;
540 return i2c_detect(adapter, &addr_data, lm87_detect); 541 return i2c_probe(adapter, &addr_data, lm87_detect);
541} 542}
542 543
543/* 544/*
@@ -608,6 +609,12 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
608 data->in_scale[7] = 1875; 609 data->in_scale[7] = 1875;
609 610
610 /* Register sysfs hooks */ 611 /* Register sysfs hooks */
612 data->class_dev = hwmon_device_register(&new_client->dev);
613 if (IS_ERR(data->class_dev)) {
614 err = PTR_ERR(data->class_dev);
615 goto exit_detach;
616 }
617
611 device_create_file(&new_client->dev, &dev_attr_in1_input); 618 device_create_file(&new_client->dev, &dev_attr_in1_input);
612 device_create_file(&new_client->dev, &dev_attr_in1_min); 619 device_create_file(&new_client->dev, &dev_attr_in1_min);
613 device_create_file(&new_client->dev, &dev_attr_in1_max); 620 device_create_file(&new_client->dev, &dev_attr_in1_max);
@@ -673,6 +680,8 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
673 680
674 return 0; 681 return 0;
675 682
683exit_detach:
684 i2c_detach_client(new_client);
676exit_free: 685exit_free:
677 kfree(data); 686 kfree(data);
678exit: 687exit:
@@ -685,7 +694,7 @@ static void lm87_init_client(struct i2c_client *client)
685 u8 config; 694 u8 config;
686 695
687 data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); 696 data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
688 data->vrm = i2c_which_vrm(); 697 data->vrm = vid_which_vrm();
689 698
690 config = lm87_read_value(client, LM87_REG_CONFIG); 699 config = lm87_read_value(client, LM87_REG_CONFIG);
691 if (!(config & 0x01)) { 700 if (!(config & 0x01)) {
@@ -719,15 +728,15 @@ static void lm87_init_client(struct i2c_client *client)
719 728
720static int lm87_detach_client(struct i2c_client *client) 729static int lm87_detach_client(struct i2c_client *client)
721{ 730{
731 struct lm87_data *data = i2c_get_clientdata(client);
722 int err; 732 int err;
723 733
724 if ((err = i2c_detach_client(client))) { 734 hwmon_device_unregister(data->class_dev);
725 dev_err(&client->dev, "Client deregistration failed, " 735
726 "client not detached.\n"); 736 if ((err = i2c_detach_client(client)))
727 return err; 737 return err;
728 }
729 738
730 kfree(i2c_get_clientdata(client)); 739 kfree(data);
731 return 0; 740 return 0;
732} 741}
733 742
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index a67dcadf7cb0..14de05fcd431 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -75,8 +75,9 @@
75#include <linux/slab.h> 75#include <linux/slab.h>
76#include <linux/jiffies.h> 76#include <linux/jiffies.h>
77#include <linux/i2c.h> 77#include <linux/i2c.h>
78#include <linux/i2c-sensor.h>
79#include <linux/hwmon-sysfs.h> 78#include <linux/hwmon-sysfs.h>
79#include <linux/hwmon.h>
80#include <linux/err.h>
80 81
81/* 82/*
82 * Addresses to scan 83 * Addresses to scan
@@ -89,13 +90,12 @@
89 */ 90 */
90 91
91static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; 92static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END };
92static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
93 93
94/* 94/*
95 * Insmod parameters 95 * Insmod parameters
96 */ 96 */
97 97
98SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); 98I2C_CLIENT_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461);
99 99
100/* 100/*
101 * The LM90 registers 101 * The LM90 registers
@@ -200,6 +200,7 @@ static struct i2c_driver lm90_driver = {
200 200
201struct lm90_data { 201struct lm90_data {
202 struct i2c_client client; 202 struct i2c_client client;
203 struct class_device *class_dev;
203 struct semaphore update_lock; 204 struct semaphore update_lock;
204 char valid; /* zero until following fields are valid */ 205 char valid; /* zero until following fields are valid */
205 unsigned long last_updated; /* in jiffies */ 206 unsigned long last_updated; /* in jiffies */
@@ -352,7 +353,7 @@ static int lm90_attach_adapter(struct i2c_adapter *adapter)
352{ 353{
353 if (!(adapter->class & I2C_CLASS_HWMON)) 354 if (!(adapter->class & I2C_CLASS_HWMON))
354 return 0; 355 return 0;
355 return i2c_detect(adapter, &addr_data, lm90_detect); 356 return i2c_probe(adapter, &addr_data, lm90_detect);
356} 357}
357 358
358/* 359/*
@@ -500,6 +501,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
500 lm90_init_client(new_client); 501 lm90_init_client(new_client);
501 502
502 /* Register sysfs hooks */ 503 /* Register sysfs hooks */
504 data->class_dev = hwmon_device_register(&new_client->dev);
505 if (IS_ERR(data->class_dev)) {
506 err = PTR_ERR(data->class_dev);
507 goto exit_detach;
508 }
509
503 device_create_file(&new_client->dev, 510 device_create_file(&new_client->dev,
504 &sensor_dev_attr_temp1_input.dev_attr); 511 &sensor_dev_attr_temp1_input.dev_attr);
505 device_create_file(&new_client->dev, 512 device_create_file(&new_client->dev,
@@ -524,6 +531,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
524 531
525 return 0; 532 return 0;
526 533
534exit_detach:
535 i2c_detach_client(new_client);
527exit_free: 536exit_free:
528 kfree(data); 537 kfree(data);
529exit: 538exit:
@@ -547,15 +556,15 @@ static void lm90_init_client(struct i2c_client *client)
547 556
548static int lm90_detach_client(struct i2c_client *client) 557static int lm90_detach_client(struct i2c_client *client)
549{ 558{
559 struct lm90_data *data = i2c_get_clientdata(client);
550 int err; 560 int err;
551 561
552 if ((err = i2c_detach_client(client))) { 562 hwmon_device_unregister(data->class_dev);
553 dev_err(&client->dev, "Client deregistration failed, " 563
554 "client not detached.\n"); 564 if ((err = i2c_detach_client(client)))
555 return err; 565 return err;
556 }
557 566
558 kfree(i2c_get_clientdata(client)); 567 kfree(data);
559 return 0; 568 return 0;
560} 569}
561 570
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 215c8e40ffdd..647b7c7cd575 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -44,17 +44,16 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/i2c-sensor.h> 47#include <linux/hwmon.h>
48 48#include <linux/err.h>
49 49
50/* The LM92 and MAX6635 have 2 two-state pins for address selection, 50/* The LM92 and MAX6635 have 2 two-state pins for address selection,
51 resulting in 4 possible addresses. */ 51 resulting in 4 possible addresses. */
52static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 52static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
53 I2C_CLIENT_END }; 53 I2C_CLIENT_END };
54static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
55 54
56/* Insmod parameters */ 55/* Insmod parameters */
57SENSORS_INSMOD_1(lm92); 56I2C_CLIENT_INSMOD_1(lm92);
58 57
59/* The LM92 registers */ 58/* The LM92 registers */
60#define LM92_REG_CONFIG 0x01 /* 8-bit, RW */ 59#define LM92_REG_CONFIG 0x01 /* 8-bit, RW */
@@ -96,6 +95,7 @@ static struct i2c_driver lm92_driver;
96/* Client data (each client gets its own) */ 95/* Client data (each client gets its own) */
97struct lm92_data { 96struct lm92_data {
98 struct i2c_client client; 97 struct i2c_client client;
98 struct class_device *class_dev;
99 struct semaphore update_lock; 99 struct semaphore update_lock;
100 char valid; /* zero until following fields are valid */ 100 char valid; /* zero until following fields are valid */
101 unsigned long last_updated; /* in jiffies */ 101 unsigned long last_updated; /* in jiffies */
@@ -359,6 +359,12 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
359 lm92_init_client(new_client); 359 lm92_init_client(new_client);
360 360
361 /* Register sysfs hooks */ 361 /* Register sysfs hooks */
362 data->class_dev = hwmon_device_register(&new_client->dev);
363 if (IS_ERR(data->class_dev)) {
364 err = PTR_ERR(data->class_dev);
365 goto exit_detach;
366 }
367
362 device_create_file(&new_client->dev, &dev_attr_temp1_input); 368 device_create_file(&new_client->dev, &dev_attr_temp1_input);
363 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 369 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
364 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); 370 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
@@ -370,6 +376,8 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
370 376
371 return 0; 377 return 0;
372 378
379exit_detach:
380 i2c_detach_client(new_client);
373exit_free: 381exit_free:
374 kfree(data); 382 kfree(data);
375exit: 383exit:
@@ -380,20 +388,20 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter)
380{ 388{
381 if (!(adapter->class & I2C_CLASS_HWMON)) 389 if (!(adapter->class & I2C_CLASS_HWMON))
382 return 0; 390 return 0;
383 return i2c_detect(adapter, &addr_data, lm92_detect); 391 return i2c_probe(adapter, &addr_data, lm92_detect);
384} 392}
385 393
386static int lm92_detach_client(struct i2c_client *client) 394static int lm92_detach_client(struct i2c_client *client)
387{ 395{
396 struct lm92_data *data = i2c_get_clientdata(client);
388 int err; 397 int err;
389 398
390 if ((err = i2c_detach_client(client))) { 399 hwmon_device_unregister(data->class_dev);
391 dev_err(&client->dev, "Client deregistration failed, " 400
392 "client not detached.\n"); 401 if ((err = i2c_detach_client(client)))
393 return err; 402 return err;
394 }
395 403
396 kfree(i2c_get_clientdata(client)); 404 kfree(data);
397 return 0; 405 return 0;
398} 406}
399 407
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 3c159f1d49ee..16bf71f3a04d 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -31,20 +31,19 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-sensor.h> 34#include <linux/hwmon.h>
35 35#include <linux/err.h>
36 36
37static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 37static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
38 0x29, 0x2a, 0x2b, 38 0x29, 0x2a, 0x2b,
39 0x4c, 0x4d, 0x4e, 39 0x4c, 0x4d, 0x4e,
40 I2C_CLIENT_END }; 40 I2C_CLIENT_END };
41static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
42 41
43/* 42/*
44 * Insmod parameters 43 * Insmod parameters
45 */ 44 */
46 45
47SENSORS_INSMOD_1(max1619); 46I2C_CLIENT_INSMOD_1(max1619);
48 47
49/* 48/*
50 * The MAX1619 registers 49 * The MAX1619 registers
@@ -104,6 +103,7 @@ static struct i2c_driver max1619_driver = {
104 103
105struct max1619_data { 104struct max1619_data {
106 struct i2c_client client; 105 struct i2c_client client;
106 struct class_device *class_dev;
107 struct semaphore update_lock; 107 struct semaphore update_lock;
108 char valid; /* zero until following fields are valid */ 108 char valid; /* zero until following fields are valid */
109 unsigned long last_updated; /* in jiffies */ 109 unsigned long last_updated; /* in jiffies */
@@ -179,7 +179,7 @@ static int max1619_attach_adapter(struct i2c_adapter *adapter)
179{ 179{
180 if (!(adapter->class & I2C_CLASS_HWMON)) 180 if (!(adapter->class & I2C_CLASS_HWMON))
181 return 0; 181 return 0;
182 return i2c_detect(adapter, &addr_data, max1619_detect); 182 return i2c_probe(adapter, &addr_data, max1619_detect);
183} 183}
184 184
185/* 185/*
@@ -275,6 +275,12 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
275 max1619_init_client(new_client); 275 max1619_init_client(new_client);
276 276
277 /* Register sysfs hooks */ 277 /* Register sysfs hooks */
278 data->class_dev = hwmon_device_register(&new_client->dev);
279 if (IS_ERR(data->class_dev)) {
280 err = PTR_ERR(data->class_dev);
281 goto exit_detach;
282 }
283
278 device_create_file(&new_client->dev, &dev_attr_temp1_input); 284 device_create_file(&new_client->dev, &dev_attr_temp1_input);
279 device_create_file(&new_client->dev, &dev_attr_temp2_input); 285 device_create_file(&new_client->dev, &dev_attr_temp2_input);
280 device_create_file(&new_client->dev, &dev_attr_temp2_min); 286 device_create_file(&new_client->dev, &dev_attr_temp2_min);
@@ -285,6 +291,8 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
285 291
286 return 0; 292 return 0;
287 293
294exit_detach:
295 i2c_detach_client(new_client);
288exit_free: 296exit_free:
289 kfree(data); 297 kfree(data);
290exit: 298exit:
@@ -308,15 +316,15 @@ static void max1619_init_client(struct i2c_client *client)
308 316
309static int max1619_detach_client(struct i2c_client *client) 317static int max1619_detach_client(struct i2c_client *client)
310{ 318{
319 struct max1619_data *data = i2c_get_clientdata(client);
311 int err; 320 int err;
312 321
313 if ((err = i2c_detach_client(client))) { 322 hwmon_device_unregister(data->class_dev);
314 dev_err(&client->dev, "Client deregistration failed, " 323
315 "client not detached.\n"); 324 if ((err = i2c_detach_client(client)))
316 return err; 325 return err;
317 }
318 326
319 kfree(i2c_get_clientdata(client)); 327 kfree(data);
320 return 0; 328 return 0;
321} 329}
322 330
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index fa4032d53b79..cf2a35799c7c 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -38,23 +38,19 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/jiffies.h> 39#include <linux/jiffies.h>
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/i2c-sensor.h> 41#include <linux/i2c-isa.h>
42#include <linux/i2c-vid.h> 42#include <linux/hwmon.h>
43#include <linux/hwmon-sysfs.h>
44#include <linux/hwmon-vid.h>
45#include <linux/err.h>
43#include <asm/io.h> 46#include <asm/io.h>
44 47
45static unsigned short normal_i2c[] = { I2C_CLIENT_END };
46static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
47static struct i2c_force_data forces[] = {{ NULL }};
48static u8 devid; 48static u8 devid;
49static unsigned int extra_isa[3]; 49static unsigned short address;
50static unsigned short extra_isa[3];
50static u8 confreg[4]; 51static u8 confreg[4];
51 52
52enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; 53enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 };
53static struct i2c_address_data addr_data = {
54 .normal_i2c = normal_i2c,
55 .normal_isa = normal_isa,
56 .forces = forces,
57};
58 54
59static int init = 1; 55static int init = 1;
60module_param(init, int, 0); 56module_param(init, int, 0);
@@ -186,6 +182,7 @@ static inline u8 PWM_TO_REG(int val, int inv)
186 182
187struct pc87360_data { 183struct pc87360_data {
188 struct i2c_client client; 184 struct i2c_client client;
185 struct class_device *class_dev;
189 struct semaphore lock; 186 struct semaphore lock;
190 struct semaphore update_lock; 187 struct semaphore update_lock;
191 char valid; /* !=0 if following fields are valid */ 188 char valid; /* !=0 if following fields are valid */
@@ -224,8 +221,7 @@ struct pc87360_data {
224 * Functions declaration 221 * Functions declaration
225 */ 222 */
226 223
227static int pc87360_attach_adapter(struct i2c_adapter *adapter); 224static int pc87360_detect(struct i2c_adapter *adapter);
228static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind);
229static int pc87360_detach_client(struct i2c_client *client); 225static int pc87360_detach_client(struct i2c_client *client);
230 226
231static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, 227static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
@@ -242,8 +238,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev);
242static struct i2c_driver pc87360_driver = { 238static struct i2c_driver pc87360_driver = {
243 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
244 .name = "pc87360", 240 .name = "pc87360",
245 .flags = I2C_DF_NOTIFY, 241 .attach_adapter = pc87360_detect,
246 .attach_adapter = pc87360_attach_adapter,
247 .detach_client = pc87360_detach_client, 242 .detach_client = pc87360_detach_client,
248}; 243};
249 244
@@ -251,168 +246,178 @@ static struct i2c_driver pc87360_driver = {
251 * Sysfs stuff 246 * Sysfs stuff
252 */ 247 */
253 248
254static ssize_t set_fan_min(struct device *dev, const char *buf, 249static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf)
255 size_t count, int nr) 250{
251 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
252 struct pc87360_data *data = pc87360_update_device(dev);
253 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index],
254 FAN_DIV_FROM_REG(data->fan_status[attr->index])));
255}
256static ssize_t show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf)
257{
258 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
259 struct pc87360_data *data = pc87360_update_device(dev);
260 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index],
261 FAN_DIV_FROM_REG(data->fan_status[attr->index])));
262}
263static ssize_t show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
264{
265 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
266 struct pc87360_data *data = pc87360_update_device(dev);
267 return sprintf(buf, "%u\n",
268 FAN_DIV_FROM_REG(data->fan_status[attr->index]));
269}
270static ssize_t show_fan_status(struct device *dev, struct device_attribute *devattr, char *buf)
256{ 271{
272 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
273 struct pc87360_data *data = pc87360_update_device(dev);
274 return sprintf(buf, "%u\n",
275 FAN_STATUS_FROM_REG(data->fan_status[attr->index]));
276}
277static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf,
278 size_t count)
279{
280 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
257 struct i2c_client *client = to_i2c_client(dev); 281 struct i2c_client *client = to_i2c_client(dev);
258 struct pc87360_data *data = i2c_get_clientdata(client); 282 struct pc87360_data *data = i2c_get_clientdata(client);
259 long fan_min = simple_strtol(buf, NULL, 10); 283 long fan_min = simple_strtol(buf, NULL, 10);
260 284
261 down(&data->update_lock); 285 down(&data->update_lock);
262 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[nr])); 286 fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
263 287
264 /* If it wouldn't fit, change clock divisor */ 288 /* If it wouldn't fit, change clock divisor */
265 while (fan_min > 255 289 while (fan_min > 255
266 && (data->fan_status[nr] & 0x60) != 0x60) { 290 && (data->fan_status[attr->index] & 0x60) != 0x60) {
267 fan_min >>= 1; 291 fan_min >>= 1;
268 data->fan[nr] >>= 1; 292 data->fan[attr->index] >>= 1;
269 data->fan_status[nr] += 0x20; 293 data->fan_status[attr->index] += 0x20;
270 } 294 }
271 data->fan_min[nr] = fan_min > 255 ? 255 : fan_min; 295 data->fan_min[attr->index] = fan_min > 255 ? 255 : fan_min;
272 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(nr), 296 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(attr->index),
273 data->fan_min[nr]); 297 data->fan_min[attr->index]);
274 298
275 /* Write new divider, preserve alarm bits */ 299 /* Write new divider, preserve alarm bits */
276 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(nr), 300 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index),
277 data->fan_status[nr] & 0xF9); 301 data->fan_status[attr->index] & 0xF9);
278 up(&data->update_lock); 302 up(&data->update_lock);
279 303
280 return count; 304 return count;
281} 305}
282 306
283#define show_and_set_fan(offset) \ 307#define show_and_set_fan(offset) \
284static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ 308static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
285{ \ 309 show_fan_input, NULL, offset-1); \
286 struct pc87360_data *data = pc87360_update_device(dev); \ 310static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
287 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \ 311 show_fan_min, set_fan_min, offset-1); \
288 FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ 312static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
289} \ 313 show_fan_div, NULL, offset-1); \
290static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ 314static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
291{ \ 315 show_fan_status, NULL, offset-1);
292 struct pc87360_data *data = pc87360_update_device(dev); \
293 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \
294 FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
295} \
296static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
297{ \
298 struct pc87360_data *data = pc87360_update_device(dev); \
299 return sprintf(buf, "%u\n", \
300 FAN_DIV_FROM_REG(data->fan_status[offset-1])); \
301} \
302static ssize_t show_fan##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
303{ \
304 struct pc87360_data *data = pc87360_update_device(dev); \
305 return sprintf(buf, "%u\n", \
306 FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \
307} \
308static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
309 size_t count) \
310{ \
311 return set_fan_min(dev, buf, count, offset-1); \
312} \
313static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
314 show_fan##offset##_input, NULL); \
315static DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
316 show_fan##offset##_min, set_fan##offset##_min); \
317static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
318 show_fan##offset##_div, NULL); \
319static DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
320 show_fan##offset##_status, NULL);
321show_and_set_fan(1) 316show_and_set_fan(1)
322show_and_set_fan(2) 317show_and_set_fan(2)
323show_and_set_fan(3) 318show_and_set_fan(3)
324 319
320static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
321{
322 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
323 struct pc87360_data *data = pc87360_update_device(dev);
324 return sprintf(buf, "%u\n",
325 PWM_FROM_REG(data->pwm[attr->index],
326 FAN_CONFIG_INVERT(data->fan_conf,
327 attr->index)));
328}
329static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf,
330 size_t count)
331{
332 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
333 struct i2c_client *client = to_i2c_client(dev);
334 struct pc87360_data *data = i2c_get_clientdata(client);
335 long val = simple_strtol(buf, NULL, 10);
336
337 down(&data->update_lock);
338 data->pwm[attr->index] = PWM_TO_REG(val,
339 FAN_CONFIG_INVERT(data->fan_conf, attr->index));
340 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index),
341 data->pwm[attr->index]);
342 up(&data->update_lock);
343 return count;
344}
345
325#define show_and_set_pwm(offset) \ 346#define show_and_set_pwm(offset) \
326static ssize_t show_pwm##offset(struct device *dev, struct device_attribute *attr, char *buf) \ 347static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
327{ \ 348 show_pwm, set_pwm, offset-1);
328 struct pc87360_data *data = pc87360_update_device(dev); \
329 return sprintf(buf, "%u\n", \
330 PWM_FROM_REG(data->pwm[offset-1], \
331 FAN_CONFIG_INVERT(data->fan_conf, \
332 offset-1))); \
333} \
334static ssize_t set_pwm##offset(struct device *dev, struct device_attribute *attr, const char *buf, \
335 size_t count) \
336{ \
337 struct i2c_client *client = to_i2c_client(dev); \
338 struct pc87360_data *data = i2c_get_clientdata(client); \
339 long val = simple_strtol(buf, NULL, 10); \
340 \
341 down(&data->update_lock); \
342 data->pwm[offset-1] = PWM_TO_REG(val, \
343 FAN_CONFIG_INVERT(data->fan_conf, offset-1)); \
344 pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(offset-1), \
345 data->pwm[offset-1]); \
346 up(&data->update_lock); \
347 return count; \
348} \
349static DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
350 show_pwm##offset, set_pwm##offset);
351show_and_set_pwm(1) 349show_and_set_pwm(1)
352show_and_set_pwm(2) 350show_and_set_pwm(2)
353show_and_set_pwm(3) 351show_and_set_pwm(3)
354 352
353static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
354{
355 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
356 struct pc87360_data *data = pc87360_update_device(dev);
357 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index],
358 data->in_vref));
359}
360static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr, char *buf)
361{
362 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
363 struct pc87360_data *data = pc87360_update_device(dev);
364 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index],
365 data->in_vref));
366}
367static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr, char *buf)
368{
369 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
370 struct pc87360_data *data = pc87360_update_device(dev);
371 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index],
372 data->in_vref));
373}
374static ssize_t show_in_status(struct device *dev, struct device_attribute *devattr, char *buf)
375{
376 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
377 struct pc87360_data *data = pc87360_update_device(dev);
378 return sprintf(buf, "%u\n", data->in_status[attr->index]);
379}
380static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, const char *buf,
381 size_t count)
382{
383 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
384 struct i2c_client *client = to_i2c_client(dev);
385 struct pc87360_data *data = i2c_get_clientdata(client);
386 long val = simple_strtol(buf, NULL, 10);
387
388 down(&data->update_lock);
389 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
390 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN,
391 data->in_min[attr->index]);
392 up(&data->update_lock);
393 return count;
394}
395static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf,
396 size_t count)
397{
398 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
399 struct i2c_client *client = to_i2c_client(dev);
400 struct pc87360_data *data = i2c_get_clientdata(client);
401 long val = simple_strtol(buf, NULL, 10);
402
403 down(&data->update_lock);
404 data->in_max[attr->index] = IN_TO_REG(val,
405 data->in_vref);
406 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX,
407 data->in_max[attr->index]);
408 up(&data->update_lock);
409 return count;
410}
411
355#define show_and_set_in(offset) \ 412#define show_and_set_in(offset) \
356static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ 413static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
357{ \ 414 show_in_input, NULL, offset); \
358 struct pc87360_data *data = pc87360_update_device(dev); \ 415static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
359 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ 416 show_in_min, set_in_min, offset); \
360 data->in_vref)); \ 417static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
361} \ 418 show_in_max, set_in_max, offset); \
362static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ 419static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \
363{ \ 420 show_in_status, NULL, offset);
364 struct pc87360_data *data = pc87360_update_device(dev); \
365 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
366 data->in_vref)); \
367} \
368static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
369{ \
370 struct pc87360_data *data = pc87360_update_device(dev); \
371 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
372 data->in_vref)); \
373} \
374static ssize_t show_in##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
375{ \
376 struct pc87360_data *data = pc87360_update_device(dev); \
377 return sprintf(buf, "%u\n", data->in_status[offset]); \
378} \
379static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
380 size_t count) \
381{ \
382 struct i2c_client *client = to_i2c_client(dev); \
383 struct pc87360_data *data = i2c_get_clientdata(client); \
384 long val = simple_strtol(buf, NULL, 10); \
385 \
386 down(&data->update_lock); \
387 data->in_min[offset] = IN_TO_REG(val, data->in_vref); \
388 pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MIN, \
389 data->in_min[offset]); \
390 up(&data->update_lock); \
391 return count; \
392} \
393static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
394 size_t count) \
395{ \
396 struct i2c_client *client = to_i2c_client(dev); \
397 struct pc87360_data *data = i2c_get_clientdata(client); \
398 long val = simple_strtol(buf, NULL, 10); \
399 \
400 down(&data->update_lock); \
401 data->in_max[offset] = IN_TO_REG(val, \
402 data->in_vref); \
403 pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MAX, \
404 data->in_max[offset]); \
405 up(&data->update_lock); \
406 return count; \
407} \
408static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
409 show_in##offset##_input, NULL); \
410static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
411 show_in##offset##_min, set_in##offset##_min); \
412static DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
413 show_in##offset##_max, set_in##offset##_max); \
414static DEVICE_ATTR(in##offset##_status, S_IRUGO, \
415 show_in##offset##_status, NULL);
416show_and_set_in(0) 421show_and_set_in(0)
417show_and_set_in(1) 422show_and_set_in(1)
418show_and_set_in(2) 423show_and_set_in(2)
@@ -425,88 +430,97 @@ show_and_set_in(8)
425show_and_set_in(9) 430show_and_set_in(9)
426show_and_set_in(10) 431show_and_set_in(10)
427 432
433static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
434{
435 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
436 struct pc87360_data *data = pc87360_update_device(dev);
437 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index],
438 data->in_vref));
439}
440static ssize_t show_therm_min(struct device *dev, struct device_attribute *devattr, char *buf)
441{
442 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
443 struct pc87360_data *data = pc87360_update_device(dev);
444 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index],
445 data->in_vref));
446}
447static ssize_t show_therm_max(struct device *dev, struct device_attribute *devattr, char *buf)
448{
449 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
450 struct pc87360_data *data = pc87360_update_device(dev);
451 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index],
452 data->in_vref));
453}
454static ssize_t show_therm_crit(struct device *dev, struct device_attribute *devattr, char *buf)
455{
456 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
457 struct pc87360_data *data = pc87360_update_device(dev);
458 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-11],
459 data->in_vref));
460}
461static ssize_t show_therm_status(struct device *dev, struct device_attribute *devattr, char *buf)
462{
463 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
464 struct pc87360_data *data = pc87360_update_device(dev);
465 return sprintf(buf, "%u\n", data->in_status[attr->index]);
466}
467static ssize_t set_therm_min(struct device *dev, struct device_attribute *devattr, const char *buf,
468 size_t count)
469{
470 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
471 struct i2c_client *client = to_i2c_client(dev);
472 struct pc87360_data *data = i2c_get_clientdata(client);
473 long val = simple_strtol(buf, NULL, 10);
474
475 down(&data->update_lock);
476 data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
477 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN,
478 data->in_min[attr->index]);
479 up(&data->update_lock);
480 return count;
481}
482static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf,
483 size_t count)
484{
485 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
486 struct i2c_client *client = to_i2c_client(dev);
487 struct pc87360_data *data = i2c_get_clientdata(client);
488 long val = simple_strtol(buf, NULL, 10);
489
490 down(&data->update_lock);
491 data->in_max[attr->index] = IN_TO_REG(val, data->in_vref);
492 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX,
493 data->in_max[attr->index]);
494 up(&data->update_lock);
495 return count;
496}
497static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
498 size_t count)
499{
500 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
501 struct i2c_client *client = to_i2c_client(dev);
502 struct pc87360_data *data = i2c_get_clientdata(client);
503 long val = simple_strtol(buf, NULL, 10);
504
505 down(&data->update_lock);
506 data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref);
507 pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT,
508 data->in_crit[attr->index-11]);
509 up(&data->update_lock);
510 return count;
511}
512
428#define show_and_set_therm(offset) \ 513#define show_and_set_therm(offset) \
429static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ 514static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
430{ \ 515 show_therm_input, NULL, 11+offset-4); \
431 struct pc87360_data *data = pc87360_update_device(dev); \ 516static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
432 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \ 517 show_therm_min, set_therm_min, 11+offset-4); \
433 data->in_vref)); \ 518static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
434} \ 519 show_therm_max, set_therm_max, 11+offset-4); \
435static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ 520static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
436{ \ 521 show_therm_crit, set_therm_crit, 11+offset-4); \
437 struct pc87360_data *data = pc87360_update_device(dev); \ 522static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
438 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \ 523 show_therm_status, NULL, 11+offset-4);
439 data->in_vref)); \
440} \
441static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
442{ \
443 struct pc87360_data *data = pc87360_update_device(dev); \
444 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \
445 data->in_vref)); \
446} \
447static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \
448{ \
449 struct pc87360_data *data = pc87360_update_device(dev); \
450 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \
451 data->in_vref)); \
452} \
453static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
454{ \
455 struct pc87360_data *data = pc87360_update_device(dev); \
456 return sprintf(buf, "%u\n", data->in_status[offset+7]); \
457} \
458static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
459 size_t count) \
460{ \
461 struct i2c_client *client = to_i2c_client(dev); \
462 struct pc87360_data *data = i2c_get_clientdata(client); \
463 long val = simple_strtol(buf, NULL, 10); \
464 \
465 down(&data->update_lock); \
466 data->in_min[offset+7] = IN_TO_REG(val, data->in_vref); \
467 pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MIN, \
468 data->in_min[offset+7]); \
469 up(&data->update_lock); \
470 return count; \
471} \
472static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
473 size_t count) \
474{ \
475 struct i2c_client *client = to_i2c_client(dev); \
476 struct pc87360_data *data = i2c_get_clientdata(client); \
477 long val = simple_strtol(buf, NULL, 10); \
478 \
479 down(&data->update_lock); \
480 data->in_max[offset+7] = IN_TO_REG(val, data->in_vref); \
481 pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MAX, \
482 data->in_max[offset+7]); \
483 up(&data->update_lock); \
484 return count; \
485} \
486static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \
487 size_t count) \
488{ \
489 struct i2c_client *client = to_i2c_client(dev); \
490 struct pc87360_data *data = i2c_get_clientdata(client); \
491 long val = simple_strtol(buf, NULL, 10); \
492 \
493 down(&data->update_lock); \
494 data->in_crit[offset-4] = IN_TO_REG(val, data->in_vref); \
495 pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_CRIT, \
496 data->in_crit[offset-4]); \
497 up(&data->update_lock); \
498 return count; \
499} \
500static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
501 show_temp##offset##_input, NULL); \
502static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
503 show_temp##offset##_min, set_temp##offset##_min); \
504static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
505 show_temp##offset##_max, set_temp##offset##_max); \
506static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
507 show_temp##offset##_crit, set_temp##offset##_crit); \
508static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
509 show_temp##offset##_status, NULL);
510show_and_set_therm(4) 524show_and_set_therm(4)
511show_and_set_therm(5) 525show_and_set_therm(5)
512show_and_set_therm(6) 526show_and_set_therm(6)
@@ -539,84 +553,93 @@ static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr,
539} 553}
540static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); 554static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
541 555
556static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf)
557{
558 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
559 struct pc87360_data *data = pc87360_update_device(dev);
560 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
561}
562static ssize_t show_temp_min(struct device *dev, struct device_attribute *devattr, char *buf)
563{
564 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
565 struct pc87360_data *data = pc87360_update_device(dev);
566 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index]));
567}
568static ssize_t show_temp_max(struct device *dev, struct device_attribute *devattr, char *buf)
569{
570 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
571 struct pc87360_data *data = pc87360_update_device(dev);
572 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index]));
573}
574static ssize_t show_temp_crit(struct device *dev, struct device_attribute *devattr, char *buf)
575{
576 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
577 struct pc87360_data *data = pc87360_update_device(dev);
578 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[attr->index]));
579}
580static ssize_t show_temp_status(struct device *dev, struct device_attribute *devattr, char *buf)
581{
582 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
583 struct pc87360_data *data = pc87360_update_device(dev);
584 return sprintf(buf, "%d\n", data->temp_status[attr->index]);
585}
586static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr, const char *buf,
587 size_t count)
588{
589 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
590 struct i2c_client *client = to_i2c_client(dev);
591 struct pc87360_data *data = i2c_get_clientdata(client);
592 long val = simple_strtol(buf, NULL, 10);
593
594 down(&data->update_lock);
595 data->temp_min[attr->index] = TEMP_TO_REG(val);
596 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN,
597 data->temp_min[attr->index]);
598 up(&data->update_lock);
599 return count;
600}
601static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf,
602 size_t count)
603{
604 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
605 struct i2c_client *client = to_i2c_client(dev);
606 struct pc87360_data *data = i2c_get_clientdata(client);
607 long val = simple_strtol(buf, NULL, 10);
608
609 down(&data->update_lock);
610 data->temp_max[attr->index] = TEMP_TO_REG(val);
611 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX,
612 data->temp_max[attr->index]);
613 up(&data->update_lock);
614 return count;
615}
616static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
617 size_t count)
618{
619 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
620 struct i2c_client *client = to_i2c_client(dev);
621 struct pc87360_data *data = i2c_get_clientdata(client);
622 long val = simple_strtol(buf, NULL, 10);
623
624 down(&data->update_lock);
625 data->temp_crit[attr->index] = TEMP_TO_REG(val);
626 pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT,
627 data->temp_crit[attr->index]);
628 up(&data->update_lock);
629 return count;
630}
631
542#define show_and_set_temp(offset) \ 632#define show_and_set_temp(offset) \
543static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ 633static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
544{ \ 634 show_temp_input, NULL, offset-1); \
545 struct pc87360_data *data = pc87360_update_device(dev); \ 635static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
546 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ 636 show_temp_min, set_temp_min, offset-1); \
547} \ 637static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
548static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ 638 show_temp_max, set_temp_max, offset-1); \
549{ \ 639static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
550 struct pc87360_data *data = pc87360_update_device(dev); \ 640 show_temp_crit, set_temp_crit, offset-1); \
551 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ 641static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
552} \ 642 show_temp_status, NULL, offset-1);
553static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
554{ \
555 struct pc87360_data *data = pc87360_update_device(dev); \
556 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \
557}\
558static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \
559{ \
560 struct pc87360_data *data = pc87360_update_device(dev); \
561 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \
562}\
563static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
564{ \
565 struct pc87360_data *data = pc87360_update_device(dev); \
566 return sprintf(buf, "%d\n", data->temp_status[offset-1]); \
567}\
568static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
569 size_t count) \
570{ \
571 struct i2c_client *client = to_i2c_client(dev); \
572 struct pc87360_data *data = i2c_get_clientdata(client); \
573 long val = simple_strtol(buf, NULL, 10); \
574 \
575 down(&data->update_lock); \
576 data->temp_min[offset-1] = TEMP_TO_REG(val); \
577 pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MIN, \
578 data->temp_min[offset-1]); \
579 up(&data->update_lock); \
580 return count; \
581} \
582static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
583 size_t count) \
584{ \
585 struct i2c_client *client = to_i2c_client(dev); \
586 struct pc87360_data *data = i2c_get_clientdata(client); \
587 long val = simple_strtol(buf, NULL, 10); \
588 \
589 down(&data->update_lock); \
590 data->temp_max[offset-1] = TEMP_TO_REG(val); \
591 pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MAX, \
592 data->temp_max[offset-1]); \
593 up(&data->update_lock); \
594 return count; \
595} \
596static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \
597 size_t count) \
598{ \
599 struct i2c_client *client = to_i2c_client(dev); \
600 struct pc87360_data *data = i2c_get_clientdata(client); \
601 long val = simple_strtol(buf, NULL, 10); \
602 \
603 down(&data->update_lock); \
604 data->temp_crit[offset-1] = TEMP_TO_REG(val); \
605 pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_CRIT, \
606 data->temp_crit[offset-1]); \
607 up(&data->update_lock); \
608 return count; \
609} \
610static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
611 show_temp##offset##_input, NULL); \
612static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
613 show_temp##offset##_min, set_temp##offset##_min); \
614static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
615 show_temp##offset##_max, set_temp##offset##_max); \
616static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
617 show_temp##offset##_crit, set_temp##offset##_crit); \
618static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
619 show_temp##offset##_status, NULL);
620show_and_set_temp(1) 643show_and_set_temp(1)
621show_and_set_temp(2) 644show_and_set_temp(2)
622show_and_set_temp(3) 645show_and_set_temp(3)
@@ -632,12 +655,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
632 * Device detection, registration and update 655 * Device detection, registration and update
633 */ 656 */
634 657
635static int pc87360_attach_adapter(struct i2c_adapter *adapter) 658static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses)
636{
637 return i2c_detect(adapter, &addr_data, pc87360_detect);
638}
639
640static int pc87360_find(int sioaddr, u8 *devid, int *address)
641{ 659{
642 u16 val; 660 u16 val;
643 int i; 661 int i;
@@ -683,7 +701,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
683 continue; 701 continue;
684 } 702 }
685 703
686 address[i] = val; 704 addresses[i] = val;
687 705
688 if (i==0) { /* Fans */ 706 if (i==0) { /* Fans */
689 confreg[0] = superio_inb(sioaddr, 0xF0); 707 confreg[0] = superio_inb(sioaddr, 0xF0);
@@ -727,9 +745,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
727 return 0; 745 return 0;
728} 746}
729 747
730/* We don't really care about the address. 748static int pc87360_detect(struct i2c_adapter *adapter)
731 Read from extra_isa instead. */
732int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
733{ 749{
734 int i; 750 int i;
735 struct i2c_client *new_client; 751 struct i2c_client *new_client;
@@ -738,9 +754,6 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
738 const char *name = "pc87360"; 754 const char *name = "pc87360";
739 int use_thermistors = 0; 755 int use_thermistors = 0;
740 756
741 if (!i2c_is_isa_adapter(adapter))
742 return -ENODEV;
743
744 if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) 757 if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
745 return -ENOMEM; 758 return -ENOMEM;
746 memset(data, 0x00, sizeof(struct pc87360_data)); 759 memset(data, 0x00, sizeof(struct pc87360_data));
@@ -838,51 +851,57 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
838 } 851 }
839 852
840 /* Register sysfs hooks */ 853 /* Register sysfs hooks */
854 data->class_dev = hwmon_device_register(&new_client->dev);
855 if (IS_ERR(data->class_dev)) {
856 err = PTR_ERR(data->class_dev);
857 goto ERROR3;
858 }
859
841 if (data->innr) { 860 if (data->innr) {
842 device_create_file(&new_client->dev, &dev_attr_in0_input); 861 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
843 device_create_file(&new_client->dev, &dev_attr_in1_input); 862 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
844 device_create_file(&new_client->dev, &dev_attr_in2_input); 863 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
845 device_create_file(&new_client->dev, &dev_attr_in3_input); 864 device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
846 device_create_file(&new_client->dev, &dev_attr_in4_input); 865 device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
847 device_create_file(&new_client->dev, &dev_attr_in5_input); 866 device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
848 device_create_file(&new_client->dev, &dev_attr_in6_input); 867 device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
849 device_create_file(&new_client->dev, &dev_attr_in7_input); 868 device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
850 device_create_file(&new_client->dev, &dev_attr_in8_input); 869 device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
851 device_create_file(&new_client->dev, &dev_attr_in9_input); 870 device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
852 device_create_file(&new_client->dev, &dev_attr_in10_input); 871 device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
853 device_create_file(&new_client->dev, &dev_attr_in0_min); 872 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
854 device_create_file(&new_client->dev, &dev_attr_in1_min); 873 device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
855 device_create_file(&new_client->dev, &dev_attr_in2_min); 874 device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
856 device_create_file(&new_client->dev, &dev_attr_in3_min); 875 device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
857 device_create_file(&new_client->dev, &dev_attr_in4_min); 876 device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
858 device_create_file(&new_client->dev, &dev_attr_in5_min); 877 device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
859 device_create_file(&new_client->dev, &dev_attr_in6_min); 878 device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
860 device_create_file(&new_client->dev, &dev_attr_in7_min); 879 device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
861 device_create_file(&new_client->dev, &dev_attr_in8_min); 880 device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
862 device_create_file(&new_client->dev, &dev_attr_in9_min); 881 device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
863 device_create_file(&new_client->dev, &dev_attr_in10_min); 882 device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
864 device_create_file(&new_client->dev, &dev_attr_in0_max); 883 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
865 device_create_file(&new_client->dev, &dev_attr_in1_max); 884 device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
866 device_create_file(&new_client->dev, &dev_attr_in2_max); 885 device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
867 device_create_file(&new_client->dev, &dev_attr_in3_max); 886 device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
868 device_create_file(&new_client->dev, &dev_attr_in4_max); 887 device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
869 device_create_file(&new_client->dev, &dev_attr_in5_max); 888 device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
870 device_create_file(&new_client->dev, &dev_attr_in6_max); 889 device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
871 device_create_file(&new_client->dev, &dev_attr_in7_max); 890 device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
872 device_create_file(&new_client->dev, &dev_attr_in8_max); 891 device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
873 device_create_file(&new_client->dev, &dev_attr_in9_max); 892 device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
874 device_create_file(&new_client->dev, &dev_attr_in10_max); 893 device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
875 device_create_file(&new_client->dev, &dev_attr_in0_status); 894 device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr);
876 device_create_file(&new_client->dev, &dev_attr_in1_status); 895 device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr);
877 device_create_file(&new_client->dev, &dev_attr_in2_status); 896 device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr);
878 device_create_file(&new_client->dev, &dev_attr_in3_status); 897 device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr);
879 device_create_file(&new_client->dev, &dev_attr_in4_status); 898 device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr);
880 device_create_file(&new_client->dev, &dev_attr_in5_status); 899 device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr);
881 device_create_file(&new_client->dev, &dev_attr_in6_status); 900 device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr);
882 device_create_file(&new_client->dev, &dev_attr_in7_status); 901 device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr);
883 device_create_file(&new_client->dev, &dev_attr_in8_status); 902 device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr);
884 device_create_file(&new_client->dev, &dev_attr_in9_status); 903 device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr);
885 device_create_file(&new_client->dev, &dev_attr_in10_status); 904 device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr);
886 905
887 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 906 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
888 device_create_file(&new_client->dev, &dev_attr_vrm); 907 device_create_file(&new_client->dev, &dev_attr_vrm);
@@ -890,90 +909,92 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
890 } 909 }
891 910
892 if (data->tempnr) { 911 if (data->tempnr) {
893 device_create_file(&new_client->dev, &dev_attr_temp1_input); 912 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
894 device_create_file(&new_client->dev, &dev_attr_temp2_input); 913 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
895 device_create_file(&new_client->dev, &dev_attr_temp1_min); 914 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
896 device_create_file(&new_client->dev, &dev_attr_temp2_min); 915 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
897 device_create_file(&new_client->dev, &dev_attr_temp1_max); 916 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
898 device_create_file(&new_client->dev, &dev_attr_temp2_max); 917 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
899 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 918 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
900 device_create_file(&new_client->dev, &dev_attr_temp2_crit); 919 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
901 device_create_file(&new_client->dev, &dev_attr_temp1_status); 920 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr);
902 device_create_file(&new_client->dev, &dev_attr_temp2_status); 921 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr);
903 922
904 device_create_file(&new_client->dev, &dev_attr_alarms_temp); 923 device_create_file(&new_client->dev, &dev_attr_alarms_temp);
905 } 924 }
906 if (data->tempnr == 3) { 925 if (data->tempnr == 3) {
907 device_create_file(&new_client->dev, &dev_attr_temp3_input); 926 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
908 device_create_file(&new_client->dev, &dev_attr_temp3_min); 927 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
909 device_create_file(&new_client->dev, &dev_attr_temp3_max); 928 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
910 device_create_file(&new_client->dev, &dev_attr_temp3_crit); 929 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
911 device_create_file(&new_client->dev, &dev_attr_temp3_status); 930 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr);
912 } 931 }
913 if (data->innr == 14) { 932 if (data->innr == 14) {
914 device_create_file(&new_client->dev, &dev_attr_temp4_input); 933 device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr);
915 device_create_file(&new_client->dev, &dev_attr_temp5_input); 934 device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr);
916 device_create_file(&new_client->dev, &dev_attr_temp6_input); 935 device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr);
917 device_create_file(&new_client->dev, &dev_attr_temp4_min); 936 device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr);
918 device_create_file(&new_client->dev, &dev_attr_temp5_min); 937 device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr);
919 device_create_file(&new_client->dev, &dev_attr_temp6_min); 938 device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr);
920 device_create_file(&new_client->dev, &dev_attr_temp4_max); 939 device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr);
921 device_create_file(&new_client->dev, &dev_attr_temp5_max); 940 device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr);
922 device_create_file(&new_client->dev, &dev_attr_temp6_max); 941 device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr);
923 device_create_file(&new_client->dev, &dev_attr_temp4_crit); 942 device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr);
924 device_create_file(&new_client->dev, &dev_attr_temp5_crit); 943 device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr);
925 device_create_file(&new_client->dev, &dev_attr_temp6_crit); 944 device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr);
926 device_create_file(&new_client->dev, &dev_attr_temp4_status); 945 device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr);
927 device_create_file(&new_client->dev, &dev_attr_temp5_status); 946 device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr);
928 device_create_file(&new_client->dev, &dev_attr_temp6_status); 947 device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr);
929 } 948 }
930 949
931 if (data->fannr) { 950 if (data->fannr) {
932 if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) { 951 if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) {
933 device_create_file(&new_client->dev, 952 device_create_file(&new_client->dev,
934 &dev_attr_fan1_input); 953 &sensor_dev_attr_fan1_input.dev_attr);
935 device_create_file(&new_client->dev, 954 device_create_file(&new_client->dev,
936 &dev_attr_fan1_min); 955 &sensor_dev_attr_fan1_min.dev_attr);
937 device_create_file(&new_client->dev, 956 device_create_file(&new_client->dev,
938 &dev_attr_fan1_div); 957 &sensor_dev_attr_fan1_div.dev_attr);
939 device_create_file(&new_client->dev, 958 device_create_file(&new_client->dev,
940 &dev_attr_fan1_status); 959 &sensor_dev_attr_fan1_status.dev_attr);
941 } 960 }
942 961
943 if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { 962 if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) {
944 device_create_file(&new_client->dev, 963 device_create_file(&new_client->dev,
945 &dev_attr_fan2_input); 964 &sensor_dev_attr_fan2_input.dev_attr);
946 device_create_file(&new_client->dev, 965 device_create_file(&new_client->dev,
947 &dev_attr_fan2_min); 966 &sensor_dev_attr_fan2_min.dev_attr);
948 device_create_file(&new_client->dev, 967 device_create_file(&new_client->dev,
949 &dev_attr_fan2_div); 968 &sensor_dev_attr_fan2_div.dev_attr);
950 device_create_file(&new_client->dev, 969 device_create_file(&new_client->dev,
951 &dev_attr_fan2_status); 970 &sensor_dev_attr_fan2_status.dev_attr);
952 } 971 }
953 972
954 if (FAN_CONFIG_CONTROL(data->fan_conf, 0)) 973 if (FAN_CONFIG_CONTROL(data->fan_conf, 0))
955 device_create_file(&new_client->dev, &dev_attr_pwm1); 974 device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
956 if (FAN_CONFIG_CONTROL(data->fan_conf, 1)) 975 if (FAN_CONFIG_CONTROL(data->fan_conf, 1))
957 device_create_file(&new_client->dev, &dev_attr_pwm2); 976 device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
958 } 977 }
959 if (data->fannr == 3) { 978 if (data->fannr == 3) {
960 if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) { 979 if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) {
961 device_create_file(&new_client->dev, 980 device_create_file(&new_client->dev,
962 &dev_attr_fan3_input); 981 &sensor_dev_attr_fan3_input.dev_attr);
963 device_create_file(&new_client->dev, 982 device_create_file(&new_client->dev,
964 &dev_attr_fan3_min); 983 &sensor_dev_attr_fan3_min.dev_attr);
965 device_create_file(&new_client->dev, 984 device_create_file(&new_client->dev,
966 &dev_attr_fan3_div); 985 &sensor_dev_attr_fan3_div.dev_attr);
967 device_create_file(&new_client->dev, 986 device_create_file(&new_client->dev,
968 &dev_attr_fan3_status); 987 &sensor_dev_attr_fan3_status.dev_attr);
969 } 988 }
970 989
971 if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) 990 if (FAN_CONFIG_CONTROL(data->fan_conf, 2))
972 device_create_file(&new_client->dev, &dev_attr_pwm3); 991 device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
973 } 992 }
974 993
975 return 0; 994 return 0;
976 995
996ERROR3:
997 i2c_detach_client(new_client);
977ERROR2: 998ERROR2:
978 for (i = 0; i < 3; i++) { 999 for (i = 0; i < 3; i++) {
979 if (data->address[i]) { 1000 if (data->address[i]) {
@@ -990,11 +1011,10 @@ static int pc87360_detach_client(struct i2c_client *client)
990 struct pc87360_data *data = i2c_get_clientdata(client); 1011 struct pc87360_data *data = i2c_get_clientdata(client);
991 int i; 1012 int i;
992 1013
993 if ((i = i2c_detach_client(client))) { 1014 hwmon_device_unregister(data->class_dev);
994 dev_err(&client->dev, "Client deregistration failed, " 1015
995 "client not detached.\n"); 1016 if ((i = i2c_detach_client(client)))
996 return i; 1017 return i;
997 }
998 1018
999 for (i = 0; i < 3; i++) { 1019 for (i = 0; i < 3; i++) {
1000 if (data->address[i]) { 1020 if (data->address[i]) {
@@ -1320,23 +1340,23 @@ static int __init pc87360_init(void)
1320 /* Arbitrarily pick one of the addresses */ 1340 /* Arbitrarily pick one of the addresses */
1321 for (i = 0; i < 3; i++) { 1341 for (i = 0; i < 3; i++) {
1322 if (extra_isa[i] != 0x0000) { 1342 if (extra_isa[i] != 0x0000) {
1323 normal_isa[0] = extra_isa[i]; 1343 address = extra_isa[i];
1324 break; 1344 break;
1325 } 1345 }
1326 } 1346 }
1327 1347
1328 if (normal_isa[0] == 0x0000) { 1348 if (address == 0x0000) {
1329 printk(KERN_WARNING "pc87360: No active logical device, " 1349 printk(KERN_WARNING "pc87360: No active logical device, "
1330 "module not inserted.\n"); 1350 "module not inserted.\n");
1331 return -ENODEV; 1351 return -ENODEV;
1332 } 1352 }
1333 1353
1334 return i2c_add_driver(&pc87360_driver); 1354 return i2c_isa_add_driver(&pc87360_driver);
1335} 1355}
1336 1356
1337static void __exit pc87360_exit(void) 1357static void __exit pc87360_exit(void)
1338{ 1358{
1339 i2c_del_driver(&pc87360_driver); 1359 i2c_isa_del_driver(&pc87360_driver);
1340} 1360}
1341 1361
1342 1362
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 6bbfc8fb4f13..8610bce08244 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -55,7 +55,9 @@
55#include <linux/ioport.h> 55#include <linux/ioport.h>
56#include <linux/pci.h> 56#include <linux/pci.h>
57#include <linux/i2c.h> 57#include <linux/i2c.h>
58#include <linux/i2c-sensor.h> 58#include <linux/i2c-isa.h>
59#include <linux/hwmon.h>
60#include <linux/err.h>
59#include <linux/init.h> 61#include <linux/init.h>
60#include <linux/jiffies.h> 62#include <linux/jiffies.h>
61#include <asm/io.h> 63#include <asm/io.h>
@@ -68,14 +70,10 @@ module_param(force_addr, ushort, 0);
68MODULE_PARM_DESC(force_addr, 70MODULE_PARM_DESC(force_addr,
69 "Initialize the base address of the sensors"); 71 "Initialize the base address of the sensors");
70 72
71/* Addresses to scan. 73/* Device address
72 Note that we can't determine the ISA address until we have initialized 74 Note that we can't determine the ISA address until we have initialized
73 our module */ 75 our module */
74static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 76static unsigned short address;
75static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
76
77/* Insmod parameters */
78SENSORS_INSMOD_1(sis5595);
79 77
80/* Many SIS5595 constants specified below */ 78/* Many SIS5595 constants specified below */
81 79
@@ -168,6 +166,7 @@ static inline u8 DIV_TO_REG(int val)
168 allocated. */ 166 allocated. */
169struct sis5595_data { 167struct sis5595_data {
170 struct i2c_client client; 168 struct i2c_client client;
169 struct class_device *class_dev;
171 struct semaphore lock; 170 struct semaphore lock;
172 171
173 struct semaphore update_lock; 172 struct semaphore update_lock;
@@ -190,8 +189,7 @@ struct sis5595_data {
190 189
191static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ 190static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
192 191
193static int sis5595_attach_adapter(struct i2c_adapter *adapter); 192static int sis5595_detect(struct i2c_adapter *adapter);
194static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind);
195static int sis5595_detach_client(struct i2c_client *client); 193static int sis5595_detach_client(struct i2c_client *client);
196 194
197static int sis5595_read_value(struct i2c_client *client, u8 register); 195static int sis5595_read_value(struct i2c_client *client, u8 register);
@@ -202,9 +200,7 @@ static void sis5595_init_client(struct i2c_client *client);
202static struct i2c_driver sis5595_driver = { 200static struct i2c_driver sis5595_driver = {
203 .owner = THIS_MODULE, 201 .owner = THIS_MODULE,
204 .name = "sis5595", 202 .name = "sis5595",
205 .id = I2C_DRIVERID_SIS5595, 203 .attach_adapter = sis5595_detect,
206 .flags = I2C_DF_NOTIFY,
207 .attach_adapter = sis5595_attach_adapter,
208 .detach_client = sis5595_detach_client, 204 .detach_client = sis5595_detach_client,
209}; 205};
210 206
@@ -476,14 +472,7 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
476static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 472static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
477 473
478/* This is called when the module is loaded */ 474/* This is called when the module is loaded */
479static int sis5595_attach_adapter(struct i2c_adapter *adapter) 475static int sis5595_detect(struct i2c_adapter *adapter)
480{
481 if (!(adapter->class & I2C_CLASS_HWMON))
482 return 0;
483 return i2c_detect(adapter, &addr_data, sis5595_detect);
484}
485
486int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
487{ 476{
488 int err = 0; 477 int err = 0;
489 int i; 478 int i;
@@ -492,10 +481,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
492 char val; 481 char val;
493 u16 a; 482 u16 a;
494 483
495 /* Make sure we are probing the ISA bus!! */
496 if (!i2c_is_isa_adapter(adapter))
497 goto exit;
498
499 if (force_addr) 484 if (force_addr)
500 address = force_addr & ~(SIS5595_EXTENT - 1); 485 address = force_addr & ~(SIS5595_EXTENT - 1);
501 /* Reserve the ISA region */ 486 /* Reserve the ISA region */
@@ -578,6 +563,12 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
578 } 563 }
579 564
580 /* Register sysfs hooks */ 565 /* Register sysfs hooks */
566 data->class_dev = hwmon_device_register(&new_client->dev);
567 if (IS_ERR(data->class_dev)) {
568 err = PTR_ERR(data->class_dev);
569 goto exit_detach;
570 }
571
581 device_create_file(&new_client->dev, &dev_attr_in0_input); 572 device_create_file(&new_client->dev, &dev_attr_in0_input);
582 device_create_file(&new_client->dev, &dev_attr_in0_min); 573 device_create_file(&new_client->dev, &dev_attr_in0_min);
583 device_create_file(&new_client->dev, &dev_attr_in0_max); 574 device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -608,7 +599,9 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
608 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 599 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
609 } 600 }
610 return 0; 601 return 0;
611 602
603exit_detach:
604 i2c_detach_client(new_client);
612exit_free: 605exit_free:
613 kfree(data); 606 kfree(data);
614exit_release: 607exit_release:
@@ -619,18 +612,17 @@ exit:
619 612
620static int sis5595_detach_client(struct i2c_client *client) 613static int sis5595_detach_client(struct i2c_client *client)
621{ 614{
615 struct sis5595_data *data = i2c_get_clientdata(client);
622 int err; 616 int err;
623 617
624 if ((err = i2c_detach_client(client))) { 618 hwmon_device_unregister(data->class_dev);
625 dev_err(&client->dev, 619
626 "Client deregistration failed, client not detached.\n"); 620 if ((err = i2c_detach_client(client)))
627 return err; 621 return err;
628 }
629 622
630 if (i2c_is_isa_client(client)) 623 release_region(client->addr, SIS5595_EXTENT);
631 release_region(client->addr, SIS5595_EXTENT);
632 624
633 kfree(i2c_get_clientdata(client)); 625 kfree(data);
634 626
635 return 0; 627 return 0;
636} 628}
@@ -745,7 +737,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
745{ 737{
746 u16 val; 738 u16 val;
747 int *i; 739 int *i;
748 int addr = 0;
749 740
750 for (i = blacklist; *i != 0; i++) { 741 for (i = blacklist; *i != 0; i++) {
751 struct pci_dev *dev; 742 struct pci_dev *dev;
@@ -761,22 +752,19 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
761 pci_read_config_word(dev, SIS5595_BASE_REG, &val)) 752 pci_read_config_word(dev, SIS5595_BASE_REG, &val))
762 return -ENODEV; 753 return -ENODEV;
763 754
764 addr = val & ~(SIS5595_EXTENT - 1); 755 address = val & ~(SIS5595_EXTENT - 1);
765 if (addr == 0 && force_addr == 0) { 756 if (address == 0 && force_addr == 0) {
766 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); 757 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
767 return -ENODEV; 758 return -ENODEV;
768 } 759 }
769 if (force_addr)
770 addr = force_addr; /* so detect will get called */
771 760
772 if (!addr) { 761 if (!address) {
773 dev_err(&dev->dev,"No SiS 5595 sensors found.\n"); 762 dev_err(&dev->dev,"No SiS 5595 sensors found.\n");
774 return -ENODEV; 763 return -ENODEV;
775 } 764 }
776 normal_isa[0] = addr;
777 765
778 s_bridge = pci_dev_get(dev); 766 s_bridge = pci_dev_get(dev);
779 if (i2c_add_driver(&sis5595_driver)) { 767 if (i2c_isa_add_driver(&sis5595_driver)) {
780 pci_dev_put(s_bridge); 768 pci_dev_put(s_bridge);
781 s_bridge = NULL; 769 s_bridge = NULL;
782 } 770 }
@@ -803,7 +791,7 @@ static void __exit sm_sis5595_exit(void)
803{ 791{
804 pci_unregister_driver(&sis5595_pci_driver); 792 pci_unregister_driver(&sis5595_pci_driver);
805 if (s_bridge != NULL) { 793 if (s_bridge != NULL) {
806 i2c_del_driver(&sis5595_driver); 794 i2c_isa_del_driver(&sis5595_driver);
807 pci_dev_put(s_bridge); 795 pci_dev_put(s_bridge);
808 s_bridge = NULL; 796 s_bridge = NULL;
809 } 797 }
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index fdeeb3ab6f2f..7fe71576dea4 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -31,23 +31,14 @@
31#include <linux/ioport.h> 31#include <linux/ioport.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-sensor.h> 34#include <linux/i2c-isa.h>
35#include <linux/hwmon.h>
36#include <linux/err.h>
35#include <linux/init.h> 37#include <linux/init.h>
36#include <asm/io.h> 38#include <asm/io.h>
37 39
38static unsigned short normal_i2c[] = { I2C_CLIENT_END };
39/* Address is autodetected, there is no default value */ 40/* Address is autodetected, there is no default value */
40static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; 41static unsigned short address;
41static struct i2c_force_data forces[] = {{NULL}};
42
43enum chips { any_chip, smsc47b397 };
44static struct i2c_address_data addr_data = {
45 .normal_i2c = normal_i2c,
46 .normal_isa = normal_isa,
47 .probe = normal_i2c, /* cheat */
48 .ignore = normal_i2c, /* cheat */
49 .forces = forces,
50};
51 42
52/* Super-I/0 registers and commands */ 43/* Super-I/0 registers and commands */
53 44
@@ -100,6 +91,7 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
100 91
101struct smsc47b397_data { 92struct smsc47b397_data {
102 struct i2c_client client; 93 struct i2c_client client;
94 struct class_device *class_dev;
103 struct semaphore lock; 95 struct semaphore lock;
104 96
105 struct semaphore update_lock; 97 struct semaphore update_lock;
@@ -215,52 +207,40 @@ sysfs_fan(4);
215#define device_create_file_fan(client, num) \ 207#define device_create_file_fan(client, num) \
216 device_create_file(&client->dev, &dev_attr_fan##num##_input) 208 device_create_file(&client->dev, &dev_attr_fan##num##_input)
217 209
218static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind);
219
220static int smsc47b397_attach_adapter(struct i2c_adapter *adapter)
221{
222 if (!(adapter->class & I2C_CLASS_HWMON))
223 return 0;
224 return i2c_detect(adapter, &addr_data, smsc47b397_detect);
225}
226
227static int smsc47b397_detach_client(struct i2c_client *client) 210static int smsc47b397_detach_client(struct i2c_client *client)
228{ 211{
212 struct smsc47b397_data *data = i2c_get_clientdata(client);
229 int err; 213 int err;
230 214
231 if ((err = i2c_detach_client(client))) { 215 hwmon_device_unregister(data->class_dev);
232 dev_err(&client->dev, "Client deregistration failed, " 216
233 "client not detached.\n"); 217 if ((err = i2c_detach_client(client)))
234 return err; 218 return err;
235 }
236 219
237 release_region(client->addr, SMSC_EXTENT); 220 release_region(client->addr, SMSC_EXTENT);
238 kfree(i2c_get_clientdata(client)); 221 kfree(data);
239 222
240 return 0; 223 return 0;
241} 224}
242 225
226static int smsc47b397_detect(struct i2c_adapter *adapter);
227
243static struct i2c_driver smsc47b397_driver = { 228static struct i2c_driver smsc47b397_driver = {
244 .owner = THIS_MODULE, 229 .owner = THIS_MODULE,
245 .name = "smsc47b397", 230 .name = "smsc47b397",
246 .id = I2C_DRIVERID_SMSC47B397, 231 .attach_adapter = smsc47b397_detect,
247 .flags = I2C_DF_NOTIFY,
248 .attach_adapter = smsc47b397_attach_adapter,
249 .detach_client = smsc47b397_detach_client, 232 .detach_client = smsc47b397_detach_client,
250}; 233};
251 234
252static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) 235static int smsc47b397_detect(struct i2c_adapter *adapter)
253{ 236{
254 struct i2c_client *new_client; 237 struct i2c_client *new_client;
255 struct smsc47b397_data *data; 238 struct smsc47b397_data *data;
256 int err = 0; 239 int err = 0;
257 240
258 if (!i2c_is_isa_adapter(adapter)) { 241 if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) {
259 return 0; 242 dev_err(&adapter->dev, "Region 0x%x already in use!\n",
260 } 243 address);
261
262 if (!request_region(addr, SMSC_EXTENT, smsc47b397_driver.name)) {
263 dev_err(&adapter->dev, "Region 0x%x already in use!\n", addr);
264 return -EBUSY; 244 return -EBUSY;
265 } 245 }
266 246
@@ -272,7 +252,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
272 252
273 new_client = &data->client; 253 new_client = &data->client;
274 i2c_set_clientdata(new_client, data); 254 i2c_set_clientdata(new_client, data);
275 new_client->addr = addr; 255 new_client->addr = address;
276 init_MUTEX(&data->lock); 256 init_MUTEX(&data->lock);
277 new_client->adapter = adapter; 257 new_client->adapter = adapter;
278 new_client->driver = &smsc47b397_driver; 258 new_client->driver = &smsc47b397_driver;
@@ -285,6 +265,12 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
285 if ((err = i2c_attach_client(new_client))) 265 if ((err = i2c_attach_client(new_client)))
286 goto error_free; 266 goto error_free;
287 267
268 data->class_dev = hwmon_device_register(&new_client->dev);
269 if (IS_ERR(data->class_dev)) {
270 err = PTR_ERR(data->class_dev);
271 goto error_detach;
272 }
273
288 device_create_file_temp(new_client, 1); 274 device_create_file_temp(new_client, 1);
289 device_create_file_temp(new_client, 2); 275 device_create_file_temp(new_client, 2);
290 device_create_file_temp(new_client, 3); 276 device_create_file_temp(new_client, 3);
@@ -297,14 +283,16 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
297 283
298 return 0; 284 return 0;
299 285
286error_detach:
287 i2c_detach_client(new_client);
300error_free: 288error_free:
301 kfree(data); 289 kfree(data);
302error_release: 290error_release:
303 release_region(addr, SMSC_EXTENT); 291 release_region(address, SMSC_EXTENT);
304 return err; 292 return err;
305} 293}
306 294
307static int __init smsc47b397_find(unsigned int *addr) 295static int __init smsc47b397_find(unsigned short *addr)
308{ 296{
309 u8 id, rev; 297 u8 id, rev;
310 298
@@ -333,15 +321,15 @@ static int __init smsc47b397_init(void)
333{ 321{
334 int ret; 322 int ret;
335 323
336 if ((ret = smsc47b397_find(normal_isa))) 324 if ((ret = smsc47b397_find(&address)))
337 return ret; 325 return ret;
338 326
339 return i2c_add_driver(&smsc47b397_driver); 327 return i2c_isa_add_driver(&smsc47b397_driver);
340} 328}
341 329
342static void __exit smsc47b397_exit(void) 330static void __exit smsc47b397_exit(void)
343{ 331{
344 i2c_del_driver(&smsc47b397_driver); 332 i2c_isa_del_driver(&smsc47b397_driver);
345} 333}
346 334
347MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>"); 335MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 7166ad0b2fda..7e699a8ede26 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -30,21 +30,14 @@
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/jiffies.h> 31#include <linux/jiffies.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-sensor.h> 33#include <linux/i2c-isa.h>
34#include <linux/hwmon.h>
35#include <linux/err.h>
34#include <linux/init.h> 36#include <linux/init.h>
35#include <asm/io.h> 37#include <asm/io.h>
36 38
37static unsigned short normal_i2c[] = { I2C_CLIENT_END };
38/* Address is autodetected, there is no default value */ 39/* Address is autodetected, there is no default value */
39static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; 40static unsigned short address;
40static struct i2c_force_data forces[] = {{NULL}};
41
42enum chips { any_chip, smsc47m1 };
43static struct i2c_address_data addr_data = {
44 .normal_i2c = normal_i2c,
45 .normal_isa = normal_isa,
46 .forces = forces,
47};
48 41
49/* Super-I/0 registers and commands */ 42/* Super-I/0 registers and commands */
50 43
@@ -108,6 +101,7 @@ superio_exit(void)
108 101
109struct smsc47m1_data { 102struct smsc47m1_data {
110 struct i2c_client client; 103 struct i2c_client client;
104 struct class_device *class_dev;
111 struct semaphore lock; 105 struct semaphore lock;
112 106
113 struct semaphore update_lock; 107 struct semaphore update_lock;
@@ -121,9 +115,7 @@ struct smsc47m1_data {
121}; 115};
122 116
123 117
124static int smsc47m1_attach_adapter(struct i2c_adapter *adapter); 118static int smsc47m1_detect(struct i2c_adapter *adapter);
125static int smsc47m1_find(int *address);
126static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind);
127static int smsc47m1_detach_client(struct i2c_client *client); 119static int smsc47m1_detach_client(struct i2c_client *client);
128 120
129static int smsc47m1_read_value(struct i2c_client *client, u8 reg); 121static int smsc47m1_read_value(struct i2c_client *client, u8 reg);
@@ -136,9 +128,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
136static struct i2c_driver smsc47m1_driver = { 128static struct i2c_driver smsc47m1_driver = {
137 .owner = THIS_MODULE, 129 .owner = THIS_MODULE,
138 .name = "smsc47m1", 130 .name = "smsc47m1",
139 .id = I2C_DRIVERID_SMSC47M1, 131 .attach_adapter = smsc47m1_detect,
140 .flags = I2C_DF_NOTIFY,
141 .attach_adapter = smsc47m1_attach_adapter,
142 .detach_client = smsc47m1_detach_client, 132 .detach_client = smsc47m1_detach_client,
143}; 133};
144 134
@@ -354,14 +344,7 @@ fan_present(2);
354 344
355static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL); 345static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL);
356 346
357static int smsc47m1_attach_adapter(struct i2c_adapter *adapter) 347static int __init smsc47m1_find(unsigned short *addr)
358{
359 if (!(adapter->class & I2C_CLASS_HWMON))
360 return 0;
361 return i2c_detect(adapter, &addr_data, smsc47m1_detect);
362}
363
364static int smsc47m1_find(int *address)
365{ 348{
366 u8 val; 349 u8 val;
367 350
@@ -388,10 +371,10 @@ static int smsc47m1_find(int *address)
388 } 371 }
389 372
390 superio_select(); 373 superio_select();
391 *address = (superio_inb(SUPERIO_REG_BASE) << 8) 374 *addr = (superio_inb(SUPERIO_REG_BASE) << 8)
392 | superio_inb(SUPERIO_REG_BASE + 1); 375 | superio_inb(SUPERIO_REG_BASE + 1);
393 val = superio_inb(SUPERIO_REG_ACT); 376 val = superio_inb(SUPERIO_REG_ACT);
394 if (*address == 0 || (val & 0x01) == 0) { 377 if (*addr == 0 || (val & 0x01) == 0) {
395 printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n"); 378 printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n");
396 superio_exit(); 379 superio_exit();
397 return -ENODEV; 380 return -ENODEV;
@@ -401,17 +384,13 @@ static int smsc47m1_find(int *address)
401 return 0; 384 return 0;
402} 385}
403 386
404static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) 387static int smsc47m1_detect(struct i2c_adapter *adapter)
405{ 388{
406 struct i2c_client *new_client; 389 struct i2c_client *new_client;
407 struct smsc47m1_data *data; 390 struct smsc47m1_data *data;
408 int err = 0; 391 int err = 0;
409 int fan1, fan2, pwm1, pwm2; 392 int fan1, fan2, pwm1, pwm2;
410 393
411 if (!i2c_is_isa_adapter(adapter)) {
412 return 0;
413 }
414
415 if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { 394 if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) {
416 dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); 395 dev_err(&adapter->dev, "Region 0x%x already in use!\n", address);
417 return -EBUSY; 396 return -EBUSY;
@@ -461,6 +440,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
461 function. */ 440 function. */
462 smsc47m1_update_device(&new_client->dev, 1); 441 smsc47m1_update_device(&new_client->dev, 1);
463 442
443 /* Register sysfs hooks */
444 data->class_dev = hwmon_device_register(&new_client->dev);
445 if (IS_ERR(data->class_dev)) {
446 err = PTR_ERR(data->class_dev);
447 goto error_detach;
448 }
449
464 if (fan1) { 450 if (fan1) {
465 device_create_file(&new_client->dev, &dev_attr_fan1_input); 451 device_create_file(&new_client->dev, &dev_attr_fan1_input);
466 device_create_file(&new_client->dev, &dev_attr_fan1_min); 452 device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -494,6 +480,8 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
494 480
495 return 0; 481 return 0;
496 482
483error_detach:
484 i2c_detach_client(new_client);
497error_free: 485error_free:
498 kfree(data); 486 kfree(data);
499error_release: 487error_release:
@@ -503,16 +491,16 @@ error_release:
503 491
504static int smsc47m1_detach_client(struct i2c_client *client) 492static int smsc47m1_detach_client(struct i2c_client *client)
505{ 493{
494 struct smsc47m1_data *data = i2c_get_clientdata(client);
506 int err; 495 int err;
507 496
508 if ((err = i2c_detach_client(client))) { 497 hwmon_device_unregister(data->class_dev);
509 dev_err(&client->dev, "Client deregistration failed, " 498
510 "client not detached.\n"); 499 if ((err = i2c_detach_client(client)))
511 return err; 500 return err;
512 }
513 501
514 release_region(client->addr, SMSC_EXTENT); 502 release_region(client->addr, SMSC_EXTENT);
515 kfree(i2c_get_clientdata(client)); 503 kfree(data);
516 504
517 return 0; 505 return 0;
518} 506}
@@ -573,16 +561,16 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
573 561
574static int __init sm_smsc47m1_init(void) 562static int __init sm_smsc47m1_init(void)
575{ 563{
576 if (smsc47m1_find(normal_isa)) { 564 if (smsc47m1_find(&address)) {
577 return -ENODEV; 565 return -ENODEV;
578 } 566 }
579 567
580 return i2c_add_driver(&smsc47m1_driver); 568 return i2c_isa_add_driver(&smsc47m1_driver);
581} 569}
582 570
583static void __exit sm_smsc47m1_exit(void) 571static void __exit sm_smsc47m1_exit(void)
584{ 572{
585 i2c_del_driver(&smsc47m1_driver); 573 i2c_isa_del_driver(&smsc47m1_driver);
586} 574}
587 575
588MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>"); 576MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>");
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 164d47948390..eb84997627c8 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -35,7 +35,9 @@
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/jiffies.h> 36#include <linux/jiffies.h>
37#include <linux/i2c.h> 37#include <linux/i2c.h>
38#include <linux/i2c-sensor.h> 38#include <linux/i2c-isa.h>
39#include <linux/hwmon.h>
40#include <linux/err.h>
39#include <linux/init.h> 41#include <linux/init.h>
40#include <asm/io.h> 42#include <asm/io.h>
41 43
@@ -47,14 +49,10 @@ module_param(force_addr, ushort, 0);
47MODULE_PARM_DESC(force_addr, 49MODULE_PARM_DESC(force_addr,
48 "Initialize the base address of the sensors"); 50 "Initialize the base address of the sensors");
49 51
50/* Addresses to scan. 52/* Device address
51 Note that we can't determine the ISA address until we have initialized 53 Note that we can't determine the ISA address until we have initialized
52 our module */ 54 our module */
53static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 55static unsigned short address;
54static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
55
56/* Insmod parameters */
57SENSORS_INSMOD_1(via686a);
58 56
59/* 57/*
60 The Via 686a southbridge has a LM78-like chip integrated on the same IC. 58 The Via 686a southbridge has a LM78-like chip integrated on the same IC.
@@ -297,6 +295,7 @@ static inline long TEMP_FROM_REG10(u16 val)
297 via686a client is allocated. */ 295 via686a client is allocated. */
298struct via686a_data { 296struct via686a_data {
299 struct i2c_client client; 297 struct i2c_client client;
298 struct class_device *class_dev;
300 struct semaphore update_lock; 299 struct semaphore update_lock;
301 char valid; /* !=0 if following fields are valid */ 300 char valid; /* !=0 if following fields are valid */
302 unsigned long last_updated; /* In jiffies */ 301 unsigned long last_updated; /* In jiffies */
@@ -315,8 +314,7 @@ struct via686a_data {
315 314
316static struct pci_dev *s_bridge; /* pointer to the (only) via686a */ 315static struct pci_dev *s_bridge; /* pointer to the (only) via686a */
317 316
318static int via686a_attach_adapter(struct i2c_adapter *adapter); 317static int via686a_detect(struct i2c_adapter *adapter);
319static int via686a_detect(struct i2c_adapter *adapter, int address, int kind);
320static int via686a_detach_client(struct i2c_client *client); 318static int via686a_detach_client(struct i2c_client *client);
321 319
322static inline int via686a_read_value(struct i2c_client *client, u8 reg) 320static inline int via686a_read_value(struct i2c_client *client, u8 reg)
@@ -576,22 +574,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
576static struct i2c_driver via686a_driver = { 574static struct i2c_driver via686a_driver = {
577 .owner = THIS_MODULE, 575 .owner = THIS_MODULE,
578 .name = "via686a", 576 .name = "via686a",
579 .id = I2C_DRIVERID_VIA686A, 577 .attach_adapter = via686a_detect,
580 .flags = I2C_DF_NOTIFY,
581 .attach_adapter = via686a_attach_adapter,
582 .detach_client = via686a_detach_client, 578 .detach_client = via686a_detach_client,
583}; 579};
584 580
585 581
586/* This is called when the module is loaded */ 582/* This is called when the module is loaded */
587static int via686a_attach_adapter(struct i2c_adapter *adapter) 583static int via686a_detect(struct i2c_adapter *adapter)
588{
589 if (!(adapter->class & I2C_CLASS_HWMON))
590 return 0;
591 return i2c_detect(adapter, &addr_data, via686a_detect);
592}
593
594static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
595{ 584{
596 struct i2c_client *new_client; 585 struct i2c_client *new_client;
597 struct via686a_data *data; 586 struct via686a_data *data;
@@ -599,13 +588,6 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
599 const char client_name[] = "via686a"; 588 const char client_name[] = "via686a";
600 u16 val; 589 u16 val;
601 590
602 /* Make sure we are probing the ISA bus!! */
603 if (!i2c_is_isa_adapter(adapter)) {
604 dev_err(&adapter->dev,
605 "via686a_detect called for an I2C bus adapter?!?\n");
606 return 0;
607 }
608
609 /* 8231 requires multiple of 256, we enforce that on 686 as well */ 591 /* 8231 requires multiple of 256, we enforce that on 686 as well */
610 if (force_addr) 592 if (force_addr)
611 address = force_addr & 0xFF00; 593 address = force_addr & 0xFF00;
@@ -637,7 +619,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
637 619
638 if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { 620 if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) {
639 err = -ENOMEM; 621 err = -ENOMEM;
640 goto ERROR0; 622 goto exit_release;
641 } 623 }
642 memset(data, 0, sizeof(struct via686a_data)); 624 memset(data, 0, sizeof(struct via686a_data));
643 625
@@ -655,12 +637,18 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
655 init_MUTEX(&data->update_lock); 637 init_MUTEX(&data->update_lock);
656 /* Tell the I2C layer a new client has arrived */ 638 /* Tell the I2C layer a new client has arrived */
657 if ((err = i2c_attach_client(new_client))) 639 if ((err = i2c_attach_client(new_client)))
658 goto ERROR3; 640 goto exit_free;
659 641
660 /* Initialize the VIA686A chip */ 642 /* Initialize the VIA686A chip */
661 via686a_init_client(new_client); 643 via686a_init_client(new_client);
662 644
663 /* Register sysfs hooks */ 645 /* Register sysfs hooks */
646 data->class_dev = hwmon_device_register(&new_client->dev);
647 if (IS_ERR(data->class_dev)) {
648 err = PTR_ERR(data->class_dev);
649 goto exit_detach;
650 }
651
664 device_create_file(&new_client->dev, &dev_attr_in0_input); 652 device_create_file(&new_client->dev, &dev_attr_in0_input);
665 device_create_file(&new_client->dev, &dev_attr_in1_input); 653 device_create_file(&new_client->dev, &dev_attr_in1_input);
666 device_create_file(&new_client->dev, &dev_attr_in2_input); 654 device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -695,25 +683,27 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
695 683
696 return 0; 684 return 0;
697 685
698ERROR3: 686exit_detach:
687 i2c_detach_client(new_client);
688exit_free:
699 kfree(data); 689 kfree(data);
700ERROR0: 690exit_release:
701 release_region(address, VIA686A_EXTENT); 691 release_region(address, VIA686A_EXTENT);
702 return err; 692 return err;
703} 693}
704 694
705static int via686a_detach_client(struct i2c_client *client) 695static int via686a_detach_client(struct i2c_client *client)
706{ 696{
697 struct via686a_data *data = i2c_get_clientdata(client);
707 int err; 698 int err;
708 699
709 if ((err = i2c_detach_client(client))) { 700 hwmon_device_unregister(data->class_dev);
710 dev_err(&client->dev, 701
711 "Client deregistration failed, client not detached.\n"); 702 if ((err = i2c_detach_client(client)))
712 return err; 703 return err;
713 }
714 704
715 release_region(client->addr, VIA686A_EXTENT); 705 release_region(client->addr, VIA686A_EXTENT);
716 kfree(i2c_get_clientdata(client)); 706 kfree(data);
717 707
718 return 0; 708 return 0;
719} 709}
@@ -810,29 +800,25 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
810 const struct pci_device_id *id) 800 const struct pci_device_id *id)
811{ 801{
812 u16 val; 802 u16 val;
813 int addr = 0;
814 803
815 if (PCIBIOS_SUCCESSFUL != 804 if (PCIBIOS_SUCCESSFUL !=
816 pci_read_config_word(dev, VIA686A_BASE_REG, &val)) 805 pci_read_config_word(dev, VIA686A_BASE_REG, &val))
817 return -ENODEV; 806 return -ENODEV;
818 807
819 addr = val & ~(VIA686A_EXTENT - 1); 808 address = val & ~(VIA686A_EXTENT - 1);
820 if (addr == 0 && force_addr == 0) { 809 if (address == 0 && force_addr == 0) {
821 dev_err(&dev->dev, "base address not set - upgrade BIOS " 810 dev_err(&dev->dev, "base address not set - upgrade BIOS "
822 "or use force_addr=0xaddr\n"); 811 "or use force_addr=0xaddr\n");
823 return -ENODEV; 812 return -ENODEV;
824 } 813 }
825 if (force_addr)
826 addr = force_addr; /* so detect will get called */
827 814
828 if (!addr) { 815 if (!address) {
829 dev_err(&dev->dev, "No Via 686A sensors found.\n"); 816 dev_err(&dev->dev, "No Via 686A sensors found.\n");
830 return -ENODEV; 817 return -ENODEV;
831 } 818 }
832 normal_isa[0] = addr;
833 819
834 s_bridge = pci_dev_get(dev); 820 s_bridge = pci_dev_get(dev);
835 if (i2c_add_driver(&via686a_driver)) { 821 if (i2c_isa_add_driver(&via686a_driver)) {
836 pci_dev_put(s_bridge); 822 pci_dev_put(s_bridge);
837 s_bridge = NULL; 823 s_bridge = NULL;
838 } 824 }
@@ -859,7 +845,7 @@ static void __exit sm_via686a_exit(void)
859{ 845{
860 pci_unregister_driver(&via686a_pci_driver); 846 pci_unregister_driver(&via686a_pci_driver);
861 if (s_bridge != NULL) { 847 if (s_bridge != NULL) {
862 i2c_del_driver(&via686a_driver); 848 i2c_isa_del_driver(&via686a_driver);
863 pci_dev_put(s_bridge); 849 pci_dev_put(s_bridge);
864 s_bridge = NULL; 850 s_bridge = NULL;
865 } 851 }
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 8a40b6976e1a..b60efe8f8b26 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -9,6 +9,9 @@
9 Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help 9 Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help
10 in testing and debugging this driver. 10 in testing and debugging this driver.
11 11
12 This driver also supports the W83627EHG, which is the lead-free
13 version of the W83627EHF.
14
12 This program is free software; you can redistribute it and/or modify 15 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 16 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or 17 the Free Software Foundation; either version 2 of the License, or
@@ -37,17 +40,14 @@
37#include <linux/init.h> 40#include <linux/init.h>
38#include <linux/slab.h> 41#include <linux/slab.h>
39#include <linux/i2c.h> 42#include <linux/i2c.h>
40#include <linux/i2c-sensor.h> 43#include <linux/i2c-isa.h>
44#include <linux/hwmon.h>
45#include <linux/err.h>
41#include <asm/io.h> 46#include <asm/io.h>
42#include "lm75.h" 47#include "lm75.h"
43 48
44/* Addresses to scan 49/* The actual ISA address is read from Super-I/O configuration space */
45 The actual ISA address is read from Super-I/O configuration space */ 50static unsigned short address;
46static unsigned short normal_i2c[] = { I2C_CLIENT_END };
47static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
48
49/* Insmod parameters */
50SENSORS_INSMOD_1(w83627ehf);
51 51
52/* 52/*
53 * Super-I/O constants and functions 53 * Super-I/O constants and functions
@@ -174,6 +174,7 @@ temp1_to_reg(int temp)
174 174
175struct w83627ehf_data { 175struct w83627ehf_data {
176 struct i2c_client client; 176 struct i2c_client client;
177 struct class_device *class_dev;
177 struct semaphore lock; 178 struct semaphore lock;
178 179
179 struct semaphore update_lock; 180 struct semaphore update_lock;
@@ -666,15 +667,12 @@ static void w83627ehf_init_client(struct i2c_client *client)
666 } 667 }
667} 668}
668 669
669static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) 670static int w83627ehf_detect(struct i2c_adapter *adapter)
670{ 671{
671 struct i2c_client *client; 672 struct i2c_client *client;
672 struct w83627ehf_data *data; 673 struct w83627ehf_data *data;
673 int i, err = 0; 674 int i, err = 0;
674 675
675 if (!i2c_is_isa_adapter(adapter))
676 return 0;
677
678 if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { 676 if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) {
679 err = -EBUSY; 677 err = -EBUSY;
680 goto exit; 678 goto exit;
@@ -720,6 +718,12 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
720 data->has_fan |= (1 << 4); 718 data->has_fan |= (1 << 4);
721 719
722 /* Register sysfs hooks */ 720 /* Register sysfs hooks */
721 data->class_dev = hwmon_device_register(&client->dev);
722 if (IS_ERR(data->class_dev)) {
723 err = PTR_ERR(data->class_dev);
724 goto exit_detach;
725 }
726
723 device_create_file(&client->dev, &dev_attr_fan1_input); 727 device_create_file(&client->dev, &dev_attr_fan1_input);
724 device_create_file(&client->dev, &dev_attr_fan1_min); 728 device_create_file(&client->dev, &dev_attr_fan1_min);
725 device_create_file(&client->dev, &dev_attr_fan1_div); 729 device_create_file(&client->dev, &dev_attr_fan1_div);
@@ -753,6 +757,8 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
753 757
754 return 0; 758 return 0;
755 759
760exit_detach:
761 i2c_detach_client(client);
756exit_free: 762exit_free:
757 kfree(data); 763 kfree(data);
758exit_release: 764exit_release:
@@ -761,24 +767,17 @@ exit:
761 return err; 767 return err;
762} 768}
763 769
764static int w83627ehf_attach_adapter(struct i2c_adapter *adapter)
765{
766 if (!(adapter->class & I2C_CLASS_HWMON))
767 return 0;
768 return i2c_detect(adapter, &addr_data, w83627ehf_detect);
769}
770
771static int w83627ehf_detach_client(struct i2c_client *client) 770static int w83627ehf_detach_client(struct i2c_client *client)
772{ 771{
772 struct w83627ehf_data *data = i2c_get_clientdata(client);
773 int err; 773 int err;
774 774
775 if ((err = i2c_detach_client(client))) { 775 hwmon_device_unregister(data->class_dev);
776 dev_err(&client->dev, "Client deregistration failed, " 776
777 "client not detached.\n"); 777 if ((err = i2c_detach_client(client)))
778 return err; 778 return err;
779 }
780 release_region(client->addr, REGION_LENGTH); 779 release_region(client->addr, REGION_LENGTH);
781 kfree(i2c_get_clientdata(client)); 780 kfree(data);
782 781
783 return 0; 782 return 0;
784} 783}
@@ -786,12 +785,11 @@ static int w83627ehf_detach_client(struct i2c_client *client)
786static struct i2c_driver w83627ehf_driver = { 785static struct i2c_driver w83627ehf_driver = {
787 .owner = THIS_MODULE, 786 .owner = THIS_MODULE,
788 .name = "w83627ehf", 787 .name = "w83627ehf",
789 .flags = I2C_DF_NOTIFY, 788 .attach_adapter = w83627ehf_detect,
790 .attach_adapter = w83627ehf_attach_adapter,
791 .detach_client = w83627ehf_detach_client, 789 .detach_client = w83627ehf_detach_client,
792}; 790};
793 791
794static int __init w83627ehf_find(int sioaddr, int *address) 792static int __init w83627ehf_find(int sioaddr, unsigned short *addr)
795{ 793{
796 u16 val; 794 u16 val;
797 795
@@ -809,8 +807,8 @@ static int __init w83627ehf_find(int sioaddr, int *address)
809 superio_select(W83627EHF_LD_HWM); 807 superio_select(W83627EHF_LD_HWM);
810 val = (superio_inb(SIO_REG_ADDR) << 8) 808 val = (superio_inb(SIO_REG_ADDR) << 8)
811 | superio_inb(SIO_REG_ADDR + 1); 809 | superio_inb(SIO_REG_ADDR + 1);
812 *address = val & ~(REGION_LENGTH - 1); 810 *addr = val & ~(REGION_LENGTH - 1);
813 if (*address == 0) { 811 if (*addr == 0) {
814 superio_exit(); 812 superio_exit();
815 return -ENODEV; 813 return -ENODEV;
816 } 814 }
@@ -826,16 +824,16 @@ static int __init w83627ehf_find(int sioaddr, int *address)
826 824
827static int __init sensors_w83627ehf_init(void) 825static int __init sensors_w83627ehf_init(void)
828{ 826{
829 if (w83627ehf_find(0x2e, &normal_isa[0]) 827 if (w83627ehf_find(0x2e, &address)
830 && w83627ehf_find(0x4e, &normal_isa[0])) 828 && w83627ehf_find(0x4e, &address))
831 return -ENODEV; 829 return -ENODEV;
832 830
833 return i2c_add_driver(&w83627ehf_driver); 831 return i2c_isa_add_driver(&w83627ehf_driver);
834} 832}
835 833
836static void __exit sensors_w83627ehf_exit(void) 834static void __exit sensors_w83627ehf_exit(void)
837{ 835{
838 i2c_del_driver(&w83627ehf_driver); 836 i2c_isa_del_driver(&w83627ehf_driver);
839} 837}
840 838
841MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); 839MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index bd87a42e068a..02bd5c0239a2 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -42,8 +42,10 @@
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/jiffies.h> 43#include <linux/jiffies.h>
44#include <linux/i2c.h> 44#include <linux/i2c.h>
45#include <linux/i2c-sensor.h> 45#include <linux/i2c-isa.h>
46#include <linux/i2c-vid.h> 46#include <linux/hwmon.h>
47#include <linux/hwmon-vid.h>
48#include <linux/err.h>
47#include <asm/io.h> 49#include <asm/io.h>
48#include "lm75.h" 50#include "lm75.h"
49 51
@@ -56,12 +58,11 @@ module_param(force_i2c, byte, 0);
56MODULE_PARM_DESC(force_i2c, 58MODULE_PARM_DESC(force_i2c,
57 "Initialize the i2c address of the sensors"); 59 "Initialize the i2c address of the sensors");
58 60
59/* Addresses to scan */ 61/* The actual ISA address is read from Super-I/O configuration space */
60static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 62static unsigned short address;
61static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
62 63
63/* Insmod parameters */ 64/* Insmod parameters */
64SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf); 65enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf };
65 66
66static int init = 1; 67static int init = 1;
67module_param(init, bool, 0); 68module_param(init, bool, 0);
@@ -277,6 +278,7 @@ static inline u8 DIV_TO_REG(long val)
277 dynamically allocated, at the same time when a new client is allocated. */ 278 dynamically allocated, at the same time when a new client is allocated. */
278struct w83627hf_data { 279struct w83627hf_data {
279 struct i2c_client client; 280 struct i2c_client client;
281 struct class_device *class_dev;
280 struct semaphore lock; 282 struct semaphore lock;
281 enum chips type; 283 enum chips type;
282 284
@@ -314,9 +316,7 @@ struct w83627hf_data {
314}; 316};
315 317
316 318
317static int w83627hf_attach_adapter(struct i2c_adapter *adapter); 319static int w83627hf_detect(struct i2c_adapter *adapter);
318static int w83627hf_detect(struct i2c_adapter *adapter, int address,
319 int kind);
320static int w83627hf_detach_client(struct i2c_client *client); 320static int w83627hf_detach_client(struct i2c_client *client);
321 321
322static int w83627hf_read_value(struct i2c_client *client, u16 register); 322static int w83627hf_read_value(struct i2c_client *client, u16 register);
@@ -328,9 +328,7 @@ static void w83627hf_init_client(struct i2c_client *client);
328static struct i2c_driver w83627hf_driver = { 328static struct i2c_driver w83627hf_driver = {
329 .owner = THIS_MODULE, 329 .owner = THIS_MODULE,
330 .name = "w83627hf", 330 .name = "w83627hf",
331 .id = I2C_DRIVERID_W83627HF, 331 .attach_adapter = w83627hf_detect,
332 .flags = I2C_DF_NOTIFY,
333 .attach_adapter = w83627hf_attach_adapter,
334 .detach_client = w83627hf_detach_client, 332 .detach_client = w83627hf_detach_client,
335}; 333};
336 334
@@ -959,16 +957,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
959} while (0) 957} while (0)
960 958
961 959
962/* This function is called when: 960static int __init w83627hf_find(int sioaddr, unsigned short *addr)
963 * w83627hf_driver is inserted (when this module is loaded), for each
964 available adapter
965 * when a new adapter is inserted (and w83627hf_driver is still present) */
966static int w83627hf_attach_adapter(struct i2c_adapter *adapter)
967{
968 return i2c_detect(adapter, &addr_data, w83627hf_detect);
969}
970
971static int w83627hf_find(int sioaddr, int *address)
972{ 961{
973 u16 val; 962 u16 val;
974 963
@@ -988,32 +977,24 @@ static int w83627hf_find(int sioaddr, int *address)
988 superio_select(W83627HF_LD_HWM); 977 superio_select(W83627HF_LD_HWM);
989 val = (superio_inb(WINB_BASE_REG) << 8) | 978 val = (superio_inb(WINB_BASE_REG) << 8) |
990 superio_inb(WINB_BASE_REG + 1); 979 superio_inb(WINB_BASE_REG + 1);
991 *address = val & ~(WINB_EXTENT - 1); 980 *addr = val & ~(WINB_EXTENT - 1);
992 if (*address == 0 && force_addr == 0) { 981 if (*addr == 0 && force_addr == 0) {
993 superio_exit(); 982 superio_exit();
994 return -ENODEV; 983 return -ENODEV;
995 } 984 }
996 if (force_addr)
997 *address = force_addr; /* so detect will get called */
998 985
999 superio_exit(); 986 superio_exit();
1000 return 0; 987 return 0;
1001} 988}
1002 989
1003int w83627hf_detect(struct i2c_adapter *adapter, int address, 990static int w83627hf_detect(struct i2c_adapter *adapter)
1004 int kind)
1005{ 991{
1006 int val; 992 int val, kind;
1007 struct i2c_client *new_client; 993 struct i2c_client *new_client;
1008 struct w83627hf_data *data; 994 struct w83627hf_data *data;
1009 int err = 0; 995 int err = 0;
1010 const char *client_name = ""; 996 const char *client_name = "";
1011 997
1012 if (!i2c_is_isa_adapter(adapter)) {
1013 err = -ENODEV;
1014 goto ERROR0;
1015 }
1016
1017 if(force_addr) 998 if(force_addr)
1018 address = force_addr & ~(WINB_EXTENT - 1); 999 address = force_addr & ~(WINB_EXTENT - 1);
1019 1000
@@ -1102,6 +1083,12 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
1102 data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3)); 1083 data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3));
1103 1084
1104 /* Register sysfs hooks */ 1085 /* Register sysfs hooks */
1086 data->class_dev = hwmon_device_register(&new_client->dev);
1087 if (IS_ERR(data->class_dev)) {
1088 err = PTR_ERR(data->class_dev);
1089 goto ERROR3;
1090 }
1091
1105 device_create_file_in(new_client, 0); 1092 device_create_file_in(new_client, 0);
1106 if (kind != w83697hf) 1093 if (kind != w83697hf)
1107 device_create_file_in(new_client, 1); 1094 device_create_file_in(new_client, 1);
@@ -1152,6 +1139,8 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
1152 1139
1153 return 0; 1140 return 0;
1154 1141
1142 ERROR3:
1143 i2c_detach_client(new_client);
1155 ERROR2: 1144 ERROR2:
1156 kfree(data); 1145 kfree(data);
1157 ERROR1: 1146 ERROR1:
@@ -1162,16 +1151,16 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
1162 1151
1163static int w83627hf_detach_client(struct i2c_client *client) 1152static int w83627hf_detach_client(struct i2c_client *client)
1164{ 1153{
1154 struct w83627hf_data *data = i2c_get_clientdata(client);
1165 int err; 1155 int err;
1166 1156
1167 if ((err = i2c_detach_client(client))) { 1157 hwmon_device_unregister(data->class_dev);
1168 dev_err(&client->dev, 1158
1169 "Client deregistration failed, client not detached.\n"); 1159 if ((err = i2c_detach_client(client)))
1170 return err; 1160 return err;
1171 }
1172 1161
1173 release_region(client->addr, WINB_EXTENT); 1162 release_region(client->addr, WINB_EXTENT);
1174 kfree(i2c_get_clientdata(client)); 1163 kfree(data);
1175 1164
1176 return 0; 1165 return 0;
1177} 1166}
@@ -1327,7 +1316,7 @@ static void w83627hf_init_client(struct i2c_client *client)
1327 data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82; 1316 data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82;
1328 } else { 1317 } else {
1329 /* Convert VID to voltage based on default VRM */ 1318 /* Convert VID to voltage based on default VRM */
1330 data->vrm = i2c_which_vrm(); 1319 data->vrm = vid_which_vrm();
1331 } 1320 }
1332 1321
1333 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1); 1322 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
@@ -1485,20 +1474,17 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1485 1474
1486static int __init sensors_w83627hf_init(void) 1475static int __init sensors_w83627hf_init(void)
1487{ 1476{
1488 int addr; 1477 if (w83627hf_find(0x2e, &address)
1489 1478 && w83627hf_find(0x4e, &address)) {
1490 if (w83627hf_find(0x2e, &addr)
1491 && w83627hf_find(0x4e, &addr)) {
1492 return -ENODEV; 1479 return -ENODEV;
1493 } 1480 }
1494 normal_isa[0] = addr;
1495 1481
1496 return i2c_add_driver(&w83627hf_driver); 1482 return i2c_isa_add_driver(&w83627hf_driver);
1497} 1483}
1498 1484
1499static void __exit sensors_w83627hf_exit(void) 1485static void __exit sensors_w83627hf_exit(void)
1500{ 1486{
1501 i2c_del_driver(&w83627hf_driver); 1487 i2c_isa_del_driver(&w83627hf_driver);
1502} 1488}
1503 1489
1504MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, " 1490MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 0bb131ce09eb..4c43337ca780 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -38,8 +38,10 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/jiffies.h> 39#include <linux/jiffies.h>
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/i2c-sensor.h> 41#include <linux/i2c-isa.h>
42#include <linux/i2c-vid.h> 42#include <linux/hwmon.h>
43#include <linux/hwmon-vid.h>
44#include <linux/err.h>
43#include <asm/io.h> 45#include <asm/io.h>
44#include "lm75.h" 46#include "lm75.h"
45 47
@@ -47,10 +49,10 @@
47static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 49static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
48 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 50 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
49 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; 51 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
50static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; 52static unsigned short isa_address = 0x290;
51 53
52/* Insmod parameters */ 54/* Insmod parameters */
53SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); 55I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
54I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 56I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
55 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 57 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
56 58
@@ -218,6 +220,7 @@ DIV_TO_REG(long val, enum chips type)
218 allocated. */ 220 allocated. */
219struct w83781d_data { 221struct w83781d_data {
220 struct i2c_client client; 222 struct i2c_client client;
223 struct class_device *class_dev;
221 struct semaphore lock; 224 struct semaphore lock;
222 enum chips type; 225 enum chips type;
223 226
@@ -255,6 +258,7 @@ struct w83781d_data {
255}; 258};
256 259
257static int w83781d_attach_adapter(struct i2c_adapter *adapter); 260static int w83781d_attach_adapter(struct i2c_adapter *adapter);
261static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter);
258static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); 262static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind);
259static int w83781d_detach_client(struct i2c_client *client); 263static int w83781d_detach_client(struct i2c_client *client);
260 264
@@ -273,6 +277,14 @@ static struct i2c_driver w83781d_driver = {
273 .detach_client = w83781d_detach_client, 277 .detach_client = w83781d_detach_client,
274}; 278};
275 279
280static struct i2c_driver w83781d_isa_driver = {
281 .owner = THIS_MODULE,
282 .name = "w83781d-isa",
283 .attach_adapter = w83781d_isa_attach_adapter,
284 .detach_client = w83781d_detach_client,
285};
286
287
276/* following are the sysfs callback functions */ 288/* following are the sysfs callback functions */
277#define show_in_reg(reg) \ 289#define show_in_reg(reg) \
278static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ 290static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
@@ -856,7 +868,13 @@ w83781d_attach_adapter(struct i2c_adapter *adapter)
856{ 868{
857 if (!(adapter->class & I2C_CLASS_HWMON)) 869 if (!(adapter->class & I2C_CLASS_HWMON))
858 return 0; 870 return 0;
859 return i2c_detect(adapter, &addr_data, w83781d_detect); 871 return i2c_probe(adapter, &addr_data, w83781d_detect);
872}
873
874static int
875w83781d_isa_attach_adapter(struct i2c_adapter *adapter)
876{
877 return w83781d_detect(adapter, isa_address, -1);
860} 878}
861 879
862/* Assumes that adapter is of I2C, not ISA variety. 880/* Assumes that adapter is of I2C, not ISA variety.
@@ -961,10 +979,10 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
961ERROR_SC_3: 979ERROR_SC_3:
962 i2c_detach_client(data->lm75[0]); 980 i2c_detach_client(data->lm75[0]);
963ERROR_SC_2: 981ERROR_SC_2:
964 if (NULL != data->lm75[1]) 982 if (data->lm75[1])
965 kfree(data->lm75[1]); 983 kfree(data->lm75[1]);
966ERROR_SC_1: 984ERROR_SC_1:
967 if (NULL != data->lm75[0]) 985 if (data->lm75[0])
968 kfree(data->lm75[0]); 986 kfree(data->lm75[0]);
969ERROR_SC_0: 987ERROR_SC_0:
970 return err; 988 return err;
@@ -999,7 +1017,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
999 1017
1000 if (is_isa) 1018 if (is_isa)
1001 if (!request_region(address, W83781D_EXTENT, 1019 if (!request_region(address, W83781D_EXTENT,
1002 w83781d_driver.name)) { 1020 w83781d_isa_driver.name)) {
1003 dev_dbg(&adapter->dev, "Request of region " 1021 dev_dbg(&adapter->dev, "Request of region "
1004 "0x%x-0x%x for w83781d failed\n", address, 1022 "0x%x-0x%x for w83781d failed\n", address,
1005 address + W83781D_EXTENT - 1); 1023 address + W83781D_EXTENT - 1);
@@ -1057,7 +1075,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1057 new_client->addr = address; 1075 new_client->addr = address;
1058 init_MUTEX(&data->lock); 1076 init_MUTEX(&data->lock);
1059 new_client->adapter = adapter; 1077 new_client->adapter = adapter;
1060 new_client->driver = &w83781d_driver; 1078 new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver;
1061 new_client->flags = 0; 1079 new_client->flags = 0;
1062 1080
1063 /* Now, we do the remaining detection. */ 1081 /* Now, we do the remaining detection. */
@@ -1189,6 +1207,12 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1189 data->pwmenable[i] = 1; 1207 data->pwmenable[i] = 1;
1190 1208
1191 /* Register sysfs hooks */ 1209 /* Register sysfs hooks */
1210 data->class_dev = hwmon_device_register(&new_client->dev);
1211 if (IS_ERR(data->class_dev)) {
1212 err = PTR_ERR(data->class_dev);
1213 goto ERROR4;
1214 }
1215
1192 device_create_file_in(new_client, 0); 1216 device_create_file_in(new_client, 0);
1193 if (kind != w83783s) 1217 if (kind != w83783s)
1194 device_create_file_in(new_client, 1); 1218 device_create_file_in(new_client, 1);
@@ -1241,6 +1265,15 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1241 1265
1242 return 0; 1266 return 0;
1243 1267
1268ERROR4:
1269 if (data->lm75[1]) {
1270 i2c_detach_client(data->lm75[1]);
1271 kfree(data->lm75[1]);
1272 }
1273 if (data->lm75[0]) {
1274 i2c_detach_client(data->lm75[0]);
1275 kfree(data->lm75[0]);
1276 }
1244ERROR3: 1277ERROR3:
1245 i2c_detach_client(new_client); 1278 i2c_detach_client(new_client);
1246ERROR2: 1279ERROR2:
@@ -1255,24 +1288,26 @@ ERROR0:
1255static int 1288static int
1256w83781d_detach_client(struct i2c_client *client) 1289w83781d_detach_client(struct i2c_client *client)
1257{ 1290{
1291 struct w83781d_data *data = i2c_get_clientdata(client);
1258 int err; 1292 int err;
1259 1293
1294 /* main client */
1295 if (data)
1296 hwmon_device_unregister(data->class_dev);
1297
1260 if (i2c_is_isa_client(client)) 1298 if (i2c_is_isa_client(client))
1261 release_region(client->addr, W83781D_EXTENT); 1299 release_region(client->addr, W83781D_EXTENT);
1262 1300
1263 if ((err = i2c_detach_client(client))) { 1301 if ((err = i2c_detach_client(client)))
1264 dev_err(&client->dev,
1265 "Client deregistration failed, client not detached.\n");
1266 return err; 1302 return err;
1267 }
1268 1303
1269 if (i2c_get_clientdata(client)==NULL) { 1304 /* main client */
1270 /* subclients */ 1305 if (data)
1306 kfree(data);
1307
1308 /* subclient */
1309 else
1271 kfree(client); 1310 kfree(client);
1272 } else {
1273 /* main client */
1274 kfree(i2c_get_clientdata(client));
1275 }
1276 1311
1277 return 0; 1312 return 0;
1278} 1313}
@@ -1443,7 +1478,7 @@ w83781d_init_client(struct i2c_client *client)
1443 w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0); 1478 w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0);
1444 } 1479 }
1445 1480
1446 data->vrm = i2c_which_vrm(); 1481 data->vrm = vid_which_vrm();
1447 1482
1448 if ((type != w83781d) && (type != as99127f)) { 1483 if ((type != w83781d) && (type != as99127f)) {
1449 tmp = w83781d_read_value(client, W83781D_REG_SCFG1); 1484 tmp = w83781d_read_value(client, W83781D_REG_SCFG1);
@@ -1613,12 +1648,25 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1613static int __init 1648static int __init
1614sensors_w83781d_init(void) 1649sensors_w83781d_init(void)
1615{ 1650{
1616 return i2c_add_driver(&w83781d_driver); 1651 int res;
1652
1653 res = i2c_add_driver(&w83781d_driver);
1654 if (res)
1655 return res;
1656
1657 res = i2c_isa_add_driver(&w83781d_isa_driver);
1658 if (res) {
1659 i2c_del_driver(&w83781d_driver);
1660 return res;
1661 }
1662
1663 return 0;
1617} 1664}
1618 1665
1619static void __exit 1666static void __exit
1620sensors_w83781d_exit(void) 1667sensors_w83781d_exit(void)
1621{ 1668{
1669 i2c_isa_del_driver(&w83781d_isa_driver);
1622 i2c_del_driver(&w83781d_driver); 1670 i2c_del_driver(&w83781d_driver);
1623} 1671}
1624 1672
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
new file mode 100644
index 000000000000..ba0c28015f6a
--- /dev/null
+++ b/drivers/hwmon/w83792d.c
@@ -0,0 +1,1649 @@
1/*
2 w83792d.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (C) 2004, 2005 Winbond Electronics Corp.
5 Chunhao Huang <DZShen@Winbond.com.tw>,
6 Rudolf Marek <r.marek@sh.cvut.cz>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 Note:
23 1. This driver is only for 2.6 kernel, 2.4 kernel need a different driver.
24 2. This driver is only for Winbond W83792D C version device, there
25 are also some motherboards with B version W83792D device. The
26 calculation method to in6-in7(measured value, limits) is a little
27 different between C and B version. C or B version can be identified
28 by CR[0x49h].
29*/
30
31/*
32 Supports following chips:
33
34 Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
35 w83792d 9 7 7 3 0x7a 0x5ca3 yes no
36*/
37
38#include <linux/config.h>
39#include <linux/module.h>
40#include <linux/init.h>
41#include <linux/slab.h>
42#include <linux/i2c.h>
43#include <linux/hwmon.h>
44#include <linux/hwmon-sysfs.h>
45#include <linux/err.h>
46
47/* Addresses to scan */
48static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
49
50/* Insmod parameters */
51I2C_CLIENT_INSMOD_1(w83792d);
52I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
53 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
54
55static int init;
56module_param(init, bool, 0);
57MODULE_PARM_DESC(init, "Set to one to force chip initialization");
58
59/* The W83792D registers */
60static const u8 W83792D_REG_IN[9] = {
61 0x20, /* Vcore A in DataSheet */
62 0x21, /* Vcore B in DataSheet */
63 0x22, /* VIN0 in DataSheet */
64 0x23, /* VIN1 in DataSheet */
65 0x24, /* VIN2 in DataSheet */
66 0x25, /* VIN3 in DataSheet */
67 0x26, /* 5VCC in DataSheet */
68 0xB0, /* 5VSB in DataSheet */
69 0xB1 /* VBAT in DataSheet */
70};
71#define W83792D_REG_LOW_BITS1 0x3E /* Low Bits I in DataSheet */
72#define W83792D_REG_LOW_BITS2 0x3F /* Low Bits II in DataSheet */
73static const u8 W83792D_REG_IN_MAX[9] = {
74 0x2B, /* Vcore A High Limit in DataSheet */
75 0x2D, /* Vcore B High Limit in DataSheet */
76 0x2F, /* VIN0 High Limit in DataSheet */
77 0x31, /* VIN1 High Limit in DataSheet */
78 0x33, /* VIN2 High Limit in DataSheet */
79 0x35, /* VIN3 High Limit in DataSheet */
80 0x37, /* 5VCC High Limit in DataSheet */
81 0xB4, /* 5VSB High Limit in DataSheet */
82 0xB6 /* VBAT High Limit in DataSheet */
83};
84static const u8 W83792D_REG_IN_MIN[9] = {
85 0x2C, /* Vcore A Low Limit in DataSheet */
86 0x2E, /* Vcore B Low Limit in DataSheet */
87 0x30, /* VIN0 Low Limit in DataSheet */
88 0x32, /* VIN1 Low Limit in DataSheet */
89 0x34, /* VIN2 Low Limit in DataSheet */
90 0x36, /* VIN3 Low Limit in DataSheet */
91 0x38, /* 5VCC Low Limit in DataSheet */
92 0xB5, /* 5VSB Low Limit in DataSheet */
93 0xB7 /* VBAT Low Limit in DataSheet */
94};
95static const u8 W83792D_REG_FAN[7] = {
96 0x28, /* FAN 1 Count in DataSheet */
97 0x29, /* FAN 2 Count in DataSheet */
98 0x2A, /* FAN 3 Count in DataSheet */
99 0xB8, /* FAN 4 Count in DataSheet */
100 0xB9, /* FAN 5 Count in DataSheet */
101 0xBA, /* FAN 6 Count in DataSheet */
102 0xBE /* FAN 7 Count in DataSheet */
103};
104static const u8 W83792D_REG_FAN_MIN[7] = {
105 0x3B, /* FAN 1 Count Low Limit in DataSheet */
106 0x3C, /* FAN 2 Count Low Limit in DataSheet */
107 0x3D, /* FAN 3 Count Low Limit in DataSheet */
108 0xBB, /* FAN 4 Count Low Limit in DataSheet */
109 0xBC, /* FAN 5 Count Low Limit in DataSheet */
110 0xBD, /* FAN 6 Count Low Limit in DataSheet */
111 0xBF /* FAN 7 Count Low Limit in DataSheet */
112};
113#define W83792D_REG_FAN_CFG 0x84 /* FAN Configuration in DataSheet */
114static const u8 W83792D_REG_FAN_DIV[4] = {
115 0x47, /* contains FAN2 and FAN1 Divisor */
116 0x5B, /* contains FAN4 and FAN3 Divisor */
117 0x5C, /* contains FAN6 and FAN5 Divisor */
118 0x9E /* contains FAN7 Divisor. */
119};
120static const u8 W83792D_REG_PWM[7] = {
121 0x81, /* FAN 1 Duty Cycle, be used to control */
122 0x83, /* FAN 2 Duty Cycle, be used to control */
123 0x94, /* FAN 3 Duty Cycle, be used to control */
124 0xA3, /* FAN 4 Duty Cycle, be used to control */
125 0xA4, /* FAN 5 Duty Cycle, be used to control */
126 0xA5, /* FAN 6 Duty Cycle, be used to control */
127 0xA6 /* FAN 7 Duty Cycle, be used to control */
128};
129#define W83792D_REG_BANK 0x4E
130#define W83792D_REG_TEMP2_CONFIG 0xC2
131#define W83792D_REG_TEMP3_CONFIG 0xCA
132
133static const u8 W83792D_REG_TEMP1[3] = {
134 0x27, /* TEMP 1 in DataSheet */
135 0x39, /* TEMP 1 Over in DataSheet */
136 0x3A, /* TEMP 1 Hyst in DataSheet */
137};
138
139static const u8 W83792D_REG_TEMP_ADD[2][6] = {
140 { 0xC0, /* TEMP 2 in DataSheet */
141 0xC1, /* TEMP 2(0.5 deg) in DataSheet */
142 0xC5, /* TEMP 2 Over High part in DataSheet */
143 0xC6, /* TEMP 2 Over Low part in DataSheet */
144 0xC3, /* TEMP 2 Thyst High part in DataSheet */
145 0xC4 }, /* TEMP 2 Thyst Low part in DataSheet */
146 { 0xC8, /* TEMP 3 in DataSheet */
147 0xC9, /* TEMP 3(0.5 deg) in DataSheet */
148 0xCD, /* TEMP 3 Over High part in DataSheet */
149 0xCE, /* TEMP 3 Over Low part in DataSheet */
150 0xCB, /* TEMP 3 Thyst High part in DataSheet */
151 0xCC } /* TEMP 3 Thyst Low part in DataSheet */
152};
153
154static const u8 W83792D_REG_THERMAL[3] = {
155 0x85, /* SmartFanI: Fan1 target value */
156 0x86, /* SmartFanI: Fan2 target value */
157 0x96 /* SmartFanI: Fan3 target value */
158};
159
160static const u8 W83792D_REG_TOLERANCE[3] = {
161 0x87, /* (bit3-0)SmartFan Fan1 tolerance */
162 0x87, /* (bit7-4)SmartFan Fan2 tolerance */
163 0x97 /* (bit3-0)SmartFan Fan3 tolerance */
164};
165
166static const u8 W83792D_REG_POINTS[3][4] = {
167 { 0x85, /* SmartFanII: Fan1 temp point 1 */
168 0xE3, /* SmartFanII: Fan1 temp point 2 */
169 0xE4, /* SmartFanII: Fan1 temp point 3 */
170 0xE5 }, /* SmartFanII: Fan1 temp point 4 */
171 { 0x86, /* SmartFanII: Fan2 temp point 1 */
172 0xE6, /* SmartFanII: Fan2 temp point 2 */
173 0xE7, /* SmartFanII: Fan2 temp point 3 */
174 0xE8 }, /* SmartFanII: Fan2 temp point 4 */
175 { 0x96, /* SmartFanII: Fan3 temp point 1 */
176 0xE9, /* SmartFanII: Fan3 temp point 2 */
177 0xEA, /* SmartFanII: Fan3 temp point 3 */
178 0xEB } /* SmartFanII: Fan3 temp point 4 */
179};
180
181static const u8 W83792D_REG_LEVELS[3][4] = {
182 { 0x88, /* (bit3-0) SmartFanII: Fan1 Non-Stop */
183 0x88, /* (bit7-4) SmartFanII: Fan1 Level 1 */
184 0xE0, /* (bit7-4) SmartFanII: Fan1 Level 2 */
185 0xE0 }, /* (bit3-0) SmartFanII: Fan1 Level 3 */
186 { 0x89, /* (bit3-0) SmartFanII: Fan2 Non-Stop */
187 0x89, /* (bit7-4) SmartFanII: Fan2 Level 1 */
188 0xE1, /* (bit7-4) SmartFanII: Fan2 Level 2 */
189 0xE1 }, /* (bit3-0) SmartFanII: Fan2 Level 3 */
190 { 0x98, /* (bit3-0) SmartFanII: Fan3 Non-Stop */
191 0x98, /* (bit7-4) SmartFanII: Fan3 Level 1 */
192 0xE2, /* (bit7-4) SmartFanII: Fan3 Level 2 */
193 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */
194};
195
196#define W83792D_REG_CONFIG 0x40
197#define W83792D_REG_VID_FANDIV 0x47
198#define W83792D_REG_CHIPID 0x49
199#define W83792D_REG_WCHIPID 0x58
200#define W83792D_REG_CHIPMAN 0x4F
201#define W83792D_REG_PIN 0x4B
202#define W83792D_REG_I2C_SUBADDR 0x4A
203
204#define W83792D_REG_ALARM1 0xA9 /* realtime status register1 */
205#define W83792D_REG_ALARM2 0xAA /* realtime status register2 */
206#define W83792D_REG_ALARM3 0xAB /* realtime status register3 */
207#define W83792D_REG_CHASSIS 0x42 /* Bit 5: Case Open status bit */
208#define W83792D_REG_CHASSIS_CLR 0x44 /* Bit 7: Case Open CLR_CHS/Reset bit */
209
210/* control in0/in1 's limit modifiability */
211#define W83792D_REG_VID_IN_B 0x17
212
213#define W83792D_REG_VBAT 0x5D
214#define W83792D_REG_I2C_ADDR 0x48
215
216/* Conversions. Rounding and limit checking is only done on the TO_REG
217 variants. Note that you should be a bit careful with which arguments
218 these macros are called: arguments may be evaluated more than once.
219 Fixing this is just not worth it. */
220#define IN_FROM_REG(nr,val) (((nr)<=1)?(val*2): \
221 ((((nr)==6)||((nr)==7))?(val*6):(val*4)))
222#define IN_TO_REG(nr,val) (((nr)<=1)?(val/2): \
223 ((((nr)==6)||((nr)==7))?(val/6):(val/4)))
224
225static inline u8
226FAN_TO_REG(long rpm, int div)
227{
228 if (rpm == 0)
229 return 255;
230 rpm = SENSORS_LIMIT(rpm, 1, 1000000);
231 return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
232}
233
234#define FAN_FROM_REG(val,div) ((val) == 0 ? -1 : \
235 ((val) == 255 ? 0 : \
236 1350000 / ((val) * (div))))
237
238/* for temp1 */
239#define TEMP1_TO_REG(val) (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
240 : (val)) / 1000, 0, 0xff))
241#define TEMP1_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
242/* for temp2 and temp3, because they need addtional resolution */
243#define TEMP_ADD_FROM_REG(val1, val2) \
244 ((((val1) & 0x80 ? (val1)-0x100 \
245 : (val1)) * 1000) + ((val2 & 0x80) ? 500 : 0))
246#define TEMP_ADD_TO_REG_HIGH(val) \
247 (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
248 : (val)) / 1000, 0, 0xff))
249#define TEMP_ADD_TO_REG_LOW(val) ((val%1000) ? 0x80 : 0x00)
250
251#define PWM_FROM_REG(val) (val)
252#define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255))
253#define DIV_FROM_REG(val) (1 << (val))
254
255static inline u8
256DIV_TO_REG(long val)
257{
258 int i;
259 val = SENSORS_LIMIT(val, 1, 128) >> 1;
260 for (i = 0; i < 6; i++) {
261 if (val == 0)
262 break;
263 val >>= 1;
264 }
265 return ((u8) i);
266}
267
268struct w83792d_data {
269 struct i2c_client client;
270 struct class_device *class_dev;
271 struct semaphore lock;
272 enum chips type;
273
274 struct semaphore update_lock;
275 char valid; /* !=0 if following fields are valid */
276 unsigned long last_updated; /* In jiffies */
277
278 /* array of 2 pointers to subclients */
279 struct i2c_client *lm75[2];
280
281 u8 in[9]; /* Register value */
282 u8 in_max[9]; /* Register value */
283 u8 in_min[9]; /* Register value */
284 u8 low_bits[2]; /* Additional resolution to voltage in0-6 */
285 u8 fan[7]; /* Register value */
286 u8 fan_min[7]; /* Register value */
287 u8 temp1[3]; /* current, over, thyst */
288 u8 temp_add[2][6]; /* Register value */
289 u8 fan_div[7]; /* Register encoding, shifted right */
290 u8 pwm[7]; /* We only consider the first 3 set of pwm,
291 although 792 chip has 7 set of pwm. */
292 u8 pwmenable[3];
293 u8 pwm_mode[7]; /* indicates PWM or DC mode: 1->PWM; 0->DC */
294 u32 alarms; /* realtime status register encoding,combined */
295 u8 chassis; /* Chassis status */
296 u8 chassis_clear; /* CLR_CHS, clear chassis intrusion detection */
297 u8 thermal_cruise[3]; /* Smart FanI: Fan1,2,3 target value */
298 u8 tolerance[3]; /* Fan1,2,3 tolerance(Smart Fan I/II) */
299 u8 sf2_points[3][4]; /* Smart FanII: Fan1,2,3 temperature points */
300 u8 sf2_levels[3][4]; /* Smart FanII: Fan1,2,3 duty cycle levels */
301};
302
303static int w83792d_attach_adapter(struct i2c_adapter *adapter);
304static int w83792d_detect(struct i2c_adapter *adapter, int address, int kind);
305static int w83792d_detach_client(struct i2c_client *client);
306
307static int w83792d_read_value(struct i2c_client *client, u8 register);
308static int w83792d_write_value(struct i2c_client *client, u8 register,
309 u8 value);
310static struct w83792d_data *w83792d_update_device(struct device *dev);
311
312#ifdef DEBUG
313static void w83792d_print_debug(struct w83792d_data *data, struct device *dev);
314#endif
315
316static void w83792d_init_client(struct i2c_client *client);
317
318static struct i2c_driver w83792d_driver = {
319 .owner = THIS_MODULE,
320 .name = "w83792d",
321 .flags = I2C_DF_NOTIFY,
322 .attach_adapter = w83792d_attach_adapter,
323 .detach_client = w83792d_detach_client,
324};
325
326static long in_count_from_reg(int nr, struct w83792d_data *data)
327{
328 u16 vol_count = data->in[nr];
329 u16 low_bits = 0;
330 vol_count = (vol_count << 2);
331 switch (nr)
332 {
333 case 0: /* vin0 */
334 low_bits = (data->low_bits[0]) & 0x03;
335 break;
336 case 1: /* vin1 */
337 low_bits = ((data->low_bits[0]) & 0x0c) >> 2;
338 break;
339 case 2: /* vin2 */
340 low_bits = ((data->low_bits[0]) & 0x30) >> 4;
341 break;
342 case 3: /* vin3 */
343 low_bits = ((data->low_bits[0]) & 0xc0) >> 6;
344 break;
345 case 4: /* vin4 */
346 low_bits = (data->low_bits[1]) & 0x03;
347 break;
348 case 5: /* vin5 */
349 low_bits = ((data->low_bits[1]) & 0x0c) >> 2;
350 break;
351 case 6: /* vin6 */
352 low_bits = ((data->low_bits[1]) & 0x30) >> 4;
353 default:
354 break;
355 }
356 vol_count = vol_count | low_bits;
357 return vol_count;
358}
359
360/* following are the sysfs callback functions */
361static ssize_t show_in(struct device *dev, struct device_attribute *attr,
362 char *buf)
363{
364 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
365 int nr = sensor_attr->index;
366 struct w83792d_data *data = w83792d_update_device(dev);
367 return sprintf(buf,"%ld\n", IN_FROM_REG(nr,(in_count_from_reg(nr, data))));
368}
369
370#define show_in_reg(reg) \
371static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
372 char *buf) \
373{ \
374 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
375 int nr = sensor_attr->index; \
376 struct w83792d_data *data = w83792d_update_device(dev); \
377 return sprintf(buf,"%ld\n", (long)(IN_FROM_REG(nr, (data->reg[nr])*4))); \
378}
379
380show_in_reg(in_min);
381show_in_reg(in_max);
382
383#define store_in_reg(REG, reg) \
384static ssize_t store_in_##reg (struct device *dev, \
385 struct device_attribute *attr, \
386 const char *buf, size_t count) \
387{ \
388 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
389 int nr = sensor_attr->index; \
390 struct i2c_client *client = to_i2c_client(dev); \
391 struct w83792d_data *data = i2c_get_clientdata(client); \
392 u32 val; \
393 \
394 val = simple_strtoul(buf, NULL, 10); \
395 data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val)/4, 0, 255); \
396 w83792d_write_value(client, W83792D_REG_IN_##REG[nr], data->in_##reg[nr]); \
397 \
398 return count; \
399}
400store_in_reg(MIN, min);
401store_in_reg(MAX, max);
402
403#define sysfs_in_reg(offset) \
404static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \
405 NULL, offset); \
406static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
407 show_in_min, store_in_min, offset); \
408static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
409 show_in_max, store_in_max, offset);
410
411sysfs_in_reg(0);
412sysfs_in_reg(1);
413sysfs_in_reg(2);
414sysfs_in_reg(3);
415sysfs_in_reg(4);
416sysfs_in_reg(5);
417sysfs_in_reg(6);
418sysfs_in_reg(7);
419sysfs_in_reg(8);
420
421#define device_create_file_in(client, offset) \
422do { \
423device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \
424device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \
425device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \
426} while (0)
427
428#define show_fan_reg(reg) \
429static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \
430 char *buf) \
431{ \
432 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
433 int nr = sensor_attr->index - 1; \
434 struct w83792d_data *data = w83792d_update_device(dev); \
435 return sprintf(buf,"%d\n", \
436 FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \
437}
438
439show_fan_reg(fan);
440show_fan_reg(fan_min);
441
442static ssize_t
443store_fan_min(struct device *dev, struct device_attribute *attr,
444 const char *buf, size_t count)
445{
446 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
447 int nr = sensor_attr->index - 1;
448 struct i2c_client *client = to_i2c_client(dev);
449 struct w83792d_data *data = i2c_get_clientdata(client);
450 u32 val;
451
452 val = simple_strtoul(buf, NULL, 10);
453 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
454 w83792d_write_value(client, W83792D_REG_FAN_MIN[nr],
455 data->fan_min[nr]);
456
457 return count;
458}
459
460static ssize_t
461show_fan_div(struct device *dev, struct device_attribute *attr,
462 char *buf)
463{
464 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
465 int nr = sensor_attr->index;
466 struct w83792d_data *data = w83792d_update_device(dev);
467 return sprintf(buf, "%u\n", DIV_FROM_REG(data->fan_div[nr - 1]));
468}
469
470/* Note: we save and restore the fan minimum here, because its value is
471 determined in part by the fan divisor. This follows the principle of
472 least suprise; the user doesn't expect the fan minimum to change just
473 because the divisor changed. */
474static ssize_t
475store_fan_div(struct device *dev, struct device_attribute *attr,
476 const char *buf, size_t count)
477{
478 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
479 int nr = sensor_attr->index - 1;
480 struct i2c_client *client = to_i2c_client(dev);
481 struct w83792d_data *data = i2c_get_clientdata(client);
482 unsigned long min;
483 /*u8 reg;*/
484 u8 fan_div_reg = 0;
485 u8 tmp_fan_div;
486
487 /* Save fan_min */
488 min = FAN_FROM_REG(data->fan_min[nr],
489 DIV_FROM_REG(data->fan_div[nr]));
490
491 data->fan_div[nr] = DIV_TO_REG(simple_strtoul(buf, NULL, 10));
492
493 fan_div_reg = w83792d_read_value(client, W83792D_REG_FAN_DIV[nr >> 1]);
494 fan_div_reg &= (nr & 0x01) ? 0x8f : 0xf8;
495 tmp_fan_div = (nr & 0x01) ? (((data->fan_div[nr]) << 4) & 0x70)
496 : ((data->fan_div[nr]) & 0x07);
497 w83792d_write_value(client, W83792D_REG_FAN_DIV[nr >> 1],
498 fan_div_reg | tmp_fan_div);
499
500 /* Restore fan_min */
501 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
502 w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], data->fan_min[nr]);
503
504 return count;
505}
506
507#define sysfs_fan(offset) \
508static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \
509 offset); \
510static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
511 show_fan_div, store_fan_div, offset); \
512static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
513 show_fan_min, store_fan_min, offset);
514
515sysfs_fan(1);
516sysfs_fan(2);
517sysfs_fan(3);
518sysfs_fan(4);
519sysfs_fan(5);
520sysfs_fan(6);
521sysfs_fan(7);
522
523#define device_create_file_fan(client, offset) \
524do { \
525device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \
526device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \
527device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \
528} while (0)
529
530
531/* read/write the temperature1, includes measured value and limits */
532
533static ssize_t show_temp1(struct device *dev, struct device_attribute *attr,
534 char *buf)
535{
536 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
537 int nr = sensor_attr->index;
538 struct w83792d_data *data = w83792d_update_device(dev);
539 return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[nr]));
540}
541
542static ssize_t store_temp1(struct device *dev, struct device_attribute *attr,
543 const char *buf, size_t count)
544{
545 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
546 int nr = sensor_attr->index;
547 struct i2c_client *client = to_i2c_client(dev);
548 struct w83792d_data *data = i2c_get_clientdata(client);
549 s32 val;
550
551 val = simple_strtol(buf, NULL, 10);
552
553 data->temp1[nr] = TEMP1_TO_REG(val);
554 w83792d_write_value(client, W83792D_REG_TEMP1[nr],
555 data->temp1[nr]);
556
557 return count;
558}
559
560
561static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0);
562static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1,
563 store_temp1, 1);
564static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1,
565 store_temp1, 2);
566
567#define device_create_file_temp1(client) \
568do { \
569device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \
570device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \
571device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \
572} while (0)
573
574
575/* read/write the temperature2-3, includes measured value and limits */
576
577static ssize_t show_temp23(struct device *dev, struct device_attribute *attr,
578 char *buf)
579{
580 struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
581 int nr = sensor_attr->nr;
582 int index = sensor_attr->index;
583 struct w83792d_data *data = w83792d_update_device(dev);
584 return sprintf(buf,"%ld\n",
585 (long)TEMP_ADD_FROM_REG(data->temp_add[nr][index],
586 data->temp_add[nr][index+1]));
587}
588
589static ssize_t store_temp23(struct device *dev, struct device_attribute *attr,
590 const char *buf, size_t count)
591{
592 struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
593 int nr = sensor_attr->nr;
594 int index = sensor_attr->index;
595 struct i2c_client *client = to_i2c_client(dev);
596 struct w83792d_data *data = i2c_get_clientdata(client);
597 s32 val;
598
599 val = simple_strtol(buf, NULL, 10);
600
601 data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val);
602 data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val);
603 w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index],
604 data->temp_add[nr][index]);
605 w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index+1],
606 data->temp_add[nr][index+1]);
607
608 return count;
609}
610
611#define sysfs_temp23(name,idx) \
612static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \
613 idx, 0); \
614static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \
615 show_temp23, store_temp23, idx, 2); \
616static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \
617 show_temp23, store_temp23, idx, 4);
618
619sysfs_temp23(temp2,0)
620sysfs_temp23(temp3,1)
621
622#define device_create_file_temp_add(client, offset) \
623do { \
624device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \
625device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \
626device_create_file(&client->dev, \
627&sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \
628} while (0)
629
630
631/* get reatime status of all sensors items: voltage, temp, fan */
632static ssize_t
633show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
634{
635 struct w83792d_data *data = w83792d_update_device(dev);
636 return sprintf(buf, "%d\n", data->alarms);
637}
638
639static
640DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
641#define device_create_file_alarms(client) \
642device_create_file(&client->dev, &dev_attr_alarms);
643
644
645
646static ssize_t
647show_pwm(struct device *dev, struct device_attribute *attr,
648 char *buf)
649{
650 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
651 int nr = sensor_attr->index;
652 struct w83792d_data *data = w83792d_update_device(dev);
653 return sprintf(buf, "%ld\n", (long) PWM_FROM_REG(data->pwm[nr-1]));
654}
655
656static ssize_t
657show_pwmenable(struct device *dev, struct device_attribute *attr,
658 char *buf)
659{
660 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
661 int nr = sensor_attr->index - 1;
662 struct w83792d_data *data = w83792d_update_device(dev);
663 long pwm_enable_tmp = 1;
664
665 switch (data->pwmenable[nr]) {
666 case 0:
667 pwm_enable_tmp = 1; /* manual mode */
668 break;
669 case 1:
670 pwm_enable_tmp = 3; /*thermal cruise/Smart Fan I */
671 break;
672 case 2:
673 pwm_enable_tmp = 2; /* Smart Fan II */
674 break;
675 }
676
677 return sprintf(buf, "%ld\n", pwm_enable_tmp);
678}
679
680static ssize_t
681store_pwm(struct device *dev, struct device_attribute *attr,
682 const char *buf, size_t count)
683{
684 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
685 int nr = sensor_attr->index - 1;
686 struct i2c_client *client = to_i2c_client(dev);
687 struct w83792d_data *data = i2c_get_clientdata(client);
688 u32 val;
689
690 val = simple_strtoul(buf, NULL, 10);
691 data->pwm[nr] = PWM_TO_REG(val);
692 w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]);
693
694 return count;
695}
696
697static ssize_t
698store_pwmenable(struct device *dev, struct device_attribute *attr,
699 const char *buf, size_t count)
700{
701 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
702 int nr = sensor_attr->index - 1;
703 struct i2c_client *client = to_i2c_client(dev);
704 struct w83792d_data *data = i2c_get_clientdata(client);
705 u32 val;
706 u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp;
707
708 val = simple_strtoul(buf, NULL, 10);
709 switch (val) {
710 case 1:
711 data->pwmenable[nr] = 0; /* manual mode */
712 break;
713 case 2:
714 data->pwmenable[nr] = 2; /* Smart Fan II */
715 break;
716 case 3:
717 data->pwmenable[nr] = 1; /* thermal cruise/Smart Fan I */
718 break;
719 default:
720 return -EINVAL;
721 }
722 cfg1_tmp = data->pwmenable[0];
723 cfg2_tmp = (data->pwmenable[1]) << 2;
724 cfg3_tmp = (data->pwmenable[2]) << 4;
725 cfg4_tmp = w83792d_read_value(client,W83792D_REG_FAN_CFG) & 0xc0;
726 fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp;
727 w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp);
728
729 return count;
730}
731
732#define sysfs_pwm(offset) \
733static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
734 show_pwm, store_pwm, offset); \
735static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
736 show_pwmenable, store_pwmenable, offset); \
737
738sysfs_pwm(1);
739sysfs_pwm(2);
740sysfs_pwm(3);
741
742
743#define device_create_file_pwm(client, offset) \
744do { \
745device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \
746} while (0)
747
748#define device_create_file_pwmenable(client, offset) \
749do { \
750device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \
751} while (0)
752
753
754static ssize_t
755show_pwm_mode(struct device *dev, struct device_attribute *attr,
756 char *buf)
757{
758 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
759 int nr = sensor_attr->index;
760 struct w83792d_data *data = w83792d_update_device(dev);
761 return sprintf(buf, "%d\n", data->pwm_mode[nr-1]);
762}
763
764static ssize_t
765store_pwm_mode(struct device *dev, struct device_attribute *attr,
766 const char *buf, size_t count)
767{
768 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
769 int nr = sensor_attr->index - 1;
770 struct i2c_client *client = to_i2c_client(dev);
771 struct w83792d_data *data = i2c_get_clientdata(client);
772 u32 val;
773 u8 pwm_mode_mask = 0;
774
775 val = simple_strtoul(buf, NULL, 10);
776 data->pwm_mode[nr] = SENSORS_LIMIT(val, 0, 1);
777 pwm_mode_mask = w83792d_read_value(client,
778 W83792D_REG_PWM[nr]) & 0x7f;
779 w83792d_write_value(client, W83792D_REG_PWM[nr],
780 ((data->pwm_mode[nr]) << 7) | pwm_mode_mask);
781
782 return count;
783}
784
785#define sysfs_pwm_mode(offset) \
786static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \
787 show_pwm_mode, store_pwm_mode, offset);
788
789sysfs_pwm_mode(1);
790sysfs_pwm_mode(2);
791sysfs_pwm_mode(3);
792
793#define device_create_file_pwm_mode(client, offset) \
794do { \
795device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \
796} while (0)
797
798
799static ssize_t
800show_regs_chassis(struct device *dev, struct device_attribute *attr,
801 char *buf)
802{
803 struct w83792d_data *data = w83792d_update_device(dev);
804 return sprintf(buf, "%d\n", data->chassis);
805}
806
807static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);
808
809#define device_create_file_chassis(client) \
810do { \
811device_create_file(&client->dev, &dev_attr_chassis); \
812} while (0)
813
814
815static ssize_t
816show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf)
817{
818 struct w83792d_data *data = w83792d_update_device(dev);
819 return sprintf(buf, "%d\n", data->chassis_clear);
820}
821
822static ssize_t
823store_chassis_clear(struct device *dev, struct device_attribute *attr,
824 const char *buf, size_t count)
825{
826 struct i2c_client *client = to_i2c_client(dev);
827 struct w83792d_data *data = i2c_get_clientdata(client);
828 u32 val;
829 u8 temp1 = 0, temp2 = 0;
830
831 val = simple_strtoul(buf, NULL, 10);
832
833 data->chassis_clear = SENSORS_LIMIT(val, 0 ,1);
834 temp1 = ((data->chassis_clear) << 7) & 0x80;
835 temp2 = w83792d_read_value(client,
836 W83792D_REG_CHASSIS_CLR) & 0x7f;
837 w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, temp1 | temp2);
838
839 return count;
840}
841
842static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR,
843 show_chassis_clear, store_chassis_clear);
844
845#define device_create_file_chassis_clear(client) \
846do { \
847device_create_file(&client->dev, &dev_attr_chassis_clear); \
848} while (0)
849
850
851
852/* For Smart Fan I / Thermal Cruise */
853static ssize_t
854show_thermal_cruise(struct device *dev, struct device_attribute *attr,
855 char *buf)
856{
857 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
858 int nr = sensor_attr->index;
859 struct w83792d_data *data = w83792d_update_device(dev);
860 return sprintf(buf, "%ld\n", (long)data->thermal_cruise[nr-1]);
861}
862
863static ssize_t
864store_thermal_cruise(struct device *dev, struct device_attribute *attr,
865 const char *buf, size_t count)
866{
867 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
868 int nr = sensor_attr->index - 1;
869 struct i2c_client *client = to_i2c_client(dev);
870 struct w83792d_data *data = i2c_get_clientdata(client);
871 u32 val;
872 u8 target_tmp=0, target_mask=0;
873
874 val = simple_strtoul(buf, NULL, 10);
875 target_tmp = val;
876 target_tmp = target_tmp & 0x7f;
877 target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80;
878 data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255);
879 w83792d_write_value(client, W83792D_REG_THERMAL[nr],
880 (data->thermal_cruise[nr]) | target_mask);
881
882 return count;
883}
884
885#define sysfs_thermal_cruise(offset) \
886static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \
887 show_thermal_cruise, store_thermal_cruise, offset);
888
889sysfs_thermal_cruise(1);
890sysfs_thermal_cruise(2);
891sysfs_thermal_cruise(3);
892
893#define device_create_file_thermal_cruise(client, offset) \
894do { \
895device_create_file(&client->dev, \
896&sensor_dev_attr_thermal_cruise##offset.dev_attr); \
897} while (0)
898
899
900/* For Smart Fan I/Thermal Cruise and Smart Fan II */
901static ssize_t
902show_tolerance(struct device *dev, struct device_attribute *attr,
903 char *buf)
904{
905 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
906 int nr = sensor_attr->index;
907 struct w83792d_data *data = w83792d_update_device(dev);
908 return sprintf(buf, "%ld\n", (long)data->tolerance[nr-1]);
909}
910
911static ssize_t
912store_tolerance(struct device *dev, struct device_attribute *attr,
913 const char *buf, size_t count)
914{
915 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
916 int nr = sensor_attr->index - 1;
917 struct i2c_client *client = to_i2c_client(dev);
918 struct w83792d_data *data = i2c_get_clientdata(client);
919 u32 val;
920 u8 tol_tmp, tol_mask;
921
922 val = simple_strtoul(buf, NULL, 10);
923 tol_mask = w83792d_read_value(client,
924 W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0);
925 tol_tmp = SENSORS_LIMIT(val, 0, 15);
926 tol_tmp &= 0x0f;
927 data->tolerance[nr] = tol_tmp;
928 if (nr == 1) {
929 tol_tmp <<= 4;
930 }
931 w83792d_write_value(client, W83792D_REG_TOLERANCE[nr],
932 tol_mask | tol_tmp);
933
934 return count;
935}
936
937#define sysfs_tolerance(offset) \
938static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \
939 show_tolerance, store_tolerance, offset);
940
941sysfs_tolerance(1);
942sysfs_tolerance(2);
943sysfs_tolerance(3);
944
945#define device_create_file_tolerance(client, offset) \
946do { \
947device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \
948} while (0)
949
950
951/* For Smart Fan II */
952static ssize_t
953show_sf2_point(struct device *dev, struct device_attribute *attr,
954 char *buf)
955{
956 struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
957 int nr = sensor_attr->nr;
958 int index = sensor_attr->index;
959 struct w83792d_data *data = w83792d_update_device(dev);
960 return sprintf(buf, "%ld\n", (long)data->sf2_points[index-1][nr-1]);
961}
962
963static ssize_t
964store_sf2_point(struct device *dev, struct device_attribute *attr,
965 const char *buf, size_t count)
966{
967 struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
968 int nr = sensor_attr->nr - 1;
969 int index = sensor_attr->index - 1;
970 struct i2c_client *client = to_i2c_client(dev);
971 struct w83792d_data *data = i2c_get_clientdata(client);
972 u32 val;
973 u8 mask_tmp = 0;
974
975 val = simple_strtoul(buf, NULL, 10);
976 data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127);
977 mask_tmp = w83792d_read_value(client,
978 W83792D_REG_POINTS[index][nr]) & 0x80;
979 w83792d_write_value(client, W83792D_REG_POINTS[index][nr],
980 mask_tmp|data->sf2_points[index][nr]);
981
982 return count;
983}
984
985#define sysfs_sf2_point(offset, index) \
986static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \
987 show_sf2_point, store_sf2_point, offset, index);
988
989sysfs_sf2_point(1, 1); /* Fan1 */
990sysfs_sf2_point(2, 1); /* Fan1 */
991sysfs_sf2_point(3, 1); /* Fan1 */
992sysfs_sf2_point(4, 1); /* Fan1 */
993sysfs_sf2_point(1, 2); /* Fan2 */
994sysfs_sf2_point(2, 2); /* Fan2 */
995sysfs_sf2_point(3, 2); /* Fan2 */
996sysfs_sf2_point(4, 2); /* Fan2 */
997sysfs_sf2_point(1, 3); /* Fan3 */
998sysfs_sf2_point(2, 3); /* Fan3 */
999sysfs_sf2_point(3, 3); /* Fan3 */
1000sysfs_sf2_point(4, 3); /* Fan3 */
1001
1002#define device_create_file_sf2_point(client, offset, index) \
1003do { \
1004device_create_file(&client->dev, \
1005&sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \
1006} while (0)
1007
1008
1009static ssize_t
1010show_sf2_level(struct device *dev, struct device_attribute *attr,
1011 char *buf)
1012{
1013 struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
1014 int nr = sensor_attr->nr;
1015 int index = sensor_attr->index;
1016 struct w83792d_data *data = w83792d_update_device(dev);
1017 return sprintf(buf, "%d\n",
1018 (((data->sf2_levels[index-1][nr]) * 100) / 15));
1019}
1020
1021static ssize_t
1022store_sf2_level(struct device *dev, struct device_attribute *attr,
1023 const char *buf, size_t count)
1024{
1025 struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
1026 int nr = sensor_attr->nr;
1027 int index = sensor_attr->index - 1;
1028 struct i2c_client *client = to_i2c_client(dev);
1029 struct w83792d_data *data = i2c_get_clientdata(client);
1030 u32 val;
1031 u8 mask_tmp=0, level_tmp=0;
1032
1033 val = simple_strtoul(buf, NULL, 10);
1034 data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15);
1035 mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr])
1036 & ((nr==3) ? 0xf0 : 0x0f);
1037 if (nr==3) {
1038 level_tmp = data->sf2_levels[index][nr];
1039 } else {
1040 level_tmp = data->sf2_levels[index][nr] << 4;
1041 }
1042 w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp);
1043
1044 return count;
1045}
1046
1047#define sysfs_sf2_level(offset, index) \
1048static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \
1049 show_sf2_level, store_sf2_level, offset, index);
1050
1051sysfs_sf2_level(1, 1); /* Fan1 */
1052sysfs_sf2_level(2, 1); /* Fan1 */
1053sysfs_sf2_level(3, 1); /* Fan1 */
1054sysfs_sf2_level(1, 2); /* Fan2 */
1055sysfs_sf2_level(2, 2); /* Fan2 */
1056sysfs_sf2_level(3, 2); /* Fan2 */
1057sysfs_sf2_level(1, 3); /* Fan3 */
1058sysfs_sf2_level(2, 3); /* Fan3 */
1059sysfs_sf2_level(3, 3); /* Fan3 */
1060
1061#define device_create_file_sf2_level(client, offset, index) \
1062do { \
1063device_create_file(&client->dev, \
1064&sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \
1065} while (0)
1066
1067
1068/* This function is called when:
1069 * w83792d_driver is inserted (when this module is loaded), for each
1070 available adapter
1071 * when a new adapter is inserted (and w83792d_driver is still present) */
1072static int
1073w83792d_attach_adapter(struct i2c_adapter *adapter)
1074{
1075 if (!(adapter->class & I2C_CLASS_HWMON))
1076 return 0;
1077 return i2c_probe(adapter, &addr_data, w83792d_detect);
1078}
1079
1080
1081static int
1082w83792d_create_subclient(struct i2c_adapter *adapter,
1083 struct i2c_client *new_client, int addr,
1084 struct i2c_client **sub_cli)
1085{
1086 int err;
1087 struct i2c_client *sub_client;
1088
1089 (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
1090 if (!(sub_client)) {
1091 return -ENOMEM;
1092 }
1093 memset(sub_client, 0x00, sizeof(struct i2c_client));
1094 sub_client->addr = 0x48 + addr;
1095 i2c_set_clientdata(sub_client, NULL);
1096 sub_client->adapter = adapter;
1097 sub_client->driver = &w83792d_driver;
1098 sub_client->flags = 0;
1099 strlcpy(sub_client->name, "w83792d subclient", I2C_NAME_SIZE);
1100 if ((err = i2c_attach_client(sub_client))) {
1101 dev_err(&new_client->dev, "subclient registration "
1102 "at address 0x%x failed\n", sub_client->addr);
1103 kfree(sub_client);
1104 return err;
1105 }
1106 return 0;
1107}
1108
1109
1110static int
1111w83792d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
1112 struct i2c_client *new_client)
1113{
1114 int i, id, err;
1115 u8 val;
1116 struct w83792d_data *data = i2c_get_clientdata(new_client);
1117
1118 id = i2c_adapter_id(adapter);
1119 if (force_subclients[0] == id && force_subclients[1] == address) {
1120 for (i = 2; i <= 3; i++) {
1121 if (force_subclients[i] < 0x48 ||
1122 force_subclients[i] > 0x4f) {
1123 dev_err(&new_client->dev, "invalid subclient "
1124 "address %d; must be 0x48-0x4f\n",
1125 force_subclients[i]);
1126 err = -ENODEV;
1127 goto ERROR_SC_0;
1128 }
1129 }
1130 w83792d_write_value(new_client, W83792D_REG_I2C_SUBADDR,
1131 (force_subclients[2] & 0x07) |
1132 ((force_subclients[3] & 0x07) << 4));
1133 }
1134
1135 val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR);
1136 if (!(val & 0x08)) {
1137 err = w83792d_create_subclient(adapter, new_client, val & 0x7,
1138 &data->lm75[0]);
1139 if (err < 0)
1140 goto ERROR_SC_0;
1141 }
1142 if (!(val & 0x80)) {
1143 if ((data->lm75[0] != NULL) &&
1144 ((val & 0x7) == ((val >> 4) & 0x7))) {
1145 dev_err(&new_client->dev, "duplicate addresses 0x%x, "
1146 "use force_subclient\n", data->lm75[0]->addr);
1147 err = -ENODEV;
1148 goto ERROR_SC_1;
1149 }
1150 err = w83792d_create_subclient(adapter, new_client,
1151 (val >> 4) & 0x7, &data->lm75[1]);
1152 if (err < 0)
1153 goto ERROR_SC_1;
1154 }
1155
1156 return 0;
1157
1158/* Undo inits in case of errors */
1159
1160ERROR_SC_1:
1161 if (data->lm75[0] != NULL) {
1162 i2c_detach_client(data->lm75[0]);
1163 kfree(data->lm75[0]);
1164 }
1165ERROR_SC_0:
1166 return err;
1167}
1168
1169
1170static int
1171w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1172{
1173 int i = 0, val1 = 0, val2;
1174 struct i2c_client *new_client;
1175 struct w83792d_data *data;
1176 int err = 0;
1177 const char *client_name = "";
1178
1179 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
1180 goto ERROR0;
1181 }
1182
1183 /* OK. For now, we presume we have a valid client. We now create the
1184 client structure, even though we cannot fill it completely yet.
1185 But it allows us to access w83792d_{read,write}_value. */
1186
1187 if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) {
1188 err = -ENOMEM;
1189 goto ERROR0;
1190 }
1191 memset(data, 0, sizeof(struct w83792d_data));
1192
1193 new_client = &data->client;
1194 i2c_set_clientdata(new_client, data);
1195 new_client->addr = address;
1196 init_MUTEX(&data->lock);
1197 new_client->adapter = adapter;
1198 new_client->driver = &w83792d_driver;
1199 new_client->flags = 0;
1200
1201 /* Now, we do the remaining detection. */
1202
1203 /* The w83792d may be stuck in some other bank than bank 0. This may
1204 make reading other information impossible. Specify a force=... or
1205 force_*=... parameter, and the Winbond will be reset to the right
1206 bank. */
1207 if (kind < 0) {
1208 if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) {
1209 dev_warn(&new_client->dev, "Detection failed at step "
1210 "3\n");
1211 goto ERROR1;
1212 }
1213 val1 = w83792d_read_value(new_client, W83792D_REG_BANK);
1214 val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);
1215 /* Check for Winbond ID if in bank 0 */
1216 if (!(val1 & 0x07)) { /* is Bank0 */
1217 if (((!(val1 & 0x80)) && (val2 != 0xa3)) ||
1218 ((val1 & 0x80) && (val2 != 0x5c))) {
1219 goto ERROR1;
1220 }
1221 }
1222 /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR
1223 should match */
1224 if (w83792d_read_value(new_client,
1225 W83792D_REG_I2C_ADDR) != address) {
1226 dev_warn(&new_client->dev, "Detection failed "
1227 "at step 5\n");
1228 goto ERROR1;
1229 }
1230 }
1231
1232 /* We have either had a force parameter, or we have already detected the
1233 Winbond. Put it now into bank 0 and Vendor ID High Byte */
1234 w83792d_write_value(new_client,
1235 W83792D_REG_BANK,
1236 (w83792d_read_value(new_client,
1237 W83792D_REG_BANK) & 0x78) | 0x80);
1238
1239 /* Determine the chip type. */
1240 if (kind <= 0) {
1241 /* get vendor ID */
1242 val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);
1243 if (val2 != 0x5c) { /* the vendor is NOT Winbond */
1244 goto ERROR1;
1245 }
1246 val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);
1247 if (val1 == 0x7a && address >= 0x2c) {
1248 kind = w83792d;
1249 } else {
1250 if (kind == 0)
1251 dev_warn(&new_client->dev,
1252 "w83792d: Ignoring 'force' parameter for"
1253 " unknown chip at adapter %d, address"
1254 " 0x%02x\n", i2c_adapter_id(adapter),
1255 address);
1256 goto ERROR1;
1257 }
1258 }
1259
1260 if (kind == w83792d) {
1261 client_name = "w83792d";
1262 } else {
1263 dev_err(&new_client->dev, "w83792d: Internal error: unknown"
1264 " kind (%d)?!?", kind);
1265 goto ERROR1;
1266 }
1267
1268 /* Fill in the remaining client fields and put into the global list */
1269 strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
1270 data->type = kind;
1271
1272 data->valid = 0;
1273 init_MUTEX(&data->update_lock);
1274
1275 /* Tell the I2C layer a new client has arrived */
1276 if ((err = i2c_attach_client(new_client)))
1277 goto ERROR1;
1278
1279 if ((err = w83792d_detect_subclients(adapter, address,
1280 kind, new_client)))
1281 goto ERROR2;
1282
1283 /* Initialize the chip */
1284 w83792d_init_client(new_client);
1285
1286 /* A few vars need to be filled upon startup */
1287 for (i = 1; i <= 7; i++) {
1288 data->fan_min[i - 1] = w83792d_read_value(new_client,
1289 W83792D_REG_FAN_MIN[i]);
1290 }
1291
1292 /* Register sysfs hooks */
1293 data->class_dev = hwmon_device_register(&new_client->dev);
1294 if (IS_ERR(data->class_dev)) {
1295 err = PTR_ERR(data->class_dev);
1296 goto ERROR3;
1297 }
1298 device_create_file_in(new_client, 0);
1299 device_create_file_in(new_client, 1);
1300 device_create_file_in(new_client, 2);
1301 device_create_file_in(new_client, 3);
1302 device_create_file_in(new_client, 4);
1303 device_create_file_in(new_client, 5);
1304 device_create_file_in(new_client, 6);
1305 device_create_file_in(new_client, 7);
1306 device_create_file_in(new_client, 8);
1307
1308 device_create_file_fan(new_client, 1);
1309 device_create_file_fan(new_client, 2);
1310 device_create_file_fan(new_client, 3);
1311 device_create_file_fan(new_client, 4);
1312 device_create_file_fan(new_client, 5);
1313 device_create_file_fan(new_client, 6);
1314 device_create_file_fan(new_client, 7);
1315
1316 device_create_file_temp1(new_client); /* Temp1 */
1317 device_create_file_temp_add(new_client, 2); /* Temp2 */
1318 device_create_file_temp_add(new_client, 3); /* Temp3 */
1319
1320 device_create_file_alarms(new_client);
1321
1322 device_create_file_pwm(new_client, 1);
1323 device_create_file_pwm(new_client, 2);
1324 device_create_file_pwm(new_client, 3);
1325
1326 device_create_file_pwmenable(new_client, 1);
1327 device_create_file_pwmenable(new_client, 2);
1328 device_create_file_pwmenable(new_client, 3);
1329
1330 device_create_file_pwm_mode(new_client, 1);
1331 device_create_file_pwm_mode(new_client, 2);
1332 device_create_file_pwm_mode(new_client, 3);
1333
1334 device_create_file_chassis(new_client);
1335 device_create_file_chassis_clear(new_client);
1336
1337 device_create_file_thermal_cruise(new_client, 1);
1338 device_create_file_thermal_cruise(new_client, 2);
1339 device_create_file_thermal_cruise(new_client, 3);
1340
1341 device_create_file_tolerance(new_client, 1);
1342 device_create_file_tolerance(new_client, 2);
1343 device_create_file_tolerance(new_client, 3);
1344
1345 device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */
1346 device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */
1347 device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */
1348 device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */
1349 device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */
1350 device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */
1351 device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */
1352 device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */
1353 device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */
1354 device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */
1355 device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */
1356 device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */
1357
1358 device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */
1359 device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */
1360 device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */
1361 device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */
1362 device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */
1363 device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */
1364 device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */
1365 device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */
1366 device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */
1367
1368 return 0;
1369
1370ERROR3:
1371 if (data->lm75[0] != NULL) {
1372 i2c_detach_client(data->lm75[0]);
1373 kfree(data->lm75[0]);
1374 }
1375 if (data->lm75[1] != NULL) {
1376 i2c_detach_client(data->lm75[1]);
1377 kfree(data->lm75[1]);
1378 }
1379ERROR2:
1380 i2c_detach_client(new_client);
1381ERROR1:
1382 kfree(data);
1383ERROR0:
1384 return err;
1385}
1386
1387static int
1388w83792d_detach_client(struct i2c_client *client)
1389{
1390 struct w83792d_data *data = i2c_get_clientdata(client);
1391 int err;
1392
1393 /* main client */
1394 if (data)
1395 hwmon_device_unregister(data->class_dev);
1396
1397 if ((err = i2c_detach_client(client)))
1398 return err;
1399
1400 /* main client */
1401 if (data)
1402 kfree(data);
1403 /* subclient */
1404 else
1405 kfree(client);
1406
1407 return 0;
1408}
1409
1410/* The SMBus locks itself, usually, but nothing may access the Winbond between
1411 bank switches. ISA access must always be locked explicitly!
1412 We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks,
1413 would slow down the W83792D access and should not be necessary.
1414 There are some ugly typecasts here, but the good news is - they should
1415 nowhere else be necessary! */
1416static int
1417w83792d_read_value(struct i2c_client *client, u8 reg)
1418{
1419 int res=0;
1420 res = i2c_smbus_read_byte_data(client, reg);
1421
1422 return res;
1423}
1424
1425static int
1426w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
1427{
1428 i2c_smbus_write_byte_data(client, reg, value);
1429 return 0;
1430}
1431
1432/* Called when we have found a new W83792D. It should set limits, etc. */
1433static void
1434w83792d_init_client(struct i2c_client *client)
1435{
1436 u8 temp2_cfg, temp3_cfg, vid_in_b;
1437
1438 if (init) {
1439 w83792d_write_value(client, W83792D_REG_CONFIG, 0x80);
1440 }
1441 /* Clear the bit6 of W83792D_REG_VID_IN_B(set it into 0):
1442 W83792D_REG_VID_IN_B bit6 = 0: the high/low limit of
1443 vin0/vin1 can be modified by user;
1444 W83792D_REG_VID_IN_B bit6 = 1: the high/low limit of
1445 vin0/vin1 auto-updated, can NOT be modified by user. */
1446 vid_in_b = w83792d_read_value(client, W83792D_REG_VID_IN_B);
1447 w83792d_write_value(client, W83792D_REG_VID_IN_B,
1448 vid_in_b & 0xbf);
1449
1450 temp2_cfg = w83792d_read_value(client, W83792D_REG_TEMP2_CONFIG);
1451 temp3_cfg = w83792d_read_value(client, W83792D_REG_TEMP3_CONFIG);
1452 w83792d_write_value(client, W83792D_REG_TEMP2_CONFIG,
1453 temp2_cfg & 0xe6);
1454 w83792d_write_value(client, W83792D_REG_TEMP3_CONFIG,
1455 temp3_cfg & 0xe6);
1456
1457 /* Start monitoring */
1458 w83792d_write_value(client, W83792D_REG_CONFIG,
1459 (w83792d_read_value(client,
1460 W83792D_REG_CONFIG) & 0xf7)
1461 | 0x01);
1462}
1463
1464static struct w83792d_data *w83792d_update_device(struct device *dev)
1465{
1466 struct i2c_client *client = to_i2c_client(dev);
1467 struct w83792d_data *data = i2c_get_clientdata(client);
1468 int i, j;
1469 u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp;
1470
1471 down(&data->update_lock);
1472
1473 if (time_after
1474 (jiffies - data->last_updated, (unsigned long) (HZ * 3))
1475 || time_before(jiffies, data->last_updated) || !data->valid) {
1476 dev_dbg(dev, "Starting device update\n");
1477
1478 /* Update the voltages measured value and limits */
1479 for (i = 0; i < 9; i++) {
1480 data->in[i] = w83792d_read_value(client,
1481 W83792D_REG_IN[i]);
1482 data->in_max[i] = w83792d_read_value(client,
1483 W83792D_REG_IN_MAX[i]);
1484 data->in_min[i] = w83792d_read_value(client,
1485 W83792D_REG_IN_MIN[i]);
1486 }
1487 data->low_bits[0] = w83792d_read_value(client,
1488 W83792D_REG_LOW_BITS1);
1489 data->low_bits[1] = w83792d_read_value(client,
1490 W83792D_REG_LOW_BITS2);
1491 for (i = 0; i < 7; i++) {
1492 /* Update the Fan measured value and limits */
1493 data->fan[i] = w83792d_read_value(client,
1494 W83792D_REG_FAN[i]);
1495 data->fan_min[i] = w83792d_read_value(client,
1496 W83792D_REG_FAN_MIN[i]);
1497 /* Update the PWM/DC Value and PWM/DC flag */
1498 pwm_array_tmp[i] = w83792d_read_value(client,
1499 W83792D_REG_PWM[i]);
1500 data->pwm[i] = pwm_array_tmp[i] & 0x0f;
1501 data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01;
1502 }
1503
1504 reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG);
1505 data->pwmenable[0] = reg_tmp & 0x03;
1506 data->pwmenable[1] = (reg_tmp>>2) & 0x03;
1507 data->pwmenable[2] = (reg_tmp>>4) & 0x03;
1508
1509 for (i = 0; i < 3; i++) {
1510 data->temp1[i] = w83792d_read_value(client,
1511 W83792D_REG_TEMP1[i]);
1512 }
1513 for (i = 0; i < 2; i++) {
1514 for (j = 0; j < 6; j++) {
1515 data->temp_add[i][j] = w83792d_read_value(
1516 client,W83792D_REG_TEMP_ADD[i][j]);
1517 }
1518 }
1519
1520 /* Update the Fan Divisor */
1521 for (i = 0; i < 4; i++) {
1522 reg_array_tmp[i] = w83792d_read_value(client,
1523 W83792D_REG_FAN_DIV[i]);
1524 }
1525 data->fan_div[0] = reg_array_tmp[0] & 0x07;
1526 data->fan_div[1] = (reg_array_tmp[0] >> 4) & 0x07;
1527 data->fan_div[2] = reg_array_tmp[1] & 0x07;
1528 data->fan_div[3] = (reg_array_tmp[1] >> 4) & 0x07;
1529 data->fan_div[4] = reg_array_tmp[2] & 0x07;
1530 data->fan_div[5] = (reg_array_tmp[2] >> 4) & 0x07;
1531 data->fan_div[6] = reg_array_tmp[3] & 0x07;
1532
1533 /* Update the realtime status */
1534 data->alarms = w83792d_read_value(client, W83792D_REG_ALARM1) +
1535 (w83792d_read_value(client, W83792D_REG_ALARM2) << 8) +
1536 (w83792d_read_value(client, W83792D_REG_ALARM3) << 16);
1537
1538 /* Update CaseOpen status and it's CLR_CHS. */
1539 data->chassis = (w83792d_read_value(client,
1540 W83792D_REG_CHASSIS) >> 5) & 0x01;
1541 data->chassis_clear = (w83792d_read_value(client,
1542 W83792D_REG_CHASSIS_CLR) >> 7) & 0x01;
1543
1544 /* Update Thermal Cruise/Smart Fan I target value */
1545 for (i = 0; i < 3; i++) {
1546 data->thermal_cruise[i] =
1547 w83792d_read_value(client,
1548 W83792D_REG_THERMAL[i]) & 0x7f;
1549 }
1550
1551 /* Update Smart Fan I/II tolerance */
1552 reg_tmp = w83792d_read_value(client, W83792D_REG_TOLERANCE[0]);
1553 data->tolerance[0] = reg_tmp & 0x0f;
1554 data->tolerance[1] = (reg_tmp >> 4) & 0x0f;
1555 data->tolerance[2] = w83792d_read_value(client,
1556 W83792D_REG_TOLERANCE[2]) & 0x0f;
1557
1558 /* Update Smart Fan II temperature points */
1559 for (i = 0; i < 3; i++) {
1560 for (j = 0; j < 4; j++) {
1561 data->sf2_points[i][j] = w83792d_read_value(
1562 client,W83792D_REG_POINTS[i][j]) & 0x7f;
1563 }
1564 }
1565
1566 /* Update Smart Fan II duty cycle levels */
1567 for (i = 0; i < 3; i++) {
1568 reg_tmp = w83792d_read_value(client,
1569 W83792D_REG_LEVELS[i][0]);
1570 data->sf2_levels[i][0] = reg_tmp & 0x0f;
1571 data->sf2_levels[i][1] = (reg_tmp >> 4) & 0x0f;
1572 reg_tmp = w83792d_read_value(client,
1573 W83792D_REG_LEVELS[i][2]);
1574 data->sf2_levels[i][2] = (reg_tmp >> 4) & 0x0f;
1575 data->sf2_levels[i][3] = reg_tmp & 0x0f;
1576 }
1577
1578 data->last_updated = jiffies;
1579 data->valid = 1;
1580 }
1581
1582 up(&data->update_lock);
1583
1584#ifdef DEBUG
1585 w83792d_print_debug(data, dev);
1586#endif
1587
1588 return data;
1589}
1590
1591#ifdef DEBUG
1592static void w83792d_print_debug(struct w83792d_data *data, struct device *dev)
1593{
1594 int i=0, j=0;
1595 dev_dbg(dev, "==========The following is the debug message...========\n");
1596 dev_dbg(dev, "9 set of Voltages: =====>\n");
1597 for (i=0; i<9; i++) {
1598 dev_dbg(dev, "vin[%d] is: 0x%x\n", i, data->in[i]);
1599 dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]);
1600 dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]);
1601 }
1602 dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]);
1603 dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]);
1604 dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n");
1605 for (i=0; i<7; i++) {
1606 dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]);
1607 dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]);
1608 dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]);
1609 dev_dbg(dev, "pwm_mode[%d] is: 0x%x\n", i, data->pwm_mode[i]);
1610 }
1611 dev_dbg(dev, "3 set of Temperatures: =====>\n");
1612 for (i=0; i<3; i++) {
1613 dev_dbg(dev, "temp1[%d] is: 0x%x\n", i, data->temp1[i]);
1614 }
1615
1616 for (i=0; i<2; i++) {
1617 for (j=0; j<6; j++) {
1618 dev_dbg(dev, "temp_add[%d][%d] is: 0x%x\n", i, j,
1619 data->temp_add[i][j]);
1620 }
1621 }
1622
1623 for (i=0; i<7; i++) {
1624 dev_dbg(dev, "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]);
1625 }
1626 dev_dbg(dev, "==========End of the debug message...==================\n");
1627 dev_dbg(dev, "\n");
1628}
1629#endif
1630
1631static int __init
1632sensors_w83792d_init(void)
1633{
1634 return i2c_add_driver(&w83792d_driver);
1635}
1636
1637static void __exit
1638sensors_w83792d_exit(void)
1639{
1640 i2c_del_driver(&w83792d_driver);
1641}
1642
1643MODULE_AUTHOR("Chunhao Huang @ Winbond <DZShen@Winbond.com.tw>");
1644MODULE_DESCRIPTION("W83792AD/D driver for linux-2.6");
1645MODULE_LICENSE("GPL");
1646
1647module_init(sensors_w83792d_init);
1648module_exit(sensors_w83792d_exit);
1649
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 4469d52aba4c..133e34ab1d0a 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -36,7 +36,8 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c-sensor.h> 39#include <linux/hwmon.h>
40#include <linux/err.h>
40 41
41/* How many retries on register read error */ 42/* How many retries on register read error */
42#define MAX_RETRIES 5 43#define MAX_RETRIES 5
@@ -47,13 +48,12 @@
47 */ 48 */
48 49
49static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; 50static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
50static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
51 51
52/* 52/*
53 * Insmod parameters 53 * Insmod parameters
54 */ 54 */
55 55
56SENSORS_INSMOD_1(w83l785ts); 56I2C_CLIENT_INSMOD_1(w83l785ts);
57 57
58/* 58/*
59 * The W83L785TS-S registers 59 * The W83L785TS-S registers
@@ -105,6 +105,7 @@ static struct i2c_driver w83l785ts_driver = {
105 105
106struct w83l785ts_data { 106struct w83l785ts_data {
107 struct i2c_client client; 107 struct i2c_client client;
108 struct class_device *class_dev;
108 struct semaphore update_lock; 109 struct semaphore update_lock;
109 char valid; /* zero until following fields are valid */ 110 char valid; /* zero until following fields are valid */
110 unsigned long last_updated; /* in jiffies */ 111 unsigned long last_updated; /* in jiffies */
@@ -140,7 +141,7 @@ static int w83l785ts_attach_adapter(struct i2c_adapter *adapter)
140{ 141{
141 if (!(adapter->class & I2C_CLASS_HWMON)) 142 if (!(adapter->class & I2C_CLASS_HWMON))
142 return 0; 143 return 0;
143 return i2c_detect(adapter, &addr_data, w83l785ts_detect); 144 return i2c_probe(adapter, &addr_data, w83l785ts_detect);
144} 145}
145 146
146/* 147/*
@@ -239,11 +240,19 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
239 */ 240 */
240 241
241 /* Register sysfs hooks */ 242 /* Register sysfs hooks */
243 data->class_dev = hwmon_device_register(&new_client->dev);
244 if (IS_ERR(data->class_dev)) {
245 err = PTR_ERR(data->class_dev);
246 goto exit_detach;
247 }
248
242 device_create_file(&new_client->dev, &dev_attr_temp1_input); 249 device_create_file(&new_client->dev, &dev_attr_temp1_input);
243 device_create_file(&new_client->dev, &dev_attr_temp1_max); 250 device_create_file(&new_client->dev, &dev_attr_temp1_max);
244 251
245 return 0; 252 return 0;
246 253
254exit_detach:
255 i2c_detach_client(new_client);
247exit_free: 256exit_free:
248 kfree(data); 257 kfree(data);
249exit: 258exit:
@@ -252,15 +261,15 @@ exit:
252 261
253static int w83l785ts_detach_client(struct i2c_client *client) 262static int w83l785ts_detach_client(struct i2c_client *client)
254{ 263{
264 struct w83l785ts_data *data = i2c_get_clientdata(client);
255 int err; 265 int err;
256 266
257 if ((err = i2c_detach_client(client))) { 267 hwmon_device_unregister(data->class_dev);
258 dev_err(&client->dev, "Client deregistration failed, " 268
259 "client not detached.\n"); 269 if ((err = i2c_detach_client(client)))
260 return err; 270 return err;
261 }
262 271
263 kfree(i2c_get_clientdata(client)); 272 kfree(data);
264 return 0; 273 return 0;
265} 274}
266 275
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index cd170395a8c7..71c5a854ac5d 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -4,12 +4,8 @@
4 4
5obj-$(CONFIG_I2C) += i2c-core.o 5obj-$(CONFIG_I2C) += i2c-core.o
6obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o 6obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
7obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o
8obj-y += busses/ chips/ algos/ 7obj-y += busses/ chips/ algos/
9 8
10i2c-sensor-objs := i2c-sensor-detect.o i2c-sensor-vid.o
11
12
13ifeq ($(CONFIG_I2C_DEBUG_CORE),y) 9ifeq ($(CONFIG_I2C_DEBUG_CORE),y)
14EXTRA_CFLAGS += -DDEBUG 10EXTRA_CFLAGS += -DDEBUG
15endif 11endif
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index fb5b732238ed..df05df1a0ef6 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -519,8 +519,6 @@ static u32 bit_func(struct i2c_adapter *adap)
519/* -----exported algorithm data: ------------------------------------- */ 519/* -----exported algorithm data: ------------------------------------- */
520 520
521static struct i2c_algorithm i2c_bit_algo = { 521static struct i2c_algorithm i2c_bit_algo = {
522 .name = "Bit-shift algorithm",
523 .id = I2C_ALGO_BIT,
524 .master_xfer = bit_xfer, 522 .master_xfer = bit_xfer,
525 .functionality = bit_func, 523 .functionality = bit_func,
526}; 524};
@@ -541,8 +539,6 @@ int i2c_bit_add_bus(struct i2c_adapter *adap)
541 DEB2(dev_dbg(&adap->dev, "hw routines registered.\n")); 539 DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
542 540
543 /* register new adapter to i2c module... */ 541 /* register new adapter to i2c module... */
544
545 adap->id |= i2c_bit_algo.id;
546 adap->algo = &i2c_bit_algo; 542 adap->algo = &i2c_bit_algo;
547 543
548 adap->timeout = 100; /* default values, should */ 544 adap->timeout = 100; /* default values, should */
diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c
index e6cae39f47aa..2db7bfc85225 100644
--- a/drivers/i2c/algos/i2c-algo-ite.c
+++ b/drivers/i2c/algos/i2c-algo-ite.c
@@ -713,8 +713,6 @@ static u32 iic_func(struct i2c_adapter *adap)
713/* -----exported algorithm data: ------------------------------------- */ 713/* -----exported algorithm data: ------------------------------------- */
714 714
715static struct i2c_algorithm iic_algo = { 715static struct i2c_algorithm iic_algo = {
716 .name = "ITE IIC algorithm",
717 .id = I2C_ALGO_IIC,
718 .master_xfer = iic_xfer, 716 .master_xfer = iic_xfer,
719 .algo_control = algo_control, /* ioctl */ 717 .algo_control = algo_control, /* ioctl */
720 .functionality = iic_func, 718 .functionality = iic_func,
@@ -738,8 +736,6 @@ int i2c_iic_add_bus(struct i2c_adapter *adap)
738 adap->name)); 736 adap->name));
739 737
740 /* register new adapter to i2c module... */ 738 /* register new adapter to i2c module... */
741
742 adap->id |= iic_algo.id;
743 adap->algo = &iic_algo; 739 adap->algo = &iic_algo;
744 740
745 adap->timeout = 100; /* default values, should */ 741 adap->timeout = 100; /* default values, should */
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index cc3a952401f2..beb10edfe9c1 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
187 int numbytes = 0; 187 int numbytes = 0;
188 int state; 188 int state;
189 int ret; 189 int ret;
190 int timeout = 100;
190 191
191 state = pca_status(adap); 192 while ((state = pca_status(adap)) != 0xf8 && timeout--) {
192 if ( state != 0xF8 ) { 193 msleep(10);
193 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state ); 194 }
194 /* FIXME: what to do. Force stop ? */ 195 if (state != 0xf8) {
195 return -EREMOTEIO; 196 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state);
197 return -EIO;
196 } 198 }
197 199
198 DEB1("{{{ XFER %d messages\n", num); 200 DEB1("{{{ XFER %d messages\n", num);
@@ -354,8 +356,6 @@ static int pca_init(struct i2c_algo_pca_data *adap)
354} 356}
355 357
356static struct i2c_algorithm pca_algo = { 358static struct i2c_algorithm pca_algo = {
357 .name = "PCA9564 algorithm",
358 .id = I2C_ALGO_PCA,
359 .master_xfer = pca_xfer, 359 .master_xfer = pca_xfer,
360 .functionality = pca_func, 360 .functionality = pca_func,
361}; 361};
@@ -369,8 +369,6 @@ int i2c_pca_add_bus(struct i2c_adapter *adap)
369 int rval; 369 int rval;
370 370
371 /* register new adapter to i2c module... */ 371 /* register new adapter to i2c module... */
372
373 adap->id |= pca_algo.id;
374 adap->algo = &pca_algo; 372 adap->algo = &pca_algo;
375 373
376 adap->timeout = 100; /* default values, should */ 374 adap->timeout = 100; /* default values, should */
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 8d087dac32af..6e498df1f717 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -459,8 +459,6 @@ static u32 pcf_func(struct i2c_adapter *adap)
459/* -----exported algorithm data: ------------------------------------- */ 459/* -----exported algorithm data: ------------------------------------- */
460 460
461static struct i2c_algorithm pcf_algo = { 461static struct i2c_algorithm pcf_algo = {
462 .name = "PCF8584 algorithm",
463 .id = I2C_ALGO_PCF,
464 .master_xfer = pcf_xfer, 462 .master_xfer = pcf_xfer,
465 .functionality = pcf_func, 463 .functionality = pcf_func,
466}; 464};
@@ -476,8 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
476 DEB2(dev_dbg(&adap->dev, "hw routines registered.\n")); 474 DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
477 475
478 /* register new adapter to i2c module... */ 476 /* register new adapter to i2c module... */
479
480 adap->id |= pcf_algo.id;
481 adap->algo = &pcf_algo; 477 adap->algo = &pcf_algo;
482 478
483 adap->timeout = 100; /* default values, should */ 479 adap->timeout = 100; /* default values, should */
diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c
index 422721b241e5..932c4fa86c73 100644
--- a/drivers/i2c/algos/i2c-algo-sgi.c
+++ b/drivers/i2c/algos/i2c-algo-sgi.c
@@ -149,7 +149,7 @@ static int sgi_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,
149 err = i2c_write(adap, p->buf, p->len); 149 err = i2c_write(adap, p->buf, p->len);
150 } 150 }
151 151
152 return err; 152 return (err < 0) ? err : i;
153} 153}
154 154
155static u32 sgi_func(struct i2c_adapter *adap) 155static u32 sgi_func(struct i2c_adapter *adap)
@@ -158,8 +158,6 @@ static u32 sgi_func(struct i2c_adapter *adap)
158} 158}
159 159
160static struct i2c_algorithm sgi_algo = { 160static struct i2c_algorithm sgi_algo = {
161 .name = "SGI algorithm",
162 .id = I2C_ALGO_SGI,
163 .master_xfer = sgi_xfer, 161 .master_xfer = sgi_xfer,
164 .functionality = sgi_func, 162 .functionality = sgi_func,
165}; 163};
@@ -169,7 +167,6 @@ static struct i2c_algorithm sgi_algo = {
169 */ 167 */
170int i2c_sgi_add_bus(struct i2c_adapter *adap) 168int i2c_sgi_add_bus(struct i2c_adapter *adap)
171{ 169{
172 adap->id |= sgi_algo.id;
173 adap->algo = &sgi_algo; 170 adap->algo = &sgi_algo;
174 171
175 return i2c_add_adapter(adap); 172 return i2c_add_adapter(adap);
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c
index f2785499237b..8ed5ad12552f 100644
--- a/drivers/i2c/algos/i2c-algo-sibyte.c
+++ b/drivers/i2c/algos/i2c-algo-sibyte.c
@@ -135,8 +135,6 @@ static u32 bit_func(struct i2c_adapter *adap)
135/* -----exported algorithm data: ------------------------------------- */ 135/* -----exported algorithm data: ------------------------------------- */
136 136
137static struct i2c_algorithm i2c_sibyte_algo = { 137static struct i2c_algorithm i2c_sibyte_algo = {
138 .name = "SiByte algorithm",
139 .id = I2C_ALGO_SIBYTE,
140 .smbus_xfer = smbus_xfer, 138 .smbus_xfer = smbus_xfer,
141 .algo_control = algo_control, /* ioctl */ 139 .algo_control = algo_control, /* ioctl */
142 .functionality = bit_func, 140 .functionality = bit_func,
@@ -151,8 +149,6 @@ int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
151 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; 149 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
152 150
153 /* register new adapter to i2c module... */ 151 /* register new adapter to i2c module... */
154
155 i2c_adap->id |= i2c_sibyte_algo.id;
156 i2c_adap->algo = &i2c_sibyte_algo; 152 i2c_adap->algo = &i2c_sibyte_algo;
157 153
158 /* Set the frequency to 100 kHz */ 154 /* Set the frequency to 100 kHz */
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 916ba5e40a96..6e9da1372225 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -182,14 +182,8 @@ config I2C_IOP3XX
182 will be called i2c-iop3xx. 182 will be called i2c-iop3xx.
183 183
184config I2C_ISA 184config I2C_ISA
185 tristate "ISA Bus support" 185 tristate
186 depends on I2C 186 depends on I2C
187 help
188 If you say yes to this option, support will be included for i2c
189 interfaces that are on the ISA bus.
190
191 This driver can also be built as a module. If so, the module
192 will be called i2c-isa.
193 187
194config I2C_ITE 188config I2C_ITE
195 tristate "ITE I2C Adapter" 189 tristate "ITE I2C Adapter"
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index f634a0780cf0..f021acd2674e 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -472,8 +472,6 @@ static u32 ali1535_func(struct i2c_adapter *adapter)
472} 472}
473 473
474static struct i2c_algorithm smbus_algorithm = { 474static struct i2c_algorithm smbus_algorithm = {
475 .name = "Non-i2c SMBus adapter",
476 .id = I2C_ALGO_SMBUS,
477 .smbus_xfer = ali1535_access, 475 .smbus_xfer = ali1535_access,
478 .functionality = ali1535_func, 476 .functionality = ali1535_func,
479}; 477};
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index fdd881aee618..86947504aea1 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -366,8 +366,6 @@ static void ali1563_shutdown(struct pci_dev *dev)
366} 366}
367 367
368static struct i2c_algorithm ali1563_algorithm = { 368static struct i2c_algorithm ali1563_algorithm = {
369 .name = "Non-i2c SMBus adapter",
370 .id = I2C_ALGO_SMBUS,
371 .smbus_xfer = ali1563_access, 369 .smbus_xfer = ali1563_access,
372 .functionality = ali1563_func, 370 .functionality = ali1563_func,
373}; 371};
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 0f781a1a3323..b3f50bff39a0 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -462,8 +462,6 @@ static u32 ali15x3_func(struct i2c_adapter *adapter)
462} 462}
463 463
464static struct i2c_algorithm smbus_algorithm = { 464static struct i2c_algorithm smbus_algorithm = {
465 .name = "Non-I2C SMBus adapter",
466 .id = I2C_ALGO_SMBUS,
467 .smbus_xfer = ali15x3_access, 465 .smbus_xfer = ali15x3_access,
468 .functionality = ali15x3_func, 466 .functionality = ali15x3_func,
469}; 467};
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 6347ebc6fb53..6ad0603384b8 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -295,8 +295,6 @@ static u32 amd756_func(struct i2c_adapter *adapter)
295} 295}
296 296
297static struct i2c_algorithm smbus_algorithm = { 297static struct i2c_algorithm smbus_algorithm = {
298 .name = "Non-I2C SMBus adapter",
299 .id = I2C_ALGO_SMBUS,
300 .smbus_xfer = amd756_access, 298 .smbus_xfer = amd756_access,
301 .functionality = amd756_func, 299 .functionality = amd756_func,
302}; 300};
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index d6644481d2a0..45ea24ba14d5 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -323,8 +323,6 @@ static u32 amd8111_func(struct i2c_adapter *adapter)
323} 323}
324 324
325static struct i2c_algorithm smbus_algorithm = { 325static struct i2c_algorithm smbus_algorithm = {
326 .name = "Non-I2C SMBus 2.0 adapter",
327 .id = I2C_ALGO_SMBUS,
328 .smbus_xfer = amd8111_access, 326 .smbus_xfer = amd8111_access,
329 .functionality = amd8111_func, 327 .functionality = amd8111_func,
330}; 328};
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index a7ff112e49bf..d06edce03bf4 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -283,8 +283,6 @@ au1550_func(struct i2c_adapter *adap)
283} 283}
284 284
285static struct i2c_algorithm au1550_algo = { 285static struct i2c_algorithm au1550_algo = {
286 .name = "Au1550 algorithm",
287 .id = I2C_ALGO_AU1550,
288 .master_xfer = au1550_xfer, 286 .master_xfer = au1550_xfer,
289 .functionality = au1550_func, 287 .functionality = au1550_func,
290}; 288};
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 1ab41313ce51..709beab76609 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -535,8 +535,6 @@ static u32 i801_func(struct i2c_adapter *adapter)
535} 535}
536 536
537static struct i2c_algorithm smbus_algorithm = { 537static struct i2c_algorithm smbus_algorithm = {
538 .name = "Non-I2C SMBus adapter",
539 .id = I2C_ALGO_SMBUS,
540 .smbus_xfer = i801_access, 538 .smbus_xfer = i801_access,
541 .functionality = i801_func, 539 .functionality = i801_func,
542}; 540};
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 93ca36dc777e..a3ed9590f028 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -627,8 +627,6 @@ static u32 iic_func(struct i2c_adapter *adap)
627} 627}
628 628
629static struct i2c_algorithm iic_algo = { 629static struct i2c_algorithm iic_algo = {
630 .name = "IBM IIC algorithm",
631 .id = I2C_ALGO_OCP,
632 .master_xfer = iic_xfer, 630 .master_xfer = iic_xfer,
633 .functionality = iic_func 631 .functionality = iic_func
634}; 632};
@@ -727,7 +725,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
727 adap = &dev->adap; 725 adap = &dev->adap;
728 strcpy(adap->name, "IBM IIC"); 726 strcpy(adap->name, "IBM IIC");
729 i2c_set_adapdata(adap, dev); 727 i2c_set_adapdata(adap, dev);
730 adap->id = I2C_HW_OCP | iic_algo.id; 728 adap->id = I2C_HW_OCP;
731 adap->algo = &iic_algo; 729 adap->algo = &iic_algo;
732 adap->client_register = NULL; 730 adap->client_register = NULL;
733 adap->client_unregister = NULL; 731 adap->client_unregister = NULL;
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 6b682e903f09..7bd9102db701 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -399,8 +399,6 @@ iop3xx_i2c_func(struct i2c_adapter *adap)
399} 399}
400 400
401static struct i2c_algorithm iop3xx_i2c_algo = { 401static struct i2c_algorithm iop3xx_i2c_algo = {
402 .name = "IOP3xx I2C algorithm",
403 .id = I2C_ALGO_IOP3XX,
404 .master_xfer = iop3xx_i2c_master_xfer, 402 .master_xfer = iop3xx_i2c_master_xfer,
405 .algo_control = iop3xx_i2c_algo_control, 403 .algo_control = iop3xx_i2c_algo_control,
406 .functionality = iop3xx_i2c_func, 404 .functionality = iop3xx_i2c_func,
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 00e7f7157b75..bdc6806dafae 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -1,6 +1,8 @@
1/* 1/*
2 i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware 2 i2c-isa.c - an i2c-core-like thing for ISA hardware monitoring chips
3 monitoring 3 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
4
5 Based on the i2c-isa pseudo-adapter from the lm_sensors project
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 6 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
5 7
6 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
@@ -18,30 +20,36 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 21*/
20 22
21/* This implements an i2c algorithm/adapter for ISA bus. Not that this is 23/* This implements an i2c-core-like thing for ISA hardware monitoring
22 on first sight very useful; almost no functionality is preserved. 24 chips. Such chips are linked to the i2c subsystem for historical
23 Except that it makes writing drivers for chips which can be on both 25 reasons (because the early ISA hardware monitoring chips such as the
24 the SMBus and the ISA bus very much easier. See lm78.c for an example 26 LM78 had both an I2C and an ISA interface). They used to be
25 of this. */ 27 registered with the main i2c-core, but as a first step in the
28 direction of a clean separation between I2C and ISA chip drivers,
29 we now have this separate core for ISA ones. It is significantly
30 more simple than the real one, of course, because we don't have to
31 handle multiple busses: there is only one (fake) ISA adapter.
32 It is worth noting that we still rely on i2c-core for some things
33 at the moment - but hopefully this won't last. */
26 34
27#include <linux/init.h> 35#include <linux/init.h>
28#include <linux/module.h> 36#include <linux/module.h>
29#include <linux/kernel.h> 37#include <linux/kernel.h>
30#include <linux/errno.h> 38#include <linux/errno.h>
31#include <linux/i2c.h> 39#include <linux/i2c.h>
40#include <linux/i2c-isa.h>
32 41
33static u32 isa_func(struct i2c_adapter *adapter); 42static u32 isa_func(struct i2c_adapter *adapter);
34 43
35/* This is the actual algorithm we define */ 44/* This is the actual algorithm we define */
36static struct i2c_algorithm isa_algorithm = { 45static struct i2c_algorithm isa_algorithm = {
37 .name = "ISA bus algorithm",
38 .id = I2C_ALGO_ISA,
39 .functionality = isa_func, 46 .functionality = isa_func,
40}; 47};
41 48
42/* There can only be one... */ 49/* There can only be one... */
43static struct i2c_adapter isa_adapter = { 50static struct i2c_adapter isa_adapter = {
44 .owner = THIS_MODULE, 51 .owner = THIS_MODULE,
52 .id = I2C_HW_ISA,
45 .class = I2C_CLASS_HWMON, 53 .class = I2C_CLASS_HWMON,
46 .algo = &isa_algorithm, 54 .algo = &isa_algorithm,
47 .name = "ISA main adapter", 55 .name = "ISA main adapter",
@@ -53,17 +61,146 @@ static u32 isa_func(struct i2c_adapter *adapter)
53 return 0; 61 return 0;
54} 62}
55 63
64
65/* Copied from i2c-core */
66static ssize_t show_adapter_name(struct device *dev,
67 struct device_attribute *attr, char *buf)
68{
69 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
70 return sprintf(buf, "%s\n", adap->name);
71}
72static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
73
74static int i2c_isa_device_probe(struct device *dev)
75{
76 return -ENODEV;
77}
78
79static int i2c_isa_device_remove(struct device *dev)
80{
81 return 0;
82}
83
84
85/* We implement an interface which resembles i2c_{add,del}_driver,
86 but for i2c-isa drivers. We don't have to remember and handle lists
87 of drivers and adapters so this is much more simple, of course. */
88
89int i2c_isa_add_driver(struct i2c_driver *driver)
90{
91 int res;
92
93 /* Add the driver to the list of i2c drivers in the driver core */
94 driver->driver.name = driver->name;
95 driver->driver.bus = &i2c_bus_type;
96 driver->driver.probe = i2c_isa_device_probe;
97 driver->driver.remove = i2c_isa_device_remove;
98 res = driver_register(&driver->driver);
99 if (res)
100 return res;
101 dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->name);
102
103 /* Now look for clients */
104 driver->attach_adapter(&isa_adapter);
105
106 return 0;
107}
108
109int i2c_isa_del_driver(struct i2c_driver *driver)
110{
111 struct list_head *item, *_n;
112 struct i2c_client *client;
113 int res;
114
115 /* Detach all clients belonging to this one driver */
116 list_for_each_safe(item, _n, &isa_adapter.clients) {
117 client = list_entry(item, struct i2c_client, list);
118 if (client->driver != driver)
119 continue;
120 dev_dbg(&isa_adapter.dev, "Detaching client %s at 0x%x\n",
121 client->name, client->addr);
122 if ((res = driver->detach_client(client))) {
123 dev_err(&isa_adapter.dev, "Failed, driver "
124 "%s not unregistered!\n",
125 driver->name);
126 return res;
127 }
128 }
129
130 /* Get the driver off the core list */
131 driver_unregister(&driver->driver);
132 dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->name);
133
134 return 0;
135}
136
137
56static int __init i2c_isa_init(void) 138static int __init i2c_isa_init(void)
57{ 139{
58 return i2c_add_adapter(&isa_adapter); 140 init_MUTEX(&isa_adapter.clist_lock);
141 INIT_LIST_HEAD(&isa_adapter.clients);
142
143 isa_adapter.nr = ANY_I2C_ISA_BUS;
144 isa_adapter.dev.parent = &platform_bus;
145 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr);
146 isa_adapter.dev.driver = &i2c_adapter_driver;
147 isa_adapter.dev.release = &i2c_adapter_dev_release;
148 device_register(&isa_adapter.dev);
149 device_create_file(&isa_adapter.dev, &dev_attr_name);
150
151 /* Add this adapter to the i2c_adapter class */
152 memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device));
153 isa_adapter.class_dev.dev = &isa_adapter.dev;
154 isa_adapter.class_dev.class = &i2c_adapter_class;
155 strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id,
156 BUS_ID_SIZE);
157 class_device_register(&isa_adapter.class_dev);
158
159 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name);
160
161 return 0;
59} 162}
60 163
61static void __exit i2c_isa_exit(void) 164static void __exit i2c_isa_exit(void)
62{ 165{
63 i2c_del_adapter(&isa_adapter); 166#ifdef DEBUG
167 struct list_head *item, *_n;
168 struct i2c_client *client = NULL;
169#endif
170
171 /* There should be no more active client */
172#ifdef DEBUG
173 dev_dbg(&isa_adapter.dev, "Looking for clients\n");
174 list_for_each_safe(item, _n, &isa_adapter.clients) {
175 client = list_entry(item, struct i2c_client, list);
176 dev_err(&isa_adapter.dev, "Driver %s still has an active "
177 "ISA client at 0x%x\n", client->driver->name,
178 client->addr);
179 }
180 if (client != NULL)
181 return;
182#endif
183
184 /* Clean up the sysfs representation */
185 dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n");
186 init_completion(&isa_adapter.dev_released);
187 init_completion(&isa_adapter.class_dev_released);
188 class_device_unregister(&isa_adapter.class_dev);
189 device_remove_file(&isa_adapter.dev, &dev_attr_name);
190 device_unregister(&isa_adapter.dev);
191
192 /* Wait for sysfs to drop all references */
193 dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n");
194 wait_for_completion(&isa_adapter.dev_released);
195 wait_for_completion(&isa_adapter.class_dev_released);
196
197 dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name);
64} 198}
65 199
66MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); 200EXPORT_SYMBOL(i2c_isa_add_driver);
201EXPORT_SYMBOL(i2c_isa_del_driver);
202
203MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
67MODULE_DESCRIPTION("ISA bus access through i2c"); 204MODULE_DESCRIPTION("ISA bus access through i2c");
68MODULE_LICENSE("GPL"); 205MODULE_LICENSE("GPL");
69 206
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index 94ae808314f7..37b49c2daf5f 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -87,12 +87,9 @@ static const char *__kw_state_names[] = {
87}; 87};
88#endif /* DEBUG */ 88#endif /* DEBUG */
89 89
90static int probe;
91
92MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); 90MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
93MODULE_DESCRIPTION("I2C driver for Apple's Keywest"); 91MODULE_DESCRIPTION("I2C driver for Apple's Keywest");
94MODULE_LICENSE("GPL"); 92MODULE_LICENSE("GPL");
95module_param(probe, bool, 0);
96 93
97#ifdef POLLED_MODE 94#ifdef POLLED_MODE
98/* Don't schedule, the g5 fan controller is too 95/* Don't schedule, the g5 fan controller is too
@@ -498,8 +495,6 @@ keywest_func(struct i2c_adapter * adapter)
498 495
499/* For now, we only handle combined mode (smbus) */ 496/* For now, we only handle combined mode (smbus) */
500static struct i2c_algorithm keywest_algorithm = { 497static struct i2c_algorithm keywest_algorithm = {
501 .name = "Keywest i2c",
502 .id = I2C_ALGO_SMBUS,
503 .smbus_xfer = keywest_smbus_xfer, 498 .smbus_xfer = keywest_smbus_xfer,
504 .master_xfer = keywest_xfer, 499 .master_xfer = keywest_xfer,
505 .functionality = keywest_func, 500 .functionality = keywest_func,
@@ -621,7 +616,6 @@ create_iface(struct device_node *np, struct device *dev)
621 sprintf(chan->adapter.name, "%s %d", np->parent->name, i); 616 sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
622 chan->iface = iface; 617 chan->iface = iface;
623 chan->chan_no = i; 618 chan->chan_no = i;
624 chan->adapter.id = I2C_ALGO_SMBUS;
625 chan->adapter.algo = &keywest_algorithm; 619 chan->adapter.algo = &keywest_algorithm;
626 chan->adapter.algo_data = NULL; 620 chan->adapter.algo_data = NULL;
627 chan->adapter.client_register = NULL; 621 chan->adapter.client_register = NULL;
@@ -635,15 +629,6 @@ create_iface(struct device_node *np, struct device *dev)
635 chan->adapter.name); 629 chan->adapter.name);
636 i2c_set_adapdata(&chan->adapter, NULL); 630 i2c_set_adapdata(&chan->adapter, NULL);
637 } 631 }
638 if (probe) {
639 printk("Probe: ");
640 for (addr = 0x00; addr <= 0x7f; addr++) {
641 if (i2c_smbus_xfer(&chan->adapter,addr,
642 0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
643 printk("%02x ", addr);
644 }
645 printk("\n");
646 }
647 } 632 }
648 633
649 printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n", 634 printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 9ad3e9262e8a..f065583ddcf1 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -272,8 +272,6 @@ static u32 mpc_functionality(struct i2c_adapter *adap)
272} 272}
273 273
274static struct i2c_algorithm mpc_algo = { 274static struct i2c_algorithm mpc_algo = {
275 .name = "MPC algorithm",
276 .id = I2C_ALGO_MPC107,
277 .master_xfer = mpc_xfer, 275 .master_xfer = mpc_xfer,
278 .functionality = mpc_functionality, 276 .functionality = mpc_functionality,
279}; 277};
@@ -281,7 +279,7 @@ static struct i2c_algorithm mpc_algo = {
281static struct i2c_adapter mpc_ops = { 279static struct i2c_adapter mpc_ops = {
282 .owner = THIS_MODULE, 280 .owner = THIS_MODULE,
283 .name = "MPC adapter", 281 .name = "MPC adapter",
284 .id = I2C_ALGO_MPC107 | I2C_HW_MPC107, 282 .id = I2C_HW_MPC107,
285 .algo = &mpc_algo, 283 .algo = &mpc_algo,
286 .class = I2C_CLASS_HWMON, 284 .class = I2C_CLASS_HWMON,
287 .timeout = 1, 285 .timeout = 1,
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 5b852782d2f5..99abca45fece 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -423,18 +423,16 @@ static int
423mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 423mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
424{ 424{
425 struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap); 425 struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap);
426 int i, rc = 0; 426 int i, rc;
427 427
428 for (i=0; i<num; i++) 428 for (i=0; i<num; i++)
429 if ((rc = mv64xxx_i2c_execute_msg(drv_data, &msgs[i])) != 0) 429 if ((rc = mv64xxx_i2c_execute_msg(drv_data, &msgs[i])) < 0)
430 break; 430 return rc;
431 431
432 return rc; 432 return num;
433} 433}
434 434
435static struct i2c_algorithm mv64xxx_i2c_algo = { 435static struct i2c_algorithm mv64xxx_i2c_algo = {
436 .name = MV64XXX_I2C_CTLR_NAME " algorithm",
437 .id = I2C_ALGO_MV64XXX,
438 .master_xfer = mv64xxx_i2c_xfer, 436 .master_xfer = mv64xxx_i2c_xfer,
439 .functionality = mv64xxx_i2c_functionality, 437 .functionality = mv64xxx_i2c_functionality,
440}; 438};
@@ -523,7 +521,7 @@ mv64xxx_i2c_probe(struct device *dev)
523 drv_data->freq_m = pdata->freq_m; 521 drv_data->freq_m = pdata->freq_m;
524 drv_data->freq_n = pdata->freq_n; 522 drv_data->freq_n = pdata->freq_n;
525 drv_data->irq = platform_get_irq(pd, 0); 523 drv_data->irq = platform_get_irq(pd, 0);
526 drv_data->adapter.id = I2C_ALGO_MV64XXX | I2C_HW_MV64XXX; 524 drv_data->adapter.id = I2C_HW_MV64XXX;
527 drv_data->adapter.algo = &mv64xxx_i2c_algo; 525 drv_data->adapter.algo = &mv64xxx_i2c_algo;
528 drv_data->adapter.owner = THIS_MODULE; 526 drv_data->adapter.owner = THIS_MODULE;
529 drv_data->adapter.class = I2C_CLASS_HWMON; 527 drv_data->adapter.class = I2C_CLASS_HWMON;
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 74eb89aa9350..e0b7a913431e 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -110,8 +110,6 @@ static u32 nforce2_func(struct i2c_adapter *adapter);
110 110
111 111
112static struct i2c_algorithm smbus_algorithm = { 112static struct i2c_algorithm smbus_algorithm = {
113 .name = "Non-I2C SMBus adapter",
114 .id = I2C_ALGO_SMBUS,
115 .smbus_xfer = nforce2_access, 113 .smbus_xfer = nforce2_access,
116 .functionality = nforce2_func, 114 .functionality = nforce2_func,
117}; 115};
@@ -131,7 +129,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
131 struct nforce2_smbus *smbus = adap->algo_data; 129 struct nforce2_smbus *smbus = adap->algo_data;
132 unsigned char protocol, pec, temp; 130 unsigned char protocol, pec, temp;
133 unsigned char len = 0; /* to keep the compiler quiet */ 131 unsigned char len = 0; /* to keep the compiler quiet */
134 int timeout = 0;
135 int i; 132 int i;
136 133
137 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : 134 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ :
@@ -191,29 +188,10 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
191 case I2C_SMBUS_PROC_CALL: 188 case I2C_SMBUS_PROC_CALL:
192 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 189 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
193 return -1; 190 return -1;
194 /*
195 outb_p(command, NVIDIA_SMB_CMD);
196 outb_p(data->word, NVIDIA_SMB_DATA);
197 outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1);
198 protocol = NVIDIA_SMB_PRTCL_PROC_CALL | pec;
199 read_write = I2C_SMBUS_READ;
200 break;
201 */
202 191
203 case I2C_SMBUS_BLOCK_PROC_CALL: 192 case I2C_SMBUS_BLOCK_PROC_CALL:
204 dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); 193 dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n");
205 return -1; 194 return -1;
206 /*
207 protocol |= pec;
208 len = min_t(u8, data->block[0], 31);
209 outb_p(command, NVIDIA_SMB_CMD);
210 outb_p(len, NVIDIA_SMB_BCNT);
211 for (i = 0; i < len; i++)
212 outb_p(data->block[i + 1], NVIDIA_SMB_DATA + i);
213 protocol = NVIDIA_SMB_PRTCL_BLOCK_PROC_CALL | pec;
214 read_write = I2C_SMBUS_READ;
215 break;
216 */
217 195
218 case I2C_SMBUS_WORD_DATA_PEC: 196 case I2C_SMBUS_WORD_DATA_PEC:
219 case I2C_SMBUS_BLOCK_DATA_PEC: 197 case I2C_SMBUS_BLOCK_DATA_PEC:
@@ -232,12 +210,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
232 210
233 temp = inb_p(NVIDIA_SMB_STS); 211 temp = inb_p(NVIDIA_SMB_STS);
234 212
235#if 0
236 do {
237 i2c_do_pause(1);
238 temp = inb_p(NVIDIA_SMB_STS);
239 } while (((temp & NVIDIA_SMB_STS_DONE) == 0) && (timeout++ < MAX_TIMEOUT));
240#endif
241 if (~temp & NVIDIA_SMB_STS_DONE) { 213 if (~temp & NVIDIA_SMB_STS_DONE) {
242 udelay(500); 214 udelay(500);
243 temp = inb_p(NVIDIA_SMB_STS); 215 temp = inb_p(NVIDIA_SMB_STS);
@@ -247,9 +219,10 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
247 temp = inb_p(NVIDIA_SMB_STS); 219 temp = inb_p(NVIDIA_SMB_STS);
248 } 220 }
249 221
250 if ((timeout >= MAX_TIMEOUT) || (~temp & NVIDIA_SMB_STS_DONE) 222 if ((~temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) {
251 || (temp & NVIDIA_SMB_STS_STATUS)) 223 dev_dbg(&adap->dev, "SMBus Timeout! (0x%02x)\n", temp);
252 return -1; 224 return -1;
225 }
253 226
254 if (read_write == I2C_SMBUS_WRITE) 227 if (read_write == I2C_SMBUS_WRITE)
255 return 0; 228 return 0;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 6d34ee381ce1..6d48a4da7bed 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -399,8 +399,6 @@ static u32 piix4_func(struct i2c_adapter *adapter)
399} 399}
400 400
401static struct i2c_algorithm smbus_algorithm = { 401static struct i2c_algorithm smbus_algorithm = {
402 .name = "Non-I2C SMBus adapter",
403 .id = I2C_ALGO_SMBUS,
404 .smbus_xfer = piix4_access, 402 .smbus_xfer = piix4_access,
405 .functionality = piix4_func, 403 .functionality = piix4_func,
406}; 404};
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index a3b38257cc3d..73a092fb0e7e 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -568,7 +568,6 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
568/* i2c bus registration info */ 568/* i2c bus registration info */
569 569
570static struct i2c_algorithm s3c24xx_i2c_algorithm = { 570static struct i2c_algorithm s3c24xx_i2c_algorithm = {
571 .name = "S3C2410-I2C-Algorithm",
572 .master_xfer = s3c24xx_i2c_xfer, 571 .master_xfer = s3c24xx_i2c_xfer,
573 .functionality = s3c24xx_i2c_func, 572 .functionality = s3c24xx_i2c_func,
574}; 573};
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index bbd5e4e52f09..080318d6f54b 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -357,8 +357,6 @@ static u32 sis5595_func(struct i2c_adapter *adapter)
357} 357}
358 358
359static struct i2c_algorithm smbus_algorithm = { 359static struct i2c_algorithm smbus_algorithm = {
360 .name = "Non-I2C SMBus adapter",
361 .id = I2C_ALGO_SMBUS,
362 .smbus_xfer = sis5595_access, 360 .smbus_xfer = sis5595_access,
363 .functionality = sis5595_func, 361 .functionality = sis5595_func,
364}; 362};
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index f58455e7689e..86f0f448fa0b 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -448,8 +448,6 @@ exit:
448 448
449 449
450static struct i2c_algorithm smbus_algorithm = { 450static struct i2c_algorithm smbus_algorithm = {
451 .name = "Non-I2C SMBus adapter",
452 .id = I2C_ALGO_SMBUS,
453 .smbus_xfer = sis630_access, 451 .smbus_xfer = sis630_access,
454 .functionality = sis630_func, 452 .functionality = sis630_func,
455}; 453};
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 6484792e23a1..ead2ff3cf60e 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -249,8 +249,6 @@ static u32 sis96x_func(struct i2c_adapter *adapter)
249} 249}
250 250
251static struct i2c_algorithm smbus_algorithm = { 251static struct i2c_algorithm smbus_algorithm = {
252 .name = "Non-I2C SMBus adapter",
253 .id = I2C_ALGO_SMBUS,
254 .smbus_xfer = sis96x_access, 252 .smbus_xfer = sis96x_access,
255 .functionality = sis96x_func, 253 .functionality = sis96x_func,
256}; 254};
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
index 00d94e886955..73f481e93a36 100644
--- a/drivers/i2c/busses/i2c-stub.c
+++ b/drivers/i2c/busses/i2c-stub.c
@@ -109,8 +109,6 @@ static u32 stub_func(struct i2c_adapter *adapter)
109} 109}
110 110
111static struct i2c_algorithm smbus_algorithm = { 111static struct i2c_algorithm smbus_algorithm = {
112 .name = "Non-I2C SMBus adapter",
113 .id = I2C_ALGO_SMBUS,
114 .functionality = stub_func, 112 .functionality = stub_func,
115 .smbus_xfer = stub_xfer, 113 .smbus_xfer = stub_xfer,
116}; 114};
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 6b5008005c6f..99d209e0485a 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -286,8 +286,6 @@ static u32 vt596_func(struct i2c_adapter *adapter)
286} 286}
287 287
288static struct i2c_algorithm smbus_algorithm = { 288static struct i2c_algorithm smbus_algorithm = {
289 .name = "Non-I2C SMBus adapter",
290 .id = I2C_ALGO_SMBUS,
291 .smbus_xfer = vt596_access, 289 .smbus_xfer = vt596_access,
292 .functionality = vt596_func, 290 .functionality = vt596_func,
293}; 291};
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index a18bdd9aa7ba..a1d580e05361 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -395,8 +395,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter)
395 395
396/* For now, we only handle combined mode (smbus) */ 396/* For now, we only handle combined mode (smbus) */
397static struct i2c_algorithm scx200_acb_algorithm = { 397static struct i2c_algorithm scx200_acb_algorithm = {
398 .name = "NatSemi SCx200 ACCESS.bus",
399 .id = I2C_ALGO_SMBUS,
400 .smbus_xfer = scx200_acb_smbus_xfer, 398 .smbus_xfer = scx200_acb_smbus_xfer,
401 .functionality = scx200_acb_func, 399 .functionality = scx200_acb_func,
402}; 400};
@@ -456,7 +454,7 @@ static int __init scx200_acb_create(int base, int index)
456 i2c_set_adapdata(adapter, iface); 454 i2c_set_adapdata(adapter, iface);
457 snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); 455 snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index);
458 adapter->owner = THIS_MODULE; 456 adapter->owner = THIS_MODULE;
459 adapter->id = I2C_ALGO_SMBUS; 457 adapter->id = I2C_HW_SMBUS_SCX200;
460 adapter->algo = &scx200_acb_algorithm; 458 adapter->algo = &scx200_acb_algorithm;
461 adapter->class = I2C_CLASS_HWMON; 459 adapter->class = I2C_CLASS_HWMON;
462 460
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 43f70dbfc03f..6bd44a44cd28 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -2,17 +2,12 @@
2# Miscellaneous I2C chip drivers configuration 2# Miscellaneous I2C chip drivers configuration
3# 3#
4 4
5config I2C_SENSOR
6 tristate
7 default n
8
9menu "Miscellaneous I2C Chip support" 5menu "Miscellaneous I2C Chip support"
10 depends on I2C 6 depends on I2C
11 7
12config SENSORS_DS1337 8config SENSORS_DS1337
13 tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" 9 tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock"
14 depends on I2C && EXPERIMENTAL 10 depends on I2C && EXPERIMENTAL
15 select I2C_SENSOR
16 help 11 help
17 If you say yes here you get support for Dallas Semiconductor 12 If you say yes here you get support for Dallas Semiconductor
18 DS1337 and DS1339 real-time clock chips. 13 DS1337 and DS1339 real-time clock chips.
@@ -23,7 +18,6 @@ config SENSORS_DS1337
23config SENSORS_DS1374 18config SENSORS_DS1374
24 tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" 19 tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock"
25 depends on I2C && EXPERIMENTAL 20 depends on I2C && EXPERIMENTAL
26 select I2C_SENSOR
27 help 21 help
28 If you say yes here you get support for Dallas Semiconductor 22 If you say yes here you get support for Dallas Semiconductor
29 DS1374 real-time clock chips. 23 DS1374 real-time clock chips.
@@ -34,7 +28,6 @@ config SENSORS_DS1374
34config SENSORS_EEPROM 28config SENSORS_EEPROM
35 tristate "EEPROM reader" 29 tristate "EEPROM reader"
36 depends on I2C && EXPERIMENTAL 30 depends on I2C && EXPERIMENTAL
37 select I2C_SENSOR
38 help 31 help
39 If you say yes here you get read-only access to the EEPROM data 32 If you say yes here you get read-only access to the EEPROM data
40 available on modern memory DIMMs and Sony Vaio laptops. Such 33 available on modern memory DIMMs and Sony Vaio laptops. Such
@@ -46,7 +39,6 @@ config SENSORS_EEPROM
46config SENSORS_PCF8574 39config SENSORS_PCF8574
47 tristate "Philips PCF8574 and PCF8574A" 40 tristate "Philips PCF8574 and PCF8574A"
48 depends on I2C && EXPERIMENTAL 41 depends on I2C && EXPERIMENTAL
49 select I2C_SENSOR
50 help 42 help
51 If you say yes here you get support for Philips PCF8574 and 43 If you say yes here you get support for Philips PCF8574 and
52 PCF8574A chips. 44 PCF8574A chips.
@@ -67,7 +59,6 @@ config SENSORS_PCA9539
67config SENSORS_PCF8591 59config SENSORS_PCF8591
68 tristate "Philips PCF8591" 60 tristate "Philips PCF8591"
69 depends on I2C && EXPERIMENTAL 61 depends on I2C && EXPERIMENTAL
70 select I2C_SENSOR
71 help 62 help
72 If you say yes here you get support for Philips PCF8591 chips. 63 If you say yes here you get support for Philips PCF8591 chips.
73 64
@@ -77,7 +68,6 @@ config SENSORS_PCF8591
77config SENSORS_RTC8564 68config SENSORS_RTC8564
78 tristate "Epson 8564 RTC chip" 69 tristate "Epson 8564 RTC chip"
79 depends on I2C && EXPERIMENTAL 70 depends on I2C && EXPERIMENTAL
80 select I2C_SENSOR
81 help 71 help
82 If you say yes here you get support for the Epson 8564 RTC chip. 72 If you say yes here you get support for the Epson 8564 RTC chip.
83 73
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 82cf959989fd..9d3175c03395 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -17,7 +17,6 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/i2c-sensor.h>
21#include <linux/string.h> 20#include <linux/string.h>
22#include <linux/rtc.h> /* get the user-level API */ 21#include <linux/rtc.h> /* get the user-level API */
23#include <linux/bcd.h> 22#include <linux/bcd.h>
@@ -39,9 +38,8 @@
39 * Functions declaration 38 * Functions declaration
40 */ 39 */
41static unsigned short normal_i2c[] = { 0x68, I2C_CLIENT_END }; 40static unsigned short normal_i2c[] = { 0x68, I2C_CLIENT_END };
42static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
43 41
44SENSORS_INSMOD_1(ds1337); 42I2C_CLIENT_INSMOD_1(ds1337);
45 43
46static int ds1337_attach_adapter(struct i2c_adapter *adapter); 44static int ds1337_attach_adapter(struct i2c_adapter *adapter);
47static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind); 45static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind);
@@ -227,7 +225,7 @@ int ds1337_do_command(int bus, int cmd, void *arg)
227 225
228static int ds1337_attach_adapter(struct i2c_adapter *adapter) 226static int ds1337_attach_adapter(struct i2c_adapter *adapter)
229{ 227{
230 return i2c_detect(adapter, &addr_data, ds1337_detect); 228 return i2c_probe(adapter, &addr_data, ds1337_detect);
231} 229}
232 230
233/* 231/*
@@ -354,11 +352,8 @@ static int ds1337_detach_client(struct i2c_client *client)
354 int err; 352 int err;
355 struct ds1337_data *data = i2c_get_clientdata(client); 353 struct ds1337_data *data = i2c_get_clientdata(client);
356 354
357 if ((err = i2c_detach_client(client))) { 355 if ((err = i2c_detach_client(client)))
358 dev_err(&client->dev, "Client deregistration failed, "
359 "client not detached.\n");
360 return err; 356 return err;
361 }
362 357
363 list_del(&data->list); 358 list_del(&data->list);
364 kfree(data); 359 kfree(data);
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index a445736d8838..0936327a946d 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -53,7 +53,6 @@ static struct i2c_client_address_data addr_data = {
53 .normal_i2c = normal_addr, 53 .normal_i2c = normal_addr,
54 .probe = ignore, 54 .probe = ignore,
55 .ignore = ignore, 55 .ignore = ignore,
56 .force = ignore,
57}; 56};
58 57
59static ulong ds1374_read_rtc(void) 58static ulong ds1374_read_rtc(void)
@@ -166,7 +165,7 @@ static void ds1374_set_tlet(ulong arg)
166 "can't confirm time set from rtc chip\n"); 165 "can't confirm time set from rtc chip\n");
167} 166}
168 167
169ulong new_time; 168static ulong new_time;
170 169
171DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); 170DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time);
172 171
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index a2da31b0dd7b..d58403a47908 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -33,15 +33,13 @@
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/jiffies.h> 34#include <linux/jiffies.h>
35#include <linux/i2c.h> 35#include <linux/i2c.h>
36#include <linux/i2c-sensor.h>
37 36
38/* Addresses to scan */ 37/* Addresses to scan */
39static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, 38static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
40 0x55, 0x56, 0x57, I2C_CLIENT_END }; 39 0x55, 0x56, 0x57, I2C_CLIENT_END };
41static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
42 40
43/* Insmod parameters */ 41/* Insmod parameters */
44SENSORS_INSMOD_1(eeprom); 42I2C_CLIENT_INSMOD_1(eeprom);
45 43
46 44
47/* Size of EEPROM in bytes */ 45/* Size of EEPROM in bytes */
@@ -153,21 +151,16 @@ static struct bin_attribute eeprom_attr = {
153 151
154static int eeprom_attach_adapter(struct i2c_adapter *adapter) 152static int eeprom_attach_adapter(struct i2c_adapter *adapter)
155{ 153{
156 return i2c_detect(adapter, &addr_data, eeprom_detect); 154 return i2c_probe(adapter, &addr_data, eeprom_detect);
157} 155}
158 156
159/* This function is called by i2c_detect */ 157/* This function is called by i2c_probe */
160int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) 158int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
161{ 159{
162 struct i2c_client *new_client; 160 struct i2c_client *new_client;
163 struct eeprom_data *data; 161 struct eeprom_data *data;
164 int err = 0; 162 int err = 0;
165 163
166 /* prevent 24RF08 corruption */
167 if (kind < 0)
168 i2c_smbus_xfer(adapter, address, 0, 0, 0,
169 I2C_SMBUS_QUICK, NULL);
170
171 /* There are three ways we can read the EEPROM data: 164 /* There are three ways we can read the EEPROM data:
172 (1) I2C block reads (faster, but unsupported by most adapters) 165 (1) I2C block reads (faster, but unsupported by most adapters)
173 (2) Consecutive byte reads (100% overhead) 166 (2) Consecutive byte reads (100% overhead)
@@ -231,10 +224,8 @@ static int eeprom_detach_client(struct i2c_client *client)
231 int err; 224 int err;
232 225
233 err = i2c_detach_client(client); 226 err = i2c_detach_client(client);
234 if (err) { 227 if (err)
235 dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
236 return err; 228 return err;
237 }
238 229
239 kfree(i2c_get_clientdata(client)); 230 kfree(i2c_get_clientdata(client));
240 231
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 778d7e12859d..3f14528a52a9 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -42,7 +42,6 @@ static struct i2c_client_address_data addr_data = {
42 .normal_i2c = normal_addr, 42 .normal_i2c = normal_addr,
43 .probe = ignore, 43 .probe = ignore,
44 .ignore = ignore, 44 .ignore = ignore,
45 .force = ignore,
46}; 45};
47 46
48ulong 47ulong
@@ -145,7 +144,7 @@ m41t00_set_tlet(ulong arg)
145 return; 144 return;
146} 145}
147 146
148ulong new_time; 147static ulong new_time;
149 148
150DECLARE_TASKLET_DISABLED(m41t00_tasklet, m41t00_set_tlet, (ulong)&new_time); 149DECLARE_TASKLET_DISABLED(m41t00_tasklet, m41t00_set_tlet, (ulong)&new_time);
151 150
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index 0230375f72e5..9e1aeb69abf9 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -5,97 +5,60 @@
5 5
6 Based on i2c/chips/eeprom.c 6 Based on i2c/chips/eeprom.c
7 7
8 The MAX6875 has two EEPROM sections: config and user. 8 The MAX6875 has a bank of registers and two banks of EEPROM.
9 At reset, the config EEPROM is read into the registers. 9 Address ranges are defined as follows:
10 * 0x0000 - 0x0046 = configuration registers
11 * 0x8000 - 0x8046 = configuration EEPROM
12 * 0x8100 - 0x82FF = user EEPROM
10 13
11 This driver make 3 binary files available in sysfs: 14 This driver makes the user EEPROM available for read.
12 reg_config - direct access to the registers
13 eeprom_config - acesses configuration eeprom space
14 eeprom_user - free for application use
15 15
16 In our application, we put device serial & model numbers in user eeprom. 16 The registers & config EEPROM should be accessed via i2c-dev.
17 17
18 Notes: 18 The MAX6875 ignores the lowest address bit, so each chip responds to
19 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT 19 two addresses - 0x50/0x51 and 0x52/0x53.
20 be overwritten, so the driver explicitly prevents that. 20
21 2) It's a good idea to keep the config (0x45) locked in config EEPROM. 21 Note that the MAX6875 uses i2c_smbus_write_byte_data() to set the read
22 You can temporarily enable config writes by changing register 0x45. 22 address, so this driver is destructive if loaded for the wrong EEPROM chip.
23 23
24 This program is free software; you can redistribute it and/or modify 24 This program is free software; you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by 25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation; version 2 of the License. 26 the Free Software Foundation; version 2 of the License.
27*/ 27*/
28 28
29#include <linux/config.h>
30#include <linux/kernel.h> 29#include <linux/kernel.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
34#include <linux/sched.h>
35#include <linux/delay.h>
36#include <linux/i2c.h> 33#include <linux/i2c.h>
37#include <linux/i2c-sensor.h> 34#include <asm/semaphore.h>
38 35
39/* Addresses to scan */ 36/* Do not scan - the MAX6875 access method will write to some EEPROM chips */
40/* No address scanned by default, as this could corrupt standard EEPROMS. */
41static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 37static unsigned short normal_i2c[] = {I2C_CLIENT_END};
42static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
43 38
44/* Insmod parameters */ 39/* Insmod parameters */
45SENSORS_INSMOD_1(max6875); 40I2C_CLIENT_INSMOD_1(max6875);
46
47/* this param will prevent 'accidental' writes to the eeprom */
48static int allow_write = 0;
49module_param(allow_write, int, 0);
50MODULE_PARM_DESC(allow_write,
51 "Enable write access:\n"
52 "*0: Read only\n"
53 " 1: Read/Write access");
54 41
55/* The MAX6875 can only read/write 16 bytes at a time */ 42/* The MAX6875 can only read/write 16 bytes at a time */
56#define SLICE_SIZE 16 43#define SLICE_SIZE 16
57#define SLICE_BITS 4 44#define SLICE_BITS 4
58 45
59/* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */
60#define CONFIG_EEPROM_BASE 0x8000
61#define CONFIG_EEPROM_SIZE 0x0046
62#define CONFIG_EEPROM_SLICES 5
63
64/* USER EEPROM is at addresses 0x8100 - 0x82FF */ 46/* USER EEPROM is at addresses 0x8100 - 0x82FF */
65#define USER_EEPROM_BASE 0x8100 47#define USER_EEPROM_BASE 0x8100
66#define USER_EEPROM_SIZE 0x0200 48#define USER_EEPROM_SIZE 0x0200
67#define USER_EEPROM_SLICES 32 49#define USER_EEPROM_SLICES 32
68 50
69/* MAX6875 commands */ 51/* MAX6875 commands */
70#define MAX6875_CMD_BLOCK_WRITE 0x83 52#define MAX6875_CMD_BLK_READ 0x84
71#define MAX6875_CMD_BLOCK_READ 0x84
72#define MAX6875_CMD_REBOOT 0x88
73
74enum max6875_area_type {
75 max6875_register_config=0,
76 max6875_eeprom_config,
77 max6875_eeprom_user,
78 max6857_max
79};
80
81struct eeprom_block {
82 enum max6875_area_type type;
83 u8 slices;
84 u32 size;
85 u32 valid;
86 u32 base;
87 unsigned long *updated;
88 u8 *data;
89};
90 53
91/* Each client has this additional data */ 54/* Each client has this additional data */
92struct max6875_data { 55struct max6875_data {
93 struct i2c_client client; 56 struct i2c_client client;
94 struct semaphore update_lock; 57 struct semaphore update_lock;
95 struct eeprom_block blocks[max6857_max]; 58
96 /* the above structs point into the arrays below */ 59 u32 valid;
97 u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)]; 60 u8 data[USER_EEPROM_SIZE];
98 unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)]; 61 unsigned long last_updated[USER_EEPROM_SLICES];
99}; 62};
100 63
101static int max6875_attach_adapter(struct i2c_adapter *adapter); 64static int max6875_attach_adapter(struct i2c_adapter *adapter);
@@ -111,337 +74,160 @@ static struct i2c_driver max6875_driver = {
111 .detach_client = max6875_detach_client, 74 .detach_client = max6875_detach_client,
112}; 75};
113 76
114static int max6875_update_slice(struct i2c_client *client, 77static void max6875_update_slice(struct i2c_client *client, int slice)
115 struct eeprom_block *blk,
116 int slice)
117{ 78{
118 struct max6875_data *data = i2c_get_clientdata(client); 79 struct max6875_data *data = i2c_get_clientdata(client);
119 int i, j, addr, count; 80 int i, j, addr;
120 u8 rdbuf[SLICE_SIZE]; 81 u8 *buf;
121 int retval = 0;
122 82
123 if (slice >= blk->slices) 83 if (slice >= USER_EEPROM_SLICES)
124 return -1; 84 return;
125 85
126 down(&data->update_lock); 86 down(&data->update_lock);
127 87
128 if (!(blk->valid & (1 << slice)) || 88 buf = &data->data[slice << SLICE_BITS];
129 (jiffies - blk->updated[slice] > 300 * HZ) ||
130 (jiffies < blk->updated[slice])) {
131 dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n",
132 slice, blk->base);
133 89
134 addr = blk->base + (slice << SLICE_BITS); 90 if (!(data->valid & (1 << slice)) ||
135 count = blk->size - (slice << SLICE_BITS); 91 time_after(jiffies, data->last_updated[slice])) {
136 if (count > SLICE_SIZE) {
137 count = SLICE_SIZE;
138 }
139 92
140 /* Preset the read address */ 93 dev_dbg(&client->dev, "Starting update of slice %u\n", slice);
141 if (addr < 0x100) { 94
142 /* select the register */ 95 data->valid &= ~(1 << slice);
143 if (i2c_smbus_write_byte(client, addr & 0xFF)) { 96
144 dev_dbg(&client->dev, "max6875 register select has failed!\n"); 97 addr = USER_EEPROM_BASE + (slice << SLICE_BITS);
145 retval = -1; 98
146 goto exit; 99 /* select the eeprom address */
147 } 100 if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) {
148 } else { 101 dev_err(&client->dev, "address set failed\n");
149 /* select the eeprom */ 102 goto exit_up;
150 if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) {
151 dev_dbg(&client->dev, "max6875 address set has failed!\n");
152 retval = -1;
153 goto exit;
154 }
155 } 103 }
156 104
157 if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 105 if (i2c_check_functionality(client->adapter,
158 if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ, 106 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
159 rdbuf) != SLICE_SIZE) 107 if (i2c_smbus_read_i2c_block_data(client,
160 { 108 MAX6875_CMD_BLK_READ,
161 retval = -1; 109 buf) != SLICE_SIZE) {
162 goto exit; 110 goto exit_up;
163 } 111 }
164
165 memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count);
166 } else { 112 } else {
167 for (i = 0; i < count; i++) { 113 for (i = 0; i < SLICE_SIZE; i++) {
168 j = i2c_smbus_read_byte(client); 114 j = i2c_smbus_read_byte(client);
169 if (j < 0) 115 if (j < 0) {
170 { 116 goto exit_up;
171 retval = -1;
172 goto exit;
173 } 117 }
174 blk->data[(slice << SLICE_BITS) + i] = (u8) j; 118 buf[i] = j;
175 } 119 }
176 } 120 }
177 blk->updated[slice] = jiffies; 121 data->last_updated[slice] = jiffies;
178 blk->valid |= (1 << slice); 122 data->valid |= (1 << slice);
179 } 123 }
180 exit: 124exit_up:
181 up(&data->update_lock); 125 up(&data->update_lock);
182 return retval;
183} 126}
184 127
185static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count, 128static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off,
186 enum max6875_area_type area_type) 129 size_t count)
187{ 130{
188 struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); 131 struct i2c_client *client = kobj_to_i2c_client(kobj);
189 struct max6875_data *data = i2c_get_clientdata(client); 132 struct max6875_data *data = i2c_get_clientdata(client);
190 struct eeprom_block *blk; 133 int slice, max_slice;
191 int slice;
192
193 blk = &data->blocks[area_type];
194 134
195 if (off > blk->size) 135 if (off > USER_EEPROM_SIZE)
196 return 0; 136 return 0;
197 if (off + count > blk->size)
198 count = blk->size - off;
199 137
200 /* Only refresh slices which contain requested bytes */ 138 if (off + count > USER_EEPROM_SIZE)
201 for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) 139 count = USER_EEPROM_SIZE - off;
202 max6875_update_slice(client, blk, slice);
203 140
204 memcpy(buf, &blk->data[off], count); 141 /* refresh slices which contain requested bytes */
142 max_slice = (off + count - 1) >> SLICE_BITS;
143 for (slice = (off >> SLICE_BITS); slice <= max_slice; slice++)
144 max6875_update_slice(client, slice);
205 145
206 return count; 146 memcpy(buf, &data->data[off], count);
207}
208
209static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
210{
211 return max6875_read(kobj, buf, off, count, max6875_eeprom_user);
212}
213
214static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
215{
216 return max6875_read(kobj, buf, off, count, max6875_eeprom_config);
217}
218
219static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
220{
221 return max6875_read(kobj, buf, off, count, max6875_register_config);
222}
223
224
225static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count,
226 enum max6875_area_type area_type)
227{
228 struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
229 struct max6875_data *data = i2c_get_clientdata(client);
230 struct eeprom_block *blk;
231 int slice, addr, retval;
232 ssize_t sent = 0;
233
234 blk = &data->blocks[area_type];
235
236 if (off > blk->size)
237 return 0;
238 if ((off + count) > blk->size)
239 count = blk->size - off;
240
241 if (down_interruptible(&data->update_lock))
242 return -EAGAIN;
243
244 /* writing to a register is done with i2c_smbus_write_byte_data() */
245 if (blk->type == max6875_register_config) {
246 for (sent = 0; sent < count; sent++) {
247 addr = off + sent;
248 if (addr == 0x44)
249 continue;
250
251 retval = i2c_smbus_write_byte_data(client, addr, buf[sent]);
252 }
253 } else {
254 int cmd, val;
255
256 /* We are writing to EEPROM */
257 for (sent = 0; sent < count; sent++) {
258 addr = blk->base + off + sent;
259 cmd = addr >> 8;
260 val = (addr & 0xff) | (buf[sent] << 8); // reversed
261
262 if (addr == 0x8044)
263 continue;
264
265 retval = i2c_smbus_write_word_data(client, cmd, val);
266
267 if (retval) {
268 goto error_exit;
269 }
270 147
271 /* A write takes up to 11 ms */ 148 return count;
272 msleep(11);
273 }
274 }
275
276 /* Invalidate the scratch buffer */
277 for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)
278 blk->valid &= ~(1 << slice);
279
280 error_exit:
281 up(&data->update_lock);
282
283 return sent;
284}
285
286static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
287{
288 return max6875_write(kobj, buf, off, count, max6875_eeprom_user);
289}
290
291static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
292{
293 return max6875_write(kobj, buf, off, count, max6875_eeprom_config);
294}
295
296static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
297{
298 return max6875_write(kobj, buf, off, count, max6875_register_config);
299} 149}
300 150
301static struct bin_attribute user_eeprom_attr = { 151static struct bin_attribute user_eeprom_attr = {
302 .attr = { 152 .attr = {
303 .name = "eeprom_user", 153 .name = "eeprom",
304 .mode = S_IRUGO | S_IWUSR | S_IWGRP, 154 .mode = S_IRUGO,
305 .owner = THIS_MODULE,
306 },
307 .size = USER_EEPROM_SIZE,
308 .read = max6875_user_read,
309 .write = max6875_user_write,
310};
311
312static struct bin_attribute config_eeprom_attr = {
313 .attr = {
314 .name = "eeprom_config",
315 .mode = S_IRUGO | S_IWUSR,
316 .owner = THIS_MODULE,
317 },
318 .size = CONFIG_EEPROM_SIZE,
319 .read = max6875_config_read,
320 .write = max6875_config_write,
321};
322
323static struct bin_attribute config_register_attr = {
324 .attr = {
325 .name = "reg_config",
326 .mode = S_IRUGO | S_IWUSR,
327 .owner = THIS_MODULE, 155 .owner = THIS_MODULE,
328 }, 156 },
329 .size = CONFIG_EEPROM_SIZE, 157 .size = USER_EEPROM_SIZE,
330 .read = max6875_cfgreg_read, 158 .read = max6875_read,
331 .write = max6875_cfgreg_write,
332}; 159};
333 160
334static int max6875_attach_adapter(struct i2c_adapter *adapter) 161static int max6875_attach_adapter(struct i2c_adapter *adapter)
335{ 162{
336 return i2c_detect(adapter, &addr_data, max6875_detect); 163 return i2c_probe(adapter, &addr_data, max6875_detect);
337} 164}
338 165
339/* This function is called by i2c_detect */ 166/* This function is called by i2c_probe */
340static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) 167static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
341{ 168{
342 struct i2c_client *new_client; 169 struct i2c_client *real_client;
170 struct i2c_client *fake_client;
343 struct max6875_data *data; 171 struct max6875_data *data;
344 int err = 0; 172 int err = 0;
345 173
346 /* Prevent 24RF08 corruption (in case of user error) */ 174 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA
347 if (kind < 0) 175 | I2C_FUNC_SMBUS_READ_BYTE))
348 i2c_smbus_xfer(adapter, address, 0, 0, 0, 176 return 0;
349 I2C_SMBUS_QUICK, NULL); 177
350 178 /* Only check even addresses */
351 /* There are three ways we can read the EEPROM data: 179 if (address & 1)
352 (1) I2C block reads (faster, but unsupported by most adapters) 180 return 0;
353 (2) Consecutive byte reads (100% overhead) 181
354 (3) Regular byte data reads (200% overhead) 182 if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL)))
355 The third method is not implemented by this driver because all 183 return -ENOMEM;
356 known adapters support at least the second. */
357 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA |
358 I2C_FUNC_SMBUS_BYTE |
359 I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
360 goto exit;
361
362 /* OK. For now, we presume we have a valid client. We now create the
363 client structure, even though we cannot fill it completely yet.
364 But it allows us to access eeprom_{read,write}_value. */
365 if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) {
366 err = -ENOMEM;
367 goto exit;
368 }
369 memset(data, 0, sizeof(struct max6875_data)); 184 memset(data, 0, sizeof(struct max6875_data));
370 185
371 new_client = &data->client; 186 /* A fake client is created on the odd address */
372 i2c_set_clientdata(new_client, data); 187 if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
373 new_client->addr = address; 188 err = -ENOMEM;
374 new_client->adapter = adapter; 189 goto exit_kfree1;
375 new_client->driver = &max6875_driver; 190 }
376 new_client->flags = 0; 191 memset(fake_client, 0, sizeof(struct i2c_client));
377 192
378 /* Setup the user section */ 193 /* Init real i2c_client */
379 data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; 194 real_client = &data->client;
380 data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; 195 i2c_set_clientdata(real_client, data);
381 data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE; 196 real_client->addr = address;
382 data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE; 197 real_client->adapter = adapter;
383 data->blocks[max6875_eeprom_user].data = data->data; 198 real_client->driver = &max6875_driver;
384 data->blocks[max6875_eeprom_user].updated = data->last_updated; 199 real_client->flags = 0;
385 200 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
386 /* Setup the config section */
387 data->blocks[max6875_eeprom_config].type = max6875_eeprom_config;
388 data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES;
389 data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE;
390 data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE;
391 data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE];
392 data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES];
393
394 /* Setup the register section */
395 data->blocks[max6875_register_config].type = max6875_register_config;
396 data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES;
397 data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE;
398 data->blocks[max6875_register_config].base = 0;
399 data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE];
400 data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES];
401
402 /* Init the data */
403 memset(data->data, 0xff, sizeof(data->data));
404
405 /* Fill in the remaining client fields */
406 strlcpy(new_client->name, "max6875", I2C_NAME_SIZE);
407 init_MUTEX(&data->update_lock); 201 init_MUTEX(&data->update_lock);
408 202
409 /* Verify that the chip is really what we think it is */ 203 /* Init fake client data */
410 if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) || 204 /* set the client data to the i2c_client so that it will get freed */
411 (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0)) 205 i2c_set_clientdata(fake_client, fake_client);
412 goto exit_kfree; 206 fake_client->addr = address | 1;
413 207 fake_client->adapter = adapter;
414 /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */ 208 fake_client->driver = &max6875_driver;
415 if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) || 209 fake_client->flags = 0;
416 (data->blocks[max6875_eeprom_config].data[0x42] != 0) || 210 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE);
417 (data->blocks[max6875_register_config].data[0x41] != 0) || 211
418 (data->blocks[max6875_register_config].data[0x42] != 0) || 212 /* Prevent 24RF08 corruption (in case of user error) */
419 (data->blocks[max6875_eeprom_config].data[0x40] != 213 i2c_smbus_write_quick(real_client, 0);
420 data->blocks[max6875_register_config].data[0x40])) 214
421 goto exit_kfree; 215 if ((err = i2c_attach_client(real_client)) != 0)
422 216 goto exit_kfree2;
423 /* Tell the I2C layer a new client has arrived */ 217
424 if ((err = i2c_attach_client(new_client))) 218 if ((err = i2c_attach_client(fake_client)) != 0)
425 goto exit_kfree; 219 goto exit_detach;
426 220
427 /* create the sysfs eeprom files with the correct permissions */ 221 sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr);
428 if (allow_write == 0) {
429 user_eeprom_attr.attr.mode &= ~S_IWUGO;
430 user_eeprom_attr.write = NULL;
431 config_eeprom_attr.attr.mode &= ~S_IWUGO;
432 config_eeprom_attr.write = NULL;
433 config_register_attr.attr.mode &= ~S_IWUGO;
434 config_register_attr.write = NULL;
435 }
436 sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr);
437 sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr);
438 sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr);
439 222
440 return 0; 223 return 0;
441 224
442exit_kfree: 225exit_detach:
226 i2c_detach_client(real_client);
227exit_kfree2:
228 kfree(fake_client);
229exit_kfree1:
443 kfree(data); 230 kfree(data);
444exit:
445 return err; 231 return err;
446} 232}
447 233
@@ -450,13 +236,9 @@ static int max6875_detach_client(struct i2c_client *client)
450 int err; 236 int err;
451 237
452 err = i2c_detach_client(client); 238 err = i2c_detach_client(client);
453 if (err) { 239 if (err)
454 dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
455 return err; 240 return err;
456 }
457
458 kfree(i2c_get_clientdata(client)); 241 kfree(i2c_get_clientdata(client));
459
460 return 0; 242 return 0;
461} 243}
462 244
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index 9f3ad45daae2..225577fdda4d 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -13,14 +13,12 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/hwmon-sysfs.h> 15#include <linux/hwmon-sysfs.h>
16#include <linux/i2c-sensor.h>
17 16
18/* Addresses to scan */ 17/* Addresses to scan */
19static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END}; 18static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END};
20static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
21 19
22/* Insmod parameters */ 20/* Insmod parameters */
23SENSORS_INSMOD_1(pca9539); 21I2C_CLIENT_INSMOD_1(pca9539);
24 22
25enum pca9539_cmd 23enum pca9539_cmd
26{ 24{
@@ -109,10 +107,10 @@ static struct attribute_group pca9539_defattr_group = {
109 107
110static int pca9539_attach_adapter(struct i2c_adapter *adapter) 108static int pca9539_attach_adapter(struct i2c_adapter *adapter)
111{ 109{
112 return i2c_detect(adapter, &addr_data, pca9539_detect); 110 return i2c_probe(adapter, &addr_data, pca9539_detect);
113} 111}
114 112
115/* This function is called by i2c_detect */ 113/* This function is called by i2c_probe */
116static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) 114static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
117{ 115{
118 struct i2c_client *new_client; 116 struct i2c_client *new_client;
@@ -164,10 +162,8 @@ static int pca9539_detach_client(struct i2c_client *client)
164{ 162{
165 int err; 163 int err;
166 164
167 if ((err = i2c_detach_client(client))) { 165 if ((err = i2c_detach_client(client)))
168 dev_err(&client->dev, "Client deregistration failed.\n");
169 return err; 166 return err;
170 }
171 167
172 kfree(i2c_get_clientdata(client)); 168 kfree(i2c_get_clientdata(client));
173 return 0; 169 return 0;
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index cfcf64654080..6525743ff9fd 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -39,16 +39,14 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/i2c.h> 41#include <linux/i2c.h>
42#include <linux/i2c-sensor.h>
43 42
44/* Addresses to scan */ 43/* Addresses to scan */
45static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 44static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
46 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 45 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
47 I2C_CLIENT_END }; 46 I2C_CLIENT_END };
48static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
49 47
50/* Insmod parameters */ 48/* Insmod parameters */
51SENSORS_INSMOD_2(pcf8574, pcf8574a); 49I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a);
52 50
53/* Initial values */ 51/* Initial values */
54#define PCF8574_INIT 255 /* All outputs on (input mode) */ 52#define PCF8574_INIT 255 /* All outputs on (input mode) */
@@ -113,10 +111,10 @@ static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write);
113 111
114static int pcf8574_attach_adapter(struct i2c_adapter *adapter) 112static int pcf8574_attach_adapter(struct i2c_adapter *adapter)
115{ 113{
116 return i2c_detect(adapter, &addr_data, pcf8574_detect); 114 return i2c_probe(adapter, &addr_data, pcf8574_detect);
117} 115}
118 116
119/* This function is called by i2c_detect */ 117/* This function is called by i2c_probe */
120int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) 118int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
121{ 119{
122 struct i2c_client *new_client; 120 struct i2c_client *new_client;
@@ -186,11 +184,8 @@ static int pcf8574_detach_client(struct i2c_client *client)
186{ 184{
187 int err; 185 int err;
188 186
189 if ((err = i2c_detach_client(client))) { 187 if ((err = i2c_detach_client(client)))
190 dev_err(&client->dev,
191 "Client deregistration failed, client not detached.\n");
192 return err; 188 return err;
193 }
194 189
195 kfree(i2c_get_clientdata(client)); 190 kfree(i2c_get_clientdata(client));
196 return 0; 191 return 0;
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index db812ade8564..80f1df9a4500 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -24,15 +24,13 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/i2c-sensor.h>
28 27
29/* Addresses to scan */ 28/* Addresses to scan */
30static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 29static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
31 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 30 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
32static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
33 31
34/* Insmod parameters */ 32/* Insmod parameters */
35SENSORS_INSMOD_1(pcf8591); 33I2C_CLIENT_INSMOD_1(pcf8591);
36 34
37static int input_mode; 35static int input_mode;
38module_param(input_mode, int, 0); 36module_param(input_mode, int, 0);
@@ -164,10 +162,10 @@ static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
164 */ 162 */
165static int pcf8591_attach_adapter(struct i2c_adapter *adapter) 163static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
166{ 164{
167 return i2c_detect(adapter, &addr_data, pcf8591_detect); 165 return i2c_probe(adapter, &addr_data, pcf8591_detect);
168} 166}
169 167
170/* This function is called by i2c_detect */ 168/* This function is called by i2c_probe */
171int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) 169int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
172{ 170{
173 struct i2c_client *new_client; 171 struct i2c_client *new_client;
@@ -241,11 +239,8 @@ static int pcf8591_detach_client(struct i2c_client *client)
241{ 239{
242 int err; 240 int err;
243 241
244 if ((err = i2c_detach_client(client))) { 242 if ((err = i2c_detach_client(client)))
245 dev_err(&client->dev,
246 "Client deregistration failed, client not detached.\n");
247 return err; 243 return err;
248 }
249 244
250 kfree(i2c_get_clientdata(client)); 245 kfree(i2c_get_clientdata(client));
251 return 0; 246 return 0;
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index 588fc2261a91..0b5385c892b1 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -67,7 +67,6 @@ static struct i2c_client_address_data addr_data = {
67 .normal_i2c = normal_addr, 67 .normal_i2c = normal_addr,
68 .probe = ignore, 68 .probe = ignore,
69 .ignore = ignore, 69 .ignore = ignore,
70 .force = ignore,
71}; 70};
72 71
73static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem); 72static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 4a9ead277596..dda472e5e8be 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -61,7 +61,7 @@ static int i2c_bus_resume(struct device * dev)
61 return rc; 61 return rc;
62} 62}
63 63
64static struct bus_type i2c_bus_type = { 64struct bus_type i2c_bus_type = {
65 .name = "i2c", 65 .name = "i2c",
66 .match = i2c_device_match, 66 .match = i2c_device_match,
67 .suspend = i2c_bus_suspend, 67 .suspend = i2c_bus_suspend,
@@ -78,13 +78,13 @@ static int i2c_device_remove(struct device *dev)
78 return 0; 78 return 0;
79} 79}
80 80
81static void i2c_adapter_dev_release(struct device *dev) 81void i2c_adapter_dev_release(struct device *dev)
82{ 82{
83 struct i2c_adapter *adap = dev_to_i2c_adapter(dev); 83 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
84 complete(&adap->dev_released); 84 complete(&adap->dev_released);
85} 85}
86 86
87static struct device_driver i2c_adapter_driver = { 87struct device_driver i2c_adapter_driver = {
88 .name = "i2c_adapter", 88 .name = "i2c_adapter",
89 .bus = &i2c_bus_type, 89 .bus = &i2c_bus_type,
90 .probe = i2c_device_probe, 90 .probe = i2c_device_probe,
@@ -97,7 +97,7 @@ static void i2c_adapter_class_dev_release(struct class_device *dev)
97 complete(&adap->class_dev_released); 97 complete(&adap->class_dev_released);
98} 98}
99 99
100static struct class i2c_adapter_class = { 100struct class i2c_adapter_class = {
101 .name = "i2c-adapter", 101 .name = "i2c-adapter",
102 .release = &i2c_adapter_class_dev_release, 102 .release = &i2c_adapter_class_dev_release,
103}; 103};
@@ -188,6 +188,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
188 strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); 188 strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE);
189 class_device_register(&adap->class_dev); 189 class_device_register(&adap->class_dev);
190 190
191 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
192
191 /* inform drivers of new adapters */ 193 /* inform drivers of new adapters */
192 list_for_each(item,&drivers) { 194 list_for_each(item,&drivers) {
193 driver = list_entry(item, struct i2c_driver, list); 195 driver = list_entry(item, struct i2c_driver, list);
@@ -196,8 +198,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
196 driver->attach_adapter(adap); 198 driver->attach_adapter(adap);
197 } 199 }
198 200
199 dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr);
200
201out_unlock: 201out_unlock:
202 up(&core_lists); 202 up(&core_lists);
203 return res; 203 return res;
@@ -220,8 +220,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
220 break; 220 break;
221 } 221 }
222 if (adap_from_list != adap) { 222 if (adap_from_list != adap) {
223 pr_debug("I2C: Attempting to delete an unregistered " 223 pr_debug("i2c-core: attempting to delete unregistered "
224 "adapter\n"); 224 "adapter [%s]\n", adap->name);
225 res = -EINVAL; 225 res = -EINVAL;
226 goto out_unlock; 226 goto out_unlock;
227 } 227 }
@@ -230,9 +230,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
230 driver = list_entry(item, struct i2c_driver, list); 230 driver = list_entry(item, struct i2c_driver, list);
231 if (driver->detach_adapter) 231 if (driver->detach_adapter)
232 if ((res = driver->detach_adapter(adap))) { 232 if ((res = driver->detach_adapter(adap))) {
233 dev_warn(&adap->dev, "can't detach adapter " 233 dev_err(&adap->dev, "detach_adapter failed "
234 "while detaching driver %s: driver " 234 "for driver [%s]\n", driver->name);
235 "not detached!\n", driver->name);
236 goto out_unlock; 235 goto out_unlock;
237 } 236 }
238 } 237 }
@@ -247,9 +246,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
247 * must be deleted, as this would cause invalid states. 246 * must be deleted, as this would cause invalid states.
248 */ 247 */
249 if ((res=client->driver->detach_client(client))) { 248 if ((res=client->driver->detach_client(client))) {
250 dev_err(&adap->dev, "adapter not " 249 dev_err(&adap->dev, "detach_client failed for client "
251 "unregistered, because client at " 250 "[%s] at address 0x%02x\n", client->name,
252 "address %02x can't be detached. ",
253 client->addr); 251 client->addr);
254 goto out_unlock; 252 goto out_unlock;
255 } 253 }
@@ -270,7 +268,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
270 /* free dynamically allocated bus id */ 268 /* free dynamically allocated bus id */
271 idr_remove(&i2c_adapter_idr, adap->nr); 269 idr_remove(&i2c_adapter_idr, adap->nr);
272 270
273 dev_dbg(&adap->dev, "adapter unregistered\n"); 271 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
274 272
275 out_unlock: 273 out_unlock:
276 up(&core_lists); 274 up(&core_lists);
@@ -303,7 +301,7 @@ int i2c_add_driver(struct i2c_driver *driver)
303 goto out_unlock; 301 goto out_unlock;
304 302
305 list_add_tail(&driver->list,&drivers); 303 list_add_tail(&driver->list,&drivers);
306 pr_debug("i2c-core: driver %s registered.\n", driver->name); 304 pr_debug("i2c-core: driver [%s] registered\n", driver->name);
307 305
308 /* now look for instances of driver on our adapters */ 306 /* now look for instances of driver on our adapters */
309 if (driver->flags & I2C_DF_NOTIFY) { 307 if (driver->flags & I2C_DF_NOTIFY) {
@@ -331,21 +329,17 @@ int i2c_del_driver(struct i2c_driver *driver)
331 /* Have a look at each adapter, if clients of this driver are still 329 /* Have a look at each adapter, if clients of this driver are still
332 * attached. If so, detach them to be able to kill the driver 330 * attached. If so, detach them to be able to kill the driver
333 * afterwards. 331 * afterwards.
334 */ 332 *
335 pr_debug("i2c-core: unregister_driver - looking for clients.\n"); 333 * Removing clients does not depend on the notify flag, else
336 /* removing clients does not depend on the notify flag, else
337 * invalid operation might (will!) result, when using stale client 334 * invalid operation might (will!) result, when using stale client
338 * pointers. 335 * pointers.
339 */ 336 */
340 list_for_each(item1,&adapters) { 337 list_for_each(item1,&adapters) {
341 adap = list_entry(item1, struct i2c_adapter, list); 338 adap = list_entry(item1, struct i2c_adapter, list);
342 dev_dbg(&adap->dev, "examining adapter\n");
343 if (driver->detach_adapter) { 339 if (driver->detach_adapter) {
344 if ((res = driver->detach_adapter(adap))) { 340 if ((res = driver->detach_adapter(adap))) {
345 dev_warn(&adap->dev, "while unregistering " 341 dev_err(&adap->dev, "detach_adapter failed "
346 "dummy driver %s, adapter could " 342 "for driver [%s]\n", driver->name);
347 "not be detached properly; driver "
348 "not unloaded!",driver->name);
349 goto out_unlock; 343 goto out_unlock;
350 } 344 }
351 } else { 345 } else {
@@ -353,16 +347,13 @@ int i2c_del_driver(struct i2c_driver *driver)
353 client = list_entry(item2, struct i2c_client, list); 347 client = list_entry(item2, struct i2c_client, list);
354 if (client->driver != driver) 348 if (client->driver != driver)
355 continue; 349 continue;
356 pr_debug("i2c-core.o: detaching client %s:\n", client->name); 350 dev_dbg(&adap->dev, "detaching client [%s] "
351 "at 0x%02x\n", client->name,
352 client->addr);
357 if ((res = driver->detach_client(client))) { 353 if ((res = driver->detach_client(client))) {
358 dev_err(&adap->dev, "while " 354 dev_err(&adap->dev, "detach_client "
359 "unregistering driver " 355 "failed for client [%s] at "
360 "`%s', the client at " 356 "0x%02x\n", client->name,
361 "address %02x of "
362 "adapter could not "
363 "be detached; driver "
364 "not unloaded!",
365 driver->name,
366 client->addr); 357 client->addr);
367 goto out_unlock; 358 goto out_unlock;
368 } 359 }
@@ -372,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver)
372 363
373 driver_unregister(&driver->driver); 364 driver_unregister(&driver->driver);
374 list_del(&driver->list); 365 list_del(&driver->list);
375 pr_debug("i2c-core: driver unregistered: %s\n", driver->name); 366 pr_debug("i2c-core: driver [%s] unregistered\n", driver->name);
376 367
377 out_unlock: 368 out_unlock:
378 up(&core_lists); 369 up(&core_lists);
@@ -417,15 +408,12 @@ int i2c_attach_client(struct i2c_client *client)
417 408
418 if (adapter->client_register) { 409 if (adapter->client_register) {
419 if (adapter->client_register(client)) { 410 if (adapter->client_register(client)) {
420 dev_warn(&adapter->dev, "warning: client_register " 411 dev_dbg(&adapter->dev, "client_register "
421 "seems to have failed for client %02x\n", 412 "failed for client [%s] at 0x%02x\n",
422 client->addr); 413 client->name, client->addr);
423 } 414 }
424 } 415 }
425 416
426 dev_dbg(&adapter->dev, "client [%s] registered to adapter\n",
427 client->name);
428
429 if (client->flags & I2C_CLIENT_ALLOW_USE) 417 if (client->flags & I2C_CLIENT_ALLOW_USE)
430 client->usage_count = 0; 418 client->usage_count = 0;
431 419
@@ -436,7 +424,8 @@ int i2c_attach_client(struct i2c_client *client)
436 424
437 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 425 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
438 "%d-%04x", i2c_adapter_id(adapter), client->addr); 426 "%d-%04x", i2c_adapter_id(adapter), client->addr);
439 pr_debug("registering %s\n", client->dev.bus_id); 427 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
428 client->name, client->dev.bus_id);
440 device_register(&client->dev); 429 device_register(&client->dev);
441 device_create_file(&client->dev, &dev_attr_client_name); 430 device_create_file(&client->dev, &dev_attr_client_name);
442 431
@@ -449,8 +438,12 @@ int i2c_detach_client(struct i2c_client *client)
449 struct i2c_adapter *adapter = client->adapter; 438 struct i2c_adapter *adapter = client->adapter;
450 int res = 0; 439 int res = 0;
451 440
452 if ((client->flags & I2C_CLIENT_ALLOW_USE) && (client->usage_count > 0)) 441 if ((client->flags & I2C_CLIENT_ALLOW_USE)
442 && (client->usage_count > 0)) {
443 dev_warn(&client->dev, "Client [%s] still busy, "
444 "can't detach\n", client->name);
453 return -EBUSY; 445 return -EBUSY;
446 }
454 447
455 if (adapter->client_unregister) { 448 if (adapter->client_unregister) {
456 res = adapter->client_unregister(client); 449 res = adapter->client_unregister(client);
@@ -669,98 +662,128 @@ int i2c_control(struct i2c_client *client,
669 * Will not work for 10-bit addresses! 662 * Will not work for 10-bit addresses!
670 * ---------------------------------------------------- 663 * ----------------------------------------------------
671 */ 664 */
665static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind,
666 int (*found_proc) (struct i2c_adapter *, int, int))
667{
668 int err;
669
670 /* Make sure the address is valid */
671 if (addr < 0x03 || addr > 0x77) {
672 dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
673 addr);
674 return -EINVAL;
675 }
676
677 /* Skip if already in use */
678 if (i2c_check_addr(adapter, addr))
679 return 0;
680
681 /* Make sure there is something at this address, unless forced */
682 if (kind < 0) {
683 if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
684 I2C_SMBUS_QUICK, NULL) < 0)
685 return 0;
686
687 /* prevent 24RF08 corruption */
688 if ((addr & ~0x0f) == 0x50)
689 i2c_smbus_xfer(adapter, addr, 0, 0, 0,
690 I2C_SMBUS_QUICK, NULL);
691 }
692
693 /* Finally call the custom detection function */
694 err = found_proc(adapter, addr, kind);
695
696 /* -ENODEV can be returned if there is a chip at the given address
697 but it isn't supported by this chip driver. We catch it here as
698 this isn't an error. */
699 return (err == -ENODEV) ? 0 : err;
700}
701
672int i2c_probe(struct i2c_adapter *adapter, 702int i2c_probe(struct i2c_adapter *adapter,
673 struct i2c_client_address_data *address_data, 703 struct i2c_client_address_data *address_data,
674 int (*found_proc) (struct i2c_adapter *, int, int)) 704 int (*found_proc) (struct i2c_adapter *, int, int))
675{ 705{
676 int addr,i,found,err; 706 int i, err;
677 int adap_id = i2c_adapter_id(adapter); 707 int adap_id = i2c_adapter_id(adapter);
678 708
679 /* Forget it if we can't probe using SMBUS_QUICK */ 709 /* Forget it if we can't probe using SMBUS_QUICK */
680 if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) 710 if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK))
681 return -1; 711 return -1;
682 712
683 for (addr = 0x00; addr <= 0x7f; addr++) { 713 /* Force entries are done first, and are not affected by ignore
684 714 entries */
685 /* Skip if already in use */ 715 if (address_data->forces) {
686 if (i2c_check_addr(adapter,addr)) 716 unsigned short **forces = address_data->forces;
687 continue; 717 int kind;
688 718
689 /* If it is in one of the force entries, we don't do any detection 719 for (kind = 0; forces[kind]; kind++) {
690 at all */ 720 for (i = 0; forces[kind][i] != I2C_CLIENT_END;
691 found = 0; 721 i += 2) {
692 722 if (forces[kind][i] == adap_id
693 for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 2) { 723 || forces[kind][i] == ANY_I2C_BUS) {
694 if (((adap_id == address_data->force[i]) || 724 dev_dbg(&adapter->dev, "found force "
695 (address_data->force[i] == ANY_I2C_BUS)) && 725 "parameter for adapter %d, "
696 (addr == address_data->force[i+1])) { 726 "addr 0x%02x, kind %d\n",
697 dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", 727 adap_id, forces[kind][i + 1],
698 adap_id, addr); 728 kind);
699 if ((err = found_proc(adapter,addr,0))) 729 err = i2c_probe_address(adapter,
700 return err; 730 forces[kind][i + 1],
701 found = 1; 731 kind, found_proc);
702 } 732 if (err)
703 } 733 return err;
704 if (found) 734 }
705 continue;
706
707 /* If this address is in one of the ignores, we can forget about
708 it right now */
709 for (i = 0;
710 !found && (address_data->ignore[i] != I2C_CLIENT_END);
711 i += 2) {
712 if (((adap_id == address_data->ignore[i]) ||
713 ((address_data->ignore[i] == ANY_I2C_BUS))) &&
714 (addr == address_data->ignore[i+1])) {
715 dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, "
716 "addr %04x\n", adap_id ,addr);
717 found = 1;
718 } 735 }
719 } 736 }
720 if (found) 737 }
721 continue;
722 738
723 /* Now, we will do a detection, but only if it is in the normal or 739 /* Probe entries are done second, and are not affected by ignore
724 probe entries */ 740 entries either */
725 for (i = 0; 741 for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) {
726 !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); 742 if (address_data->probe[i] == adap_id
727 i += 1) { 743 || address_data->probe[i] == ANY_I2C_BUS) {
728 if (addr == address_data->normal_i2c[i]) { 744 dev_dbg(&adapter->dev, "found probe parameter for "
729 found = 1; 745 "adapter %d, addr 0x%02x\n", adap_id,
730 dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, " 746 address_data->probe[i + 1]);
731 "addr %02x\n", adap_id, addr); 747 err = i2c_probe_address(adapter,
732 } 748 address_data->probe[i + 1],
749 -1, found_proc);
750 if (err)
751 return err;
733 } 752 }
753 }
734 754
735 for (i = 0; 755 /* Normal entries are done last, unless shadowed by an ignore entry */
736 !found && (address_data->probe[i] != I2C_CLIENT_END); 756 for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) {
737 i += 2) { 757 int j, ignore;
738 if (((adap_id == address_data->probe[i]) || 758
739 ((address_data->probe[i] == ANY_I2C_BUS))) && 759 ignore = 0;
740 (addr == address_data->probe[i+1])) { 760 for (j = 0; address_data->ignore[j] != I2C_CLIENT_END;
741 found = 1; 761 j += 2) {
742 dev_dbg(&adapter->dev, "found probe parameter for adapter %d, " 762 if ((address_data->ignore[j] == adap_id ||
743 "addr %04x\n", adap_id,addr); 763 address_data->ignore[j] == ANY_I2C_BUS)
764 && address_data->ignore[j + 1]
765 == address_data->normal_i2c[i]) {
766 dev_dbg(&adapter->dev, "found ignore "
767 "parameter for adapter %d, "
768 "addr 0x%02x\n", adap_id,
769 address_data->ignore[j + 1]);
744 } 770 }
771 ignore = 1;
772 break;
745 } 773 }
746 if (!found) 774 if (ignore)
747 continue; 775 continue;
748 776
749 /* OK, so we really should examine this address. First check 777 dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
750 whether there is some client here at all! */ 778 "addr 0x%02x\n", adap_id,
751 if (i2c_smbus_xfer(adapter,addr,0,0,0,I2C_SMBUS_QUICK,NULL) >= 0) 779 address_data->normal_i2c[i]);
752 if ((err = found_proc(adapter,addr,-1))) 780 err = i2c_probe_address(adapter, address_data->normal_i2c[i],
753 return err; 781 -1, found_proc);
782 if (err)
783 return err;
754 } 784 }
755 return 0;
756}
757 785
758/* 786 return 0;
759 * return id number for a specific adapter
760 */
761int i2c_adapter_id(struct i2c_adapter *adap)
762{
763 return adap->nr;
764} 787}
765 788
766struct i2c_adapter* i2c_get_adapter(int id) 789struct i2c_adapter* i2c_get_adapter(int id)
@@ -1171,6 +1194,12 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1171} 1194}
1172 1195
1173 1196
1197/* Next four are needed by i2c-isa */
1198EXPORT_SYMBOL_GPL(i2c_adapter_dev_release);
1199EXPORT_SYMBOL_GPL(i2c_adapter_driver);
1200EXPORT_SYMBOL_GPL(i2c_adapter_class);
1201EXPORT_SYMBOL_GPL(i2c_bus_type);
1202
1174EXPORT_SYMBOL(i2c_add_adapter); 1203EXPORT_SYMBOL(i2c_add_adapter);
1175EXPORT_SYMBOL(i2c_del_adapter); 1204EXPORT_SYMBOL(i2c_del_adapter);
1176EXPORT_SYMBOL(i2c_add_driver); 1205EXPORT_SYMBOL(i2c_add_driver);
@@ -1186,7 +1215,6 @@ EXPORT_SYMBOL(i2c_master_send);
1186EXPORT_SYMBOL(i2c_master_recv); 1215EXPORT_SYMBOL(i2c_master_recv);
1187EXPORT_SYMBOL(i2c_control); 1216EXPORT_SYMBOL(i2c_control);
1188EXPORT_SYMBOL(i2c_transfer); 1217EXPORT_SYMBOL(i2c_transfer);
1189EXPORT_SYMBOL(i2c_adapter_id);
1190EXPORT_SYMBOL(i2c_get_adapter); 1218EXPORT_SYMBOL(i2c_get_adapter);
1191EXPORT_SYMBOL(i2c_put_adapter); 1219EXPORT_SYMBOL(i2c_put_adapter);
1192EXPORT_SYMBOL(i2c_probe); 1220EXPORT_SYMBOL(i2c_probe);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index bc5d557e5dd9..aa7a4fadef64 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -434,7 +434,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
434 434
435 devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), 435 devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor),
436 S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); 436 S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor);
437 dev_dbg(&adap->dev, "Registered as minor %d\n", i2c_dev->minor); 437 pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
438 adap->name, i2c_dev->minor);
438 439
439 /* register this i2c device with the driver core */ 440 /* register this i2c device with the driver core */
440 i2c_dev->adap = adap; 441 i2c_dev->adap = adap;
@@ -471,7 +472,7 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
471 wait_for_completion(&i2c_dev->released); 472 wait_for_completion(&i2c_dev->released);
472 kfree(i2c_dev); 473 kfree(i2c_dev);
473 474
474 dev_dbg(&adap->dev, "Adapter unregistered\n"); 475 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
475 return 0; 476 return 0;
476} 477}
477 478
diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c
deleted file mode 100644
index f99a8161a9f1..000000000000
--- a/drivers/i2c/i2c-sensor-detect.c
+++ /dev/null
@@ -1,145 +0,0 @@
1/*
2 i2c-sensor-detect.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and
5 Mark D. Studebaker <mdsxyz123@yahoo.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/i2c.h>
25#include <linux/i2c-sensor.h>
26
27static unsigned short empty[] = {I2C_CLIENT_END};
28static unsigned int empty_isa[] = {I2C_CLIENT_ISA_END};
29
30/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
31int i2c_detect(struct i2c_adapter *adapter,
32 struct i2c_address_data *address_data,
33 int (*found_proc) (struct i2c_adapter *, int, int))
34{
35 int addr, i, found, j, err;
36 struct i2c_force_data *this_force;
37 int is_isa = i2c_is_isa_adapter(adapter);
38 int adapter_id =
39 is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter);
40 unsigned short *normal_i2c;
41 unsigned int *normal_isa;
42 unsigned short *probe;
43 unsigned short *ignore;
44
45 /* Forget it if we can't probe using SMBUS_QUICK */
46 if ((!is_isa) &&
47 !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
48 return -1;
49
50 /* Use default "empty" list if the adapter doesn't specify any */
51 normal_i2c = probe = ignore = empty;
52 normal_isa = empty_isa;
53 if (address_data->normal_i2c)
54 normal_i2c = address_data->normal_i2c;
55 if (address_data->normal_isa)
56 normal_isa = address_data->normal_isa;
57 if (address_data->probe)
58 probe = address_data->probe;
59 if (address_data->ignore)
60 ignore = address_data->ignore;
61
62 for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
63 if (!is_isa && i2c_check_addr(adapter, addr))
64 continue;
65
66 /* If it is in one of the force entries, we don't do any
67 detection at all */
68 found = 0;
69 for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) {
70 for (j = 0; !found && (this_force->force[j] != I2C_CLIENT_END); j += 2) {
71 if ( ((adapter_id == this_force->force[j]) ||
72 ((this_force->force[j] == ANY_I2C_BUS) && !is_isa)) &&
73 (addr == this_force->force[j + 1]) ) {
74 dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
75 if ((err = found_proc(adapter, addr, this_force->kind)))
76 return err;
77 found = 1;
78 }
79 }
80 }
81 if (found)
82 continue;
83
84 /* If this address is in one of the ignores, we can forget about it
85 right now */
86 for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) {
87 if ( ((adapter_id == ignore[i]) ||
88 ((ignore[i] == ANY_I2C_BUS) &&
89 !is_isa)) &&
90 (addr == ignore[i + 1])) {
91 dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
92 found = 1;
93 }
94 }
95 if (found)
96 continue;
97
98 /* Now, we will do a detection, but only if it is in the normal or
99 probe entries */
100 if (is_isa) {
101 for (i = 0; !found && (normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) {
102 if (addr == normal_isa[i]) {
103 dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
104 found = 1;
105 }
106 }
107 } else {
108 for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) {
109 if (addr == normal_i2c[i]) {
110 found = 1;
111 dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr);
112 }
113 }
114 }
115
116 for (i = 0;
117 !found && (probe[i] != I2C_CLIENT_END);
118 i += 2) {
119 if (((adapter_id == probe[i]) ||
120 ((probe[i] == ANY_I2C_BUS) && !is_isa))
121 && (addr == probe[i + 1])) {
122 dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
123 found = 1;
124 }
125 }
126 if (!found)
127 continue;
128
129 /* OK, so we really should examine this address. First check
130 whether there is some client here at all! */
131 if (is_isa ||
132 (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
133 if ((err = found_proc(adapter, addr, -1)))
134 return err;
135 }
136 return 0;
137}
138
139EXPORT_SYMBOL(i2c_detect);
140
141MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
142 "Rudolf Marek <r.marek@sh.cvut.cz>");
143
144MODULE_DESCRIPTION("i2c-sensor driver");
145MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/i2c-sensor-vid.c b/drivers/i2c/i2c-sensor-vid.c
deleted file mode 100644
index 922e22f054bb..000000000000
--- a/drivers/i2c/i2c-sensor-vid.c
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 i2c-sensor-vid.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4
5 Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include <linux/config.h>
23#include <linux/module.h>
24#include <linux/kernel.h>
25
26struct vrm_model {
27 u8 vendor;
28 u8 eff_family;
29 u8 eff_model;
30 int vrm_type;
31};
32
33#define ANY 0xFF
34
35#ifdef CONFIG_X86
36
37static struct vrm_model vrm_models[] = {
38 {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */
39 {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */
40 {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */
41 {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* 0xB Tualatin */
42 {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */
43 {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */
44 {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */
45 {X86_VENDOR_INTEL, 0xF, ANY, 90}, /* P4 before Prescott */
46 {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */
47 {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */
48 };
49
50static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
51{
52 int i = 0;
53
54 while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN) {
55 if (vrm_models[i].vendor==vendor)
56 if ((vrm_models[i].eff_family==eff_family)&& \
57 ((vrm_models[i].eff_model==eff_model)|| \
58 (vrm_models[i].eff_model==ANY)))
59 return vrm_models[i].vrm_type;
60 i++;
61 }
62
63 return 0;
64}
65
66int i2c_which_vrm(void)
67{
68 struct cpuinfo_x86 *c = cpu_data;
69 u32 eax;
70 u8 eff_family, eff_model;
71 int vrm_ret;
72
73 if (c->x86 < 6) return 0; /* any CPU with familly lower than 6
74 dont have VID and/or CPUID */
75 eax = cpuid_eax(1);
76 eff_family = ((eax & 0x00000F00)>>8);
77 eff_model = ((eax & 0x000000F0)>>4);
78 if (eff_family == 0xF) { /* use extended model & family */
79 eff_family += ((eax & 0x00F00000)>>20);
80 eff_model += ((eax & 0x000F0000)>>16)<<4;
81 }
82 vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
83 if (vrm_ret == 0)
84 printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your"
85 " x86 CPU\n");
86 return vrm_ret;
87}
88
89/* and now for something completely different for Non-x86 world*/
90#else
91int i2c_which_vrm(void)
92{
93 printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your CPU\n");
94 return 0;
95}
96#endif
97
98EXPORT_SYMBOL(i2c_which_vrm);
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 36074e6eeebb..6b1ab875333b 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1464,26 +1464,6 @@ static int __devinit add_card(struct pci_dev *dev,
1464 { 0x50, I2C_M_RD, 20, (unsigned char*) lynx->bus_info_block } 1464 { 0x50, I2C_M_RD, 20, (unsigned char*) lynx->bus_info_block }
1465 }; 1465 };
1466 1466
1467
1468#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
1469 union i2c_smbus_data data;
1470
1471 if (i2c_smbus_xfer(i2c_ad, 80, 0, I2C_SMBUS_WRITE, 0, I2C_SMBUS_BYTE,NULL))
1472 PRINT(KERN_ERR, lynx->id,"eeprom read start has failed");
1473 else
1474 {
1475 u16 addr;
1476 for (addr=0x00; addr < 0x100; addr++) {
1477 if (i2c_smbus_xfer(i2c_ad, 80, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE,& data)) {
1478 PRINT(KERN_ERR, lynx->id, "unable to read i2c %x", addr);
1479 break;
1480 }
1481 else
1482 PRINT(KERN_DEBUG, lynx->id,"got serial eeprom data at %x: %x",addr, data.byte);
1483 }
1484 }
1485#endif
1486
1487 /* we use i2c_transfer, because i2c_smbus_read_block_data does not work properly and we 1467 /* we use i2c_transfer, because i2c_smbus_read_block_data does not work properly and we
1488 do it more efficiently in one transaction rather then using several reads */ 1468 do it more efficiently in one transaction rather then using several reads */
1489 if (i2c_transfer(i2c_ad, msg, 2) < 0) { 1469 if (i2c_transfer(i2c_ad, msg, 2) < 0) {
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index 781f23f0cbcc..6284894505c6 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -387,8 +387,6 @@ static int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, in
387 387
388/* exported algorithm data */ 388/* exported algorithm data */
389static struct i2c_algorithm saa7146_algo = { 389static struct i2c_algorithm saa7146_algo = {
390 .name = "saa7146 i2c algorithm",
391 .id = I2C_ALGO_SAA7146,
392 .master_xfer = saa7146_i2c_xfer, 390 .master_xfer = saa7146_i2c_xfer,
393 .functionality = saa7146_i2c_func, 391 .functionality = saa7146_i2c_func,
394}; 392};
@@ -412,7 +410,7 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c
412#endif 410#endif
413 i2c_adapter->algo = &saa7146_algo; 411 i2c_adapter->algo = &saa7146_algo;
414 i2c_adapter->algo_data = NULL; 412 i2c_adapter->algo_data = NULL;
415 i2c_adapter->id = I2C_ALGO_SAA7146; 413 i2c_adapter->id = I2C_HW_SAA7146;
416 i2c_adapter->timeout = SAA7146_I2C_TIMEOUT; 414 i2c_adapter->timeout = SAA7146_I2C_TIMEOUT;
417 i2c_adapter->retries = SAA7146_I2C_RETRIES; 415 i2c_adapter->retries = SAA7146_I2C_RETRIES;
418 } 416 }
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index be4266d4ae91..56495cb6cd02 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -172,8 +172,6 @@ static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
172} 172}
173 173
174static struct i2c_algorithm flexcop_algo = { 174static struct i2c_algorithm flexcop_algo = {
175 .name = "FlexCop I2C algorithm",
176 .id = I2C_ALGO_BIT,
177 .master_xfer = flexcop_master_xfer, 175 .master_xfer = flexcop_master_xfer,
178 .functionality = flexcop_i2c_func, 176 .functionality = flexcop_i2c_func,
179}; 177};
@@ -192,7 +190,6 @@ int flexcop_i2c_init(struct flexcop_device *fc)
192 fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL; 190 fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
193 fc->i2c_adap.algo = &flexcop_algo; 191 fc->i2c_adap.algo = &flexcop_algo;
194 fc->i2c_adap.algo_data = NULL; 192 fc->i2c_adap.algo_data = NULL;
195 fc->i2c_adap.id = I2C_ALGO_BIT;
196 193
197 if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0) 194 if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0)
198 return ret; 195 return ret;
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index c3e1b661aae6..9e96a188f1e9 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -141,8 +141,6 @@ static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
141} 141}
142 142
143static struct i2c_algorithm cxusb_i2c_algo = { 143static struct i2c_algorithm cxusb_i2c_algo = {
144 .name = "Conexant USB I2C algorithm",
145 .id = I2C_ALGO_BIT,
146 .master_xfer = cxusb_i2c_xfer, 144 .master_xfer = cxusb_i2c_xfer,
147 .functionality = cxusb_i2c_func, 145 .functionality = cxusb_i2c_func,
148}; 146};
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 9b9d6f8ee74e..00b946419b40 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -156,8 +156,6 @@ static u32 dibusb_i2c_func(struct i2c_adapter *adapter)
156} 156}
157 157
158struct i2c_algorithm dibusb_i2c_algo = { 158struct i2c_algorithm dibusb_i2c_algo = {
159 .name = "DiBcom USB I2C algorithm",
160 .id = I2C_ALGO_BIT,
161 .master_xfer = dibusb_i2c_xfer, 159 .master_xfer = dibusb_i2c_xfer,
162 .functionality = dibusb_i2c_func, 160 .functionality = dibusb_i2c_func,
163}; 161};
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 9a676afc1d6e..f70e0be0920a 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -77,8 +77,6 @@ static u32 digitv_i2c_func(struct i2c_adapter *adapter)
77} 77}
78 78
79static struct i2c_algorithm digitv_i2c_algo = { 79static struct i2c_algorithm digitv_i2c_algo = {
80 .name = "Nebula DigiTV USB I2C algorithm",
81 .id = I2C_ALGO_BIT,
82 .master_xfer = digitv_i2c_xfer, 80 .master_xfer = digitv_i2c_xfer,
83 .functionality = digitv_i2c_func, 81 .functionality = digitv_i2c_func,
84}; 82};
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index 9f0a8d90d146..da970947dfc7 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
@@ -27,7 +27,6 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
27#endif 27#endif
28 d->i2c_adap.algo = d->props.i2c_algo; 28 d->i2c_adap.algo = d->props.i2c_algo;
29 d->i2c_adap.algo_data = NULL; 29 d->i2c_adap.algo_data = NULL;
30 d->i2c_adap.id = I2C_ALGO_BIT;
31 30
32 i2c_set_adapdata(&d->i2c_adap, d); 31 i2c_set_adapdata(&d->i2c_adap, d);
33 32
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 706e0bcb5ede..85b437bbddcd 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -633,7 +633,6 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
633 i2c_set_adapdata(&pluto->i2c_adap, pluto); 633 i2c_set_adapdata(&pluto->i2c_adap, pluto);
634 strcpy(pluto->i2c_adap.name, DRIVER_NAME); 634 strcpy(pluto->i2c_adap.name, DRIVER_NAME);
635 pluto->i2c_adap.owner = THIS_MODULE; 635 pluto->i2c_adap.owner = THIS_MODULE;
636 pluto->i2c_adap.id = I2C_ALGO_BIT;
637 pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL; 636 pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
638 pluto->i2c_adap.dev.parent = &pdev->dev; 637 pluto->i2c_adap.dev.parent = &pdev->dev;
639 pluto->i2c_adap.algo_data = &pluto->i2c_bit; 638 pluto->i2c_adap.algo_data = &pluto->i2c_bit;
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index aa43b5fcb8e7..7daf7b1598a0 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1472,8 +1472,6 @@ static void frontend_init(struct ttusb* ttusb)
1472 1472
1473 1473
1474static struct i2c_algorithm ttusb_dec_algo = { 1474static struct i2c_algorithm ttusb_dec_algo = {
1475 .name = "ttusb dec i2c algorithm",
1476 .id = I2C_ALGO_BIT,
1477 .master_xfer = master_xfer, 1475 .master_xfer = master_xfer,
1478 .functionality = functionality, 1476 .functionality = functionality,
1479}; 1477};
@@ -1525,7 +1523,6 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1525#endif 1523#endif
1526 ttusb->i2c_adap.algo = &ttusb_dec_algo; 1524 ttusb->i2c_adap.algo = &ttusb_dec_algo;
1527 ttusb->i2c_adap.algo_data = NULL; 1525 ttusb->i2c_adap.algo_data = NULL;
1528 ttusb->i2c_adap.id = I2C_ALGO_BIT;
1529 1526
1530 result = i2c_add_adapter(&ttusb->i2c_adap); 1527 result = i2c_add_adapter(&ttusb->i2c_adap);
1531 if (result) { 1528 if (result) {
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 48989eda2400..52e32f05d625 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -391,7 +391,6 @@ static struct i2c_client_address_data addr_data = {
391 .normal_i2c = normal_i2c, 391 .normal_i2c = normal_i2c,
392 .probe = &ignore, 392 .probe = &ignore,
393 .ignore = &ignore, 393 .ignore = &ignore,
394 .force = &ignore,
395}; 394};
396 395
397static struct i2c_driver i2c_driver_adv7170; 396static struct i2c_driver i2c_driver_adv7170;
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index f898b6586374..b5ed9544bdea 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -441,7 +441,6 @@ static struct i2c_client_address_data addr_data = {
441 .normal_i2c = normal_i2c, 441 .normal_i2c = normal_i2c,
442 .probe = &ignore, 442 .probe = &ignore,
443 .ignore = &ignore, 443 .ignore = &ignore,
444 .force = &ignore,
445}; 444};
446 445
447static struct i2c_driver i2c_driver_adv7175; 446static struct i2c_driver i2c_driver_adv7175;
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 8733588f6db3..c6cfa7c48b04 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -507,7 +507,6 @@ static struct i2c_client_address_data addr_data = {
507 .normal_i2c = normal_i2c, 507 .normal_i2c = normal_i2c,
508 .probe = &ignore, 508 .probe = &ignore,
509 .ignore = &ignore, 509 .ignore = &ignore,
510 .force = &ignore,
511}; 510};
512 511
513static struct i2c_driver i2c_driver_bt819; 512static struct i2c_driver i2c_driver_bt819;
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index a070417e65e6..76c1b63ebdf2 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -188,7 +188,7 @@ static int bt832_probe(struct i2c_adapter *adap)
188 if (adap->class & I2C_CLASS_TV_ANALOG) 188 if (adap->class & I2C_CLASS_TV_ANALOG)
189 return i2c_probe(adap, &addr_data, bt832_attach); 189 return i2c_probe(adap, &addr_data, bt832_attach);
190#else 190#else
191 if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) 191 if (adap->id == I2C_HW_B_BT848)
192 return i2c_probe(adap, &addr_data, bt832_attach); 192 return i2c_probe(adap, &addr_data, bt832_attach);
193#endif 193#endif
194 return 0; 194 return 0;
@@ -241,7 +241,7 @@ static struct i2c_driver driver = {
241}; 241};
242static struct i2c_client client_template = 242static struct i2c_client client_template =
243{ 243{
244 I2C_DEVNAME("bt832"), 244 .name = "bt832",
245 .flags = I2C_CLIENT_ALLOW_USE, 245 .flags = I2C_CLIENT_ALLOW_USE,
246 .driver = &driver, 246 .driver = &driver,
247}; 247};
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index a5d529ccf3ad..c13d28658868 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -295,7 +295,6 @@ static struct i2c_client_address_data addr_data = {
295 .normal_i2c = normal_i2c, 295 .normal_i2c = normal_i2c,
296 .probe = &ignore, 296 .probe = &ignore,
297 .ignore = &ignore, 297 .ignore = &ignore,
298 .force = &ignore,
299}; 298};
300 299
301static struct i2c_driver i2c_driver_bt856; 300static struct i2c_driver i2c_driver_bt856;
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index 234a85563769..706dc48df962 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -109,7 +109,7 @@ static struct i2c_adapter bttv_i2c_adap_sw_template = {
109#ifdef I2C_CLASS_TV_ANALOG 109#ifdef I2C_CLASS_TV_ANALOG
110 .class = I2C_CLASS_TV_ANALOG, 110 .class = I2C_CLASS_TV_ANALOG,
111#endif 111#endif
112 I2C_DEVNAME("bt848"), 112 .name = "bt848",
113 .id = I2C_HW_B_BT848, 113 .id = I2C_HW_B_BT848,
114 .client_register = attach_inform, 114 .client_register = attach_inform,
115}; 115};
@@ -270,8 +270,6 @@ static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int
270} 270}
271 271
272static struct i2c_algorithm bttv_algo = { 272static struct i2c_algorithm bttv_algo = {
273 .name = "bt878",
274 .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
275 .master_xfer = bttv_i2c_xfer, 273 .master_xfer = bttv_i2c_xfer,
276 .algo_control = algo_control, 274 .algo_control = algo_control,
277 .functionality = functionality, 275 .functionality = functionality,
@@ -282,8 +280,8 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = {
282#ifdef I2C_CLASS_TV_ANALOG 280#ifdef I2C_CLASS_TV_ANALOG
283 .class = I2C_CLASS_TV_ANALOG, 281 .class = I2C_CLASS_TV_ANALOG,
284#endif 282#endif
285 I2C_DEVNAME("bt878"), 283 .name = "bt878",
286 .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */, 284 .id = I2C_HW_B_BT848 /* FIXME */,
287 .algo = &bttv_algo, 285 .algo = &bttv_algo,
288 .client_register = attach_inform, 286 .client_register = attach_inform,
289}; 287};
@@ -298,7 +296,7 @@ static int attach_inform(struct i2c_client *client)
298 if (bttv_debug) 296 if (bttv_debug)
299 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n", 297 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
300 btv->c.nr,client->driver->name,client->addr, 298 btv->c.nr,client->driver->name,client->addr,
301 i2c_clientname(client)); 299 client->name);
302 if (!client->driver->command) 300 if (!client->driver->command)
303 return 0; 301 return 0;
304 302
@@ -326,7 +324,7 @@ void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
326} 324}
327 325
328static struct i2c_client bttv_i2c_client_template = { 326static struct i2c_client bttv_i2c_client_template = {
329 I2C_DEVNAME("bttv internal"), 327 .name = "bttv internal",
330}; 328};
331 329
332 330
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index a628a55299c6..7f598039e025 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -95,7 +95,7 @@ static int attach_inform(struct i2c_client *client)
95 struct cx88_core *core = i2c_get_adapdata(client->adapter); 95 struct cx88_core *core = i2c_get_adapdata(client->adapter);
96 96
97 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", 97 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
98 client->driver->name,client->addr,i2c_clientname(client)); 98 client->driver->name, client->addr, client->name);
99 if (!client->driver->command) 99 if (!client->driver->command)
100 return 0; 100 return 0;
101 101
@@ -128,7 +128,7 @@ static int detach_inform(struct i2c_client *client)
128{ 128{
129 struct cx88_core *core = i2c_get_adapdata(client->adapter); 129 struct cx88_core *core = i2c_get_adapdata(client->adapter);
130 130
131 dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client)); 131 dprintk(1, "i2c detach [client=%s]\n", client->name);
132 return 0; 132 return 0;
133} 133}
134 134
@@ -152,7 +152,7 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
152/* ----------------------------------------------------------------------- */ 152/* ----------------------------------------------------------------------- */
153 153
154static struct i2c_adapter cx8800_i2c_adap_template = { 154static struct i2c_adapter cx8800_i2c_adap_template = {
155 I2C_DEVNAME("cx2388x"), 155 .name = "cx2388x",
156 .owner = THIS_MODULE, 156 .owner = THIS_MODULE,
157 .id = I2C_HW_B_CX2388x, 157 .id = I2C_HW_B_CX2388x,
158 .client_register = attach_inform, 158 .client_register = attach_inform,
@@ -160,7 +160,7 @@ static struct i2c_adapter cx8800_i2c_adap_template = {
160}; 160};
161 161
162static struct i2c_client cx8800_i2c_client_template = { 162static struct i2c_client cx8800_i2c_client_template = {
163 I2C_DEVNAME("cx88xx internal"), 163 .name = "cx88xx internal",
164}; 164};
165 165
166static char *i2c_devs[128] = { 166static char *i2c_devs[128] = {
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 9fc5055e001c..1e273ff3f956 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -308,7 +308,7 @@ static struct i2c_driver driver = {
308 308
309static struct i2c_client client_template = 309static struct i2c_client client_template =
310{ 310{
311 I2C_DEVNAME("unset"), 311 .name = "unset",
312 .driver = &driver 312 .driver = &driver
313}; 313};
314 314
@@ -429,10 +429,10 @@ static int ir_probe(struct i2c_adapter *adap)
429 struct i2c_client c; char buf; int i,rc; 429 struct i2c_client c; char buf; int i,rc;
430 430
431 switch (adap->id) { 431 switch (adap->id) {
432 case I2C_ALGO_BIT | I2C_HW_B_BT848: 432 case I2C_HW_B_BT848:
433 probe = probe_bttv; 433 probe = probe_bttv;
434 break; 434 break;
435 case I2C_ALGO_SAA7134: 435 case I2C_HW_SAA7134:
436 probe = probe_saa7134; 436 probe = probe_saa7134;
437 break; 437 break;
438 } 438 }
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index e956234abf24..ca02f6f14b00 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -1437,7 +1437,7 @@ static struct i2c_driver driver = {
1437 1437
1438static struct i2c_client client_template = 1438static struct i2c_client client_template =
1439{ 1439{
1440 I2C_DEVNAME("(unset)"), 1440 .name = "(unset)",
1441 .flags = I2C_CLIENT_ALLOW_USE, 1441 .flags = I2C_CLIENT_ALLOW_USE,
1442 .driver = &driver, 1442 .driver = &driver,
1443}; 1443};
@@ -1509,7 +1509,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
1509 } 1509 }
1510 1510
1511 /* hello world :-) */ 1511 /* hello world :-) */
1512 printk(KERN_INFO "msp34xx: init: chip=%s",i2c_clientname(c)); 1512 printk(KERN_INFO "msp34xx: init: chip=%s", c->name);
1513 if (HAVE_NICAM(msp)) 1513 if (HAVE_NICAM(msp))
1514 printk(" +nicam"); 1514 printk(" +nicam");
1515 if (HAVE_SIMPLE(msp)) 1515 if (HAVE_SIMPLE(msp))
diff --git a/drivers/media/video/ovcamchip/ov6x20.c b/drivers/media/video/ovcamchip/ov6x20.c
index 3433619ad93f..b3f4d266cede 100644
--- a/drivers/media/video/ovcamchip/ov6x20.c
+++ b/drivers/media/video/ovcamchip/ov6x20.c
@@ -164,10 +164,10 @@ static int ov6x20_init(struct i2c_client *c)
164 DDEBUG(4, &c->dev, "entered"); 164 DDEBUG(4, &c->dev, "entered");
165 165
166 switch (c->adapter->id) { 166 switch (c->adapter->id) {
167 case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511: 167 case I2C_HW_SMBUS_OV511:
168 rc = ov_write_regvals(c, regvals_init_6x20_511); 168 rc = ov_write_regvals(c, regvals_init_6x20_511);
169 break; 169 break;
170 case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518: 170 case I2C_HW_SMBUS_OV518:
171 rc = ov_write_regvals(c, regvals_init_6x20_518); 171 rc = ov_write_regvals(c, regvals_init_6x20_518);
172 break; 172 break;
173 default: 173 default:
@@ -338,7 +338,7 @@ static int ov6x20_mode_init(struct i2c_client *c, struct ovcamchip_window *win)
338 /******** Palette-specific regs ********/ 338 /******** Palette-specific regs ********/
339 339
340 /* OV518 needs 8 bit multiplexed in color mode, and 16 bit in B&W */ 340 /* OV518 needs 8 bit multiplexed in color mode, and 16 bit in B&W */
341 if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { 341 if (c->adapter->id == I2C_HW_SMBUS_OV518) {
342 if (win->format == VIDEO_PALETTE_GREY) 342 if (win->format == VIDEO_PALETTE_GREY)
343 ov_write_mask(c, 0x13, 0x00, 0x20); 343 ov_write_mask(c, 0x13, 0x00, 0x20);
344 else 344 else
diff --git a/drivers/media/video/ovcamchip/ov6x30.c b/drivers/media/video/ovcamchip/ov6x30.c
index 44a842379b45..6eab458ab792 100644
--- a/drivers/media/video/ovcamchip/ov6x30.c
+++ b/drivers/media/video/ovcamchip/ov6x30.c
@@ -301,7 +301,7 @@ static int ov6x30_mode_init(struct i2c_client *c, struct ovcamchip_window *win)
301 /******** Palette-specific regs ********/ 301 /******** Palette-specific regs ********/
302 302
303 if (win->format == VIDEO_PALETTE_GREY) { 303 if (win->format == VIDEO_PALETTE_GREY) {
304 if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { 304 if (c->adapter->id == I2C_HW_SMBUS_OV518) {
305 /* Do nothing - we're already in 8-bit mode */ 305 /* Do nothing - we're already in 8-bit mode */
306 } else { 306 } else {
307 ov_write_mask(c, 0x13, 0x20, 0x20); 307 ov_write_mask(c, 0x13, 0x20, 0x20);
@@ -313,7 +313,7 @@ static int ov6x30_mode_init(struct i2c_client *c, struct ovcamchip_window *win)
313 * Therefore, the OV6630 needs to be in 8-bit multiplexed 313 * Therefore, the OV6630 needs to be in 8-bit multiplexed
314 * output mode */ 314 * output mode */
315 315
316 if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { 316 if (c->adapter->id == I2C_HW_SMBUS_OV518) {
317 /* Do nothing - we want to stay in 8-bit mode */ 317 /* Do nothing - we want to stay in 8-bit mode */
318 /* Warning: Messing with reg 0x13 breaks OV518 color */ 318 /* Warning: Messing with reg 0x13 breaks OV518 color */
319 } else { 319 } else {
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index 54dd5612d3b8..2de34ebf0673 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c
@@ -296,10 +296,10 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
296 * attach to adapters that are known to contain OV camera chips. */ 296 * attach to adapters that are known to contain OV camera chips. */
297 297
298 switch (adap->id) { 298 switch (adap->id) {
299 case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511): 299 case I2C_HW_SMBUS_OV511:
300 case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518): 300 case I2C_HW_SMBUS_OV518:
301 case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OVFX2): 301 case I2C_HW_SMBUS_OVFX2:
302 case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF): 302 case I2C_HW_SMBUS_W9968CF:
303 PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id); 303 PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id);
304 break; 304 break;
305 default: 305 default:
@@ -314,7 +314,7 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
314 } 314 }
315 memcpy(c, &client_template, sizeof *c); 315 memcpy(c, &client_template, sizeof *c);
316 c->adapter = adap; 316 c->adapter = adap;
317 strcpy(i2c_clientname(c), "OV????"); 317 strcpy(c->name, "OV????");
318 318
319 ov = kmalloc(sizeof *ov, GFP_KERNEL); 319 ov = kmalloc(sizeof *ov, GFP_KERNEL);
320 if (!ov) { 320 if (!ov) {
@@ -328,7 +328,7 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
328 if (rc < 0) 328 if (rc < 0)
329 goto error; 329 goto error;
330 330
331 strcpy(i2c_clientname(c), chip_names[ov->subtype]); 331 strcpy(c->name, chip_names[ov->subtype]);
332 332
333 PDEBUG(1, "Camera chip detection complete"); 333 PDEBUG(1, "Camera chip detection complete");
334 334
@@ -421,7 +421,7 @@ static struct i2c_driver driver = {
421}; 421};
422 422
423static struct i2c_client client_template = { 423static struct i2c_client client_template = {
424 I2C_DEVNAME("(unset)"), 424 .name = "(unset)",
425 .driver = &driver, 425 .driver = &driver,
426}; 426};
427 427
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 22d055d8a695..e116bdbed310 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -470,7 +470,6 @@ static struct i2c_client_address_data addr_data = {
470 .normal_i2c = normal_i2c, 470 .normal_i2c = normal_i2c,
471 .probe = &ignore, 471 .probe = &ignore,
472 .ignore = &ignore, 472 .ignore = &ignore,
473 .force = &ignore,
474}; 473};
475 474
476static struct i2c_driver i2c_driver_saa7110; 475static struct i2c_driver i2c_driver_saa7110;
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index fcd897382fcf..f18df53d98ff 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -489,7 +489,6 @@ static struct i2c_client_address_data addr_data = {
489 .normal_i2c = normal_i2c, 489 .normal_i2c = normal_i2c,
490 .probe = &ignore, 490 .probe = &ignore,
491 .ignore = &ignore, 491 .ignore = &ignore,
492 .force = &ignore,
493}; 492};
494 493
495static struct i2c_driver i2c_driver_saa7111; 494static struct i2c_driver i2c_driver_saa7111;
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 2ba997f5ef1d..e0c70f54f073 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -827,7 +827,6 @@ static struct i2c_client_address_data addr_data = {
827 .normal_i2c = normal_i2c, 827 .normal_i2c = normal_i2c,
828 .probe = &ignore, 828 .probe = &ignore,
829 .ignore = &ignore, 829 .ignore = &ignore,
830 .force = &ignore,
831}; 830};
832 831
833static struct i2c_driver i2c_driver_saa7114; 832static struct i2c_driver i2c_driver_saa7114;
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 79d05ea1b69b..382911c6ef22 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -598,7 +598,7 @@ static struct i2c_driver driver = {
598 598
599static struct i2c_client client_template = 599static struct i2c_client client_template =
600{ 600{
601 I2C_DEVNAME("saa6752hs"), 601 .name = "saa6752hs",
602 .flags = I2C_CLIENT_ALLOW_USE, 602 .flags = I2C_CLIENT_ALLOW_USE,
603 .driver = &driver, 603 .driver = &driver,
604}; 604};
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index 1203b93a572c..eae6b529713f 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -334,7 +334,7 @@ static int attach_inform(struct i2c_client *client)
334 struct tuner_setup tun_setup; 334 struct tuner_setup tun_setup;
335 335
336 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", 336 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
337 client->driver->name,client->addr,i2c_clientname(client)); 337 client->driver->name, client->addr, client->name);
338 338
339 if (!client->driver->command) 339 if (!client->driver->command)
340 return 0; 340 return 0;
@@ -370,8 +370,6 @@ static int attach_inform(struct i2c_client *client)
370} 370}
371 371
372static struct i2c_algorithm saa7134_algo = { 372static struct i2c_algorithm saa7134_algo = {
373 .name = "saa7134",
374 .id = I2C_ALGO_SAA7134,
375 .master_xfer = saa7134_i2c_xfer, 373 .master_xfer = saa7134_i2c_xfer,
376 .algo_control = algo_control, 374 .algo_control = algo_control,
377 .functionality = functionality, 375 .functionality = functionality,
@@ -382,14 +380,14 @@ static struct i2c_adapter saa7134_adap_template = {
382#ifdef I2C_CLASS_TV_ANALOG 380#ifdef I2C_CLASS_TV_ANALOG
383 .class = I2C_CLASS_TV_ANALOG, 381 .class = I2C_CLASS_TV_ANALOG,
384#endif 382#endif
385 I2C_DEVNAME("saa7134"), 383 .name = "saa7134",
386 .id = I2C_ALGO_SAA7134, 384 .id = I2C_HW_SAA7134,
387 .algo = &saa7134_algo, 385 .algo = &saa7134_algo,
388 .client_register = attach_inform, 386 .client_register = attach_inform,
389}; 387};
390 388
391static struct i2c_client saa7134_client_template = { 389static struct i2c_client saa7134_client_template = {
392 I2C_DEVNAME("saa7134 internal"), 390 .name = "saa7134 internal",
393}; 391};
394 392
395/* ----------------------------------------------------------- */ 393/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 108e7a4a0273..e93412f4407c 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -387,7 +387,6 @@ static struct i2c_client_address_data addr_data = {
387 .normal_i2c = normal_i2c, 387 .normal_i2c = normal_i2c,
388 .probe = &ignore, 388 .probe = &ignore,
389 .ignore = &ignore, 389 .ignore = &ignore,
390 .force = &ignore,
391}; 390};
392 391
393static struct i2c_driver i2c_driver_saa7185; 392static struct i2c_driver i2c_driver_saa7185;
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 7cb1fb3e66f9..255b6088ebf9 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -328,7 +328,7 @@ static int tda7432_probe(struct i2c_adapter *adap)
328 if (adap->class & I2C_CLASS_TV_ANALOG) 328 if (adap->class & I2C_CLASS_TV_ANALOG)
329 return i2c_probe(adap, &addr_data, tda7432_attach); 329 return i2c_probe(adap, &addr_data, tda7432_attach);
330#else 330#else
331 if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) 331 if (adap->id == I2C_HW_B_BT848)
332 return i2c_probe(adap, &addr_data, tda7432_attach); 332 return i2c_probe(adap, &addr_data, tda7432_attach);
333#endif 333#endif
334 return 0; 334 return 0;
@@ -513,7 +513,7 @@ static struct i2c_driver driver = {
513 513
514static struct i2c_client client_template = 514static struct i2c_client client_template =
515{ 515{
516 I2C_DEVNAME("tda7432"), 516 .name = "tda7432",
517 .driver = &driver, 517 .driver = &driver,
518}; 518};
519 519
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index c29bdfc3244e..1794686612c6 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -205,7 +205,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
205static int attach(struct i2c_adapter *adapter) 205static int attach(struct i2c_adapter *adapter)
206{ 206{
207 /* let's see whether this is a know adapter we can attach to */ 207 /* let's see whether this is a know adapter we can attach to */
208 if (adapter->id != I2C_ALGO_SAA7146) { 208 if (adapter->id != I2C_HW_SAA7146) {
209 dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id); 209 dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
210 return -ENODEV; 210 return -ENODEV;
211 } 211 }
@@ -231,7 +231,7 @@ static struct i2c_driver driver = {
231}; 231};
232 232
233static struct i2c_client client_template = { 233static struct i2c_client client_template = {
234 I2C_DEVNAME("tda9840"), 234 .name = "tda9840",
235 .driver = &driver, 235 .driver = &driver,
236}; 236};
237 237
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 566e1a5ca135..7e3dcdb262b0 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -262,7 +262,7 @@ static int tda9875_probe(struct i2c_adapter *adap)
262 if (adap->class & I2C_CLASS_TV_ANALOG) 262 if (adap->class & I2C_CLASS_TV_ANALOG)
263 return i2c_probe(adap, &addr_data, tda9875_attach); 263 return i2c_probe(adap, &addr_data, tda9875_attach);
264#else 264#else
265 if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) 265 if (adap->id == I2C_HW_B_BT848)
266 return i2c_probe(adap, &addr_data, tda9875_attach); 266 return i2c_probe(adap, &addr_data, tda9875_attach);
267#endif 267#endif
268 return 0; 268 return 0;
@@ -384,7 +384,7 @@ static struct i2c_driver driver = {
384 384
385static struct i2c_client client_template = 385static struct i2c_client client_template =
386{ 386{
387 I2C_DEVNAME("tda9875"), 387 .name = "tda9875",
388 .driver = &driver, 388 .driver = &driver,
389}; 389};
390 390
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index a28a395d6dfe..d60fc562aecd 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -618,9 +618,9 @@ static int tda9887_probe(struct i2c_adapter *adap)
618 return i2c_probe(adap, &addr_data, tda9887_attach); 618 return i2c_probe(adap, &addr_data, tda9887_attach);
619#else 619#else
620 switch (adap->id) { 620 switch (adap->id) {
621 case I2C_ALGO_BIT | I2C_HW_B_BT848: 621 case I2C_HW_B_BT848:
622 case I2C_ALGO_BIT | I2C_HW_B_RIVA: 622 case I2C_HW_B_RIVA:
623 case I2C_ALGO_SAA7134: 623 case I2C_HW_SAA7134:
624 return i2c_probe(adap, &addr_data, tda9887_attach); 624 return i2c_probe(adap, &addr_data, tda9887_attach);
625 break; 625 break;
626 } 626 }
@@ -793,7 +793,7 @@ static struct i2c_driver driver = {
793}; 793};
794static struct i2c_client client_template = 794static struct i2c_client client_template =
795{ 795{
796 I2C_DEVNAME("tda9887"), 796 .name = "tda9887",
797 .flags = I2C_CLIENT_ALLOW_USE, 797 .flags = I2C_CLIENT_ALLOW_USE,
798 .driver = &driver, 798 .driver = &driver,
799}; 799};
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index b44db8a7b94d..ee3688348b66 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -86,7 +86,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
86static int attach(struct i2c_adapter *adapter) 86static int attach(struct i2c_adapter *adapter)
87{ 87{
88 /* let's see whether this is a know adapter we can attach to */ 88 /* let's see whether this is a know adapter we can attach to */
89 if (adapter->id != I2C_ALGO_SAA7146) { 89 if (adapter->id != I2C_HW_SAA7146) {
90 dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id); 90 dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
91 return -ENODEV; 91 return -ENODEV;
92 } 92 }
@@ -200,7 +200,7 @@ static struct i2c_driver driver = {
200}; 200};
201 201
202static struct i2c_client client_template = { 202static struct i2c_client client_template = {
203 I2C_DEVNAME("tea6415c"), 203 .name = "tea6415c",
204 .driver = &driver, 204 .driver = &driver,
205}; 205};
206 206
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index 48d4db7d507b..17975c19da5e 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -135,7 +135,7 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
135static int attach(struct i2c_adapter *adapter) 135static int attach(struct i2c_adapter *adapter)
136{ 136{
137 /* let's see whether this is a know adapter we can attach to */ 137 /* let's see whether this is a know adapter we can attach to */
138 if (adapter->id != I2C_ALGO_SAA7146) { 138 if (adapter->id != I2C_HW_SAA7146) {
139 dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id); 139 dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
140 return -ENODEV; 140 return -ENODEV;
141 } 141 }
@@ -177,7 +177,7 @@ static struct i2c_driver driver = {
177}; 177};
178 178
179static struct i2c_client client_template = { 179static struct i2c_client client_template = {
180 I2C_DEVNAME("tea6420"), 180 .name = "tea6420",
181 .driver = &driver, 181 .driver = &driver,
182}; 182};
183 183
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index 7d825e510ffd..79203595b9c1 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -41,7 +41,6 @@ static struct i2c_client_address_data addr_data = {
41 .normal_i2c = normal_i2c, 41 .normal_i2c = normal_i2c,
42 .probe = &ignore, 42 .probe = &ignore,
43 .ignore = &ignore, 43 .ignore = &ignore,
44 .force = &ignore,
45}; 44};
46 45
47/* ---------------------------------------------------------------------- */ 46/* ---------------------------------------------------------------------- */
@@ -166,7 +165,7 @@ static int
166tuner_probe(struct i2c_adapter *adap) 165tuner_probe(struct i2c_adapter *adap)
167{ 166{
168 this_adap = 0; 167 this_adap = 0;
169 if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_LP)) 168 if (adap->id == I2C_HW_B_LP)
170 return i2c_probe(adap, &addr_data, tuner_attach); 169 return i2c_probe(adap, &addr_data, tuner_attach);
171 return 0; 170 return 0;
172} 171}
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index a155e99a263b..3b1893c2ae3b 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -709,7 +709,7 @@ static struct i2c_driver driver = {
709 }, 709 },
710}; 710};
711static struct i2c_client client_template = { 711static struct i2c_client client_template = {
712 I2C_DEVNAME("(tuner unset)"), 712 .name = "(tuner unset)",
713 .flags = I2C_CLIENT_ALLOW_USE, 713 .flags = I2C_CLIENT_ALLOW_USE,
714 .driver = &driver, 714 .driver = &driver,
715}; 715};
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index f42a1efa8fcf..258724b2d6d2 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -162,24 +162,23 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
162 unsigned char buffer[2]; 162 unsigned char buffer[2];
163 163
164 if (-1 == subaddr) { 164 if (-1 == subaddr) {
165 dprintk("%s: chip_write: 0x%x\n", 165 dprintk("%s: chip_write: 0x%x\n", chip->c.name, val);
166 i2c_clientname(&chip->c), val);
167 chip->shadow.bytes[1] = val; 166 chip->shadow.bytes[1] = val;
168 buffer[0] = val; 167 buffer[0] = val;
169 if (1 != i2c_master_send(&chip->c,buffer,1)) { 168 if (1 != i2c_master_send(&chip->c,buffer,1)) {
170 printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", 169 printk(KERN_WARNING "%s: I/O error (write 0x%x)\n",
171 i2c_clientname(&chip->c), val); 170 chip->c.name, val);
172 return -1; 171 return -1;
173 } 172 }
174 } else { 173 } else {
175 dprintk("%s: chip_write: reg%d=0x%x\n", 174 dprintk("%s: chip_write: reg%d=0x%x\n",
176 i2c_clientname(&chip->c), subaddr, val); 175 chip->c.name, subaddr, val);
177 chip->shadow.bytes[subaddr+1] = val; 176 chip->shadow.bytes[subaddr+1] = val;
178 buffer[0] = subaddr; 177 buffer[0] = subaddr;
179 buffer[1] = val; 178 buffer[1] = val;
180 if (2 != i2c_master_send(&chip->c,buffer,2)) { 179 if (2 != i2c_master_send(&chip->c,buffer,2)) {
181 printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", 180 printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n",
182 i2c_clientname(&chip->c), subaddr, val); 181 chip->c.name, subaddr, val);
183 return -1; 182 return -1;
184 } 183 }
185 } 184 }
@@ -203,11 +202,10 @@ static int chip_read(struct CHIPSTATE *chip)
203 unsigned char buffer; 202 unsigned char buffer;
204 203
205 if (1 != i2c_master_recv(&chip->c,&buffer,1)) { 204 if (1 != i2c_master_recv(&chip->c,&buffer,1)) {
206 printk(KERN_WARNING "%s: I/O error (read)\n", 205 printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name);
207 i2c_clientname(&chip->c));
208 return -1; 206 return -1;
209 } 207 }
210 dprintk("%s: chip_read: 0x%x\n",i2c_clientname(&chip->c),buffer); 208 dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer);
211 return buffer; 209 return buffer;
212} 210}
213 211
@@ -222,12 +220,11 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr)
222 write[0] = subaddr; 220 write[0] = subaddr;
223 221
224 if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { 222 if (2 != i2c_transfer(chip->c.adapter,msgs,2)) {
225 printk(KERN_WARNING "%s: I/O error (read2)\n", 223 printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name);
226 i2c_clientname(&chip->c));
227 return -1; 224 return -1;
228 } 225 }
229 dprintk("%s: chip_read2: reg%d=0x%x\n", 226 dprintk("%s: chip_read2: reg%d=0x%x\n",
230 i2c_clientname(&chip->c),subaddr,read[0]); 227 chip->c.name, subaddr, read[0]);
231 return read[0]; 228 return read[0];
232} 229}
233 230
@@ -240,7 +237,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
240 237
241 /* update our shadow register set; print bytes if (debug > 0) */ 238 /* update our shadow register set; print bytes if (debug > 0) */
242 dprintk("%s: chip_cmd(%s): reg=%d, data:", 239 dprintk("%s: chip_cmd(%s): reg=%d, data:",
243 i2c_clientname(&chip->c),name,cmd->bytes[0]); 240 chip->c.name, name, cmd->bytes[0]);
244 for (i = 1; i < cmd->count; i++) { 241 for (i = 1; i < cmd->count; i++) {
245 dprintk(" 0x%x",cmd->bytes[i]); 242 dprintk(" 0x%x",cmd->bytes[i]);
246 chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; 243 chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i];
@@ -249,7 +246,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
249 246
250 /* send data to the chip */ 247 /* send data to the chip */
251 if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { 248 if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) {
252 printk(KERN_WARNING "%s: I/O error (%s)\n", i2c_clientname(&chip->c), name); 249 printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name);
253 return -1; 250 return -1;
254 } 251 }
255 return 0; 252 return 0;
@@ -274,9 +271,9 @@ static int chip_thread(void *data)
274 struct CHIPSTATE *chip = data; 271 struct CHIPSTATE *chip = data;
275 struct CHIPDESC *desc = chiplist + chip->type; 272 struct CHIPDESC *desc = chiplist + chip->type;
276 273
277 daemonize("%s",i2c_clientname(&chip->c)); 274 daemonize("%s", chip->c.name);
278 allow_signal(SIGTERM); 275 allow_signal(SIGTERM);
279 dprintk("%s: thread started\n", i2c_clientname(&chip->c)); 276 dprintk("%s: thread started\n", chip->c.name);
280 277
281 for (;;) { 278 for (;;) {
282 add_wait_queue(&chip->wq, &wait); 279 add_wait_queue(&chip->wq, &wait);
@@ -288,7 +285,7 @@ static int chip_thread(void *data)
288 try_to_freeze(); 285 try_to_freeze();
289 if (chip->done || signal_pending(current)) 286 if (chip->done || signal_pending(current))
290 break; 287 break;
291 dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c)); 288 dprintk("%s: thread wakeup\n", chip->c.name);
292 289
293 /* don't do anything for radio or if mode != auto */ 290 /* don't do anything for radio or if mode != auto */
294 if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) 291 if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0)
@@ -301,7 +298,7 @@ static int chip_thread(void *data)
301 mod_timer(&chip->wt, jiffies+2*HZ); 298 mod_timer(&chip->wt, jiffies+2*HZ);
302 } 299 }
303 300
304 dprintk("%s: thread exiting\n", i2c_clientname(&chip->c)); 301 dprintk("%s: thread exiting\n", chip->c.name);
305 complete_and_exit(&chip->texit, 0); 302 complete_and_exit(&chip->texit, 0);
306 return 0; 303 return 0;
307} 304}
@@ -314,7 +311,7 @@ static void generic_checkmode(struct CHIPSTATE *chip)
314 if (mode == chip->prevmode) 311 if (mode == chip->prevmode)
315 return; 312 return;
316 313
317 dprintk("%s: thread checkmode\n", i2c_clientname(&chip->c)); 314 dprintk("%s: thread checkmode\n", chip->c.name);
318 chip->prevmode = mode; 315 chip->prevmode = mode;
319 316
320 if (mode & VIDEO_SOUND_STEREO) 317 if (mode & VIDEO_SOUND_STEREO)
@@ -1098,7 +1095,7 @@ static int tda8425_initialize(struct CHIPSTATE *chip)
1098 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF, 1095 /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF,
1099 /* off */ TDA8425_S1_OFF, /* on */ TDA8425_S1_CH2}; 1096 /* off */ TDA8425_S1_OFF, /* on */ TDA8425_S1_CH2};
1100 1097
1101 if (chip->c.adapter->id == (I2C_ALGO_BIT | I2C_HW_B_RIVA)) { 1098 if (chip->c.adapter->id == I2C_HW_B_RIVA) {
1102 memcpy (desc->inputmap, inputmap, sizeof (inputmap)); 1099 memcpy (desc->inputmap, inputmap, sizeof (inputmap));
1103 } 1100 }
1104 return 0; 1101 return 0;
@@ -1501,7 +1498,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1501 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); 1498 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : "");
1502 1499
1503 /* fill required data structures */ 1500 /* fill required data structures */
1504 strcpy(i2c_clientname(&chip->c),desc->name); 1501 strcpy(chip->c.name, desc->name);
1505 chip->type = desc-chiplist; 1502 chip->type = desc-chiplist;
1506 chip->shadow.count = desc->registers+1; 1503 chip->shadow.count = desc->registers+1;
1507 chip->prevmode = -1; 1504 chip->prevmode = -1;
@@ -1538,7 +1535,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1538 chip->tpid = kernel_thread(chip_thread,(void *)chip,0); 1535 chip->tpid = kernel_thread(chip_thread,(void *)chip,0);
1539 if (chip->tpid < 0) 1536 if (chip->tpid < 0)
1540 printk(KERN_WARNING "%s: kernel_thread() failed\n", 1537 printk(KERN_WARNING "%s: kernel_thread() failed\n",
1541 i2c_clientname(&chip->c)); 1538 chip->c.name);
1542 wake_up_interruptible(&chip->wq); 1539 wake_up_interruptible(&chip->wq);
1543 } 1540 }
1544 return 0; 1541 return 0;
@@ -1548,16 +1545,16 @@ static int chip_probe(struct i2c_adapter *adap)
1548{ 1545{
1549 /* don't attach on saa7146 based cards, 1546 /* don't attach on saa7146 based cards,
1550 because dedicated drivers are used */ 1547 because dedicated drivers are used */
1551 if ((adap->id & I2C_ALGO_SAA7146)) 1548 if (adap->id == I2C_HW_SAA7146)
1552 return 0; 1549 return 0;
1553#ifdef I2C_CLASS_TV_ANALOG 1550#ifdef I2C_CLASS_TV_ANALOG
1554 if (adap->class & I2C_CLASS_TV_ANALOG) 1551 if (adap->class & I2C_CLASS_TV_ANALOG)
1555 return i2c_probe(adap, &addr_data, chip_attach); 1552 return i2c_probe(adap, &addr_data, chip_attach);
1556#else 1553#else
1557 switch (adap->id) { 1554 switch (adap->id) {
1558 case I2C_ALGO_BIT | I2C_HW_B_BT848: 1555 case I2C_HW_B_BT848:
1559 case I2C_ALGO_BIT | I2C_HW_B_RIVA: 1556 case I2C_HW_B_RIVA:
1560 case I2C_ALGO_SAA7134: 1557 case I2C_HW_SAA7134:
1561 return i2c_probe(adap, &addr_data, chip_attach); 1558 return i2c_probe(adap, &addr_data, chip_attach);
1562 } 1559 }
1563#endif 1560#endif
@@ -1591,7 +1588,7 @@ static int chip_command(struct i2c_client *client,
1591 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1588 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1592 struct CHIPDESC *desc = chiplist + chip->type; 1589 struct CHIPDESC *desc = chiplist + chip->type;
1593 1590
1594 dprintk("%s: chip_command 0x%x\n",i2c_clientname(&chip->c),cmd); 1591 dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd);
1595 1592
1596 switch (cmd) { 1593 switch (cmd) {
1597 case AUDC_SET_INPUT: 1594 case AUDC_SET_INPUT:
@@ -1702,7 +1699,7 @@ static struct i2c_driver driver = {
1702 1699
1703static struct i2c_client client_template = 1700static struct i2c_client client_template =
1704{ 1701{
1705 I2C_DEVNAME("(unset)"), 1702 .name = "(unset)",
1706 .flags = I2C_CLIENT_ALLOW_USE, 1703 .flags = I2C_CLIENT_ALLOW_USE,
1707 .driver = &driver, 1704 .driver = &driver,
1708}; 1705};
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 127ec38ebd60..3c3356a01cc6 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -534,7 +534,7 @@ static int
534tveeprom_attach_adapter (struct i2c_adapter *adapter) 534tveeprom_attach_adapter (struct i2c_adapter *adapter)
535{ 535{
536 dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id); 536 dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id);
537 if (adapter->id != (I2C_ALGO_BIT | I2C_HW_B_BT848)) 537 if (adapter->id != I2C_HW_B_BT848)
538 return 0; 538 return 0;
539 return i2c_probe(adapter, &addr_data, tveeprom_detect_client); 539 return i2c_probe(adapter, &addr_data, tveeprom_detect_client);
540} 540}
diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
index 51b99cdbf29e..a43301a154af 100644
--- a/drivers/media/video/tvmixer.c
+++ b/drivers/media/video/tvmixer.c
@@ -91,7 +91,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
91 if (cmd == SOUND_MIXER_INFO) { 91 if (cmd == SOUND_MIXER_INFO) {
92 mixer_info info; 92 mixer_info info;
93 strlcpy(info.id, "tv card", sizeof(info.id)); 93 strlcpy(info.id, "tv card", sizeof(info.id));
94 strlcpy(info.name, i2c_clientname(client), sizeof(info.name)); 94 strlcpy(info.name, client->name, sizeof(info.name));
95 info.modify_counter = 42 /* FIXME */; 95 info.modify_counter = 42 /* FIXME */;
96 if (copy_to_user(argp, &info, sizeof(info))) 96 if (copy_to_user(argp, &info, sizeof(info)))
97 return -EFAULT; 97 return -EFAULT;
@@ -100,7 +100,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm
100 if (cmd == SOUND_OLD_MIXER_INFO) { 100 if (cmd == SOUND_OLD_MIXER_INFO) {
101 _old_mixer_info info; 101 _old_mixer_info info;
102 strlcpy(info.id, "tv card", sizeof(info.id)); 102 strlcpy(info.id, "tv card", sizeof(info.id));
103 strlcpy(info.name, i2c_clientname(client), sizeof(info.name)); 103 strlcpy(info.name, client->name, sizeof(info.name));
104 if (copy_to_user(argp, &info, sizeof(info))) 104 if (copy_to_user(argp, &info, sizeof(info)))
105 return -EFAULT; 105 return -EFAULT;
106 return 0; 106 return 0;
@@ -276,9 +276,9 @@ static int tvmixer_clients(struct i2c_client *client)
276#else 276#else
277 /* TV card ??? */ 277 /* TV card ??? */
278 switch (client->adapter->id) { 278 switch (client->adapter->id) {
279 case I2C_ALGO_BIT | I2C_HW_SMBUS_VOODOO3: 279 case I2C_HW_SMBUS_VOODOO3:
280 case I2C_ALGO_BIT | I2C_HW_B_BT848: 280 case I2C_HW_B_BT848:
281 case I2C_ALGO_BIT | I2C_HW_B_RIVA: 281 case I2C_HW_B_RIVA:
282 /* ok, have a look ... */ 282 /* ok, have a look ... */
283 break; 283 break;
284 default: 284 default:
@@ -295,7 +295,7 @@ static int tvmixer_clients(struct i2c_client *client)
295 devices[i].dev = NULL; 295 devices[i].dev = NULL;
296 devices[i].minor = -1; 296 devices[i].minor = -1;
297 printk("tvmixer: %s unregistered (#1)\n", 297 printk("tvmixer: %s unregistered (#1)\n",
298 i2c_clientname(client)); 298 client->name);
299 return 0; 299 return 0;
300 } 300 }
301 } 301 }
@@ -354,7 +354,7 @@ static void __exit tvmixer_cleanup_module(void)
354 if (devices[i].minor != -1) { 354 if (devices[i].minor != -1) {
355 unregister_sound_mixer(devices[i].minor); 355 unregister_sound_mixer(devices[i].minor);
356 printk("tvmixer: %s unregistered (#2)\n", 356 printk("tvmixer: %s unregistered (#2)\n",
357 i2c_clientname(devices[i].dev)); 357 devices[i].dev->name);
358 } 358 }
359 } 359 }
360} 360}
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 5dbd9f6bf353..4437bdebe24f 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -576,7 +576,6 @@ static struct i2c_client_address_data addr_data = {
576 .normal_i2c = normal_i2c, 576 .normal_i2c = normal_i2c,
577 .probe = &ignore, 577 .probe = &ignore,
578 .ignore = &ignore, 578 .ignore = &ignore,
579 .force = &ignore,
580}; 579};
581 580
582static struct i2c_driver vpx3220_i2c_driver; 581static struct i2c_driver vpx3220_i2c_driver;
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 25743085b2d5..eed2acea1779 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -737,7 +737,7 @@ static struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
737}; 737};
738 738
739static struct i2c_adapter zoran_i2c_adapter_template = { 739static struct i2c_adapter zoran_i2c_adapter_template = {
740 I2C_DEVNAME("zr36057"), 740 .name = "zr36057",
741 .id = I2C_HW_B_ZR36067, 741 .id = I2C_HW_B_ZR36067,
742 .algo = NULL, 742 .algo = NULL,
743 .client_register = zoran_i2c_client_register, 743 .client_register = zoran_i2c_client_register,
diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c
index ca9f3a30634f..f36c0b6c6e36 100644
--- a/drivers/usb/media/w9968cf.c
+++ b/drivers/usb/media/w9968cf.c
@@ -1523,7 +1523,6 @@ static u32 w9968cf_i2c_func(struct i2c_adapter* adap)
1523static int w9968cf_i2c_attach_inform(struct i2c_client* client) 1523static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1524{ 1524{
1525 struct w9968cf_device* cam = i2c_get_adapdata(client->adapter); 1525 struct w9968cf_device* cam = i2c_get_adapdata(client->adapter);
1526 const char* clientname = i2c_clientname(client);
1527 int id = client->driver->id, err = 0; 1526 int id = client->driver->id, err = 0;
1528 1527
1529 if (id == I2C_DRIVERID_OVCAMCHIP) { 1528 if (id == I2C_DRIVERID_OVCAMCHIP) {
@@ -1535,12 +1534,12 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1535 } 1534 }
1536 } else { 1535 } else {
1537 DBG(4, "Rejected client [%s] with driver [%s]", 1536 DBG(4, "Rejected client [%s] with driver [%s]",
1538 clientname, client->driver->name) 1537 client->name, client->driver->name)
1539 return -EINVAL; 1538 return -EINVAL;
1540 } 1539 }
1541 1540
1542 DBG(5, "I2C attach client [%s] with driver [%s]", 1541 DBG(5, "I2C attach client [%s] with driver [%s]",
1543 clientname, client->driver->name) 1542 client->name, client->driver->name)
1544 1543
1545 return 0; 1544 return 0;
1546} 1545}
@@ -1549,12 +1548,11 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1549static int w9968cf_i2c_detach_inform(struct i2c_client* client) 1548static int w9968cf_i2c_detach_inform(struct i2c_client* client)
1550{ 1549{
1551 struct w9968cf_device* cam = i2c_get_adapdata(client->adapter); 1550 struct w9968cf_device* cam = i2c_get_adapdata(client->adapter);
1552 const char* clientname = i2c_clientname(client);
1553 1551
1554 if (cam->sensor_client == client) 1552 if (cam->sensor_client == client)
1555 cam->sensor_client = NULL; 1553 cam->sensor_client = NULL;
1556 1554
1557 DBG(5, "I2C detach client [%s]", clientname) 1555 DBG(5, "I2C detach client [%s]", client->name)
1558 1556
1559 return 0; 1557 return 0;
1560} 1558}
@@ -1573,15 +1571,13 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam)
1573 int err = 0; 1571 int err = 0;
1574 1572
1575 static struct i2c_algorithm algo = { 1573 static struct i2c_algorithm algo = {
1576 .name = "W996[87]CF algorithm",
1577 .id = I2C_ALGO_SMBUS,
1578 .smbus_xfer = w9968cf_i2c_smbus_xfer, 1574 .smbus_xfer = w9968cf_i2c_smbus_xfer,
1579 .algo_control = w9968cf_i2c_control, 1575 .algo_control = w9968cf_i2c_control,
1580 .functionality = w9968cf_i2c_func, 1576 .functionality = w9968cf_i2c_func,
1581 }; 1577 };
1582 1578
1583 static struct i2c_adapter adap = { 1579 static struct i2c_adapter adap = {
1584 .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF, 1580 .id = I2C_HW_SMBUS_W9968CF,
1585 .class = I2C_CLASS_CAM_DIGITAL, 1581 .class = I2C_CLASS_CAM_DIGITAL,
1586 .owner = THIS_MODULE, 1582 .owner = THIS_MODULE,
1587 .client_register = w9968cf_i2c_attach_inform, 1583 .client_register = w9968cf_i2c_attach_inform,
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 762244164c81..a9d0414e4655 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -75,7 +75,7 @@ static int radeon_setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
75 75
76 strcpy(chan->adapter.name, name); 76 strcpy(chan->adapter.name, name);
77 chan->adapter.owner = THIS_MODULE; 77 chan->adapter.owner = THIS_MODULE;
78 chan->adapter.id = I2C_ALGO_ATI; 78 chan->adapter.id = I2C_HW_B_RADEON;
79 chan->adapter.algo_data = &chan->algo; 79 chan->adapter.algo_data = &chan->algo;
80 chan->adapter.dev.parent = &chan->rinfo->pdev->dev; 80 chan->adapter.dev.parent = &chan->rinfo->pdev->dev;
81 chan->algo.setsda = radeon_gpio_setsda; 81 chan->algo.setsda = radeon_gpio_setsda;
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c
index 67f85344f0cc..ad60bbb16cdf 100644
--- a/drivers/video/matrox/matroxfb_maven.c
+++ b/drivers/video/matrox/matroxfb_maven.c
@@ -1271,7 +1271,7 @@ ERROR0:;
1271} 1271}
1272 1272
1273static int maven_attach_adapter(struct i2c_adapter* adapter) { 1273static int maven_attach_adapter(struct i2c_adapter* adapter) {
1274 if (adapter->id == (I2C_ALGO_BIT | I2C_HW_B_G400)) 1274 if (adapter->id == I2C_HW_B_G400)
1275 return i2c_probe(adapter, &addr_data, &maven_detect_client); 1275 return i2c_probe(adapter, &addr_data, &maven_detect_client);
1276 return 0; 1276 return 0;
1277} 1277}
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c
index 3757c1407c19..1a91bffdda26 100644
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -90,14 +90,13 @@ static int nvidia_gpio_getsda(void *data)
90 return val; 90 return val;
91} 91}
92 92
93#define I2C_ALGO_NVIDIA 0x0e0000
94static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name) 93static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name)
95{ 94{
96 int rc; 95 int rc;
97 96
98 strcpy(chan->adapter.name, name); 97 strcpy(chan->adapter.name, name);
99 chan->adapter.owner = THIS_MODULE; 98 chan->adapter.owner = THIS_MODULE;
100 chan->adapter.id = I2C_ALGO_NVIDIA; 99 chan->adapter.id = I2C_HW_B_NVIDIA;
101 chan->adapter.algo_data = &chan->algo; 100 chan->adapter.algo_data = &chan->algo;
102 chan->adapter.dev.parent = &chan->par->pci_dev->dev; 101 chan->adapter.dev.parent = &chan->par->pci_dev->dev;
103 chan->algo.setsda = nvidia_gpio_setsda; 102 chan->algo.setsda = nvidia_gpio_setsda;
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c
index da1334dfd51d..77151d8e0766 100644
--- a/drivers/video/riva/rivafb-i2c.c
+++ b/drivers/video/riva/rivafb-i2c.c
@@ -92,14 +92,13 @@ static int riva_gpio_getsda(void* data)
92 return val; 92 return val;
93} 93}
94 94
95#define I2C_ALGO_RIVA 0x0e0000
96static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name) 95static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name)
97{ 96{
98 int rc; 97 int rc;
99 98
100 strcpy(chan->adapter.name, name); 99 strcpy(chan->adapter.name, name);
101 chan->adapter.owner = THIS_MODULE; 100 chan->adapter.owner = THIS_MODULE;
102 chan->adapter.id = I2C_ALGO_RIVA; 101 chan->adapter.id = I2C_HW_B_RIVA;
103 chan->adapter.algo_data = &chan->algo; 102 chan->adapter.algo_data = &chan->algo;
104 chan->adapter.dev.parent = &chan->par->pdev->dev; 103 chan->adapter.dev.parent = &chan->par->pdev->dev;
105 chan->algo.setsda = riva_gpio_setsda; 104 chan->algo.setsda = riva_gpio_setsda;
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
index 024a0cecff15..847698b5cfe7 100644
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -137,7 +137,6 @@ static int prosavage_gpio_getsda(void* data)
137 return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN)); 137 return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
138} 138}
139 139
140#define I2C_ALGO_SAVAGE 0x0f0000
141static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan, 140static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
142 const char *name) 141 const char *name)
143{ 142{
@@ -147,7 +146,7 @@ static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
147 if (add_bus && chan->par) { 146 if (add_bus && chan->par) {
148 strcpy(chan->adapter.name, name); 147 strcpy(chan->adapter.name, name);
149 chan->adapter.owner = THIS_MODULE; 148 chan->adapter.owner = THIS_MODULE;
150 chan->adapter.id = I2C_ALGO_SAVAGE; 149 chan->adapter.id = I2C_HW_B_SAVAGE;
151 chan->adapter.algo_data = &chan->algo; 150 chan->adapter.algo_data = &chan->algo;
152 chan->adapter.dev.parent = &chan->par->pcidev->dev; 151 chan->adapter.dev.parent = &chan->par->pcidev->dev;
153 chan->algo.udelay = 40; 152 chan->algo.udelay = 40;
diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
index 1b5018a965f5..7eb4004b3601 100644
--- a/include/linux/hwmon-sysfs.h
+++ b/include/linux/hwmon-sysfs.h
@@ -33,4 +33,19 @@ struct sensor_device_attribute sensor_dev_attr_##_name = { \
33 .index = _index, \ 33 .index = _index, \
34} 34}
35 35
36struct sensor_device_attribute_2 {
37 struct device_attribute dev_attr;
38 u8 index;
39 u8 nr;
40};
41#define to_sensor_dev_attr_2(_dev_attr) \
42 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
43
44#define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \
45struct sensor_device_attribute_2 sensor_dev_attr_##_name = { \
46 .dev_attr = __ATTR(_name,_mode,_show,_store), \
47 .index = _index, \
48 .nr = _nr, \
49}
50
36#endif /* _LINUX_HWMON_SYSFS_H */ 51#endif /* _LINUX_HWMON_SYSFS_H */
diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h
new file mode 100644
index 000000000000..cd4b7a042b86
--- /dev/null
+++ b/include/linux/hwmon-vid.h
@@ -0,0 +1,45 @@
1/*
2 hwmon-vid.h - VID/VRM/VRD voltage conversions
3
4 Originally part of lm_sensors
5 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
6 With assistance from Trent Piepho <xyzzy@speakeasy.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23#ifndef _LINUX_HWMON_VID_H
24#define _LINUX_HWMON_VID_H
25
26int vid_from_reg(int val, int vrm);
27int vid_which_vrm(void);
28
29/* vrm is the VRM/VRD document version multiplied by 10.
30 val is in mV to avoid floating point in the kernel.
31 Returned value is the 4-, 5- or 6-bit VID code.
32 Note that only VRM 9.x is supported for now. */
33static inline int vid_to_reg(int val, int vrm)
34{
35 switch (vrm) {
36 case 91: /* VRM 9.1 */
37 case 90: /* VRM 9.0 */
38 return ((val >= 1100) && (val <= 1850) ?
39 ((18499 - val * 10) / 25 + 5) / 10 : -1);
40 default:
41 return -1;
42 }
43}
44
45#endif /* _LINUX_HWMON_VID_H */
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
new file mode 100644
index 000000000000..0efd994c37f1
--- /dev/null
+++ b/include/linux/hwmon.h
@@ -0,0 +1,35 @@
1/*
2 hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring
3
4 This file declares helper functions for the sysfs class "hwmon",
5 for use by sensors drivers.
6
7 Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
12*/
13
14#ifndef _HWMON_H_
15#define _HWMON_H_
16
17#include <linux/device.h>
18
19struct class_device *hwmon_device_register(struct device *dev);
20
21void hwmon_device_unregister(struct class_device *cdev);
22
23/* Scale user input to sensible values */
24static inline int SENSORS_LIMIT(long value, long low, long high)
25{
26 if (value < low)
27 return low;
28 else if (value > high)
29 return high;
30 else
31 return value;
32}
33
34#endif
35
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 33f08258f22b..44f30876a1c9 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -1,6 +1,6 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* i2c.h - definitions for the i2c-bus interface */ 3/* i2c-id.h - identifier values for i2c drivers and adapters */
4/* */ 4/* */
5/* ------------------------------------------------------------------------- */ 5/* ------------------------------------------------------------------------- */
6/* Copyright (C) 1995-1999 Simon G. Vogl 6/* Copyright (C) 1995-1999 Simon G. Vogl
@@ -24,16 +24,6 @@
24#define LINUX_I2C_ID_H 24#define LINUX_I2C_ID_H
25 25
26/* 26/*
27 * This file is part of the i2c-bus package and contains the identifier
28 * values for drivers, adapters and other folk populating these serial
29 * worlds.
30 *
31 * These will change often (i.e. additions) , therefore this has been
32 * separated from the functional interface definitions of the i2c api.
33 *
34 */
35
36/*
37 * ---- Driver types ----------------------------------------------------- 27 * ---- Driver types -----------------------------------------------------
38 * device id name + number function description, i2c address(es) 28 * device id name + number function description, i2c address(es)
39 * 29 *
@@ -170,151 +160,113 @@
170 160
171/* 161/*
172 * ---- Adapter types ---------------------------------------------------- 162 * ---- Adapter types ----------------------------------------------------
173 *
174 * First, we distinguish between several algorithms to access the hardware
175 * interface types, as a PCF 8584 needs other care than a bit adapter.
176 */
177
178#define I2C_ALGO_NONE 0x000000
179#define I2C_ALGO_BIT 0x010000 /* bit style adapters */
180#define I2C_ALGO_PCF 0x020000 /* PCF 8584 style adapters */
181#define I2C_ALGO_ATI 0x030000 /* ATI video card */
182#define I2C_ALGO_SMBUS 0x040000
183#define I2C_ALGO_ISA 0x050000 /* lm_sensors ISA pseudo-adapter */
184#define I2C_ALGO_SAA7146 0x060000 /* SAA 7146 video decoder bus */
185#define I2C_ALGO_ACB 0x070000 /* ACCESS.bus algorithm */
186#define I2C_ALGO_IIC 0x080000 /* ITE IIC bus */
187#define I2C_ALGO_SAA7134 0x090000
188#define I2C_ALGO_MPC824X 0x0a0000 /* Motorola 8240 / 8245 */
189#define I2C_ALGO_IPMI 0x0b0000 /* IPMI dummy adapter */
190#define I2C_ALGO_IPMB 0x0c0000 /* IPMB adapter */
191#define I2C_ALGO_MPC107 0x0d0000
192#define I2C_ALGO_EC 0x100000 /* ACPI embedded controller */
193
194#define I2C_ALGO_MPC8XX 0x110000 /* MPC8xx PowerPC I2C algorithm */
195#define I2C_ALGO_OCP 0x120000 /* IBM or otherwise On-chip I2C algorithm */
196#define I2C_ALGO_BITHS 0x130000 /* enhanced bit style adapters */
197#define I2C_ALGO_IOP3XX 0x140000 /* XSCALE IOP3XX On-chip I2C alg */
198#define I2C_ALGO_SIBYTE 0x150000 /* Broadcom SiByte SOCs */
199#define I2C_ALGO_SGI 0x160000 /* SGI algorithm */
200
201#define I2C_ALGO_USB 0x170000 /* USB algorithm */
202#define I2C_ALGO_VIRT 0x180000 /* Virtual bus adapter */
203
204#define I2C_ALGO_MV64XXX 0x190000 /* Marvell mv64xxx i2c ctlr */
205#define I2C_ALGO_PCA 0x1a0000 /* PCA 9564 style adapters */
206#define I2C_ALGO_AU1550 0x1b0000 /* Au1550 PSC algorithm */
207
208#define I2C_ALGO_EXP 0x800000 /* experimental */
209
210#define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */
211#define I2C_ALGO_SHIFT 0x10 /* right shift to get index values */
212
213#define I2C_HW_ADAPS 0x10000 /* # adapter types */
214#define I2C_HW_MASK 0xffff
215
216
217/* hw specific modules that are defined per algorithm layer
218 */ 163 */
219 164
220/* --- Bit algorithm adapters */ 165/* --- Bit algorithm adapters */
221#define I2C_HW_B_LP 0x00 /* Parallel port Philips style adapter */ 166#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */
222#define I2C_HW_B_LPC 0x01 /* Parallel port, over control reg. */ 167#define I2C_HW_B_LPC 0x010001 /* Parallel port control reg. */
223#define I2C_HW_B_SER 0x02 /* Serial line interface */ 168#define I2C_HW_B_SER 0x010002 /* Serial line interface */
224#define I2C_HW_B_ELV 0x03 /* ELV Card */ 169#define I2C_HW_B_ELV 0x010003 /* ELV Card */
225#define I2C_HW_B_VELLE 0x04 /* Vellemann K8000 */ 170#define I2C_HW_B_VELLE 0x010004 /* Vellemann K8000 */
226#define I2C_HW_B_BT848 0x05 /* BT848 video boards */ 171#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
227#define I2C_HW_B_WNV 0x06 /* Winnov Videums */ 172#define I2C_HW_B_WNV 0x010006 /* Winnov Videums */
228#define I2C_HW_B_VIA 0x07 /* Via vt82c586b */ 173#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */
229#define I2C_HW_B_HYDRA 0x08 /* Apple Hydra Mac I/O */ 174#define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */
230#define I2C_HW_B_G400 0x09 /* Matrox G400 */ 175#define I2C_HW_B_G400 0x010009 /* Matrox G400 */
231#define I2C_HW_B_I810 0x0a /* Intel I810 */ 176#define I2C_HW_B_I810 0x01000a /* Intel I810 */
232#define I2C_HW_B_VOO 0x0b /* 3dfx Voodoo 3 / Banshee */ 177#define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */
233#define I2C_HW_B_PPORT 0x0c /* Primitive parallel port adapter */ 178#define I2C_HW_B_PPORT 0x01000c /* Primitive parallel port adapter */
234#define I2C_HW_B_SAVG 0x0d /* Savage 4 */ 179#define I2C_HW_B_SAVG 0x01000d /* Savage 4 */
235#define I2C_HW_B_SCX200 0x0e /* Nat'l Semi SCx200 I2C */ 180#define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */
236#define I2C_HW_B_RIVA 0x10 /* Riva based graphics cards */ 181#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */
237#define I2C_HW_B_IOC 0x11 /* IOC bit-wiggling */ 182#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */
238#define I2C_HW_B_TSUNA 0x12 /* DEC Tsunami chipset */ 183#define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */
239#define I2C_HW_B_FRODO 0x13 /* 2d3D, Inc. SA-1110 Development Board */ 184#define I2C_HW_B_FRODO 0x010013 /* 2d3D SA-1110 Development Board */
240#define I2C_HW_B_OMAHA 0x14 /* Omaha I2C interface (ARM) */ 185#define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */
241#define I2C_HW_B_GUIDE 0x15 /* Guide bit-basher */ 186#define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */
242#define I2C_HW_B_IXP2000 0x16 /* GPIO on IXP2000 systems */ 187#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */
243#define I2C_HW_B_IXP4XX 0x17 /* GPIO on IXP4XX systems */ 188#define I2C_HW_B_IXP4XX 0x010017 /* GPIO on IXP4XX systems */
244#define I2C_HW_B_S3VIA 0x18 /* S3Via ProSavage adapter */ 189#define I2C_HW_B_S3VIA 0x010018 /* S3Via ProSavage adapter */
245#define I2C_HW_B_ZR36067 0x19 /* Zoran-36057/36067 based boards */ 190#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */
246#define I2C_HW_B_PCILYNX 0x1a /* TI PCILynx I2C adapter */ 191#define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */
247#define I2C_HW_B_CX2388x 0x1b /* connexant 2388x based tv cards */ 192#define I2C_HW_B_CX2388x 0x01001b /* connexant 2388x based tv cards */
193#define I2C_HW_B_NVIDIA 0x01001c /* nvidia framebuffer driver */
194#define I2C_HW_B_SAVAGE 0x01001d /* savage framebuffer driver */
195#define I2C_HW_B_RADEON 0x01001e /* radeon framebuffer driver */
248 196
249/* --- PCF 8584 based algorithms */ 197/* --- PCF 8584 based algorithms */
250#define I2C_HW_P_LP 0x00 /* Parallel port interface */ 198#define I2C_HW_P_LP 0x020000 /* Parallel port interface */
251#define I2C_HW_P_ISA 0x01 /* generic ISA Bus inteface card */ 199#define I2C_HW_P_ISA 0x020001 /* generic ISA Bus inteface card */
252#define I2C_HW_P_ELEK 0x02 /* Elektor ISA Bus inteface card */ 200#define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */
253 201
254/* --- PCA 9564 based algorithms */ 202/* --- PCA 9564 based algorithms */
255#define I2C_HW_A_ISA 0x00 /* generic ISA Bus interface card */ 203#define I2C_HW_A_ISA 0x1a0000 /* generic ISA Bus interface card */
256 204
257/* --- ACPI Embedded controller algorithms */ 205/* --- ACPI Embedded controller algorithms */
258#define I2C_HW_ACPI_EC 0x00 206#define I2C_HW_ACPI_EC 0x1f0000
259 207
260/* --- MPC824x PowerPC adapters */ 208/* --- MPC824x PowerPC adapters */
261#define I2C_HW_MPC824X 0x00 /* Motorola 8240 / 8245 */ 209#define I2C_HW_MPC824X 0x100001 /* Motorola 8240 / 8245 */
262 210
263/* --- MPC8xx PowerPC adapters */ 211/* --- MPC8xx PowerPC adapters */
264#define I2C_HW_MPC8XX_EPON 0x00 /* Eponymous MPC8xx I2C adapter */ 212#define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */
265 213
266/* --- ITE based algorithms */ 214/* --- ITE based algorithms */
267#define I2C_HW_I_IIC 0x00 /* controller on the ITE */ 215#define I2C_HW_I_IIC 0x080000 /* controller on the ITE */
268 216
269/* --- PowerPC on-chip adapters */ 217/* --- PowerPC on-chip adapters */
270#define I2C_HW_OCP 0x00 /* IBM on-chip I2C adapter */ 218#define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */
271 219
272/* --- Broadcom SiByte adapters */ 220/* --- Broadcom SiByte adapters */
273#define I2C_HW_SIBYTE 0x00 221#define I2C_HW_SIBYTE 0x150000
274 222
275/* --- SGI adapters */ 223/* --- SGI adapters */
276#define I2C_HW_SGI_VINO 0x00 224#define I2C_HW_SGI_VINO 0x160000
277#define I2C_HW_SGI_MACE 0x01 225#define I2C_HW_SGI_MACE 0x160001
278 226
279/* --- XSCALE on-chip adapters */ 227/* --- XSCALE on-chip adapters */
280#define I2C_HW_IOP3XX 0x00 228#define I2C_HW_IOP3XX 0x140000
281 229
282/* --- Au1550 PSC adapters adapters */ 230/* --- Au1550 PSC adapters adapters */
283#define I2C_HW_AU1550_PSC 0x00 231#define I2C_HW_AU1550_PSC 0x1b0000
284 232
285/* --- SMBus only adapters */ 233/* --- SMBus only adapters */
286#define I2C_HW_SMBUS_PIIX4 0x00 234#define I2C_HW_SMBUS_PIIX4 0x040000
287#define I2C_HW_SMBUS_ALI15X3 0x01 235#define I2C_HW_SMBUS_ALI15X3 0x040001
288#define I2C_HW_SMBUS_VIA2 0x02 236#define I2C_HW_SMBUS_VIA2 0x040002
289#define I2C_HW_SMBUS_VOODOO3 0x03 237#define I2C_HW_SMBUS_VOODOO3 0x040003
290#define I2C_HW_SMBUS_I801 0x04 238#define I2C_HW_SMBUS_I801 0x040004
291#define I2C_HW_SMBUS_AMD756 0x05 239#define I2C_HW_SMBUS_AMD756 0x040005
292#define I2C_HW_SMBUS_SIS5595 0x06 240#define I2C_HW_SMBUS_SIS5595 0x040006
293#define I2C_HW_SMBUS_ALI1535 0x07 241#define I2C_HW_SMBUS_ALI1535 0x040007
294#define I2C_HW_SMBUS_SIS630 0x08 242#define I2C_HW_SMBUS_SIS630 0x040008
295#define I2C_HW_SMBUS_SIS96X 0x09 243#define I2C_HW_SMBUS_SIS96X 0x040009
296#define I2C_HW_SMBUS_AMD8111 0x0a 244#define I2C_HW_SMBUS_AMD8111 0x04000a
297#define I2C_HW_SMBUS_SCX200 0x0b 245#define I2C_HW_SMBUS_SCX200 0x04000b
298#define I2C_HW_SMBUS_NFORCE2 0x0c 246#define I2C_HW_SMBUS_NFORCE2 0x04000c
299#define I2C_HW_SMBUS_W9968CF 0x0d 247#define I2C_HW_SMBUS_W9968CF 0x04000d
300#define I2C_HW_SMBUS_OV511 0x0e /* OV511(+) USB 1.1 webcam ICs */ 248#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */
301#define I2C_HW_SMBUS_OV518 0x0f /* OV518(+) USB 1.1 webcam ICs */ 249#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */
302#define I2C_HW_SMBUS_OV519 0x10 /* OV519 USB 1.1 webcam IC */ 250#define I2C_HW_SMBUS_OV519 0x040010 /* OV519 USB 1.1 webcam IC */
303#define I2C_HW_SMBUS_OVFX2 0x11 /* Cypress/OmniVision FX2 webcam */ 251#define I2C_HW_SMBUS_OVFX2 0x040011 /* Cypress/OmniVision FX2 webcam */
304 252
305/* --- ISA pseudo-adapter */ 253/* --- ISA pseudo-adapter */
306#define I2C_HW_ISA 0x00 254#define I2C_HW_ISA 0x050000
307 255
308/* --- IPMI pseudo-adapter */ 256/* --- IPMI pseudo-adapter */
309#define I2C_HW_IPMI 0x00 257#define I2C_HW_IPMI 0x0b0000
310 258
311/* --- IPMB adapter */ 259/* --- IPMB adapter */
312#define I2C_HW_IPMB 0x00 260#define I2C_HW_IPMB 0x0c0000
313 261
314/* --- MCP107 adapter */ 262/* --- MCP107 adapter */
315#define I2C_HW_MPC107 0x00 263#define I2C_HW_MPC107 0x0d0000
316 264
317/* --- Marvell mv64xxx i2c adapter */ 265/* --- Marvell mv64xxx i2c adapter */
318#define I2C_HW_MV64XXX 0x00 266#define I2C_HW_MV64XXX 0x190000
267
268/* --- Miscellaneous adapters */
269#define I2C_HW_SAA7146 0x060000 /* SAA7146 video decoder bus */
270#define I2C_HW_SAA7134 0x090000 /* SAA7134 video decoder bus */
319 271
320#endif /* LINUX_I2C_ID_H */ 272#endif /* LINUX_I2C_ID_H */
diff --git a/include/linux/i2c-isa.h b/include/linux/i2c-isa.h
new file mode 100644
index 000000000000..67e3598c4cec
--- /dev/null
+++ b/include/linux/i2c-isa.h
@@ -0,0 +1,36 @@
1/*
2 * i2c-isa.h - definitions for the i2c-isa pseudo-i2c-adapter interface
3 *
4 * Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
5 *
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
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef _LINUX_I2C_ISA_H
22#define _LINUX_I2C_ISA_H
23
24#include <linux/i2c.h>
25
26extern int i2c_isa_add_driver(struct i2c_driver *driver);
27extern int i2c_isa_del_driver(struct i2c_driver *driver);
28
29/* Detect whether we are on the isa bus. This is only useful to hybrid
30 (i2c+isa) drivers. */
31#define i2c_is_isa_adapter(adapptr) \
32 ((adapptr)->id == I2C_HW_ISA)
33#define i2c_is_isa_client(clientptr) \
34 i2c_is_isa_adapter((clientptr)->adapter)
35
36#endif /* _LINUX_I2C_ISA_H */
diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h
deleted file mode 100644
index 21b625204956..000000000000
--- a/include/linux/i2c-sensor.h
+++ /dev/null
@@ -1,263 +0,0 @@
1/*
2 i2c-sensor.h - Part of the i2c package
3 was originally sensors.h - Part of lm_sensors, Linux kernel modules
4 for hardware monitoring
5 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef _LINUX_I2C_SENSOR_H
23#define _LINUX_I2C_SENSOR_H
24
25/* A structure containing detect information.
26 Force variables overrule all other variables; they force a detection on
27 that place. If a specific chip is given, the module blindly assumes this
28 chip type is present; if a general force (kind == 0) is given, the module
29 will still try to figure out what type of chip is present. This is useful
30 if for some reasons the detect for SMBus or ISA address space filled
31 fails.
32 probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
33 A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
34 the ISA bus, -1 for any I2C bus), the second is the address.
35 kind: The kind of chip. 0 equals any chip.
36*/
37struct i2c_force_data {
38 unsigned short *force;
39 unsigned short kind;
40};
41
42/* A structure containing the detect information.
43 normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END.
44 A list of I2C addresses which should normally be examined.
45 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
46 A list of ISA addresses which should normally be examined.
47 probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
48 A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
49 the ISA bus, -1 for any I2C bus), the second is the address. These
50 addresses are also probed, as if they were in the 'normal' list.
51 ignore: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values.
52 A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for
53 the ISA bus, -1 for any I2C bus), the second is the I2C address. These
54 addresses are never probed. This parameter overrules 'normal' and
55 'probe', but not the 'force' lists.
56 force_data: insmod parameters. A list, ending with an element of which
57 the force field is NULL.
58*/
59struct i2c_address_data {
60 unsigned short *normal_i2c;
61 unsigned int *normal_isa;
62 unsigned short *probe;
63 unsigned short *ignore;
64 struct i2c_force_data *forces;
65};
66
67#define SENSORS_MODULE_PARM_FORCE(name) \
68 I2C_CLIENT_MODULE_PARM(force_ ## name, \
69 "List of adapter,address pairs which are unquestionably" \
70 " assumed to contain a `" # name "' chip")
71
72
73/* This defines several insmod variables, and the addr_data structure */
74#define SENSORS_INSMOD \
75 I2C_CLIENT_MODULE_PARM(probe, \
76 "List of adapter,address pairs to scan additionally"); \
77 I2C_CLIENT_MODULE_PARM(ignore, \
78 "List of adapter,address pairs not to scan"); \
79 static struct i2c_address_data addr_data = { \
80 .normal_i2c = normal_i2c, \
81 .normal_isa = normal_isa, \
82 .probe = probe, \
83 .ignore = ignore, \
84 .forces = forces, \
85 }
86
87/* The following functions create an enum with the chip names as elements.
88 The first element of the enum is any_chip. These are the only macros
89 a module will want to use. */
90
91#define SENSORS_INSMOD_0 \
92 enum chips { any_chip }; \
93 I2C_CLIENT_MODULE_PARM(force, \
94 "List of adapter,address pairs to boldly assume " \
95 "to be present"); \
96 static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
97 SENSORS_INSMOD
98
99#define SENSORS_INSMOD_1(chip1) \
100 enum chips { any_chip, chip1 }; \
101 I2C_CLIENT_MODULE_PARM(force, \
102 "List of adapter,address pairs to boldly assume " \
103 "to be present"); \
104 SENSORS_MODULE_PARM_FORCE(chip1); \
105 static struct i2c_force_data forces[] = {{force,any_chip},\
106 {force_ ## chip1,chip1}, \
107 {NULL}}; \
108 SENSORS_INSMOD
109
110#define SENSORS_INSMOD_2(chip1,chip2) \
111 enum chips { any_chip, chip1, chip2 }; \
112 I2C_CLIENT_MODULE_PARM(force, \
113 "List of adapter,address pairs to boldly assume " \
114 "to be present"); \
115 SENSORS_MODULE_PARM_FORCE(chip1); \
116 SENSORS_MODULE_PARM_FORCE(chip2); \
117 static struct i2c_force_data forces[] = {{force,any_chip}, \
118 {force_ ## chip1,chip1}, \
119 {force_ ## chip2,chip2}, \
120 {NULL}}; \
121 SENSORS_INSMOD
122
123#define SENSORS_INSMOD_3(chip1,chip2,chip3) \
124 enum chips { any_chip, chip1, chip2, chip3 }; \
125 I2C_CLIENT_MODULE_PARM(force, \
126 "List of adapter,address pairs to boldly assume " \
127 "to be present"); \
128 SENSORS_MODULE_PARM_FORCE(chip1); \
129 SENSORS_MODULE_PARM_FORCE(chip2); \
130 SENSORS_MODULE_PARM_FORCE(chip3); \
131 static struct i2c_force_data forces[] = {{force,any_chip}, \
132 {force_ ## chip1,chip1}, \
133 {force_ ## chip2,chip2}, \
134 {force_ ## chip3,chip3}, \
135 {NULL}}; \
136 SENSORS_INSMOD
137
138#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
139 enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
140 I2C_CLIENT_MODULE_PARM(force, \
141 "List of adapter,address pairs to boldly assume " \
142 "to be present"); \
143 SENSORS_MODULE_PARM_FORCE(chip1); \
144 SENSORS_MODULE_PARM_FORCE(chip2); \
145 SENSORS_MODULE_PARM_FORCE(chip3); \
146 SENSORS_MODULE_PARM_FORCE(chip4); \
147 static struct i2c_force_data forces[] = {{force,any_chip}, \
148 {force_ ## chip1,chip1}, \
149 {force_ ## chip2,chip2}, \
150 {force_ ## chip3,chip3}, \
151 {force_ ## chip4,chip4}, \
152 {NULL}}; \
153 SENSORS_INSMOD
154
155#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
156 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
157 I2C_CLIENT_MODULE_PARM(force, \
158 "List of adapter,address pairs to boldly assume " \
159 "to be present"); \
160 SENSORS_MODULE_PARM_FORCE(chip1); \
161 SENSORS_MODULE_PARM_FORCE(chip2); \
162 SENSORS_MODULE_PARM_FORCE(chip3); \
163 SENSORS_MODULE_PARM_FORCE(chip4); \
164 SENSORS_MODULE_PARM_FORCE(chip5); \
165 static struct i2c_force_data forces[] = {{force,any_chip}, \
166 {force_ ## chip1,chip1}, \
167 {force_ ## chip2,chip2}, \
168 {force_ ## chip3,chip3}, \
169 {force_ ## chip4,chip4}, \
170 {force_ ## chip5,chip5}, \
171 {NULL}}; \
172 SENSORS_INSMOD
173
174#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
175 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
176 I2C_CLIENT_MODULE_PARM(force, \
177 "List of adapter,address pairs to boldly assume " \
178 "to be present"); \
179 SENSORS_MODULE_PARM_FORCE(chip1); \
180 SENSORS_MODULE_PARM_FORCE(chip2); \
181 SENSORS_MODULE_PARM_FORCE(chip3); \
182 SENSORS_MODULE_PARM_FORCE(chip4); \
183 SENSORS_MODULE_PARM_FORCE(chip5); \
184 SENSORS_MODULE_PARM_FORCE(chip6); \
185 static struct i2c_force_data forces[] = {{force,any_chip}, \
186 {force_ ## chip1,chip1}, \
187 {force_ ## chip2,chip2}, \
188 {force_ ## chip3,chip3}, \
189 {force_ ## chip4,chip4}, \
190 {force_ ## chip5,chip5}, \
191 {force_ ## chip6,chip6}, \
192 {NULL}}; \
193 SENSORS_INSMOD
194
195#define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
196 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
197 I2C_CLIENT_MODULE_PARM(force, \
198 "List of adapter,address pairs to boldly assume " \
199 "to be present"); \
200 SENSORS_MODULE_PARM_FORCE(chip1); \
201 SENSORS_MODULE_PARM_FORCE(chip2); \
202 SENSORS_MODULE_PARM_FORCE(chip3); \
203 SENSORS_MODULE_PARM_FORCE(chip4); \
204 SENSORS_MODULE_PARM_FORCE(chip5); \
205 SENSORS_MODULE_PARM_FORCE(chip6); \
206 SENSORS_MODULE_PARM_FORCE(chip7); \
207 static struct i2c_force_data forces[] = {{force,any_chip}, \
208 {force_ ## chip1,chip1}, \
209 {force_ ## chip2,chip2}, \
210 {force_ ## chip3,chip3}, \
211 {force_ ## chip4,chip4}, \
212 {force_ ## chip5,chip5}, \
213 {force_ ## chip6,chip6}, \
214 {force_ ## chip7,chip7}, \
215 {NULL}}; \
216 SENSORS_INSMOD
217
218#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
219 enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
220 I2C_CLIENT_MODULE_PARM(force, \
221 "List of adapter,address pairs to boldly assume " \
222 "to be present"); \
223 SENSORS_MODULE_PARM_FORCE(chip1); \
224 SENSORS_MODULE_PARM_FORCE(chip2); \
225 SENSORS_MODULE_PARM_FORCE(chip3); \
226 SENSORS_MODULE_PARM_FORCE(chip4); \
227 SENSORS_MODULE_PARM_FORCE(chip5); \
228 SENSORS_MODULE_PARM_FORCE(chip6); \
229 SENSORS_MODULE_PARM_FORCE(chip7); \
230 SENSORS_MODULE_PARM_FORCE(chip8); \
231 static struct i2c_force_data forces[] = {{force,any_chip}, \
232 {force_ ## chip1,chip1}, \
233 {force_ ## chip2,chip2}, \
234 {force_ ## chip3,chip3}, \
235 {force_ ## chip4,chip4}, \
236 {force_ ## chip5,chip5}, \
237 {force_ ## chip6,chip6}, \
238 {force_ ## chip7,chip7}, \
239 {force_ ## chip8,chip8}, \
240 {NULL}}; \
241 SENSORS_INSMOD
242
243/* Detect function. It iterates over all possible addresses itself. For
244 SMBus addresses, it will only call found_proc if some client is connected
245 to the SMBus (unless a 'force' matched); for ISA detections, this is not
246 done. */
247extern int i2c_detect(struct i2c_adapter *adapter,
248 struct i2c_address_data *address_data,
249 int (*found_proc) (struct i2c_adapter *, int, int));
250
251
252/* This macro is used to scale user-input to sensible values in almost all
253 chip drivers. */
254static inline int SENSORS_LIMIT(long value, long low, long high)
255{
256 if (value < low)
257 return low;
258 else if (value > high)
259 return high;
260 else
261 return value;
262}
263#endif /* def _LINUX_I2C_SENSOR_H */
diff --git a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h
deleted file mode 100644
index 41d0635e0ba9..000000000000
--- a/include/linux/i2c-vid.h
+++ /dev/null
@@ -1,111 +0,0 @@
1/*
2 i2c-vid.h - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
5 With assistance from Trent Piepho <xyzzy@speakeasy.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22/*
23 This file contains common code for decoding VID pins.
24 This file is #included in various chip drivers in this directory.
25 As the user is unlikely to load more than one driver which
26 includes this code we don't worry about the wasted space.
27 Reference: VRM x.y DC-DC Converter Design Guidelines,
28 available at http://developer.intel.com
29*/
30
31/*
32 AMD Opteron processors don't follow the Intel VRM spec.
33 I'm going to "make up" 2.4 as the VRM spec for the Opterons.
34 No good reason just a mnemonic for the 24x Opteron processor
35 series
36
37 Opteron VID encoding is:
38
39 00000 = 1.550 V
40 00001 = 1.525 V
41 . . . .
42 11110 = 0.800 V
43 11111 = 0.000 V (off)
44 */
45
46/*
47 Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
48 vrm is the Intel VRM document version.
49 Note: vrm version is scaled by 10 and the return value is scaled by 1000
50 to avoid floating point in the kernel.
51*/
52
53int i2c_which_vrm(void);
54
55#define DEFAULT_VRM 82
56
57static inline int vid_from_reg(int val, int vrm)
58{
59 int vid;
60
61 switch(vrm) {
62
63 case 0:
64 return 0;
65
66 case 100: /* VRD 10.0 */
67 if((val & 0x1f) == 0x1f)
68 return 0;
69 if((val & 0x1f) <= 0x09 || val == 0x0a)
70 vid = 10875 - (val & 0x1f) * 250;
71 else
72 vid = 18625 - (val & 0x1f) * 250;
73 if(val & 0x20)
74 vid -= 125;
75 vid /= 10; /* only return 3 dec. places for now */
76 return vid;
77
78 case 24: /* Opteron processor */
79 return(val == 0x1f ? 0 : 1550 - val * 25);
80
81 case 91: /* VRM 9.1 */
82 case 90: /* VRM 9.0 */
83 return(val == 0x1f ? 0 :
84 1850 - val * 25);
85
86 case 85: /* VRM 8.5 */
87 return((val & 0x10 ? 25 : 0) +
88 ((val & 0x0f) > 0x04 ? 2050 : 1250) -
89 ((val & 0x0f) * 50));
90
91 case 84: /* VRM 8.4 */
92 val &= 0x0f;
93 /* fall through */
94 default: /* VRM 8.2 */
95 return(val == 0x1f ? 0 :
96 val & 0x10 ? 5100 - (val) * 100 :
97 2050 - (val) * 50);
98 }
99}
100
101static inline int vid_to_reg(int val, int vrm)
102{
103 switch (vrm) {
104 case 91: /* VRM 9.1 */
105 case 90: /* VRM 9.0 */
106 return ((val >= 1100) && (val <= 1850) ?
107 ((18499 - val * 10) / 25 + 5) / 10 : -1);
108 default:
109 return -1;
110 }
111}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index be837b13f297..be35332b67e6 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -34,6 +34,13 @@
34#include <linux/device.h> /* for struct device */ 34#include <linux/device.h> /* for struct device */
35#include <asm/semaphore.h> 35#include <asm/semaphore.h>
36 36
37/* --- For i2c-isa ---------------------------------------------------- */
38
39extern void i2c_adapter_dev_release(struct device *dev);
40extern struct device_driver i2c_adapter_driver;
41extern struct class i2c_adapter_class;
42extern struct bus_type i2c_bus_type;
43
37/* --- General options ------------------------------------------------ */ 44/* --- General options ------------------------------------------------ */
38 45
39struct i2c_msg; 46struct i2c_msg;
@@ -41,7 +48,6 @@ struct i2c_algorithm;
41struct i2c_adapter; 48struct i2c_adapter;
42struct i2c_client; 49struct i2c_client;
43struct i2c_driver; 50struct i2c_driver;
44struct i2c_client_address_data;
45union i2c_smbus_data; 51union i2c_smbus_data;
46 52
47/* 53/*
@@ -143,12 +149,9 @@ struct i2c_driver {
143 */ 149 */
144struct i2c_client { 150struct i2c_client {
145 unsigned int flags; /* div., see below */ 151 unsigned int flags; /* div., see below */
146 unsigned int addr; /* chip address - NOTE: 7bit */ 152 unsigned short addr; /* chip address - NOTE: 7bit */
147 /* addresses are stored in the */ 153 /* addresses are stored in the */
148 /* _LOWER_ 7 bits of this char */ 154 /* _LOWER_ 7 bits */
149 /* addr: unsigned int to make lm_sensors i2c-isa adapter work
150 more cleanly. It does not take any more memory space, due to
151 alignment considerations */
152 struct i2c_adapter *adapter; /* the adapter we sit on */ 155 struct i2c_adapter *adapter; /* the adapter we sit on */
153 struct i2c_driver *driver; /* and our access routines */ 156 struct i2c_driver *driver; /* and our access routines */
154 int usage_count; /* How many accesses currently */ 157 int usage_count; /* How many accesses currently */
@@ -160,6 +163,11 @@ struct i2c_client {
160}; 163};
161#define to_i2c_client(d) container_of(d, struct i2c_client, dev) 164#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
162 165
166static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
167{
168 return to_i2c_client(container_of(kobj, struct device, kobj));
169}
170
163static inline void *i2c_get_clientdata (struct i2c_client *dev) 171static inline void *i2c_get_clientdata (struct i2c_client *dev)
164{ 172{
165 return dev_get_drvdata (&dev->dev); 173 return dev_get_drvdata (&dev->dev);
@@ -170,13 +178,6 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
170 dev_set_drvdata (&dev->dev, data); 178 dev_set_drvdata (&dev->dev, data);
171} 179}
172 180
173#define I2C_DEVNAME(str) .name = str
174
175static inline char *i2c_clientname(struct i2c_client *c)
176{
177 return &c->name[0];
178}
179
180/* 181/*
181 * The following structs are for those who like to implement new bus drivers: 182 * The following structs are for those who like to implement new bus drivers:
182 * i2c_algorithm is the interface to a class of hardware solutions which can 183 * i2c_algorithm is the interface to a class of hardware solutions which can
@@ -184,9 +185,6 @@ static inline char *i2c_clientname(struct i2c_client *c)
184 * to name two of the most common. 185 * to name two of the most common.
185 */ 186 */
186struct i2c_algorithm { 187struct i2c_algorithm {
187 char name[32]; /* textual description */
188 unsigned int id;
189
190 /* If an adapter algorithm can't do I2C-level access, set master_xfer 188 /* If an adapter algorithm can't do I2C-level access, set master_xfer
191 to NULL. If an adapter algorithm can do SMBus access, set 189 to NULL. If an adapter algorithm can do SMBus access, set
192 smbus_xfer. If set to NULL, the SMBus protocol is simulated 190 smbus_xfer. If set to NULL, the SMBus protocol is simulated
@@ -214,8 +212,7 @@ struct i2c_algorithm {
214 */ 212 */
215struct i2c_adapter { 213struct i2c_adapter {
216 struct module *owner; 214 struct module *owner;
217 unsigned int id;/* == is algo->id | hwdep.struct->id, */ 215 unsigned int id;
218 /* for registered values see below */
219 unsigned int class; 216 unsigned int class;
220 struct i2c_algorithm *algo;/* the algorithm to access the bus */ 217 struct i2c_algorithm *algo;/* the algorithm to access the bus */
221 void *algo_data; 218 void *algo_data;
@@ -292,12 +289,11 @@ struct i2c_client_address_data {
292 unsigned short *normal_i2c; 289 unsigned short *normal_i2c;
293 unsigned short *probe; 290 unsigned short *probe;
294 unsigned short *ignore; 291 unsigned short *ignore;
295 unsigned short *force; 292 unsigned short **forces;
296}; 293};
297 294
298/* Internal numbers to terminate lists */ 295/* Internal numbers to terminate lists */
299#define I2C_CLIENT_END 0xfffeU 296#define I2C_CLIENT_END 0xfffeU
300#define I2C_CLIENT_ISA_END 0xfffefffeU
301 297
302/* The numbers to use to set I2C bus address */ 298/* The numbers to use to set I2C bus address */
303#define ANY_I2C_BUS 0xffff 299#define ANY_I2C_BUS 0xffff
@@ -356,10 +352,6 @@ extern int i2c_probe(struct i2c_adapter *adapter,
356 */ 352 */
357extern int i2c_control(struct i2c_client *,unsigned int, unsigned long); 353extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
358 354
359/* This call returns a unique low identifier for each registered adapter,
360 * or -1 if the adapter was not registered.
361 */
362extern int i2c_adapter_id(struct i2c_adapter *adap);
363extern struct i2c_adapter* i2c_get_adapter(int id); 355extern struct i2c_adapter* i2c_get_adapter(int id);
364extern void i2c_put_adapter(struct i2c_adapter *adap); 356extern void i2c_put_adapter(struct i2c_adapter *adap);
365 357
@@ -376,6 +368,12 @@ static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
376 return (func & i2c_get_functionality(adap)) == func; 368 return (func & i2c_get_functionality(adap)) == func;
377} 369}
378 370
371/* Return id number for a specific adapter */
372static inline int i2c_adapter_id(struct i2c_adapter *adap)
373{
374 return adap->nr;
375}
376
379/* 377/*
380 * I2C Message - used for pure i2c transaction, also from /dev interface 378 * I2C Message - used for pure i2c transaction, also from /dev interface
381 */ 379 */
@@ -510,9 +508,6 @@ union i2c_smbus_data {
510#define I2C_FUNCS 0x0705 /* Get the adapter functionality */ 508#define I2C_FUNCS 0x0705 /* Get the adapter functionality */
511#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ 509#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/
512#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ 510#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */
513#if 0
514#define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific address */
515#endif
516 511
517#define I2C_SMBUS 0x0720 /* SMBus-level access */ 512#define I2C_SMBUS 0x0720 /* SMBus-level access */
518 513
@@ -556,27 +551,148 @@ union i2c_smbus_data {
556 module_param_array(var, short, &var##_num, 0); \ 551 module_param_array(var, short, &var##_num, 0); \
557 MODULE_PARM_DESC(var,desc) 552 MODULE_PARM_DESC(var,desc)
558 553
559/* This is the one you want to use in your own modules */ 554#define I2C_CLIENT_MODULE_PARM_FORCE(name) \
555I2C_CLIENT_MODULE_PARM(force_##name, \
556 "List of adapter,address pairs which are " \
557 "unquestionably assumed to contain a `" \
558 # name "' chip")
559
560
561#define I2C_CLIENT_INSMOD_COMMON \
562I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
563 "additionally"); \
564I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
565 "scan"); \
566static struct i2c_client_address_data addr_data = { \
567 .normal_i2c = normal_i2c, \
568 .probe = probe, \
569 .ignore = ignore, \
570 .forces = forces, \
571}
572
573/* These are the ones you want to use in your own drivers. Pick the one
574 which matches the number of devices the driver differenciates between. */
560#define I2C_CLIENT_INSMOD \ 575#define I2C_CLIENT_INSMOD \
561 I2C_CLIENT_MODULE_PARM(probe, \
562 "List of adapter,address pairs to scan additionally"); \
563 I2C_CLIENT_MODULE_PARM(ignore, \
564 "List of adapter,address pairs not to scan"); \
565 I2C_CLIENT_MODULE_PARM(force, \ 576 I2C_CLIENT_MODULE_PARM(force, \
566 "List of adapter,address pairs to boldly assume " \ 577 "List of adapter,address pairs to boldly assume " \
567 "to be present"); \ 578 "to be present"); \
568 static struct i2c_client_address_data addr_data = { \ 579 static unsigned short *forces[] = { \
569 .normal_i2c = normal_i2c, \ 580 force, \
570 .probe = probe, \ 581 NULL \
571 .ignore = ignore, \ 582 }; \
572 .force = force, \ 583I2C_CLIENT_INSMOD_COMMON
573 } 584
574 585#define I2C_CLIENT_INSMOD_1(chip1) \
575/* Detect whether we are on the isa bus. If this returns true, all i2c 586enum chips { any_chip, chip1 }; \
576 access will fail! */ 587I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
577#define i2c_is_isa_client(clientptr) \ 588 "boldly assume to be present"); \
578 ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) 589I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
579#define i2c_is_isa_adapter(adapptr) \ 590static unsigned short *forces[] = { force, force_##chip1, NULL }; \
580 ((adapptr)->algo->id == I2C_ALGO_ISA) 591I2C_CLIENT_INSMOD_COMMON
592
593#define I2C_CLIENT_INSMOD_2(chip1, chip2) \
594enum chips { any_chip, chip1, chip2 }; \
595I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
596 "boldly assume to be present"); \
597I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
598I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
599static unsigned short *forces[] = { force, force_##chip1, \
600 force_##chip2, NULL }; \
601I2C_CLIENT_INSMOD_COMMON
602
603#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \
604enum chips { any_chip, chip1, chip2, chip3 }; \
605I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
606 "boldly assume to be present"); \
607I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
608I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
609I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
610static unsigned short *forces[] = { force, force_##chip1, \
611 force_##chip2, force_##chip3, \
612 NULL }; \
613I2C_CLIENT_INSMOD_COMMON
614
615#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \
616enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
617I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
618 "boldly assume to be present"); \
619I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
620I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
621I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
622I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
623static unsigned short *forces[] = { force, force_##chip1, \
624 force_##chip2, force_##chip3, \
625 force_##chip4, NULL}; \
626I2C_CLIENT_INSMOD_COMMON
627
628#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \
629enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
630I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
631 "boldly assume to be present"); \
632I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
633I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
634I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
635I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
636I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
637static unsigned short *forces[] = { force, force_##chip1, \
638 force_##chip2, force_##chip3, \
639 force_##chip4, force_##chip5, \
640 NULL }; \
641I2C_CLIENT_INSMOD_COMMON
642
643#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \
644enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
645I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
646 "boldly assume to be present"); \
647I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
648I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
649I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
650I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
651I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
652I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
653static unsigned short *forces[] = { force, force_##chip1, \
654 force_##chip2, force_##chip3, \
655 force_##chip4, force_##chip5, \
656 force_##chip6, NULL }; \
657I2C_CLIENT_INSMOD_COMMON
658
659#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
660enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
661 chip7 }; \
662I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
663 "boldly assume to be present"); \
664I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
665I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
666I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
667I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
668I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
669I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
670I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
671static unsigned short *forces[] = { force, force_##chip1, \
672 force_##chip2, force_##chip3, \
673 force_##chip4, force_##chip5, \
674 force_##chip6, force_##chip7, \
675 NULL }; \
676I2C_CLIENT_INSMOD_COMMON
677
678#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
679enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
680 chip7, chip8 }; \
681I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \
682 "boldly assume to be present"); \
683I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
684I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
685I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
686I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
687I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
688I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
689I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
690I2C_CLIENT_MODULE_PARM_FORCE(chip8); \
691static unsigned short *forces[] = { force, force_##chip1, \
692 force_##chip2, force_##chip3, \
693 force_##chip4, force_##chip5, \
694 force_##chip6, force_##chip7, \
695 force_##chip8, NULL }; \
696I2C_CLIENT_INSMOD_COMMON
581 697
582#endif /* _LINUX_I2C_H */ 698#endif /* _LINUX_I2C_H */
diff --git a/include/media/id.h b/include/media/id.h
index a39a6423914b..801ddef301aa 100644
--- a/include/media/id.h
+++ b/include/media/id.h
@@ -34,8 +34,3 @@
34#ifndef I2C_DRIVERID_SAA6752HS 34#ifndef I2C_DRIVERID_SAA6752HS
35# define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8 35# define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8
36#endif 36#endif
37
38/* algorithms */
39#ifndef I2C_ALGO_SAA7134
40# define I2C_ALGO_SAA7134 0x090000
41#endif