diff options
Diffstat (limited to 'drivers/i2c')
88 files changed, 5595 insertions, 1885 deletions
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index c3d912cbbbc3..cc3a952401f2 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -49,7 +49,7 @@ static int i2c_debug=0; | |||
49 | /* | 49 | /* |
50 | * Generate a start condition on the i2c bus. | 50 | * Generate a start condition on the i2c bus. |
51 | * | 51 | * |
52 | * returns after the start condition has occured | 52 | * returns after the start condition has occurred |
53 | */ | 53 | */ |
54 | static void pca_start(struct i2c_algo_pca_data *adap) | 54 | static void pca_start(struct i2c_algo_pca_data *adap) |
55 | { | 55 | { |
@@ -62,9 +62,9 @@ static void pca_start(struct i2c_algo_pca_data *adap) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Generate a repeated start condition on the i2c bus | 65 | * Generate a repeated start condition on the i2c bus |
66 | * | 66 | * |
67 | * return after the repeated start condition has occured | 67 | * return after the repeated start condition has occurred |
68 | */ | 68 | */ |
69 | static void pca_repeated_start(struct i2c_algo_pca_data *adap) | 69 | static void pca_repeated_start(struct i2c_algo_pca_data *adap) |
70 | { | 70 | { |
@@ -82,7 +82,7 @@ static void pca_repeated_start(struct i2c_algo_pca_data *adap) | |||
82 | * returns after the stop condition has been generated | 82 | * returns after the stop condition has been generated |
83 | * | 83 | * |
84 | * STOPs do not generate an interrupt or set the SI flag, since the | 84 | * STOPs do not generate an interrupt or set the SI flag, since the |
85 | * part returns the the idle state (0xf8). Hence we don't need to | 85 | * part returns the idle state (0xf8). Hence we don't need to |
86 | * pca_wait here. | 86 | * pca_wait here. |
87 | */ | 87 | */ |
88 | static void pca_stop(struct i2c_algo_pca_data *adap) | 88 | static void pca_stop(struct i2c_algo_pca_data *adap) |
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 35789bb7126a..f2785499237b 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ | 25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a0018de3bef4..916ba5e40a96 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -7,7 +7,7 @@ menu "I2C Hardware Bus support" | |||
7 | 7 | ||
8 | config I2C_ALI1535 | 8 | config I2C_ALI1535 |
9 | tristate "ALI 1535" | 9 | tristate "ALI 1535" |
10 | depends on I2C && PCI && EXPERIMENTAL | 10 | depends on I2C && PCI |
11 | help | 11 | help |
12 | If you say yes to this option, support will be included for the SMB | 12 | If you say yes to this option, support will be included for the SMB |
13 | Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB | 13 | Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB |
@@ -31,7 +31,7 @@ config I2C_ALI1563 | |||
31 | 31 | ||
32 | config I2C_ALI15X3 | 32 | config I2C_ALI15X3 |
33 | tristate "ALI 15x3" | 33 | tristate "ALI 15x3" |
34 | depends on I2C && PCI && EXPERIMENTAL | 34 | depends on I2C && PCI |
35 | help | 35 | help |
36 | If you say yes to this option, support will be included for the | 36 | If you say yes to this option, support will be included for the |
37 | Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. | 37 | Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. |
@@ -41,7 +41,7 @@ config I2C_ALI15X3 | |||
41 | 41 | ||
42 | config I2C_AMD756 | 42 | config I2C_AMD756 |
43 | tristate "AMD 756/766/768/8111 and nVidia nForce" | 43 | tristate "AMD 756/766/768/8111 and nVidia nForce" |
44 | depends on I2C && PCI && EXPERIMENTAL | 44 | depends on I2C && PCI |
45 | help | 45 | help |
46 | If you say yes to this option, support will be included for the AMD | 46 | If you say yes to this option, support will be included for the AMD |
47 | 756/766/768 mainboard I2C interfaces. The driver also includes | 47 | 756/766/768 mainboard I2C interfaces. The driver also includes |
@@ -66,7 +66,7 @@ config I2C_AMD756_S4882 | |||
66 | 66 | ||
67 | config I2C_AMD8111 | 67 | config I2C_AMD8111 |
68 | tristate "AMD 8111" | 68 | tristate "AMD 8111" |
69 | depends on I2C && PCI && EXPERIMENTAL | 69 | depends on I2C && PCI |
70 | help | 70 | help |
71 | If you say yes to this option, support will be included for the | 71 | If you say yes to this option, support will be included for the |
72 | second (SMBus 2.0) AMD 8111 mainboard I2C interface. | 72 | second (SMBus 2.0) AMD 8111 mainboard I2C interface. |
@@ -109,7 +109,7 @@ config I2C_HYDRA | |||
109 | 109 | ||
110 | config I2C_I801 | 110 | config I2C_I801 |
111 | tristate "Intel 82801 (ICH)" | 111 | tristate "Intel 82801 (ICH)" |
112 | depends on I2C && PCI && EXPERIMENTAL | 112 | depends on I2C && PCI |
113 | help | 113 | help |
114 | If you say yes to this option, support will be included for the Intel | 114 | If you say yes to this option, support will be included for the Intel |
115 | 801 family of mainboard I2C interfaces. Specifically, the following | 115 | 801 family of mainboard I2C interfaces. Specifically, the following |
@@ -130,7 +130,7 @@ config I2C_I801 | |||
130 | 130 | ||
131 | config I2C_I810 | 131 | config I2C_I810 |
132 | tristate "Intel 810/815" | 132 | tristate "Intel 810/815" |
133 | depends on I2C && PCI && EXPERIMENTAL | 133 | depends on I2C && PCI |
134 | select I2C_ALGOBIT | 134 | select I2C_ALGOBIT |
135 | help | 135 | help |
136 | If you say yes to this option, support will be included for the Intel | 136 | If you say yes to this option, support will be included for the Intel |
@@ -183,7 +183,7 @@ config I2C_IOP3XX | |||
183 | 183 | ||
184 | config I2C_ISA | 184 | config I2C_ISA |
185 | tristate "ISA Bus support" | 185 | tristate "ISA Bus support" |
186 | depends on I2C && EXPERIMENTAL | 186 | depends on I2C |
187 | help | 187 | help |
188 | If you say yes to this option, support will be included for i2c | 188 | If you say yes to this option, support will be included for i2c |
189 | interfaces that are on the ISA bus. | 189 | interfaces that are on the ISA bus. |
@@ -248,12 +248,11 @@ config I2C_MPC | |||
248 | will be called i2c-mpc. | 248 | will be called i2c-mpc. |
249 | 249 | ||
250 | config I2C_NFORCE2 | 250 | config I2C_NFORCE2 |
251 | tristate "Nvidia Nforce2" | 251 | tristate "Nvidia nForce2, nForce3 and nForce4" |
252 | depends on I2C && PCI && EXPERIMENTAL | 252 | depends on I2C && PCI |
253 | help | 253 | help |
254 | If you say yes to this option, support will be included for the Nvidia | 254 | If you say yes to this option, support will be included for the Nvidia |
255 | Nforce2 family of mainboard I2C interfaces. | 255 | nForce2, nForce3 and nForce4 families of mainboard I2C interfaces. |
256 | This driver also supports the nForce3 Pro 150 MCP. | ||
257 | 256 | ||
258 | This driver can also be built as a module. If so, the module | 257 | This driver can also be built as a module. If so, the module |
259 | will be called i2c-nforce2. | 258 | will be called i2c-nforce2. |
@@ -305,7 +304,7 @@ config I2C_PARPORT_LIGHT | |||
305 | 304 | ||
306 | config I2C_PROSAVAGE | 305 | config I2C_PROSAVAGE |
307 | tristate "S3/VIA (Pro)Savage" | 306 | tristate "S3/VIA (Pro)Savage" |
308 | depends on I2C && PCI && EXPERIMENTAL | 307 | depends on I2C && PCI |
309 | select I2C_ALGOBIT | 308 | select I2C_ALGOBIT |
310 | help | 309 | help |
311 | If you say yes to this option, support will be included for the | 310 | If you say yes to this option, support will be included for the |
@@ -388,7 +387,7 @@ config SCx200_ACB | |||
388 | 387 | ||
389 | config I2C_SIS5595 | 388 | config I2C_SIS5595 |
390 | tristate "SiS 5595" | 389 | tristate "SiS 5595" |
391 | depends on I2C && PCI && EXPERIMENTAL | 390 | depends on I2C && PCI |
392 | help | 391 | help |
393 | If you say yes to this option, support will be included for the | 392 | If you say yes to this option, support will be included for the |
394 | SiS5595 SMBus (a subset of I2C) interface. | 393 | SiS5595 SMBus (a subset of I2C) interface. |
@@ -398,7 +397,7 @@ config I2C_SIS5595 | |||
398 | 397 | ||
399 | config I2C_SIS630 | 398 | config I2C_SIS630 |
400 | tristate "SiS 630/730" | 399 | tristate "SiS 630/730" |
401 | depends on I2C && PCI && EXPERIMENTAL | 400 | depends on I2C && PCI |
402 | help | 401 | help |
403 | If you say yes to this option, support will be included for the | 402 | If you say yes to this option, support will be included for the |
404 | SiS630 and SiS730 SMBus (a subset of I2C) interface. | 403 | SiS630 and SiS730 SMBus (a subset of I2C) interface. |
@@ -408,7 +407,7 @@ config I2C_SIS630 | |||
408 | 407 | ||
409 | config I2C_SIS96X | 408 | config I2C_SIS96X |
410 | tristate "SiS 96x" | 409 | tristate "SiS 96x" |
411 | depends on I2C && PCI && EXPERIMENTAL | 410 | depends on I2C && PCI |
412 | help | 411 | help |
413 | If you say yes to this option, support will be included for the SiS | 412 | If you say yes to this option, support will be included for the SiS |
414 | 96x SMBus (a subset of I2C) interfaces. Specifically, the following | 413 | 96x SMBus (a subset of I2C) interfaces. Specifically, the following |
@@ -419,6 +418,7 @@ config I2C_SIS96X | |||
419 | 648/961 | 418 | 648/961 |
420 | 650/961 | 419 | 650/961 |
421 | 735 | 420 | 735 |
421 | 745 | ||
422 | 422 | ||
423 | This driver can also be built as a module. If so, the module | 423 | This driver can also be built as a module. If so, the module |
424 | will be called i2c-sis96x. | 424 | will be called i2c-sis96x. |
@@ -449,7 +449,7 @@ config I2C_VIA | |||
449 | 449 | ||
450 | config I2C_VIAPRO | 450 | config I2C_VIAPRO |
451 | tristate "VIA 82C596/82C686/823x" | 451 | tristate "VIA 82C596/82C686/823x" |
452 | depends on I2C && PCI && EXPERIMENTAL | 452 | depends on I2C && PCI |
453 | help | 453 | help |
454 | If you say yes to this option, support will be included for the VIA | 454 | If you say yes to this option, support will be included for the VIA |
455 | 82C596/82C686/823x I2C interfaces. Specifically, the following | 455 | 82C596/82C686/823x I2C interfaces. Specifically, the following |
@@ -467,7 +467,7 @@ config I2C_VIAPRO | |||
467 | 467 | ||
468 | config I2C_VOODOO3 | 468 | config I2C_VOODOO3 |
469 | tristate "Voodoo 3" | 469 | tristate "Voodoo 3" |
470 | depends on I2C && PCI && EXPERIMENTAL | 470 | depends on I2C && PCI |
471 | select I2C_ALGOBIT | 471 | select I2C_ALGOBIT |
472 | help | 472 | help |
473 | If you say yes to this option, support will be included for the | 473 | If you say yes to this option, support will be included for the |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index b00cd4098221..f634a0780cf0 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -53,7 +53,6 @@ | |||
53 | 53 | ||
54 | /* Note: we assume there can only be one ALI1535, with one SMBus interface */ | 54 | /* Note: we assume there can only be one ALI1535, with one SMBus interface */ |
55 | 55 | ||
56 | #include <linux/config.h> | ||
57 | #include <linux/module.h> | 56 | #include <linux/module.h> |
58 | #include <linux/pci.h> | 57 | #include <linux/pci.h> |
59 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 35710818fe47..fdd881aee618 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge | 2 | * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Patrick Mochel | 4 | * Copyright (C) 2004 Patrick Mochel |
5 | * 2005 Rudolf Marek <r.marek@sh.cvut.cz> | ||
5 | * | 6 | * |
6 | * The 1563 southbridge is deceptively similar to the 1533, with a | 7 | * The 1563 southbridge is deceptively similar to the 1533, with a |
7 | * few notable exceptions. One of those happens to be the fact they | 8 | * few notable exceptions. One of those happens to be the fact they |
@@ -57,10 +58,11 @@ | |||
57 | #define HST_CNTL2_BLOCK 0x05 | 58 | #define HST_CNTL2_BLOCK 0x05 |
58 | 59 | ||
59 | 60 | ||
61 | #define HST_CNTL2_SIZEMASK 0x38 | ||
60 | 62 | ||
61 | static unsigned short ali1563_smba; | 63 | static unsigned short ali1563_smba; |
62 | 64 | ||
63 | static int ali1563_transaction(struct i2c_adapter * a) | 65 | static int ali1563_transaction(struct i2c_adapter * a, int size) |
64 | { | 66 | { |
65 | u32 data; | 67 | u32 data; |
66 | int timeout; | 68 | int timeout; |
@@ -73,7 +75,7 @@ static int ali1563_transaction(struct i2c_adapter * a) | |||
73 | 75 | ||
74 | data = inb_p(SMB_HST_STS); | 76 | data = inb_p(SMB_HST_STS); |
75 | if (data & HST_STS_BAD) { | 77 | if (data & HST_STS_BAD) { |
76 | dev_warn(&a->dev,"ali1563: Trying to reset busy device\n"); | 78 | dev_err(&a->dev, "ali1563: Trying to reset busy device\n"); |
77 | outb_p(data | HST_STS_BAD,SMB_HST_STS); | 79 | outb_p(data | HST_STS_BAD,SMB_HST_STS); |
78 | data = inb_p(SMB_HST_STS); | 80 | data = inb_p(SMB_HST_STS); |
79 | if (data & HST_STS_BAD) | 81 | if (data & HST_STS_BAD) |
@@ -94,19 +96,31 @@ static int ali1563_transaction(struct i2c_adapter * a) | |||
94 | 96 | ||
95 | if (timeout && !(data & HST_STS_BAD)) | 97 | if (timeout && !(data & HST_STS_BAD)) |
96 | return 0; | 98 | return 0; |
97 | dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n", | ||
98 | timeout ? "Timeout " : "", | ||
99 | data & HST_STS_FAIL ? "Transaction Failed " : "", | ||
100 | data & HST_STS_BUSERR ? "No response or Bus Collision " : "", | ||
101 | data & HST_STS_DEVERR ? "Device Error " : "", | ||
102 | !(data & HST_STS_DONE) ? "Transaction Never Finished " : ""); | ||
103 | 99 | ||
104 | if (!(data & HST_STS_DONE)) | 100 | if (!timeout) { |
101 | dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n"); | ||
105 | /* Issue 'kill' to host controller */ | 102 | /* Issue 'kill' to host controller */ |
106 | outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); | 103 | outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); |
107 | else | 104 | data = inb_p(SMB_HST_STS); |
108 | /* Issue timeout to reset all devices on bus */ | 105 | } |
106 | |||
107 | /* device error - no response, ignore the autodetection case */ | ||
108 | if ((data & HST_STS_DEVERR) && (size != HST_CNTL2_QUICK)) { | ||
109 | dev_err(&a->dev, "Device error!\n"); | ||
110 | } | ||
111 | |||
112 | /* bus collision */ | ||
113 | if (data & HST_STS_BUSERR) { | ||
114 | dev_err(&a->dev, "Bus collision!\n"); | ||
115 | /* Issue timeout, hoping it helps */ | ||
109 | outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1); | 116 | outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1); |
117 | } | ||
118 | |||
119 | if (data & HST_STS_FAIL) { | ||
120 | dev_err(&a->dev, "Cleaning fail after KILL!\n"); | ||
121 | outb_p(0x0,SMB_HST_CNTL2); | ||
122 | } | ||
123 | |||
110 | return -1; | 124 | return -1; |
111 | } | 125 | } |
112 | 126 | ||
@@ -149,7 +163,7 @@ static int ali1563_block_start(struct i2c_adapter * a) | |||
149 | 163 | ||
150 | if (timeout && !(data & HST_STS_BAD)) | 164 | if (timeout && !(data & HST_STS_BAD)) |
151 | return 0; | 165 | return 0; |
152 | dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n", | 166 | dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n", |
153 | timeout ? "Timeout " : "", | 167 | timeout ? "Timeout " : "", |
154 | data & HST_STS_FAIL ? "Transaction Failed " : "", | 168 | data & HST_STS_FAIL ? "Transaction Failed " : "", |
155 | data & HST_STS_BUSERR ? "No response or Bus Collision " : "", | 169 | data & HST_STS_BUSERR ? "No response or Bus Collision " : "", |
@@ -242,13 +256,15 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr, | |||
242 | } | 256 | } |
243 | 257 | ||
244 | outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); | 258 | outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); |
245 | outb_p(inb_p(SMB_HST_CNTL2) | (size << 3), SMB_HST_CNTL2); | 259 | outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) | (size << 3), SMB_HST_CNTL2); |
246 | 260 | ||
247 | /* Write the command register */ | 261 | /* Write the command register */ |
262 | |||
248 | switch(size) { | 263 | switch(size) { |
249 | case HST_CNTL2_BYTE: | 264 | case HST_CNTL2_BYTE: |
250 | if (rw== I2C_SMBUS_WRITE) | 265 | if (rw== I2C_SMBUS_WRITE) |
251 | outb_p(cmd, SMB_HST_CMD); | 266 | /* Beware it uses DAT0 register and not CMD! */ |
267 | outb_p(cmd, SMB_HST_DAT0); | ||
252 | break; | 268 | break; |
253 | case HST_CNTL2_BYTE_DATA: | 269 | case HST_CNTL2_BYTE_DATA: |
254 | outb_p(cmd, SMB_HST_CMD); | 270 | outb_p(cmd, SMB_HST_CMD); |
@@ -268,7 +284,7 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr, | |||
268 | goto Done; | 284 | goto Done; |
269 | } | 285 | } |
270 | 286 | ||
271 | if ((error = ali1563_transaction(a))) | 287 | if ((error = ali1563_transaction(a, size))) |
272 | goto Done; | 288 | goto Done; |
273 | 289 | ||
274 | if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK)) | 290 | if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK)) |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 5bd6a4a77c1e..0f781a1a3323 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -60,7 +60,6 @@ | |||
60 | 60 | ||
61 | /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ | 61 | /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ |
62 | 62 | ||
63 | #include <linux/config.h> | ||
64 | #include <linux/module.h> | 63 | #include <linux/module.h> |
65 | #include <linux/pci.h> | 64 | #include <linux/pci.h> |
66 | #include <linux/kernel.h> | 65 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index eca5ed3738b8..6347ebc6fb53 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -37,7 +37,6 @@ | |||
37 | Note: we assume there can only be one device, with one SMBus interface. | 37 | Note: we assume there can only be one device, with one SMBus interface. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index af22b401a38b..d6644481d2a0 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * the Free Software Foundation version 2. | 8 | * the Free Software Foundation version 2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/config.h> | ||
12 | #include <linux/module.h> | 11 | #include <linux/module.h> |
13 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
14 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c index 75831a20b0bd..a7ff112e49bf 100644 --- a/drivers/i2c/busses/i2c-au1550.c +++ b/drivers/i2c/busses/i2c-au1550.c | |||
@@ -27,7 +27,6 @@ | |||
27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 32 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 0a7720000a0c..6930b660e508 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -25,7 +25,6 @@ | |||
25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of | 25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of |
26 | for Alpha Processor Inc. UP-2000(+) boards */ | 26 | for Alpha Processor Inc. UP-2000(+) boards */ |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
30 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
31 | #include <linux/module.h> | 30 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c index e093829a0bf7..b6f52f5a4138 100644 --- a/drivers/i2c/busses/i2c-frodo.c +++ b/drivers/i2c/busses/i2c-frodo.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * version 2 as published by the Free Software Foundation. | 12 | * version 2 as published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/config.h> | ||
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 59c238c42e8c..45e6efb1dcd1 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -41,7 +41,6 @@ | |||
41 | 41 | ||
42 | /* Note: we assume there can only be one I801, with one SMBus interface */ | 42 | /* Note: we assume there can only be one I801, with one SMBus interface */ |
43 | 43 | ||
44 | #include <linux/config.h> | ||
45 | #include <linux/module.h> | 44 | #include <linux/module.h> |
46 | #include <linux/pci.h> | 45 | #include <linux/pci.h> |
47 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index ef358bd9c3da..0ff7016e0629 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -34,7 +34,6 @@ | |||
34 | i815 1132 | 34 | i815 1132 |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <linux/config.h> | ||
38 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
39 | #include <linux/module.h> | 38 | #include <linux/module.h> |
40 | #include <linux/init.h> | 39 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index bb885215c08d..93ca36dc777e 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -695,7 +695,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
695 | 695 | ||
696 | dev->irq = iic_force_poll ? -1 : ocp->def->irq; | 696 | dev->irq = iic_force_poll ? -1 : ocp->def->irq; |
697 | if (dev->irq >= 0){ | 697 | if (dev->irq >= 0){ |
698 | /* Disable interrupts until we finish intialization, | 698 | /* Disable interrupts until we finish initialization, |
699 | assumes level-sensitive IRQ setup... | 699 | assumes level-sensitive IRQ setup... |
700 | */ | 700 | */ |
701 | iic_interrupt_mode(dev, 0); | 701 | iic_interrupt_mode(dev, 0); |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.h b/drivers/i2c/busses/i2c-ibm_iic.h index d819a955d890..2b3219d00e92 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.h +++ b/drivers/i2c/busses/i2c-ibm_iic.h | |||
@@ -22,7 +22,6 @@ | |||
22 | #ifndef __I2C_IBM_IIC_H_ | 22 | #ifndef __I2C_IBM_IIC_H_ |
23 | #define __I2C_IBM_IIC_H_ | 23 | #define __I2C_IBM_IIC_H_ |
24 | 24 | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
27 | 26 | ||
28 | struct iic_regs { | 27 | struct iic_regs { |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index c961ba4cfb32..6b682e903f09 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -85,7 +85,7 @@ iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap) | |||
85 | u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; | 85 | u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * Everytime unit enable is asserted, GPOD needs to be cleared | 88 | * Every time unit enable is asserted, GPOD needs to be cleared |
89 | * on IOP321 to avoid data corruption on the bus. | 89 | * on IOP321 to avoid data corruption on the bus. |
90 | */ | 90 | */ |
91 | #ifdef CONFIG_ARCH_IOP321 | 91 | #ifdef CONFIG_ARCH_IOP321 |
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 0f54a2a0afa5..00e7f7157b75 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -24,7 +24,6 @@ | |||
24 | the SMBus and the ISA bus very much easier. See lm78.c for an example | 24 | the SMBus and the ISA bus very much easier. See lm78.c for an example |
25 | of this. */ | 25 | of this. */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c index 702e3def1b81..5f5d2944808b 100644 --- a/drivers/i2c/busses/i2c-ite.c +++ b/drivers/i2c/busses/i2c-ite.c | |||
@@ -33,7 +33,6 @@ | |||
33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | 33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
34 | Frodo Looijaard <frodol@dds.nl> */ | 34 | Frodo Looijaard <frodol@dds.nl> */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
38 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
39 | #include <linux/module.h> | 38 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 21cd54d02302..1956af382cd8 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -26,11 +26,6 @@ | |||
26 | * 'enabled' to drive the GPIOs. | 26 | * 'enabled' to drive the GPIOs. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #ifdef CONFIG_I2C_DEBUG_BUS | ||
31 | #define DEBUG 1 | ||
32 | #endif | ||
33 | |||
34 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
35 | #include <linux/init.h> | 30 | #include <linux/init.h> |
36 | #include <linux/device.h> | 31 | #include <linux/device.h> |
@@ -38,7 +33,8 @@ | |||
38 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
39 | #include <linux/i2c-algo-bit.h> | 34 | #include <linux/i2c-algo-bit.h> |
40 | 35 | ||
41 | #include <asm/hardware.h> /* Pick up IXP42000-specific bits */ | 36 | #include <asm/hardware.h> /* Pick up IXP2000-specific bits */ |
37 | #include <asm/arch/gpio.h> | ||
42 | 38 | ||
43 | static inline int ixp2000_scl_pin(void *data) | 39 | static inline int ixp2000_scl_pin(void *data) |
44 | { | 40 | { |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index 8c55eafc3a09..f6f5ca31fdba 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -26,11 +26,6 @@ | |||
26 | * that is passed as the platform_data to this driver. | 26 | * that is passed as the platform_data to this driver. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #ifdef CONFIG_I2C_DEBUG_BUS | ||
31 | #define DEBUG 1 | ||
32 | #endif | ||
33 | |||
34 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
35 | #include <linux/init.h> | 30 | #include <linux/init.h> |
36 | #include <linux/device.h> | 31 | #include <linux/device.h> |
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index dd0d4c463146..363e545fc01f 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c | |||
@@ -46,7 +46,6 @@ | |||
46 | sound driver to be happy | 46 | sound driver to be happy |
47 | */ | 47 | */ |
48 | 48 | ||
49 | #include <linux/config.h> | ||
50 | #include <linux/module.h> | 49 | #include <linux/module.h> |
51 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
52 | #include <linux/ioport.h> | 51 | #include <linux/ioport.h> |
@@ -516,6 +515,11 @@ create_iface(struct device_node *np, struct device *dev) | |||
516 | u32 *psteps, *prate; | 515 | u32 *psteps, *prate; |
517 | int rc; | 516 | int rc; |
518 | 517 | ||
518 | if (np->n_intrs < 1 || np->n_addrs < 1) { | ||
519 | printk(KERN_ERR "%s: Missing interrupt or address !\n", | ||
520 | np->full_name); | ||
521 | return -ENODEV; | ||
522 | } | ||
519 | if (pmac_low_i2c_lock(np)) | 523 | if (pmac_low_i2c_lock(np)) |
520 | return -ENODEV; | 524 | return -ENODEV; |
521 | 525 | ||
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 6f33496d31c3..03c23ce98edb 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -20,13 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | #ifdef CONFIG_FSL_OCP | ||
24 | #include <asm/ocp.h> | ||
25 | #define FSL_I2C_DEV_SEPARATE_DFSRR FS_I2C_SEPARATE_DFSRR | ||
26 | #define FSL_I2C_DEV_CLOCK_5200 FS_I2C_CLOCK_5200 | ||
27 | #else | ||
28 | #include <linux/fsl_devices.h> | 23 | #include <linux/fsl_devices.h> |
29 | #endif | ||
30 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
31 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
32 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
@@ -294,202 +288,6 @@ static struct i2c_adapter mpc_ops = { | |||
294 | .retries = 1 | 288 | .retries = 1 |
295 | }; | 289 | }; |
296 | 290 | ||
297 | #ifdef CONFIG_FSL_OCP | ||
298 | static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | ||
299 | { | ||
300 | int result = 0; | ||
301 | struct mpc_i2c *i2c; | ||
302 | |||
303 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | ||
304 | return -ENOMEM; | ||
305 | } | ||
306 | memset(i2c, 0, sizeof(*i2c)); | ||
307 | |||
308 | i2c->irq = ocp->def->irq; | ||
309 | i2c->flags = ((struct ocp_fs_i2c_data *)ocp->def->additions)->flags; | ||
310 | init_waitqueue_head(&i2c->queue); | ||
311 | |||
312 | if (!request_mem_region(ocp->def->paddr, MPC_I2C_REGION, "i2c-mpc")) { | ||
313 | printk(KERN_ERR "i2c-mpc - resource unavailable\n"); | ||
314 | return -ENODEV; | ||
315 | } | ||
316 | |||
317 | i2c->base = ioremap(ocp->def->paddr, MPC_I2C_REGION); | ||
318 | |||
319 | if (!i2c->base) { | ||
320 | printk(KERN_ERR "i2c-mpc - failed to map controller\n"); | ||
321 | result = -ENOMEM; | ||
322 | goto fail_map; | ||
323 | } | ||
324 | |||
325 | if (i2c->irq != OCP_IRQ_NA) | ||
326 | { | ||
327 | if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, | ||
328 | 0, "i2c-mpc", i2c)) < 0) { | ||
329 | printk(KERN_ERR | ||
330 | "i2c-mpc - failed to attach interrupt\n"); | ||
331 | goto fail_irq; | ||
332 | } | ||
333 | } else | ||
334 | i2c->irq = 0; | ||
335 | |||
336 | i2c->adap = mpc_ops; | ||
337 | i2c_set_adapdata(&i2c->adap, i2c); | ||
338 | |||
339 | if ((result = i2c_add_adapter(&i2c->adap)) < 0) { | ||
340 | printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); | ||
341 | goto fail_add; | ||
342 | } | ||
343 | |||
344 | mpc_i2c_setclock(i2c); | ||
345 | ocp_set_drvdata(ocp, i2c); | ||
346 | return result; | ||
347 | |||
348 | fail_add: | ||
349 | if (ocp->def->irq != OCP_IRQ_NA) | ||
350 | free_irq(ocp->def->irq, 0); | ||
351 | fail_irq: | ||
352 | iounmap(i2c->base); | ||
353 | fail_map: | ||
354 | release_mem_region(ocp->def->paddr, MPC_I2C_REGION); | ||
355 | kfree(i2c); | ||
356 | return result; | ||
357 | } | ||
358 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) | ||
359 | { | ||
360 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); | ||
361 | ocp_set_drvdata(ocp, NULL); | ||
362 | i2c_del_adapter(&i2c->adap); | ||
363 | |||
364 | if (ocp->def->irq != OCP_IRQ_NA) | ||
365 | free_irq(i2c->irq, i2c); | ||
366 | iounmap(i2c->base); | ||
367 | release_mem_region(ocp->def->paddr, MPC_I2C_REGION); | ||
368 | kfree(i2c); | ||
369 | } | ||
370 | |||
371 | static struct ocp_device_id mpc_iic_ids[] __devinitdata = { | ||
372 | {.vendor = OCP_VENDOR_FREESCALE,.function = OCP_FUNC_IIC}, | ||
373 | {.vendor = OCP_VENDOR_INVALID} | ||
374 | }; | ||
375 | |||
376 | MODULE_DEVICE_TABLE(ocp, mpc_iic_ids); | ||
377 | |||
378 | static struct ocp_driver mpc_iic_driver = { | ||
379 | .name = "iic", | ||
380 | .id_table = mpc_iic_ids, | ||
381 | .probe = mpc_i2c_probe, | ||
382 | .remove = __devexit_p(mpc_i2c_remove) | ||
383 | }; | ||
384 | |||
385 | static int __init iic_init(void) | ||
386 | { | ||
387 | return ocp_register_driver(&mpc_iic_driver); | ||
388 | } | ||
389 | |||
390 | static void __exit iic_exit(void) | ||
391 | { | ||
392 | ocp_unregister_driver(&mpc_iic_driver); | ||
393 | } | ||
394 | |||
395 | module_init(iic_init); | ||
396 | module_exit(iic_exit); | ||
397 | #else | ||
398 | static int fsl_i2c_probe(struct device *device) | ||
399 | { | ||
400 | int result = 0; | ||
401 | struct mpc_i2c *i2c; | ||
402 | struct platform_device *pdev = to_platform_device(device); | ||
403 | struct fsl_i2c_platform_data *pdata; | ||
404 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
405 | |||
406 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | ||
407 | |||
408 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | ||
409 | return -ENOMEM; | ||
410 | } | ||
411 | memset(i2c, 0, sizeof(*i2c)); | ||
412 | |||
413 | i2c->irq = platform_get_irq(pdev, 0); | ||
414 | i2c->flags = pdata->device_flags; | ||
415 | init_waitqueue_head(&i2c->queue); | ||
416 | |||
417 | i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION); | ||
418 | |||
419 | if (!i2c->base) { | ||
420 | printk(KERN_ERR "i2c-mpc - failed to map controller\n"); | ||
421 | result = -ENOMEM; | ||
422 | goto fail_map; | ||
423 | } | ||
424 | |||
425 | if (i2c->irq != 0) | ||
426 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | ||
427 | 0, "fsl-i2c", i2c)) < 0) { | ||
428 | printk(KERN_ERR | ||
429 | "i2c-mpc - failed to attach interrupt\n"); | ||
430 | goto fail_irq; | ||
431 | } | ||
432 | |||
433 | i2c->adap = mpc_ops; | ||
434 | i2c_set_adapdata(&i2c->adap, i2c); | ||
435 | i2c->adap.dev.parent = &pdev->dev; | ||
436 | if ((result = i2c_add_adapter(&i2c->adap)) < 0) { | ||
437 | printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); | ||
438 | goto fail_add; | ||
439 | } | ||
440 | |||
441 | mpc_i2c_setclock(i2c); | ||
442 | dev_set_drvdata(device, i2c); | ||
443 | return result; | ||
444 | |||
445 | fail_add: | ||
446 | if (i2c->irq != 0) | ||
447 | free_irq(i2c->irq, NULL); | ||
448 | fail_irq: | ||
449 | iounmap(i2c->base); | ||
450 | fail_map: | ||
451 | kfree(i2c); | ||
452 | return result; | ||
453 | }; | ||
454 | |||
455 | static int fsl_i2c_remove(struct device *device) | ||
456 | { | ||
457 | struct mpc_i2c *i2c = dev_get_drvdata(device); | ||
458 | |||
459 | dev_set_drvdata(device, NULL); | ||
460 | i2c_del_adapter(&i2c->adap); | ||
461 | |||
462 | if (i2c->irq != 0) | ||
463 | free_irq(i2c->irq, i2c); | ||
464 | |||
465 | iounmap(i2c->base); | ||
466 | kfree(i2c); | ||
467 | return 0; | ||
468 | }; | ||
469 | |||
470 | /* Structure for a device driver */ | ||
471 | static struct device_driver fsl_i2c_driver = { | ||
472 | .name = "fsl-i2c", | ||
473 | .bus = &platform_bus_type, | ||
474 | .probe = fsl_i2c_probe, | ||
475 | .remove = fsl_i2c_remove, | ||
476 | }; | ||
477 | |||
478 | static int __init fsl_i2c_init(void) | ||
479 | { | ||
480 | return driver_register(&fsl_i2c_driver); | ||
481 | } | ||
482 | |||
483 | static void __exit fsl_i2c_exit(void) | ||
484 | { | ||
485 | driver_unregister(&fsl_i2c_driver); | ||
486 | } | ||
487 | |||
488 | module_init(fsl_i2c_init); | ||
489 | module_exit(fsl_i2c_exit); | ||
490 | |||
491 | #endif /* CONFIG_FSL_OCP */ | ||
492 | |||
493 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); | 291 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); |
494 | MODULE_DESCRIPTION | 292 | MODULE_DESCRIPTION |
495 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); | 293 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 6d13127c8c4e..74eb89aa9350 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ | 38 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index cb5e722301d8..3e5eba9fcacb 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -24,7 +24,6 @@ | |||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | * ------------------------------------------------------------------------ */ | 25 | * ------------------------------------------------------------------------ */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index e9560bab51c4..71a2502fe069 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -24,7 +24,6 @@ | |||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | * ------------------------------------------------------------------------ */ | 25 | * ------------------------------------------------------------------------ */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
@@ -131,7 +130,7 @@ static int parport_getsda(void *data) | |||
131 | /* Encapsulate the functions above in the correct structure. | 130 | /* Encapsulate the functions above in the correct structure. |
132 | Note that this is only a template, from which the real structures are | 131 | Note that this is only a template, from which the real structures are |
133 | copied. The attaching code will set getscl to NULL for adapters that | 132 | copied. The attaching code will set getscl to NULL for adapters that |
134 | cannot read SCL back, and will also make the the data field point to | 133 | cannot read SCL back, and will also make the data field point to |
135 | the parallel port structure. */ | 134 | the parallel port structure. */ |
136 | static struct i2c_algo_bit_data parport_algo_data = { | 135 | static struct i2c_algo_bit_data parport_algo_data = { |
137 | .setsda = parport_setsda, | 136 | .setsda = parport_setsda, |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index 9c611134db9c..d9b4ddbad7e0 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
22 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 646381b6b3bf..1f80ba9da6f1 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -28,7 +28,6 @@ | |||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one SMBus interface. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/config.h> | ||
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
34 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index 13d66289933b..83fd16d61ce5 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c | |||
@@ -54,7 +54,6 @@ | |||
54 | * (Additional documentation needed :( | 54 | * (Additional documentation needed :( |
55 | */ | 55 | */ |
56 | 56 | ||
57 | #include <linux/config.h> | ||
58 | #include <linux/module.h> | 57 | #include <linux/module.h> |
59 | #include <linux/init.h> | 58 | #include <linux/init.h> |
60 | #include <linux/pci.h> | 59 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-rpx.c b/drivers/i2c/busses/i2c-rpx.c index 9497b1b6852f..0ebec3c1a54e 100644 --- a/drivers/i2c/busses/i2c-rpx.c +++ b/drivers/i2c/busses/i2c-rpx.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * changed to eliminate RPXLite references. | 11 | * changed to eliminate RPXLite references. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/config.h> | ||
15 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index fcfa51c1436b..a3b38257cc3d 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/config.h> | ||
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | 26 | ||
@@ -533,7 +534,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int | |||
533 | /* s3c24xx_i2c_xfer | 534 | /* s3c24xx_i2c_xfer |
534 | * | 535 | * |
535 | * first port of call from the i2c bus code when an message needs | 536 | * first port of call from the i2c bus code when an message needs |
536 | * transfering across the i2c bus. | 537 | * transferring across the i2c bus. |
537 | */ | 538 | */ |
538 | 539 | ||
539 | static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | 540 | static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 092d0323c6c6..0c8518298e4d 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -29,7 +29,6 @@ | |||
29 | it easier to add later. | 29 | it easier to add later. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <linux/config.h> | ||
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/init.h> | 34 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c index e5dd90bdb04a..1c99536b673b 100644 --- a/drivers/i2c/busses/i2c-sibyte.c +++ b/drivers/i2c/busses/i2c-sibyte.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/module.h> | 20 | #include <linux/module.h> |
22 | #include <linux/i2c-algo-sibyte.h> | 21 | #include <linux/i2c-algo-sibyte.h> |
23 | #include <asm/sibyte/sb1250_regs.h> | 22 | #include <asm/sibyte/sb1250_regs.h> |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 425733b019b6..2b5911cfb7b5 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -55,7 +55,6 @@ | |||
55 | * Add adapter resets | 55 | * Add adapter resets |
56 | */ | 56 | */ |
57 | 57 | ||
58 | #include <linux/config.h> | ||
59 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
60 | #include <linux/module.h> | 59 | #include <linux/module.h> |
61 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 58df63df1540..f58455e7689e 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -48,7 +48,6 @@ | |||
48 | Note: we assume there can only be one device, with one SMBus interface. | 48 | Note: we assume there can only be one device, with one SMBus interface. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | #include <linux/config.h> | ||
52 | #include <linux/kernel.h> | 51 | #include <linux/kernel.h> |
53 | #include <linux/module.h> | 52 | #include <linux/module.h> |
54 | #include <linux/delay.h> | 53 | #include <linux/delay.h> |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 3cac6d43bce5..6484792e23a1 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -32,7 +32,6 @@ | |||
32 | We assume there can only be one SiS96x with one SMBus interface. | 32 | We assume there can only be one SiS96x with one SMBus interface. |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/config.h> | ||
36 | #include <linux/module.h> | 35 | #include <linux/module.h> |
37 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
38 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 19c805ead4d8..00d94e886955 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #define DEBUG 1 | 22 | #define DEBUG 1 |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 2cbc4cd22366..040b8abeabba 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -21,7 +21,6 @@ | |||
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 0bb60a636e16..6b5008005c6f 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -33,7 +33,6 @@ | |||
33 | Note: we assume there can only be one device, with one SMBus interface. | 33 | Note: we assume there can only be one device, with one SMBus interface. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
39 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index 3edf0e34155e..b675773b0cc1 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -27,7 +27,6 @@ | |||
27 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to | 27 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to |
28 | the BT869 and possibly other I2C devices. */ | 28 | the BT869 and possibly other I2C devices. */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 1c4159a93623..a18bdd9aa7ba 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/module.h> | 27 | #include <linux/module.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 74d23cfce2a3..a0982da09803 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # I2C Sensor device configuration | 2 | # I2C Sensor and "other" chip configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Hardware Sensors Chip support" | 5 | menu "Hardware Sensors Chip support" |
@@ -11,7 +11,7 @@ config I2C_SENSOR | |||
11 | 11 | ||
12 | config SENSORS_ADM1021 | 12 | config SENSORS_ADM1021 |
13 | tristate "Analog Devices ADM1021 and compatibles" | 13 | tristate "Analog Devices ADM1021 and compatibles" |
14 | depends on I2C && EXPERIMENTAL | 14 | depends on I2C |
15 | select I2C_SENSOR | 15 | select I2C_SENSOR |
16 | help | 16 | help |
17 | If you say yes here you get support for Analog Devices ADM1021 | 17 | If you say yes here you get support for Analog Devices ADM1021 |
@@ -29,6 +29,7 @@ config SENSORS_ADM1025 | |||
29 | help | 29 | help |
30 | If you say yes here you get support for Analog Devices ADM1025 | 30 | If you say yes here you get support for Analog Devices ADM1025 |
31 | and Philips NE1619 sensor chips. | 31 | and Philips NE1619 sensor chips. |
32 | |||
32 | This driver can also be built as a module. If so, the module | 33 | This driver can also be built as a module. If so, the module |
33 | will be called adm1025. | 34 | will be called adm1025. |
34 | 35 | ||
@@ -38,6 +39,8 @@ config SENSORS_ADM1026 | |||
38 | select I2C_SENSOR | 39 | select I2C_SENSOR |
39 | help | 40 | help |
40 | If you say yes here you get support for Analog Devices ADM1026 | 41 | If you say yes here you get support for Analog Devices ADM1026 |
42 | sensor chip. | ||
43 | |||
41 | This driver can also be built as a module. If so, the module | 44 | This driver can also be built as a module. If so, the module |
42 | will be called adm1026. | 45 | will be called adm1026. |
43 | 46 | ||
@@ -48,9 +51,21 @@ config SENSORS_ADM1031 | |||
48 | help | 51 | help |
49 | If you say yes here you get support for Analog Devices ADM1031 | 52 | If you say yes here you get support for Analog Devices ADM1031 |
50 | and ADM1030 sensor chips. | 53 | and ADM1030 sensor chips. |
54 | |||
51 | This driver can also be built as a module. If so, the module | 55 | This driver can also be built as a module. If so, the module |
52 | will be called adm1031. | 56 | will be called adm1031. |
53 | 57 | ||
58 | config SENSORS_ADM9240 | ||
59 | tristate "Analog Devices ADM9240 and compatibles" | ||
60 | depends on I2C && EXPERIMENTAL | ||
61 | select I2C_SENSOR | ||
62 | help | ||
63 | If you say yes here you get support for Analog Devices ADM9240, | ||
64 | Dallas DS1780, National Semiconductor LM81 sensor chips. | ||
65 | |||
66 | This driver can also be built as a module. If so, the module | ||
67 | will be called adm9240. | ||
68 | |||
54 | config SENSORS_ASB100 | 69 | config SENSORS_ASB100 |
55 | tristate "Asus ASB100 Bach" | 70 | tristate "Asus ASB100 Bach" |
56 | depends on I2C && EXPERIMENTAL | 71 | depends on I2C && EXPERIMENTAL |
@@ -62,6 +77,19 @@ config SENSORS_ASB100 | |||
62 | This driver can also be built as a module. If so, the module | 77 | This driver can also be built as a module. If so, the module |
63 | will be called asb100. | 78 | will be called asb100. |
64 | 79 | ||
80 | config SENSORS_ATXP1 | ||
81 | tristate "Attansic ATXP1 VID controller" | ||
82 | depends on I2C && EXPERIMENTAL | ||
83 | help | ||
84 | If you say yes here you get support for the Attansic ATXP1 VID | ||
85 | controller. | ||
86 | |||
87 | If your board have such a chip, you are able to control your CPU | ||
88 | core and other voltages. | ||
89 | |||
90 | This driver can also be built as a module. If so, the module | ||
91 | will be called atxp1. | ||
92 | |||
65 | config SENSORS_DS1621 | 93 | config SENSORS_DS1621 |
66 | tristate "Dallas Semiconductor DS1621 and DS1625" | 94 | tristate "Dallas Semiconductor DS1621 and DS1625" |
67 | depends on I2C && EXPERIMENTAL | 95 | depends on I2C && EXPERIMENTAL |
@@ -97,7 +125,7 @@ config SENSORS_FSCPOS | |||
97 | 125 | ||
98 | config SENSORS_GL518SM | 126 | config SENSORS_GL518SM |
99 | tristate "Genesys Logic GL518SM" | 127 | tristate "Genesys Logic GL518SM" |
100 | depends on I2C && EXPERIMENTAL | 128 | depends on I2C |
101 | select I2C_SENSOR | 129 | select I2C_SENSOR |
102 | help | 130 | help |
103 | If you say yes here you get support for Genesys Logic GL518SM | 131 | If you say yes here you get support for Genesys Logic GL518SM |
@@ -119,7 +147,7 @@ config SENSORS_GL520SM | |||
119 | 147 | ||
120 | config SENSORS_IT87 | 148 | config SENSORS_IT87 |
121 | tristate "ITE IT87xx and compatibles" | 149 | tristate "ITE IT87xx and compatibles" |
122 | depends on I2C && EXPERIMENTAL | 150 | depends on I2C |
123 | select I2C_SENSOR | 151 | select I2C_SENSOR |
124 | help | 152 | help |
125 | If you say yes here you get support for ITE IT87xx sensor chips | 153 | If you say yes here you get support for ITE IT87xx sensor chips |
@@ -143,7 +171,7 @@ config SENSORS_LM63 | |||
143 | 171 | ||
144 | config SENSORS_LM75 | 172 | config SENSORS_LM75 |
145 | tristate "National Semiconductor LM75 and compatibles" | 173 | tristate "National Semiconductor LM75 and compatibles" |
146 | depends on I2C && EXPERIMENTAL | 174 | depends on I2C |
147 | select I2C_SENSOR | 175 | select I2C_SENSOR |
148 | help | 176 | help |
149 | If you say yes here you get support for National Semiconductor LM75 | 177 | If you say yes here you get support for National Semiconductor LM75 |
@@ -174,8 +202,7 @@ config SENSORS_LM78 | |||
174 | select I2C_SENSOR | 202 | select I2C_SENSOR |
175 | help | 203 | help |
176 | If you say yes here you get support for National Semiconductor LM78, | 204 | If you say yes here you get support for National Semiconductor LM78, |
177 | LM78-J and LM79. This can also be built as a module which can be | 205 | LM78-J and LM79. |
178 | inserted and removed while the kernel is running. | ||
179 | 206 | ||
180 | This driver can also be built as a module. If so, the module | 207 | This driver can also be built as a module. If so, the module |
181 | will be called lm78. | 208 | will be called lm78. |
@@ -208,7 +235,7 @@ config SENSORS_LM85 | |||
208 | select I2C_SENSOR | 235 | select I2C_SENSOR |
209 | help | 236 | help |
210 | If you say yes here you get support for National Semiconductor LM85 | 237 | If you say yes here you get support for National Semiconductor LM85 |
211 | sensor chips and clones: ADT7463 and ADM1027. | 238 | sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027. |
212 | 239 | ||
213 | This driver can also be built as a module. If so, the module | 240 | This driver can also be built as a module. If so, the module |
214 | will be called lm85. | 241 | will be called lm85. |
@@ -307,14 +334,14 @@ config SENSORS_SMSC47M1 | |||
307 | help | 334 | help |
308 | If you say yes here you get support for the integrated fan | 335 | If you say yes here you get support for the integrated fan |
309 | monitoring and control capabilities of the SMSC LPC47B27x, | 336 | monitoring and control capabilities of the SMSC LPC47B27x, |
310 | LPC47M10x, LPC47M13x and LPC47M14x chips. | 337 | LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips. |
311 | 338 | ||
312 | This driver can also be built as a module. If so, the module | 339 | This driver can also be built as a module. If so, the module |
313 | will be called smsc47m1. | 340 | will be called smsc47m1. |
314 | 341 | ||
315 | config SENSORS_VIA686A | 342 | config SENSORS_VIA686A |
316 | tristate "VIA686A" | 343 | tristate "VIA686A" |
317 | depends on I2C && PCI && EXPERIMENTAL | 344 | depends on I2C && PCI |
318 | select I2C_SENSOR | 345 | select I2C_SENSOR |
319 | select I2C_ISA | 346 | select I2C_ISA |
320 | help | 347 | help |
@@ -326,7 +353,7 @@ config SENSORS_VIA686A | |||
326 | 353 | ||
327 | config SENSORS_W83781D | 354 | config SENSORS_W83781D |
328 | tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" | 355 | tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" |
329 | depends on I2C && EXPERIMENTAL | 356 | depends on I2C |
330 | select I2C_SENSOR | 357 | select I2C_SENSOR |
331 | help | 358 | help |
332 | 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 |
@@ -360,22 +387,47 @@ config SENSORS_W83627HF | |||
360 | This driver can also be built as a module. If so, the module | 387 | This driver can also be built as a module. If so, the module |
361 | will be called w83627hf. | 388 | will be called w83627hf. |
362 | 389 | ||
390 | config SENSORS_W83627EHF | ||
391 | tristate "Winbond W83627EHF" | ||
392 | depends on I2C && EXPERIMENTAL | ||
393 | select I2C_SENSOR | ||
394 | select I2C_ISA | ||
395 | help | ||
396 | If you say yes here you get preliminary support for the hardware | ||
397 | monitoring functionality of the Winbond W83627EHF Super-I/O chip. | ||
398 | Only fan and temperature inputs are supported at the moment, while | ||
399 | the chip does much more than that. | ||
400 | |||
401 | This driver can also be built as a module. If so, the module | ||
402 | will be called w83627ehf. | ||
403 | |||
363 | endmenu | 404 | endmenu |
364 | 405 | ||
365 | menu "Other I2C Chip support" | 406 | menu "Other I2C Chip support" |
366 | depends on I2C | 407 | depends on I2C |
367 | 408 | ||
368 | config SENSORS_DS1337 | 409 | config SENSORS_DS1337 |
369 | tristate "Dallas Semiconductor DS1337 Real Time Clock" | 410 | tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" |
370 | depends on I2C && EXPERIMENTAL | 411 | depends on I2C && EXPERIMENTAL |
371 | select I2C_SENSOR | 412 | select I2C_SENSOR |
372 | help | 413 | help |
373 | If you say yes here you get support for Dallas Semiconductor | 414 | If you say yes here you get support for Dallas Semiconductor |
374 | DS1337 real-time clock chips. | 415 | DS1337 and DS1339 real-time clock chips. |
375 | 416 | ||
376 | This driver can also be built as a module. If so, the module | 417 | This driver can also be built as a module. If so, the module |
377 | will be called ds1337. | 418 | will be called ds1337. |
378 | 419 | ||
420 | config SENSORS_DS1374 | ||
421 | tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" | ||
422 | depends on I2C && EXPERIMENTAL | ||
423 | select I2C_SENSOR | ||
424 | help | ||
425 | If you say yes here you get support for Dallas Semiconductor | ||
426 | DS1374 real-time clock chips. | ||
427 | |||
428 | This driver can also be built as a module. If so, the module | ||
429 | will be called ds1374. | ||
430 | |||
379 | config SENSORS_EEPROM | 431 | config SENSORS_EEPROM |
380 | tristate "EEPROM reader" | 432 | tristate "EEPROM reader" |
381 | depends on I2C && EXPERIMENTAL | 433 | depends on I2C && EXPERIMENTAL |
@@ -399,6 +451,16 @@ config SENSORS_PCF8574 | |||
399 | This driver can also be built as a module. If so, the module | 451 | This driver can also be built as a module. If so, the module |
400 | will be called pcf8574. | 452 | will be called pcf8574. |
401 | 453 | ||
454 | config SENSORS_PCA9539 | ||
455 | tristate "Philips PCA9539 16-bit I/O port" | ||
456 | depends on I2C && EXPERIMENTAL | ||
457 | help | ||
458 | If you say yes here you get support for the Philips PCA9539 | ||
459 | 16-bit I/O port. | ||
460 | |||
461 | This driver can also be built as a module. If so, the module | ||
462 | will be called pca9539. | ||
463 | |||
402 | config SENSORS_PCF8591 | 464 | config SENSORS_PCF8591 |
403 | tristate "Philips PCF8591" | 465 | tristate "Philips PCF8591" |
404 | depends on I2C && EXPERIMENTAL | 466 | depends on I2C && EXPERIMENTAL |
@@ -431,6 +493,23 @@ config ISP1301_OMAP | |||
431 | This driver can also be built as a module. If so, the module | 493 | This driver can also be built as a module. If so, the module |
432 | will be called isp1301_omap. | 494 | will be called isp1301_omap. |
433 | 495 | ||
496 | # NOTE: This isn't really OMAP-specific, except for the current | ||
497 | # interface location in <include/asm-arm/arch-omap/tps65010.h> | ||
498 | # and having mostly OMAP-specific board support | ||
499 | config TPS65010 | ||
500 | tristate "TPS6501x Power Management chips" | ||
501 | depends on I2C && ARCH_OMAP | ||
502 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK | ||
503 | help | ||
504 | If you say yes here you get support for the TPS6501x series of | ||
505 | Power Management chips. These include voltage regulators, | ||
506 | lithium ion/polymer battery charging, and other features that | ||
507 | are often used in portable devices like cell phones and cameras. | ||
508 | |||
509 | This driver can also be built as a module. If so, the module | ||
510 | will be called tps65010. | ||
511 | |||
512 | |||
434 | config SENSORS_M41T00 | 513 | config SENSORS_M41T00 |
435 | tristate "ST M41T00 RTC chip" | 514 | tristate "ST M41T00 RTC chip" |
436 | depends on I2C && PPC32 | 515 | depends on I2C && PPC32 |
@@ -440,4 +519,16 @@ config SENSORS_M41T00 | |||
440 | This driver can also be built as a module. If so, the module | 519 | This driver can also be built as a module. If so, the module |
441 | will be called m41t00. | 520 | will be called m41t00. |
442 | 521 | ||
522 | config SENSORS_MAX6875 | ||
523 | tristate "MAXIM MAX6875 Power supply supervisor" | ||
524 | depends on I2C && EXPERIMENTAL | ||
525 | help | ||
526 | If you say yes here you get support for the MAX6875 | ||
527 | EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors. | ||
528 | |||
529 | This provides a interface to program the EEPROM and reset the chip. | ||
530 | |||
531 | This driver can also be built as a module. If so, the module | ||
532 | will be called max6875. | ||
533 | |||
443 | endmenu | 534 | endmenu |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 65599161a172..b5e6d2f84f97 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the kernel hardware sensors chip drivers. | 2 | # Makefile for sensor and "other" I2C chip drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | # asb100, then w83781d go first, as they can override other drivers' addresses. | 5 | # asb100, then w83781d go first, as they can override other drivers' addresses. |
@@ -11,7 +11,10 @@ obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o | |||
11 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o | 11 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o |
12 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o | 12 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o |
13 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | 13 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o |
14 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | ||
15 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | ||
14 | obj-$(CONFIG_SENSORS_DS1337) += ds1337.o | 16 | obj-$(CONFIG_SENSORS_DS1337) += ds1337.o |
17 | obj-$(CONFIG_SENSORS_DS1374) += ds1374.o | ||
15 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o | 18 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o |
16 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o | 19 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o |
17 | obj-$(CONFIG_SENSORS_FSCHER) += fscher.o | 20 | obj-$(CONFIG_SENSORS_FSCHER) += fscher.o |
@@ -30,8 +33,10 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o | |||
30 | obj-$(CONFIG_SENSORS_LM90) += lm90.o | 33 | obj-$(CONFIG_SENSORS_LM90) += lm90.o |
31 | obj-$(CONFIG_SENSORS_LM92) += lm92.o | 34 | obj-$(CONFIG_SENSORS_LM92) += lm92.o |
32 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o | 35 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o |
36 | obj-$(CONFIG_SENSORS_MAX6875) += max6875.o | ||
33 | obj-$(CONFIG_SENSORS_M41T00) += m41t00.o | 37 | obj-$(CONFIG_SENSORS_M41T00) += m41t00.o |
34 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | 38 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o |
39 | obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o | ||
35 | obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o | 40 | obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o |
36 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | 41 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o |
37 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o | 42 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o |
@@ -39,8 +44,11 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o | |||
39 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o | 44 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o |
40 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o | 45 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o |
41 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o | 46 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o |
47 | obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o | ||
42 | obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o | 48 | obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o |
49 | |||
43 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 50 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
51 | obj-$(CONFIG_TPS65010) += tps65010.o | ||
44 | 52 | ||
45 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 53 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
46 | EXTRA_CFLAGS += -DDEBUG | 54 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index 9c59a370b6d9..d2c774c32f45 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c | |||
@@ -19,7 +19,6 @@ | |||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/config.h> | ||
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
@@ -103,8 +102,6 @@ struct adm1021_data { | |||
103 | u8 remote_temp_hyst; | 102 | u8 remote_temp_hyst; |
104 | u8 remote_temp_input; | 103 | u8 remote_temp_input; |
105 | u8 alarms; | 104 | u8 alarms; |
106 | /* special values for ADM1021 only */ | ||
107 | u8 die_code; | ||
108 | /* Special values for ADM1023 only */ | 105 | /* Special values for ADM1023 only */ |
109 | u8 remote_temp_prec; | 106 | u8 remote_temp_prec; |
110 | u8 remote_temp_os_prec; | 107 | u8 remote_temp_os_prec; |
@@ -137,7 +134,7 @@ static struct i2c_driver adm1021_driver = { | |||
137 | }; | 134 | }; |
138 | 135 | ||
139 | #define show(value) \ | 136 | #define show(value) \ |
140 | static ssize_t show_##value(struct device *dev, char *buf) \ | 137 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
141 | { \ | 138 | { \ |
142 | struct adm1021_data *data = adm1021_update_device(dev); \ | 139 | struct adm1021_data *data = adm1021_update_device(dev); \ |
143 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ | 140 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ |
@@ -150,16 +147,15 @@ show(remote_temp_hyst); | |||
150 | show(remote_temp_input); | 147 | show(remote_temp_input); |
151 | 148 | ||
152 | #define show2(value) \ | 149 | #define show2(value) \ |
153 | static ssize_t show_##value(struct device *dev, char *buf) \ | 150 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
154 | { \ | 151 | { \ |
155 | struct adm1021_data *data = adm1021_update_device(dev); \ | 152 | struct adm1021_data *data = adm1021_update_device(dev); \ |
156 | return sprintf(buf, "%d\n", data->value); \ | 153 | return sprintf(buf, "%d\n", data->value); \ |
157 | } | 154 | } |
158 | show2(alarms); | 155 | show2(alarms); |
159 | show2(die_code); | ||
160 | 156 | ||
161 | #define set(value, reg) \ | 157 | #define set(value, reg) \ |
162 | static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ | 158 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
163 | { \ | 159 | { \ |
164 | struct i2c_client *client = to_i2c_client(dev); \ | 160 | struct i2c_client *client = to_i2c_client(dev); \ |
165 | struct adm1021_data *data = i2c_get_clientdata(client); \ | 161 | struct adm1021_data *data = i2c_get_clientdata(client); \ |
@@ -183,7 +179,6 @@ static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_remote_temp_max, set_remot | |||
183 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); | 179 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); |
184 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); | 180 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); |
185 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 181 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
186 | static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); | ||
187 | 182 | ||
188 | 183 | ||
189 | static int adm1021_attach_adapter(struct i2c_adapter *adapter) | 184 | static int adm1021_attach_adapter(struct i2c_adapter *adapter) |
@@ -307,8 +302,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
307 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 302 | device_create_file(&new_client->dev, &dev_attr_temp2_min); |
308 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 303 | device_create_file(&new_client->dev, &dev_attr_temp2_input); |
309 | device_create_file(&new_client->dev, &dev_attr_alarms); | 304 | device_create_file(&new_client->dev, &dev_attr_alarms); |
310 | if (data->type == adm1021) | ||
311 | device_create_file(&new_client->dev, &dev_attr_die_code); | ||
312 | 305 | ||
313 | return 0; | 306 | return 0; |
314 | 307 | ||
@@ -371,8 +364,6 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
371 | data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); | 364 | data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); |
372 | data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); | 365 | data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); |
373 | data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; | 366 | data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; |
374 | if (data->type == adm1021) | ||
375 | data->die_code = adm1021_read_value(client, ADM1021_REG_DIE_CODE); | ||
376 | if (data->type == adm1023) { | 367 | if (data->type == adm1023) { |
377 | data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); | 368 | data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); |
378 | data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); | 369 | data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); |
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/i2c/chips/adm1025.c index e0771a3d05c9..e452d0daf906 100644 --- a/drivers/i2c/chips/adm1025.c +++ b/drivers/i2c/chips/adm1025.c | |||
@@ -45,7 +45,6 @@ | |||
45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <linux/config.h> | ||
49 | #include <linux/module.h> | 48 | #include <linux/module.h> |
50 | #include <linux/init.h> | 49 | #include <linux/init.h> |
51 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
@@ -153,19 +152,19 @@ struct adm1025_data { | |||
153 | */ | 152 | */ |
154 | 153 | ||
155 | #define show_in(offset) \ | 154 | #define show_in(offset) \ |
156 | static ssize_t show_in##offset(struct device *dev, char *buf) \ | 155 | static ssize_t show_in##offset(struct device *dev, struct device_attribute *attr, char *buf) \ |
157 | { \ | 156 | { \ |
158 | struct adm1025_data *data = adm1025_update_device(dev); \ | 157 | struct adm1025_data *data = adm1025_update_device(dev); \ |
159 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ | 158 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ |
160 | in_scale[offset])); \ | 159 | in_scale[offset])); \ |
161 | } \ | 160 | } \ |
162 | static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ | 161 | static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
163 | { \ | 162 | { \ |
164 | struct adm1025_data *data = adm1025_update_device(dev); \ | 163 | struct adm1025_data *data = adm1025_update_device(dev); \ |
165 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ | 164 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ |
166 | in_scale[offset])); \ | 165 | in_scale[offset])); \ |
167 | } \ | 166 | } \ |
168 | static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ | 167 | static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ |
169 | { \ | 168 | { \ |
170 | struct adm1025_data *data = adm1025_update_device(dev); \ | 169 | struct adm1025_data *data = adm1025_update_device(dev); \ |
171 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ | 170 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ |
@@ -180,17 +179,17 @@ show_in(4); | |||
180 | show_in(5); | 179 | show_in(5); |
181 | 180 | ||
182 | #define show_temp(offset) \ | 181 | #define show_temp(offset) \ |
183 | static ssize_t show_temp##offset(struct device *dev, char *buf) \ | 182 | static ssize_t show_temp##offset(struct device *dev, struct device_attribute *attr, char *buf) \ |
184 | { \ | 183 | { \ |
185 | struct adm1025_data *data = adm1025_update_device(dev); \ | 184 | struct adm1025_data *data = adm1025_update_device(dev); \ |
186 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ | 185 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ |
187 | } \ | 186 | } \ |
188 | static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \ | 187 | static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
189 | { \ | 188 | { \ |
190 | struct adm1025_data *data = adm1025_update_device(dev); \ | 189 | struct adm1025_data *data = adm1025_update_device(dev); \ |
191 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ | 190 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ |
192 | } \ | 191 | } \ |
193 | static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \ | 192 | static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ |
194 | { \ | 193 | { \ |
195 | struct adm1025_data *data = adm1025_update_device(dev); \ | 194 | struct adm1025_data *data = adm1025_update_device(dev); \ |
196 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ | 195 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ |
@@ -200,7 +199,7 @@ show_temp(1); | |||
200 | show_temp(2); | 199 | show_temp(2); |
201 | 200 | ||
202 | #define set_in(offset) \ | 201 | #define set_in(offset) \ |
203 | static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \ | 202 | static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
204 | size_t count) \ | 203 | size_t count) \ |
205 | { \ | 204 | { \ |
206 | struct i2c_client *client = to_i2c_client(dev); \ | 205 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -214,7 +213,7 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \ | |||
214 | up(&data->update_lock); \ | 213 | up(&data->update_lock); \ |
215 | return count; \ | 214 | return count; \ |
216 | } \ | 215 | } \ |
217 | static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \ | 216 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
218 | size_t count) \ | 217 | size_t count) \ |
219 | { \ | 218 | { \ |
220 | struct i2c_client *client = to_i2c_client(dev); \ | 219 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -240,7 +239,7 @@ set_in(4); | |||
240 | set_in(5); | 239 | set_in(5); |
241 | 240 | ||
242 | #define set_temp(offset) \ | 241 | #define set_temp(offset) \ |
243 | static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ | 242 | static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
244 | size_t count) \ | 243 | size_t count) \ |
245 | { \ | 244 | { \ |
246 | struct i2c_client *client = to_i2c_client(dev); \ | 245 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -254,7 +253,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ | |||
254 | up(&data->update_lock); \ | 253 | up(&data->update_lock); \ |
255 | return count; \ | 254 | return count; \ |
256 | } \ | 255 | } \ |
257 | static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ | 256 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
258 | size_t count) \ | 257 | size_t count) \ |
259 | { \ | 258 | { \ |
260 | struct i2c_client *client = to_i2c_client(dev); \ | 259 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -275,26 +274,28 @@ static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ | |||
275 | set_temp(1); | 274 | set_temp(1); |
276 | set_temp(2); | 275 | set_temp(2); |
277 | 276 | ||
278 | static ssize_t show_alarms(struct device *dev, char *buf) | 277 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
279 | { | 278 | { |
280 | struct adm1025_data *data = adm1025_update_device(dev); | 279 | struct adm1025_data *data = adm1025_update_device(dev); |
281 | return sprintf(buf, "%u\n", data->alarms); | 280 | return sprintf(buf, "%u\n", data->alarms); |
282 | } | 281 | } |
283 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 282 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
284 | 283 | ||
285 | static ssize_t show_vid(struct device *dev, char *buf) | 284 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
286 | { | 285 | { |
287 | struct adm1025_data *data = adm1025_update_device(dev); | 286 | struct adm1025_data *data = adm1025_update_device(dev); |
288 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); | 287 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); |
289 | } | 288 | } |
289 | /* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | ||
290 | static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); | 290 | static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); |
291 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
291 | 292 | ||
292 | static ssize_t show_vrm(struct device *dev, char *buf) | 293 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) |
293 | { | 294 | { |
294 | struct adm1025_data *data = adm1025_update_device(dev); | 295 | struct adm1025_data *data = adm1025_update_device(dev); |
295 | return sprintf(buf, "%u\n", data->vrm); | 296 | return sprintf(buf, "%u\n", data->vrm); |
296 | } | 297 | } |
297 | static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) | 298 | static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
298 | { | 299 | { |
299 | struct i2c_client *client = to_i2c_client(dev); | 300 | struct i2c_client *client = to_i2c_client(dev); |
300 | struct adm1025_data *data = i2c_get_clientdata(client); | 301 | struct adm1025_data *data = i2c_get_clientdata(client); |
@@ -437,7 +438,9 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 438 | device_create_file(&new_client->dev, &dev_attr_temp1_max); |
438 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 439 | device_create_file(&new_client->dev, &dev_attr_temp2_max); |
439 | device_create_file(&new_client->dev, &dev_attr_alarms); | 440 | device_create_file(&new_client->dev, &dev_attr_alarms); |
441 | /* in1_ref is deprecated, remove after 2005-11-11 */ | ||
440 | device_create_file(&new_client->dev, &dev_attr_in1_ref); | 442 | device_create_file(&new_client->dev, &dev_attr_in1_ref); |
443 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
441 | device_create_file(&new_client->dev, &dev_attr_vrm); | 444 | device_create_file(&new_client->dev, &dev_attr_vrm); |
442 | 445 | ||
443 | /* Pin 11 is either in4 (+12V) or VID4 */ | 446 | /* Pin 11 is either in4 (+12V) or VID4 */ |
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/i2c/chips/adm1026.c index 39e2f4a900bf..3c85fe150cd7 100644 --- a/drivers/i2c/chips/adm1026.c +++ b/drivers/i2c/chips/adm1026.c | |||
@@ -23,7 +23,6 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -31,6 +30,7 @@ | |||
31 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
32 | #include <linux/i2c-sensor.h> | 31 | #include <linux/i2c-sensor.h> |
33 | #include <linux/i2c-vid.h> | 32 | #include <linux/i2c-vid.h> |
33 | #include <linux/hwmon-sysfs.h> | ||
34 | 34 | ||
35 | /* Addresses to scan */ | 35 | /* Addresses to scan */ |
36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -711,19 +711,27 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
711 | return data; | 711 | return data; |
712 | } | 712 | } |
713 | 713 | ||
714 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 714 | static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
715 | char *buf) | ||
715 | { | 716 | { |
717 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
718 | int nr = sensor_attr->index; | ||
716 | struct adm1026_data *data = adm1026_update_device(dev); | 719 | struct adm1026_data *data = adm1026_update_device(dev); |
717 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr])); | 720 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr])); |
718 | } | 721 | } |
719 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 722 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
723 | char *buf) | ||
720 | { | 724 | { |
725 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
726 | int nr = sensor_attr->index; | ||
721 | struct adm1026_data *data = adm1026_update_device(dev); | 727 | struct adm1026_data *data = adm1026_update_device(dev); |
722 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr])); | 728 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
723 | } | 729 | } |
724 | static ssize_t set_in_min(struct device *dev, const char *buf, | 730 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
725 | size_t count, int nr) | 731 | const char *buf, size_t count) |
726 | { | 732 | { |
733 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
734 | int nr = sensor_attr->index; | ||
727 | struct i2c_client *client = to_i2c_client(dev); | 735 | struct i2c_client *client = to_i2c_client(dev); |
728 | struct adm1026_data *data = i2c_get_clientdata(client); | 736 | struct adm1026_data *data = i2c_get_clientdata(client); |
729 | int val = simple_strtol(buf, NULL, 10); | 737 | int val = simple_strtol(buf, NULL, 10); |
@@ -734,14 +742,19 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
734 | up(&data->update_lock); | 742 | up(&data->update_lock); |
735 | return count; | 743 | return count; |
736 | } | 744 | } |
737 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 745 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
746 | char *buf) | ||
738 | { | 747 | { |
748 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
749 | int nr = sensor_attr->index; | ||
739 | struct adm1026_data *data = adm1026_update_device(dev); | 750 | struct adm1026_data *data = adm1026_update_device(dev); |
740 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr])); | 751 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
741 | } | 752 | } |
742 | static ssize_t set_in_max(struct device *dev, const char *buf, | 753 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
743 | size_t count, int nr) | 754 | const char *buf, size_t count) |
744 | { | 755 | { |
756 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
757 | int nr = sensor_attr->index; | ||
745 | struct i2c_client *client = to_i2c_client(dev); | 758 | struct i2c_client *client = to_i2c_client(dev); |
746 | struct adm1026_data *data = i2c_get_clientdata(client); | 759 | struct adm1026_data *data = i2c_get_clientdata(client); |
747 | int val = simple_strtol(buf, NULL, 10); | 760 | int val = simple_strtol(buf, NULL, 10); |
@@ -753,34 +766,13 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
753 | return count; | 766 | return count; |
754 | } | 767 | } |
755 | 768 | ||
756 | #define in_reg(offset) \ | 769 | #define in_reg(offset) \ |
757 | static ssize_t show_in##offset (struct device *dev, char *buf) \ | 770 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ |
758 | { \ | 771 | NULL, offset); \ |
759 | return show_in(dev, buf, offset); \ | 772 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
760 | } \ | 773 | show_in_min, set_in_min, offset); \ |
761 | static ssize_t show_in##offset##_min (struct device *dev, char *buf) \ | 774 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
762 | { \ | 775 | show_in_max, set_in_max, offset); |
763 | return show_in_min(dev, buf, offset); \ | ||
764 | } \ | ||
765 | static ssize_t set_in##offset##_min (struct device *dev, \ | ||
766 | const char *buf, size_t count) \ | ||
767 | { \ | ||
768 | return set_in_min(dev, buf, count, offset); \ | ||
769 | } \ | ||
770 | static ssize_t show_in##offset##_max (struct device *dev, char *buf) \ | ||
771 | { \ | ||
772 | return show_in_max(dev, buf, offset); \ | ||
773 | } \ | ||
774 | static ssize_t set_in##offset##_max (struct device *dev, \ | ||
775 | const char *buf, size_t count) \ | ||
776 | { \ | ||
777 | return set_in_max(dev, buf, count, offset); \ | ||
778 | } \ | ||
779 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | ||
780 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
781 | show_in##offset##_min, set_in##offset##_min); \ | ||
782 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
783 | show_in##offset##_max, set_in##offset##_max); | ||
784 | 776 | ||
785 | 777 | ||
786 | in_reg(0); | 778 | in_reg(0); |
@@ -800,19 +792,19 @@ in_reg(13); | |||
800 | in_reg(14); | 792 | in_reg(14); |
801 | in_reg(15); | 793 | in_reg(15); |
802 | 794 | ||
803 | static ssize_t show_in16(struct device *dev, char *buf) | 795 | static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf) |
804 | { | 796 | { |
805 | struct adm1026_data *data = adm1026_update_device(dev); | 797 | struct adm1026_data *data = adm1026_update_device(dev); |
806 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) - | 798 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) - |
807 | NEG12_OFFSET); | 799 | NEG12_OFFSET); |
808 | } | 800 | } |
809 | static ssize_t show_in16_min(struct device *dev, char *buf) | 801 | static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf) |
810 | { | 802 | { |
811 | struct adm1026_data *data = adm1026_update_device(dev); | 803 | struct adm1026_data *data = adm1026_update_device(dev); |
812 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16]) | 804 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16]) |
813 | - NEG12_OFFSET); | 805 | - NEG12_OFFSET); |
814 | } | 806 | } |
815 | static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count) | 807 | static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
816 | { | 808 | { |
817 | struct i2c_client *client = to_i2c_client(dev); | 809 | struct i2c_client *client = to_i2c_client(dev); |
818 | struct adm1026_data *data = i2c_get_clientdata(client); | 810 | struct adm1026_data *data = i2c_get_clientdata(client); |
@@ -824,13 +816,13 @@ static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count) | |||
824 | up(&data->update_lock); | 816 | up(&data->update_lock); |
825 | return count; | 817 | return count; |
826 | } | 818 | } |
827 | static ssize_t show_in16_max(struct device *dev, char *buf) | 819 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
828 | { | 820 | { |
829 | struct adm1026_data *data = adm1026_update_device(dev); | 821 | struct adm1026_data *data = adm1026_update_device(dev); |
830 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16]) | 822 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16]) |
831 | - NEG12_OFFSET); | 823 | - NEG12_OFFSET); |
832 | } | 824 | } |
833 | static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count) | 825 | static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
834 | { | 826 | { |
835 | struct i2c_client *client = to_i2c_client(dev); | 827 | struct i2c_client *client = to_i2c_client(dev); |
836 | struct adm1026_data *data = i2c_get_clientdata(client); | 828 | struct adm1026_data *data = i2c_get_clientdata(client); |
@@ -843,30 +835,38 @@ static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count) | |||
843 | return count; | 835 | return count; |
844 | } | 836 | } |
845 | 837 | ||
846 | static DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL); | 838 | static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL, 16); |
847 | static DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min); | 839 | static SENSOR_DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min, 16); |
848 | static DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max); | 840 | static SENSOR_DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max, 16); |
849 | 841 | ||
850 | 842 | ||
851 | 843 | ||
852 | 844 | ||
853 | /* Now add fan read/write functions */ | 845 | /* Now add fan read/write functions */ |
854 | 846 | ||
855 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 847 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
848 | char *buf) | ||
856 | { | 849 | { |
850 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
851 | int nr = sensor_attr->index; | ||
857 | struct adm1026_data *data = adm1026_update_device(dev); | 852 | struct adm1026_data *data = adm1026_update_device(dev); |
858 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 853 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], |
859 | data->fan_div[nr])); | 854 | data->fan_div[nr])); |
860 | } | 855 | } |
861 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 856 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
857 | char *buf) | ||
862 | { | 858 | { |
859 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
860 | int nr = sensor_attr->index; | ||
863 | struct adm1026_data *data = adm1026_update_device(dev); | 861 | struct adm1026_data *data = adm1026_update_device(dev); |
864 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr], | 862 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr], |
865 | data->fan_div[nr])); | 863 | data->fan_div[nr])); |
866 | } | 864 | } |
867 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 865 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
868 | size_t count, int nr) | 866 | const char *buf, size_t count) |
869 | { | 867 | { |
868 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
869 | int nr = sensor_attr->index; | ||
870 | struct i2c_client *client = to_i2c_client(dev); | 870 | struct i2c_client *client = to_i2c_client(dev); |
871 | struct adm1026_data *data = i2c_get_clientdata(client); | 871 | struct adm1026_data *data = i2c_get_clientdata(client); |
872 | int val = simple_strtol(buf, NULL, 10); | 872 | int val = simple_strtol(buf, NULL, 10); |
@@ -879,23 +879,11 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
879 | return count; | 879 | return count; |
880 | } | 880 | } |
881 | 881 | ||
882 | #define fan_offset(offset) \ | 882 | #define fan_offset(offset) \ |
883 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 883 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ |
884 | { \ | 884 | offset - 1); \ |
885 | return show_fan(dev, buf, offset - 1); \ | 885 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
886 | } \ | 886 | show_fan_min, set_fan_min, offset - 1); |
887 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | ||
888 | { \ | ||
889 | return show_fan_min(dev, buf, offset - 1); \ | ||
890 | } \ | ||
891 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
892 | const char *buf, size_t count) \ | ||
893 | { \ | ||
894 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
895 | } \ | ||
896 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \ | ||
897 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
898 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
899 | 887 | ||
900 | fan_offset(1); | 888 | fan_offset(1); |
901 | fan_offset(2); | 889 | fan_offset(2); |
@@ -926,14 +914,19 @@ static void fixup_fan_min(struct device *dev, int fan, int old_div) | |||
926 | } | 914 | } |
927 | 915 | ||
928 | /* Now add fan_div read/write functions */ | 916 | /* Now add fan_div read/write functions */ |
929 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 917 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
918 | char *buf) | ||
930 | { | 919 | { |
920 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
921 | int nr = sensor_attr->index; | ||
931 | struct adm1026_data *data = adm1026_update_device(dev); | 922 | struct adm1026_data *data = adm1026_update_device(dev); |
932 | return sprintf(buf,"%d\n", data->fan_div[nr]); | 923 | return sprintf(buf,"%d\n", data->fan_div[nr]); |
933 | } | 924 | } |
934 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 925 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
935 | size_t count, int nr) | 926 | const char *buf, size_t count) |
936 | { | 927 | { |
928 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
929 | int nr = sensor_attr->index; | ||
937 | struct i2c_client *client = to_i2c_client(dev); | 930 | struct i2c_client *client = to_i2c_client(dev); |
938 | struct adm1026_data *data = i2c_get_clientdata(client); | 931 | struct adm1026_data *data = i2c_get_clientdata(client); |
939 | int val,orig_div,new_div,shift; | 932 | int val,orig_div,new_div,shift; |
@@ -967,17 +960,8 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
967 | } | 960 | } |
968 | 961 | ||
969 | #define fan_offset_div(offset) \ | 962 | #define fan_offset_div(offset) \ |
970 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | 963 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
971 | { \ | 964 | show_fan_div, set_fan_div, offset - 1); |
972 | return show_fan_div(dev, buf, offset - 1); \ | ||
973 | } \ | ||
974 | static ssize_t set_fan_##offset##_div (struct device *dev, \ | ||
975 | const char *buf, size_t count) \ | ||
976 | { \ | ||
977 | return set_fan_div(dev, buf, count, offset - 1); \ | ||
978 | } \ | ||
979 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | ||
980 | show_fan_##offset##_div, set_fan_##offset##_div); | ||
981 | 965 | ||
982 | fan_offset_div(1); | 966 | fan_offset_div(1); |
983 | fan_offset_div(2); | 967 | fan_offset_div(2); |
@@ -989,19 +973,27 @@ fan_offset_div(7); | |||
989 | fan_offset_div(8); | 973 | fan_offset_div(8); |
990 | 974 | ||
991 | /* Temps */ | 975 | /* Temps */ |
992 | static ssize_t show_temp(struct device *dev, char *buf, int nr) | 976 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
977 | char *buf) | ||
993 | { | 978 | { |
979 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
980 | int nr = sensor_attr->index; | ||
994 | struct adm1026_data *data = adm1026_update_device(dev); | 981 | struct adm1026_data *data = adm1026_update_device(dev); |
995 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr])); | 982 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr])); |
996 | } | 983 | } |
997 | static ssize_t show_temp_min(struct device *dev, char *buf, int nr) | 984 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
985 | char *buf) | ||
998 | { | 986 | { |
987 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
988 | int nr = sensor_attr->index; | ||
999 | struct adm1026_data *data = adm1026_update_device(dev); | 989 | struct adm1026_data *data = adm1026_update_device(dev); |
1000 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr])); | 990 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
1001 | } | 991 | } |
1002 | static ssize_t set_temp_min(struct device *dev, const char *buf, | 992 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
1003 | size_t count, int nr) | 993 | const char *buf, size_t count) |
1004 | { | 994 | { |
995 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
996 | int nr = sensor_attr->index; | ||
1005 | struct i2c_client *client = to_i2c_client(dev); | 997 | struct i2c_client *client = to_i2c_client(dev); |
1006 | struct adm1026_data *data = i2c_get_clientdata(client); | 998 | struct adm1026_data *data = i2c_get_clientdata(client); |
1007 | int val = simple_strtol(buf, NULL, 10); | 999 | int val = simple_strtol(buf, NULL, 10); |
@@ -1013,14 +1005,19 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
1013 | up(&data->update_lock); | 1005 | up(&data->update_lock); |
1014 | return count; | 1006 | return count; |
1015 | } | 1007 | } |
1016 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 1008 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
1009 | char *buf) | ||
1017 | { | 1010 | { |
1011 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1012 | int nr = sensor_attr->index; | ||
1018 | struct adm1026_data *data = adm1026_update_device(dev); | 1013 | struct adm1026_data *data = adm1026_update_device(dev); |
1019 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr])); | 1014 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
1020 | } | 1015 | } |
1021 | static ssize_t set_temp_max(struct device *dev, const char *buf, | 1016 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
1022 | size_t count, int nr) | 1017 | const char *buf, size_t count) |
1023 | { | 1018 | { |
1019 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1020 | int nr = sensor_attr->index; | ||
1024 | struct i2c_client *client = to_i2c_client(dev); | 1021 | struct i2c_client *client = to_i2c_client(dev); |
1025 | struct adm1026_data *data = i2c_get_clientdata(client); | 1022 | struct adm1026_data *data = i2c_get_clientdata(client); |
1026 | int val = simple_strtol(buf, NULL, 10); | 1023 | int val = simple_strtol(buf, NULL, 10); |
@@ -1032,48 +1029,34 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
1032 | up(&data->update_lock); | 1029 | up(&data->update_lock); |
1033 | return count; | 1030 | return count; |
1034 | } | 1031 | } |
1035 | #define temp_reg(offset) \ | 1032 | |
1036 | static ssize_t show_temp_##offset (struct device *dev, char *buf) \ | 1033 | #define temp_reg(offset) \ |
1037 | { \ | 1034 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ |
1038 | return show_temp(dev, buf, offset - 1); \ | 1035 | NULL, offset - 1); \ |
1039 | } \ | 1036 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
1040 | static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \ | 1037 | show_temp_min, set_temp_min, offset - 1); \ |
1041 | { \ | 1038 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
1042 | return show_temp_min(dev, buf, offset - 1); \ | 1039 | show_temp_max, set_temp_max, offset - 1); |
1043 | } \ | ||
1044 | static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \ | ||
1045 | { \ | ||
1046 | return show_temp_max(dev, buf, offset - 1); \ | ||
1047 | } \ | ||
1048 | static ssize_t set_temp_##offset##_min (struct device *dev, \ | ||
1049 | const char *buf, size_t count) \ | ||
1050 | { \ | ||
1051 | return set_temp_min(dev, buf, count, offset - 1); \ | ||
1052 | } \ | ||
1053 | static ssize_t set_temp_##offset##_max (struct device *dev, \ | ||
1054 | const char *buf, size_t count) \ | ||
1055 | { \ | ||
1056 | return set_temp_max(dev, buf, count, offset - 1); \ | ||
1057 | } \ | ||
1058 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \ | ||
1059 | static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | ||
1060 | show_temp_##offset##_min, set_temp_##offset##_min); \ | ||
1061 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
1062 | show_temp_##offset##_max, set_temp_##offset##_max); | ||
1063 | 1040 | ||
1064 | 1041 | ||
1065 | temp_reg(1); | 1042 | temp_reg(1); |
1066 | temp_reg(2); | 1043 | temp_reg(2); |
1067 | temp_reg(3); | 1044 | temp_reg(3); |
1068 | 1045 | ||
1069 | static ssize_t show_temp_offset(struct device *dev, char *buf, int nr) | 1046 | static ssize_t show_temp_offset(struct device *dev, |
1047 | struct device_attribute *attr, char *buf) | ||
1070 | { | 1048 | { |
1049 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1050 | int nr = sensor_attr->index; | ||
1071 | struct adm1026_data *data = adm1026_update_device(dev); | 1051 | struct adm1026_data *data = adm1026_update_device(dev); |
1072 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr])); | 1052 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr])); |
1073 | } | 1053 | } |
1074 | static ssize_t set_temp_offset(struct device *dev, const char *buf, | 1054 | static ssize_t set_temp_offset(struct device *dev, |
1075 | size_t count, int nr) | 1055 | struct device_attribute *attr, const char *buf, |
1056 | size_t count) | ||
1076 | { | 1057 | { |
1058 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1059 | int nr = sensor_attr->index; | ||
1077 | struct i2c_client *client = to_i2c_client(dev); | 1060 | struct i2c_client *client = to_i2c_client(dev); |
1078 | struct adm1026_data *data = i2c_get_clientdata(client); | 1061 | struct adm1026_data *data = i2c_get_clientdata(client); |
1079 | int val = simple_strtol(buf, NULL, 10); | 1062 | int val = simple_strtol(buf, NULL, 10); |
@@ -1086,46 +1069,45 @@ static ssize_t set_temp_offset(struct device *dev, const char *buf, | |||
1086 | return count; | 1069 | return count; |
1087 | } | 1070 | } |
1088 | 1071 | ||
1089 | #define temp_offset_reg(offset) \ | 1072 | #define temp_offset_reg(offset) \ |
1090 | static ssize_t show_temp_##offset##_offset (struct device *dev, char *buf) \ | 1073 | static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \ |
1091 | { \ | 1074 | show_temp_offset, set_temp_offset, offset - 1); |
1092 | return show_temp_offset(dev, buf, offset - 1); \ | ||
1093 | } \ | ||
1094 | static ssize_t set_temp_##offset##_offset (struct device *dev, \ | ||
1095 | const char *buf, size_t count) \ | ||
1096 | { \ | ||
1097 | return set_temp_offset(dev, buf, count, offset - 1); \ | ||
1098 | } \ | ||
1099 | static DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \ | ||
1100 | show_temp_##offset##_offset, set_temp_##offset##_offset); | ||
1101 | 1075 | ||
1102 | temp_offset_reg(1); | 1076 | temp_offset_reg(1); |
1103 | temp_offset_reg(2); | 1077 | temp_offset_reg(2); |
1104 | temp_offset_reg(3); | 1078 | temp_offset_reg(3); |
1105 | 1079 | ||
1106 | static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, char *buf, | 1080 | static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, |
1107 | int nr) | 1081 | struct device_attribute *attr, char *buf) |
1108 | { | 1082 | { |
1083 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1084 | int nr = sensor_attr->index; | ||
1109 | struct adm1026_data *data = adm1026_update_device(dev); | 1085 | struct adm1026_data *data = adm1026_update_device(dev); |
1110 | return sprintf(buf,"%d\n", TEMP_FROM_REG( | 1086 | return sprintf(buf,"%d\n", TEMP_FROM_REG( |
1111 | ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); | 1087 | ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); |
1112 | } | 1088 | } |
1113 | static ssize_t show_temp_auto_point2_temp(struct device *dev, char *buf, | 1089 | static ssize_t show_temp_auto_point2_temp(struct device *dev, |
1114 | int nr) | 1090 | struct device_attribute *attr, char *buf) |
1115 | { | 1091 | { |
1092 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1093 | int nr = sensor_attr->index; | ||
1116 | struct adm1026_data *data = adm1026_update_device(dev); | 1094 | struct adm1026_data *data = adm1026_update_device(dev); |
1117 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + | 1095 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + |
1118 | ADM1026_FAN_CONTROL_TEMP_RANGE)); | 1096 | ADM1026_FAN_CONTROL_TEMP_RANGE)); |
1119 | } | 1097 | } |
1120 | static ssize_t show_temp_auto_point1_temp(struct device *dev, char *buf, | 1098 | static ssize_t show_temp_auto_point1_temp(struct device *dev, |
1121 | int nr) | 1099 | struct device_attribute *attr, char *buf) |
1122 | { | 1100 | { |
1101 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1102 | int nr = sensor_attr->index; | ||
1123 | struct adm1026_data *data = adm1026_update_device(dev); | 1103 | struct adm1026_data *data = adm1026_update_device(dev); |
1124 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); | 1104 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); |
1125 | } | 1105 | } |
1126 | static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf, | 1106 | static ssize_t set_temp_auto_point1_temp(struct device *dev, |
1127 | size_t count, int nr) | 1107 | struct device_attribute *attr, const char *buf, size_t count) |
1128 | { | 1108 | { |
1109 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1110 | int nr = sensor_attr->index; | ||
1129 | struct i2c_client *client = to_i2c_client(dev); | 1111 | struct i2c_client *client = to_i2c_client(dev); |
1130 | struct adm1026_data *data = i2c_get_clientdata(client); | 1112 | struct adm1026_data *data = i2c_get_clientdata(client); |
1131 | int val = simple_strtol(buf, NULL, 10); | 1113 | int val = simple_strtol(buf, NULL, 10); |
@@ -1138,46 +1120,27 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf, | |||
1138 | return count; | 1120 | return count; |
1139 | } | 1121 | } |
1140 | 1122 | ||
1141 | #define temp_auto_point(offset) \ | 1123 | #define temp_auto_point(offset) \ |
1142 | static ssize_t show_temp##offset##_auto_point1_temp (struct device *dev, \ | 1124 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR, \ |
1143 | char *buf) \ | 1125 | show_temp_auto_point1_temp, set_temp_auto_point1_temp, \ |
1144 | { \ | 1126 | offset - 1); \ |
1145 | return show_temp_auto_point1_temp(dev, buf, offset - 1); \ | 1127 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO, \ |
1146 | } \ | 1128 | show_temp_auto_point1_temp_hyst, NULL, offset - 1); \ |
1147 | static ssize_t set_temp##offset##_auto_point1_temp (struct device *dev, \ | 1129 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ |
1148 | const char *buf, size_t count) \ | 1130 | show_temp_auto_point2_temp, NULL, offset - 1); |
1149 | { \ | ||
1150 | return set_temp_auto_point1_temp(dev, buf, count, offset - 1); \ | ||
1151 | } \ | ||
1152 | static ssize_t show_temp##offset##_auto_point1_temp_hyst (struct device \ | ||
1153 | *dev, char *buf) \ | ||
1154 | { \ | ||
1155 | return show_temp_auto_point1_temp_hyst(dev, buf, offset - 1); \ | ||
1156 | } \ | ||
1157 | static ssize_t show_temp##offset##_auto_point2_temp (struct device *dev, \ | ||
1158 | char *buf) \ | ||
1159 | { \ | ||
1160 | return show_temp_auto_point2_temp(dev, buf, offset - 1); \ | ||
1161 | } \ | ||
1162 | static DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR, \ | ||
1163 | show_temp##offset##_auto_point1_temp, \ | ||
1164 | set_temp##offset##_auto_point1_temp); \ | ||
1165 | static DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO, \ | ||
1166 | show_temp##offset##_auto_point1_temp_hyst, NULL); \ | ||
1167 | static DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ | ||
1168 | show_temp##offset##_auto_point2_temp, NULL); | ||
1169 | 1131 | ||
1170 | temp_auto_point(1); | 1132 | temp_auto_point(1); |
1171 | temp_auto_point(2); | 1133 | temp_auto_point(2); |
1172 | temp_auto_point(3); | 1134 | temp_auto_point(3); |
1173 | 1135 | ||
1174 | static ssize_t show_temp_crit_enable(struct device *dev, char *buf) | 1136 | static ssize_t show_temp_crit_enable(struct device *dev, |
1137 | struct device_attribute *attr, char *buf) | ||
1175 | { | 1138 | { |
1176 | struct adm1026_data *data = adm1026_update_device(dev); | 1139 | struct adm1026_data *data = adm1026_update_device(dev); |
1177 | return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); | 1140 | return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); |
1178 | } | 1141 | } |
1179 | static ssize_t set_temp_crit_enable(struct device *dev, const char *buf, | 1142 | static ssize_t set_temp_crit_enable(struct device *dev, |
1180 | size_t count) | 1143 | struct device_attribute *attr, const char *buf, size_t count) |
1181 | { | 1144 | { |
1182 | struct i2c_client *client = to_i2c_client(dev); | 1145 | struct i2c_client *client = to_i2c_client(dev); |
1183 | struct adm1026_data *data = i2c_get_clientdata(client); | 1146 | struct adm1026_data *data = i2c_get_clientdata(client); |
@@ -1193,24 +1156,27 @@ static ssize_t set_temp_crit_enable(struct device *dev, const char *buf, | |||
1193 | return count; | 1156 | return count; |
1194 | } | 1157 | } |
1195 | 1158 | ||
1196 | static DEVICE_ATTR(temp1_crit_enable, S_IRUGO | S_IWUSR, | 1159 | #define temp_crit_enable(offset) \ |
1197 | show_temp_crit_enable, set_temp_crit_enable); | 1160 | static DEVICE_ATTR(temp##offset##_crit_enable, S_IRUGO | S_IWUSR, \ |
1198 | |||
1199 | static DEVICE_ATTR(temp2_crit_enable, S_IRUGO | S_IWUSR, | ||
1200 | show_temp_crit_enable, set_temp_crit_enable); | ||
1201 | |||
1202 | static DEVICE_ATTR(temp3_crit_enable, S_IRUGO | S_IWUSR, | ||
1203 | show_temp_crit_enable, set_temp_crit_enable); | 1161 | show_temp_crit_enable, set_temp_crit_enable); |
1204 | 1162 | ||
1163 | temp_crit_enable(1); | ||
1164 | temp_crit_enable(2); | ||
1165 | temp_crit_enable(3); | ||
1205 | 1166 | ||
1206 | static ssize_t show_temp_crit(struct device *dev, char *buf, int nr) | 1167 | static ssize_t show_temp_crit(struct device *dev, |
1168 | struct device_attribute *attr, char *buf) | ||
1207 | { | 1169 | { |
1170 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1171 | int nr = sensor_attr->index; | ||
1208 | struct adm1026_data *data = adm1026_update_device(dev); | 1172 | struct adm1026_data *data = adm1026_update_device(dev); |
1209 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr])); | 1173 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr])); |
1210 | } | 1174 | } |
1211 | static ssize_t set_temp_crit(struct device *dev, const char *buf, | 1175 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, |
1212 | size_t count, int nr) | 1176 | const char *buf, size_t count) |
1213 | { | 1177 | { |
1178 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1179 | int nr = sensor_attr->index; | ||
1214 | struct i2c_client *client = to_i2c_client(dev); | 1180 | struct i2c_client *client = to_i2c_client(dev); |
1215 | struct adm1026_data *data = i2c_get_clientdata(client); | 1181 | struct adm1026_data *data = i2c_get_clientdata(client); |
1216 | int val = simple_strtol(buf, NULL, 10); | 1182 | int val = simple_strtol(buf, NULL, 10); |
@@ -1223,29 +1189,20 @@ static ssize_t set_temp_crit(struct device *dev, const char *buf, | |||
1223 | return count; | 1189 | return count; |
1224 | } | 1190 | } |
1225 | 1191 | ||
1226 | #define temp_crit_reg(offset) \ | 1192 | #define temp_crit_reg(offset) \ |
1227 | static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf) \ | 1193 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \ |
1228 | { \ | 1194 | show_temp_crit, set_temp_crit, offset - 1); |
1229 | return show_temp_crit(dev, buf, offset - 1); \ | ||
1230 | } \ | ||
1231 | static ssize_t set_temp_##offset##_crit (struct device *dev, \ | ||
1232 | const char *buf, size_t count) \ | ||
1233 | { \ | ||
1234 | return set_temp_crit(dev, buf, count, offset - 1); \ | ||
1235 | } \ | ||
1236 | static DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \ | ||
1237 | show_temp_##offset##_crit, set_temp_##offset##_crit); | ||
1238 | 1195 | ||
1239 | temp_crit_reg(1); | 1196 | temp_crit_reg(1); |
1240 | temp_crit_reg(2); | 1197 | temp_crit_reg(2); |
1241 | temp_crit_reg(3); | 1198 | temp_crit_reg(3); |
1242 | 1199 | ||
1243 | static ssize_t show_analog_out_reg(struct device *dev, char *buf) | 1200 | static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1244 | { | 1201 | { |
1245 | struct adm1026_data *data = adm1026_update_device(dev); | 1202 | struct adm1026_data *data = adm1026_update_device(dev); |
1246 | return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out)); | 1203 | return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out)); |
1247 | } | 1204 | } |
1248 | static ssize_t set_analog_out_reg(struct device *dev, const char *buf, | 1205 | static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1249 | size_t count) | 1206 | size_t count) |
1250 | { | 1207 | { |
1251 | struct i2c_client *client = to_i2c_client(dev); | 1208 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1262,20 +1219,21 @@ static ssize_t set_analog_out_reg(struct device *dev, const char *buf, | |||
1262 | static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, | 1219 | static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, |
1263 | set_analog_out_reg); | 1220 | set_analog_out_reg); |
1264 | 1221 | ||
1265 | static ssize_t show_vid_reg(struct device *dev, char *buf) | 1222 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1266 | { | 1223 | { |
1267 | struct adm1026_data *data = adm1026_update_device(dev); | 1224 | struct adm1026_data *data = adm1026_update_device(dev); |
1268 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); | 1225 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); |
1269 | } | 1226 | } |
1270 | 1227 | /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | |
1271 | static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); | 1228 | static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); |
1229 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | ||
1272 | 1230 | ||
1273 | static ssize_t show_vrm_reg(struct device *dev, char *buf) | 1231 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1274 | { | 1232 | { |
1275 | struct adm1026_data *data = adm1026_update_device(dev); | 1233 | struct adm1026_data *data = adm1026_update_device(dev); |
1276 | return sprintf(buf,"%d\n", data->vrm); | 1234 | return sprintf(buf,"%d\n", data->vrm); |
1277 | } | 1235 | } |
1278 | static ssize_t store_vrm_reg(struct device *dev, const char *buf, | 1236 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1279 | size_t count) | 1237 | size_t count) |
1280 | { | 1238 | { |
1281 | struct i2c_client *client = to_i2c_client(dev); | 1239 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1287,7 +1245,7 @@ static ssize_t store_vrm_reg(struct device *dev, const char *buf, | |||
1287 | 1245 | ||
1288 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | 1246 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); |
1289 | 1247 | ||
1290 | static ssize_t show_alarms_reg(struct device *dev, char *buf) | 1248 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1291 | { | 1249 | { |
1292 | struct adm1026_data *data = adm1026_update_device(dev); | 1250 | struct adm1026_data *data = adm1026_update_device(dev); |
1293 | return sprintf(buf, "%ld\n", (long) (data->alarms)); | 1251 | return sprintf(buf, "%ld\n", (long) (data->alarms)); |
@@ -1295,12 +1253,12 @@ static ssize_t show_alarms_reg(struct device *dev, char *buf) | |||
1295 | 1253 | ||
1296 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 1254 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
1297 | 1255 | ||
1298 | static ssize_t show_alarm_mask(struct device *dev, char *buf) | 1256 | static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf) |
1299 | { | 1257 | { |
1300 | struct adm1026_data *data = adm1026_update_device(dev); | 1258 | struct adm1026_data *data = adm1026_update_device(dev); |
1301 | return sprintf(buf,"%ld\n", data->alarm_mask); | 1259 | return sprintf(buf,"%ld\n", data->alarm_mask); |
1302 | } | 1260 | } |
1303 | static ssize_t set_alarm_mask(struct device *dev, const char *buf, | 1261 | static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf, |
1304 | size_t count) | 1262 | size_t count) |
1305 | { | 1263 | { |
1306 | struct i2c_client *client = to_i2c_client(dev); | 1264 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1331,12 +1289,12 @@ static DEVICE_ATTR(alarm_mask, S_IRUGO | S_IWUSR, show_alarm_mask, | |||
1331 | set_alarm_mask); | 1289 | set_alarm_mask); |
1332 | 1290 | ||
1333 | 1291 | ||
1334 | static ssize_t show_gpio(struct device *dev, char *buf) | 1292 | static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf) |
1335 | { | 1293 | { |
1336 | struct adm1026_data *data = adm1026_update_device(dev); | 1294 | struct adm1026_data *data = adm1026_update_device(dev); |
1337 | return sprintf(buf,"%ld\n", data->gpio); | 1295 | return sprintf(buf,"%ld\n", data->gpio); |
1338 | } | 1296 | } |
1339 | static ssize_t set_gpio(struct device *dev, const char *buf, | 1297 | static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf, |
1340 | size_t count) | 1298 | size_t count) |
1341 | { | 1299 | { |
1342 | struct i2c_client *client = to_i2c_client(dev); | 1300 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1359,12 +1317,12 @@ static ssize_t set_gpio(struct device *dev, const char *buf, | |||
1359 | static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio); | 1317 | static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio); |
1360 | 1318 | ||
1361 | 1319 | ||
1362 | static ssize_t show_gpio_mask(struct device *dev, char *buf) | 1320 | static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf) |
1363 | { | 1321 | { |
1364 | struct adm1026_data *data = adm1026_update_device(dev); | 1322 | struct adm1026_data *data = adm1026_update_device(dev); |
1365 | return sprintf(buf,"%ld\n", data->gpio_mask); | 1323 | return sprintf(buf,"%ld\n", data->gpio_mask); |
1366 | } | 1324 | } |
1367 | static ssize_t set_gpio_mask(struct device *dev, const char *buf, | 1325 | static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf, |
1368 | size_t count) | 1326 | size_t count) |
1369 | { | 1327 | { |
1370 | struct i2c_client *client = to_i2c_client(dev); | 1328 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1386,12 +1344,12 @@ static ssize_t set_gpio_mask(struct device *dev, const char *buf, | |||
1386 | 1344 | ||
1387 | static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask); | 1345 | static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask); |
1388 | 1346 | ||
1389 | static ssize_t show_pwm_reg(struct device *dev, char *buf) | 1347 | static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1390 | { | 1348 | { |
1391 | struct adm1026_data *data = adm1026_update_device(dev); | 1349 | struct adm1026_data *data = adm1026_update_device(dev); |
1392 | return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm)); | 1350 | return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm)); |
1393 | } | 1351 | } |
1394 | static ssize_t set_pwm_reg(struct device *dev, const char *buf, | 1352 | static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1395 | size_t count) | 1353 | size_t count) |
1396 | { | 1354 | { |
1397 | struct i2c_client *client = to_i2c_client(dev); | 1355 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1407,12 +1365,12 @@ static ssize_t set_pwm_reg(struct device *dev, const char *buf, | |||
1407 | } | 1365 | } |
1408 | return count; | 1366 | return count; |
1409 | } | 1367 | } |
1410 | static ssize_t show_auto_pwm_min(struct device *dev, char *buf) | 1368 | static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf) |
1411 | { | 1369 | { |
1412 | struct adm1026_data *data = adm1026_update_device(dev); | 1370 | struct adm1026_data *data = adm1026_update_device(dev); |
1413 | return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min); | 1371 | return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min); |
1414 | } | 1372 | } |
1415 | static ssize_t set_auto_pwm_min(struct device *dev, const char *buf, | 1373 | static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf, |
1416 | size_t count) | 1374 | size_t count) |
1417 | { | 1375 | { |
1418 | struct i2c_client *client = to_i2c_client(dev); | 1376 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1429,16 +1387,16 @@ static ssize_t set_auto_pwm_min(struct device *dev, const char *buf, | |||
1429 | up(&data->update_lock); | 1387 | up(&data->update_lock); |
1430 | return count; | 1388 | return count; |
1431 | } | 1389 | } |
1432 | static ssize_t show_auto_pwm_max(struct device *dev, char *buf) | 1390 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
1433 | { | 1391 | { |
1434 | return sprintf(buf,"%d\n", ADM1026_PWM_MAX); | 1392 | return sprintf(buf,"%d\n", ADM1026_PWM_MAX); |
1435 | } | 1393 | } |
1436 | static ssize_t show_pwm_enable(struct device *dev, char *buf) | 1394 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) |
1437 | { | 1395 | { |
1438 | struct adm1026_data *data = adm1026_update_device(dev); | 1396 | struct adm1026_data *data = adm1026_update_device(dev); |
1439 | return sprintf(buf,"%d\n", data->pwm1.enable); | 1397 | return sprintf(buf,"%d\n", data->pwm1.enable); |
1440 | } | 1398 | } |
1441 | static ssize_t set_pwm_enable(struct device *dev, const char *buf, | 1399 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, |
1442 | size_t count) | 1400 | size_t count) |
1443 | { | 1401 | { |
1444 | struct i2c_client *client = to_i2c_client(dev); | 1402 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1597,118 +1555,120 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1597 | adm1026_init_client(new_client); | 1555 | adm1026_init_client(new_client); |
1598 | 1556 | ||
1599 | /* Register sysfs hooks */ | 1557 | /* Register sysfs hooks */ |
1600 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 1558 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); |
1601 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 1559 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); |
1602 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 1560 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); |
1603 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 1561 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); |
1604 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 1562 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); |
1605 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 1563 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); |
1606 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 1564 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); |
1607 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 1565 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); |
1608 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 1566 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); |
1609 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 1567 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); |
1610 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 1568 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); |
1611 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 1569 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); |
1612 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 1570 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); |
1613 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 1571 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); |
1614 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 1572 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); |
1615 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 1573 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); |
1616 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 1574 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); |
1617 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 1575 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); |
1618 | device_create_file(&new_client->dev, &dev_attr_in6_input); | 1576 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); |
1619 | device_create_file(&new_client->dev, &dev_attr_in6_max); | 1577 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); |
1620 | device_create_file(&new_client->dev, &dev_attr_in6_min); | 1578 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); |
1621 | device_create_file(&new_client->dev, &dev_attr_in7_input); | 1579 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); |
1622 | device_create_file(&new_client->dev, &dev_attr_in7_max); | 1580 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); |
1623 | device_create_file(&new_client->dev, &dev_attr_in7_min); | 1581 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); |
1624 | device_create_file(&new_client->dev, &dev_attr_in8_input); | 1582 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); |
1625 | device_create_file(&new_client->dev, &dev_attr_in8_max); | 1583 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr); |
1626 | device_create_file(&new_client->dev, &dev_attr_in8_min); | 1584 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr); |
1627 | device_create_file(&new_client->dev, &dev_attr_in9_input); | 1585 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr); |
1628 | device_create_file(&new_client->dev, &dev_attr_in9_max); | 1586 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr); |
1629 | device_create_file(&new_client->dev, &dev_attr_in9_min); | 1587 | device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr); |
1630 | device_create_file(&new_client->dev, &dev_attr_in10_input); | 1588 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr); |
1631 | device_create_file(&new_client->dev, &dev_attr_in10_max); | 1589 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr); |
1632 | device_create_file(&new_client->dev, &dev_attr_in10_min); | 1590 | device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr); |
1633 | device_create_file(&new_client->dev, &dev_attr_in11_input); | 1591 | device_create_file(&new_client->dev, &sensor_dev_attr_in11_input.dev_attr); |
1634 | device_create_file(&new_client->dev, &dev_attr_in11_max); | 1592 | device_create_file(&new_client->dev, &sensor_dev_attr_in11_max.dev_attr); |
1635 | device_create_file(&new_client->dev, &dev_attr_in11_min); | 1593 | device_create_file(&new_client->dev, &sensor_dev_attr_in11_min.dev_attr); |
1636 | device_create_file(&new_client->dev, &dev_attr_in12_input); | 1594 | device_create_file(&new_client->dev, &sensor_dev_attr_in12_input.dev_attr); |
1637 | device_create_file(&new_client->dev, &dev_attr_in12_max); | 1595 | device_create_file(&new_client->dev, &sensor_dev_attr_in12_max.dev_attr); |
1638 | device_create_file(&new_client->dev, &dev_attr_in12_min); | 1596 | device_create_file(&new_client->dev, &sensor_dev_attr_in12_min.dev_attr); |
1639 | device_create_file(&new_client->dev, &dev_attr_in13_input); | 1597 | device_create_file(&new_client->dev, &sensor_dev_attr_in13_input.dev_attr); |
1640 | device_create_file(&new_client->dev, &dev_attr_in13_max); | 1598 | device_create_file(&new_client->dev, &sensor_dev_attr_in13_max.dev_attr); |
1641 | device_create_file(&new_client->dev, &dev_attr_in13_min); | 1599 | device_create_file(&new_client->dev, &sensor_dev_attr_in13_min.dev_attr); |
1642 | device_create_file(&new_client->dev, &dev_attr_in14_input); | 1600 | device_create_file(&new_client->dev, &sensor_dev_attr_in14_input.dev_attr); |
1643 | device_create_file(&new_client->dev, &dev_attr_in14_max); | 1601 | device_create_file(&new_client->dev, &sensor_dev_attr_in14_max.dev_attr); |
1644 | device_create_file(&new_client->dev, &dev_attr_in14_min); | 1602 | device_create_file(&new_client->dev, &sensor_dev_attr_in14_min.dev_attr); |
1645 | device_create_file(&new_client->dev, &dev_attr_in15_input); | 1603 | device_create_file(&new_client->dev, &sensor_dev_attr_in15_input.dev_attr); |
1646 | device_create_file(&new_client->dev, &dev_attr_in15_max); | 1604 | device_create_file(&new_client->dev, &sensor_dev_attr_in15_max.dev_attr); |
1647 | device_create_file(&new_client->dev, &dev_attr_in15_min); | 1605 | device_create_file(&new_client->dev, &sensor_dev_attr_in15_min.dev_attr); |
1648 | device_create_file(&new_client->dev, &dev_attr_in16_input); | 1606 | device_create_file(&new_client->dev, &sensor_dev_attr_in16_input.dev_attr); |
1649 | device_create_file(&new_client->dev, &dev_attr_in16_max); | 1607 | device_create_file(&new_client->dev, &sensor_dev_attr_in16_max.dev_attr); |
1650 | device_create_file(&new_client->dev, &dev_attr_in16_min); | 1608 | device_create_file(&new_client->dev, &sensor_dev_attr_in16_min.dev_attr); |
1651 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 1609 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); |
1652 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 1610 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr); |
1653 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 1611 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr); |
1654 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 1612 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr); |
1655 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 1613 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr); |
1656 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 1614 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr); |
1657 | device_create_file(&new_client->dev, &dev_attr_fan3_input); | 1615 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr); |
1658 | device_create_file(&new_client->dev, &dev_attr_fan3_div); | 1616 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr); |
1659 | device_create_file(&new_client->dev, &dev_attr_fan3_min); | 1617 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr); |
1660 | device_create_file(&new_client->dev, &dev_attr_fan4_input); | 1618 | device_create_file(&new_client->dev, &sensor_dev_attr_fan4_input.dev_attr); |
1661 | device_create_file(&new_client->dev, &dev_attr_fan4_div); | 1619 | device_create_file(&new_client->dev, &sensor_dev_attr_fan4_div.dev_attr); |
1662 | device_create_file(&new_client->dev, &dev_attr_fan4_min); | 1620 | device_create_file(&new_client->dev, &sensor_dev_attr_fan4_min.dev_attr); |
1663 | device_create_file(&new_client->dev, &dev_attr_fan5_input); | 1621 | device_create_file(&new_client->dev, &sensor_dev_attr_fan5_input.dev_attr); |
1664 | device_create_file(&new_client->dev, &dev_attr_fan5_div); | 1622 | device_create_file(&new_client->dev, &sensor_dev_attr_fan5_div.dev_attr); |
1665 | device_create_file(&new_client->dev, &dev_attr_fan5_min); | 1623 | device_create_file(&new_client->dev, &sensor_dev_attr_fan5_min.dev_attr); |
1666 | device_create_file(&new_client->dev, &dev_attr_fan6_input); | 1624 | device_create_file(&new_client->dev, &sensor_dev_attr_fan6_input.dev_attr); |
1667 | device_create_file(&new_client->dev, &dev_attr_fan6_div); | 1625 | device_create_file(&new_client->dev, &sensor_dev_attr_fan6_div.dev_attr); |
1668 | device_create_file(&new_client->dev, &dev_attr_fan6_min); | 1626 | device_create_file(&new_client->dev, &sensor_dev_attr_fan6_min.dev_attr); |
1669 | device_create_file(&new_client->dev, &dev_attr_fan7_input); | 1627 | device_create_file(&new_client->dev, &sensor_dev_attr_fan7_input.dev_attr); |
1670 | device_create_file(&new_client->dev, &dev_attr_fan7_div); | 1628 | device_create_file(&new_client->dev, &sensor_dev_attr_fan7_div.dev_attr); |
1671 | device_create_file(&new_client->dev, &dev_attr_fan7_min); | 1629 | device_create_file(&new_client->dev, &sensor_dev_attr_fan7_min.dev_attr); |
1672 | device_create_file(&new_client->dev, &dev_attr_fan8_input); | 1630 | device_create_file(&new_client->dev, &sensor_dev_attr_fan8_input.dev_attr); |
1673 | device_create_file(&new_client->dev, &dev_attr_fan8_div); | 1631 | device_create_file(&new_client->dev, &sensor_dev_attr_fan8_div.dev_attr); |
1674 | device_create_file(&new_client->dev, &dev_attr_fan8_min); | 1632 | device_create_file(&new_client->dev, &sensor_dev_attr_fan8_min.dev_attr); |
1675 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 1633 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); |
1676 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 1634 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); |
1677 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 1635 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); |
1678 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 1636 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); |
1679 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 1637 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); |
1680 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 1638 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); |
1681 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 1639 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); |
1682 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 1640 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); |
1683 | device_create_file(&new_client->dev, &dev_attr_temp3_min); | 1641 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); |
1684 | device_create_file(&new_client->dev, &dev_attr_temp1_offset); | 1642 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_offset.dev_attr); |
1685 | device_create_file(&new_client->dev, &dev_attr_temp2_offset); | 1643 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_offset.dev_attr); |
1686 | device_create_file(&new_client->dev, &dev_attr_temp3_offset); | 1644 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_offset.dev_attr); |
1687 | device_create_file(&new_client->dev, | 1645 | device_create_file(&new_client->dev, |
1688 | &dev_attr_temp1_auto_point1_temp); | 1646 | &sensor_dev_attr_temp1_auto_point1_temp.dev_attr); |
1689 | device_create_file(&new_client->dev, | 1647 | device_create_file(&new_client->dev, |
1690 | &dev_attr_temp2_auto_point1_temp); | 1648 | &sensor_dev_attr_temp2_auto_point1_temp.dev_attr); |
1691 | device_create_file(&new_client->dev, | 1649 | device_create_file(&new_client->dev, |
1692 | &dev_attr_temp3_auto_point1_temp); | 1650 | &sensor_dev_attr_temp3_auto_point1_temp.dev_attr); |
1693 | device_create_file(&new_client->dev, | 1651 | device_create_file(&new_client->dev, |
1694 | &dev_attr_temp1_auto_point1_temp_hyst); | 1652 | &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr); |
1695 | device_create_file(&new_client->dev, | 1653 | device_create_file(&new_client->dev, |
1696 | &dev_attr_temp2_auto_point1_temp_hyst); | 1654 | &sensor_dev_attr_temp2_auto_point1_temp_hyst.dev_attr); |
1697 | device_create_file(&new_client->dev, | 1655 | device_create_file(&new_client->dev, |
1698 | &dev_attr_temp3_auto_point1_temp_hyst); | 1656 | &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr); |
1699 | device_create_file(&new_client->dev, | 1657 | device_create_file(&new_client->dev, |
1700 | &dev_attr_temp1_auto_point2_temp); | 1658 | &sensor_dev_attr_temp1_auto_point2_temp.dev_attr); |
1701 | device_create_file(&new_client->dev, | 1659 | device_create_file(&new_client->dev, |
1702 | &dev_attr_temp2_auto_point2_temp); | 1660 | &sensor_dev_attr_temp2_auto_point2_temp.dev_attr); |
1703 | device_create_file(&new_client->dev, | 1661 | device_create_file(&new_client->dev, |
1704 | &dev_attr_temp3_auto_point2_temp); | 1662 | &sensor_dev_attr_temp3_auto_point2_temp.dev_attr); |
1705 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 1663 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr); |
1706 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 1664 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr); |
1707 | device_create_file(&new_client->dev, &dev_attr_temp3_crit); | 1665 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr); |
1708 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); | 1666 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); |
1709 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); | 1667 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); |
1710 | device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); | 1668 | device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); |
1669 | /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | ||
1711 | device_create_file(&new_client->dev, &dev_attr_vid); | 1670 | device_create_file(&new_client->dev, &dev_attr_vid); |
1671 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
1712 | device_create_file(&new_client->dev, &dev_attr_vrm); | 1672 | device_create_file(&new_client->dev, &dev_attr_vrm); |
1713 | device_create_file(&new_client->dev, &dev_attr_alarms); | 1673 | device_create_file(&new_client->dev, &dev_attr_alarms); |
1714 | device_create_file(&new_client->dev, &dev_attr_alarm_mask); | 1674 | device_create_file(&new_client->dev, &dev_attr_alarm_mask); |
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/i2c/chips/adm1031.c index d4385a23f79a..9168e983ca1d 100644 --- a/drivers/i2c/chips/adm1031.c +++ b/drivers/i2c/chips/adm1031.c | |||
@@ -292,11 +292,11 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) | |||
292 | } | 292 | } |
293 | 293 | ||
294 | #define fan_auto_channel_offset(offset) \ | 294 | #define fan_auto_channel_offset(offset) \ |
295 | static ssize_t show_fan_auto_channel_##offset (struct device *dev, char *buf) \ | 295 | static ssize_t show_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
296 | { \ | 296 | { \ |
297 | return show_fan_auto_channel(dev, buf, offset - 1); \ | 297 | return show_fan_auto_channel(dev, buf, offset - 1); \ |
298 | } \ | 298 | } \ |
299 | static ssize_t set_fan_auto_channel_##offset (struct device *dev, \ | 299 | static ssize_t set_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, \ |
300 | const char *buf, size_t count) \ | 300 | const char *buf, size_t count) \ |
301 | { \ | 301 | { \ |
302 | return set_fan_auto_channel(dev, buf, count, offset - 1); \ | 302 | return set_fan_auto_channel(dev, buf, count, offset - 1); \ |
@@ -357,24 +357,24 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr) | |||
357 | } | 357 | } |
358 | 358 | ||
359 | #define auto_temp_reg(offset) \ | 359 | #define auto_temp_reg(offset) \ |
360 | static ssize_t show_auto_temp_##offset##_off (struct device *dev, char *buf) \ | 360 | static ssize_t show_auto_temp_##offset##_off (struct device *dev, struct device_attribute *attr, char *buf) \ |
361 | { \ | 361 | { \ |
362 | return show_auto_temp_off(dev, buf, offset - 1); \ | 362 | return show_auto_temp_off(dev, buf, offset - 1); \ |
363 | } \ | 363 | } \ |
364 | static ssize_t show_auto_temp_##offset##_min (struct device *dev, char *buf) \ | 364 | static ssize_t show_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
365 | { \ | 365 | { \ |
366 | return show_auto_temp_min(dev, buf, offset - 1); \ | 366 | return show_auto_temp_min(dev, buf, offset - 1); \ |
367 | } \ | 367 | } \ |
368 | static ssize_t show_auto_temp_##offset##_max (struct device *dev, char *buf) \ | 368 | static ssize_t show_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
369 | { \ | 369 | { \ |
370 | return show_auto_temp_max(dev, buf, offset - 1); \ | 370 | return show_auto_temp_max(dev, buf, offset - 1); \ |
371 | } \ | 371 | } \ |
372 | static ssize_t set_auto_temp_##offset##_min (struct device *dev, \ | 372 | static ssize_t set_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
373 | const char *buf, size_t count) \ | 373 | const char *buf, size_t count) \ |
374 | { \ | 374 | { \ |
375 | return set_auto_temp_min(dev, buf, count, offset - 1); \ | 375 | return set_auto_temp_min(dev, buf, count, offset - 1); \ |
376 | } \ | 376 | } \ |
377 | static ssize_t set_auto_temp_##offset##_max (struct device *dev, \ | 377 | static ssize_t set_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \ |
378 | const char *buf, size_t count) \ | 378 | const char *buf, size_t count) \ |
379 | { \ | 379 | { \ |
380 | return set_auto_temp_max(dev, buf, count, offset - 1); \ | 380 | return set_auto_temp_max(dev, buf, count, offset - 1); \ |
@@ -421,11 +421,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr) | |||
421 | } | 421 | } |
422 | 422 | ||
423 | #define pwm_reg(offset) \ | 423 | #define pwm_reg(offset) \ |
424 | static ssize_t show_pwm_##offset (struct device *dev, char *buf) \ | 424 | static ssize_t show_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
425 | { \ | 425 | { \ |
426 | return show_pwm(dev, buf, offset - 1); \ | 426 | return show_pwm(dev, buf, offset - 1); \ |
427 | } \ | 427 | } \ |
428 | static ssize_t set_pwm_##offset (struct device *dev, \ | 428 | static ssize_t set_pwm_##offset (struct device *dev, struct device_attribute *attr, \ |
429 | const char *buf, size_t count) \ | 429 | const char *buf, size_t count) \ |
430 | { \ | 430 | { \ |
431 | return set_pwm(dev, buf, count, offset - 1); \ | 431 | return set_pwm(dev, buf, count, offset - 1); \ |
@@ -440,7 +440,7 @@ pwm_reg(2); | |||
440 | 440 | ||
441 | /* | 441 | /* |
442 | * That function checks the cases where the fan reading is not | 442 | * That function checks the cases where the fan reading is not |
443 | * relevent. It is used to provide 0 as fan reading when the fan is | 443 | * relevant. It is used to provide 0 as fan reading when the fan is |
444 | * not supposed to run | 444 | * not supposed to run |
445 | */ | 445 | */ |
446 | static int trust_fan_readings(struct adm1031_data *data, int chan) | 446 | static int trust_fan_readings(struct adm1031_data *data, int chan) |
@@ -557,24 +557,24 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr) | |||
557 | } | 557 | } |
558 | 558 | ||
559 | #define fan_offset(offset) \ | 559 | #define fan_offset(offset) \ |
560 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 560 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
561 | { \ | 561 | { \ |
562 | return show_fan(dev, buf, offset - 1); \ | 562 | return show_fan(dev, buf, offset - 1); \ |
563 | } \ | 563 | } \ |
564 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 564 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
565 | { \ | 565 | { \ |
566 | return show_fan_min(dev, buf, offset - 1); \ | 566 | return show_fan_min(dev, buf, offset - 1); \ |
567 | } \ | 567 | } \ |
568 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | 568 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
569 | { \ | 569 | { \ |
570 | return show_fan_div(dev, buf, offset - 1); \ | 570 | return show_fan_div(dev, buf, offset - 1); \ |
571 | } \ | 571 | } \ |
572 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | 572 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
573 | const char *buf, size_t count) \ | 573 | const char *buf, size_t count) \ |
574 | { \ | 574 | { \ |
575 | return set_fan_min(dev, buf, count, offset - 1); \ | 575 | return set_fan_min(dev, buf, count, offset - 1); \ |
576 | } \ | 576 | } \ |
577 | static ssize_t set_fan_##offset##_div (struct device *dev, \ | 577 | static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \ |
578 | const char *buf, size_t count) \ | 578 | const char *buf, size_t count) \ |
579 | { \ | 579 | { \ |
580 | return set_fan_div(dev, buf, count, offset - 1); \ | 580 | return set_fan_div(dev, buf, count, offset - 1); \ |
@@ -667,33 +667,33 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr) | |||
667 | } | 667 | } |
668 | 668 | ||
669 | #define temp_reg(offset) \ | 669 | #define temp_reg(offset) \ |
670 | static ssize_t show_temp_##offset (struct device *dev, char *buf) \ | 670 | static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
671 | { \ | 671 | { \ |
672 | return show_temp(dev, buf, offset - 1); \ | 672 | return show_temp(dev, buf, offset - 1); \ |
673 | } \ | 673 | } \ |
674 | static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \ | 674 | static ssize_t show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
675 | { \ | 675 | { \ |
676 | return show_temp_min(dev, buf, offset - 1); \ | 676 | return show_temp_min(dev, buf, offset - 1); \ |
677 | } \ | 677 | } \ |
678 | static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \ | 678 | static ssize_t show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
679 | { \ | 679 | { \ |
680 | return show_temp_max(dev, buf, offset - 1); \ | 680 | return show_temp_max(dev, buf, offset - 1); \ |
681 | } \ | 681 | } \ |
682 | static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf) \ | 682 | static ssize_t show_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, char *buf) \ |
683 | { \ | 683 | { \ |
684 | return show_temp_crit(dev, buf, offset - 1); \ | 684 | return show_temp_crit(dev, buf, offset - 1); \ |
685 | } \ | 685 | } \ |
686 | static ssize_t set_temp_##offset##_min (struct device *dev, \ | 686 | static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
687 | const char *buf, size_t count) \ | 687 | const char *buf, size_t count) \ |
688 | { \ | 688 | { \ |
689 | return set_temp_min(dev, buf, count, offset - 1); \ | 689 | return set_temp_min(dev, buf, count, offset - 1); \ |
690 | } \ | 690 | } \ |
691 | static ssize_t set_temp_##offset##_max (struct device *dev, \ | 691 | static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \ |
692 | const char *buf, size_t count) \ | 692 | const char *buf, size_t count) \ |
693 | { \ | 693 | { \ |
694 | return set_temp_max(dev, buf, count, offset - 1); \ | 694 | return set_temp_max(dev, buf, count, offset - 1); \ |
695 | } \ | 695 | } \ |
696 | static ssize_t set_temp_##offset##_crit (struct device *dev, \ | 696 | static ssize_t set_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, \ |
697 | const char *buf, size_t count) \ | 697 | const char *buf, size_t count) \ |
698 | { \ | 698 | { \ |
699 | return set_temp_crit(dev, buf, count, offset - 1); \ | 699 | return set_temp_crit(dev, buf, count, offset - 1); \ |
@@ -712,7 +712,7 @@ temp_reg(2); | |||
712 | temp_reg(3); | 712 | temp_reg(3); |
713 | 713 | ||
714 | /* Alarms */ | 714 | /* Alarms */ |
715 | static ssize_t show_alarms(struct device *dev, char *buf) | 715 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
716 | { | 716 | { |
717 | struct adm1031_data *data = adm1031_update_device(dev); | 717 | struct adm1031_data *data = adm1031_update_device(dev); |
718 | return sprintf(buf, "%d\n", data->alarm); | 718 | return sprintf(buf, "%d\n", data->alarm); |
diff --git a/drivers/i2c/chips/adm9240.c b/drivers/i2c/chips/adm9240.c new file mode 100644 index 000000000000..5c68e9c311aa --- /dev/null +++ b/drivers/i2c/chips/adm9240.c | |||
@@ -0,0 +1,791 @@ | |||
1 | /* | ||
2 | * adm9240.c Part of lm_sensors, Linux kernel modules for hardware | ||
3 | * monitoring | ||
4 | * | ||
5 | * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> | ||
6 | * Philip Edelbrock <phil@netroedge.com> | ||
7 | * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> | ||
8 | * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable | ||
9 | * guidance from Jean Delvare | ||
10 | * | ||
11 | * Driver supports Analog Devices ADM9240 | ||
12 | * Dallas Semiconductor DS1780 | ||
13 | * National Semiconductor LM81 | ||
14 | * | ||
15 | * ADM9240 is the reference, DS1780 and LM81 are register compatibles | ||
16 | * | ||
17 | * Voltage Six inputs are scaled by chip, VID also reported | ||
18 | * Temperature Chip temperature to 0.5'C, maximum and max_hysteris | ||
19 | * Fans 2 fans, low speed alarm, automatic fan clock divider | ||
20 | * Alarms 16-bit map of active alarms | ||
21 | * Analog Out 0..1250 mV output | ||
22 | * | ||
23 | * Chassis Intrusion: clear CI latch with 'echo 1 > chassis_clear' | ||
24 | * | ||
25 | * Test hardware: Intel SE440BX-2 desktop motherboard --Grant | ||
26 | * | ||
27 | * LM81 extended temp reading not implemented | ||
28 | * | ||
29 | * This program is free software; you can redistribute it and/or modify | ||
30 | * it under the terms of the GNU General Public License as published by | ||
31 | * the Free Software Foundation; either version 2 of the License, or | ||
32 | * (at your option) any later version. | ||
33 | * | ||
34 | * This program is distributed in the hope that it will be useful, | ||
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
37 | * GNU General Public License for more details. | ||
38 | * | ||
39 | * You should have received a copy of the GNU General Public License | ||
40 | * along with this program; if not, write to the Free Software | ||
41 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
42 | */ | ||
43 | |||
44 | #include <linux/init.h> | ||
45 | #include <linux/module.h> | ||
46 | #include <linux/slab.h> | ||
47 | #include <linux/i2c.h> | ||
48 | #include <linux/i2c-sensor.h> | ||
49 | #include <linux/i2c-vid.h> | ||
50 | |||
51 | /* Addresses to scan */ | ||
52 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | ||
53 | I2C_CLIENT_END }; | ||
54 | |||
55 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
56 | |||
57 | /* Insmod parameters */ | ||
58 | SENSORS_INSMOD_3(adm9240, ds1780, lm81); | ||
59 | |||
60 | /* ADM9240 registers */ | ||
61 | #define ADM9240_REG_MAN_ID 0x3e | ||
62 | #define ADM9240_REG_DIE_REV 0x3f | ||
63 | #define ADM9240_REG_CONFIG 0x40 | ||
64 | |||
65 | #define ADM9240_REG_IN(nr) (0x20 + (nr)) /* 0..5 */ | ||
66 | #define ADM9240_REG_IN_MAX(nr) (0x2b + (nr) * 2) | ||
67 | #define ADM9240_REG_IN_MIN(nr) (0x2c + (nr) * 2) | ||
68 | #define ADM9240_REG_FAN(nr) (0x28 + (nr)) /* 0..1 */ | ||
69 | #define ADM9240_REG_FAN_MIN(nr) (0x3b + (nr)) | ||
70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | ||
71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | ||
72 | #define ADM9240_REG_TEMP 0x27 | ||
73 | #define ADM9240_REG_TEMP_HIGH 0x39 | ||
74 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
75 | #define ADM9240_REG_ANALOG_OUT 0x19 | ||
76 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | ||
77 | #define ADM9240_REG_VID_FAN_DIV 0x47 | ||
78 | #define ADM9240_REG_I2C_ADDR 0x48 | ||
79 | #define ADM9240_REG_VID4 0x49 | ||
80 | #define ADM9240_REG_TEMP_CONF 0x4b | ||
81 | |||
82 | /* generalised scaling with integer rounding */ | ||
83 | static inline int SCALE(long val, int mul, int div) | ||
84 | { | ||
85 | if (val < 0) | ||
86 | return (val * mul - div / 2) / div; | ||
87 | else | ||
88 | return (val * mul + div / 2) / div; | ||
89 | } | ||
90 | |||
91 | /* adm9240 internally scales voltage measurements */ | ||
92 | static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 }; | ||
93 | |||
94 | static inline unsigned int IN_FROM_REG(u8 reg, int n) | ||
95 | { | ||
96 | return SCALE(reg, nom_mv[n], 192); | ||
97 | } | ||
98 | |||
99 | static inline u8 IN_TO_REG(unsigned long val, int n) | ||
100 | { | ||
101 | return SENSORS_LIMIT(SCALE(val, 192, nom_mv[n]), 0, 255); | ||
102 | } | ||
103 | |||
104 | /* temperature range: -40..125, 127 disables temperature alarm */ | ||
105 | static inline s8 TEMP_TO_REG(long val) | ||
106 | { | ||
107 | return SENSORS_LIMIT(SCALE(val, 1, 1000), -40, 127); | ||
108 | } | ||
109 | |||
110 | /* two fans, each with low fan speed limit */ | ||
111 | static inline unsigned int FAN_FROM_REG(u8 reg, u8 div) | ||
112 | { | ||
113 | if (!reg) /* error */ | ||
114 | return -1; | ||
115 | |||
116 | if (reg == 255) | ||
117 | return 0; | ||
118 | |||
119 | return SCALE(1350000, 1, reg * div); | ||
120 | } | ||
121 | |||
122 | /* analog out 0..1250mV */ | ||
123 | static inline u8 AOUT_TO_REG(unsigned long val) | ||
124 | { | ||
125 | return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255); | ||
126 | } | ||
127 | |||
128 | static inline unsigned int AOUT_FROM_REG(u8 reg) | ||
129 | { | ||
130 | return SCALE(reg, 1250, 255); | ||
131 | } | ||
132 | |||
133 | static int adm9240_attach_adapter(struct i2c_adapter *adapter); | ||
134 | static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind); | ||
135 | static void adm9240_init_client(struct i2c_client *client); | ||
136 | static int adm9240_detach_client(struct i2c_client *client); | ||
137 | static struct adm9240_data *adm9240_update_device(struct device *dev); | ||
138 | |||
139 | /* driver data */ | ||
140 | static struct i2c_driver adm9240_driver = { | ||
141 | .owner = THIS_MODULE, | ||
142 | .name = "adm9240", | ||
143 | .id = I2C_DRIVERID_ADM9240, | ||
144 | .flags = I2C_DF_NOTIFY, | ||
145 | .attach_adapter = adm9240_attach_adapter, | ||
146 | .detach_client = adm9240_detach_client, | ||
147 | }; | ||
148 | |||
149 | /* per client data */ | ||
150 | struct adm9240_data { | ||
151 | enum chips type; | ||
152 | struct i2c_client client; | ||
153 | struct semaphore update_lock; | ||
154 | char valid; | ||
155 | unsigned long last_updated_measure; | ||
156 | unsigned long last_updated_config; | ||
157 | |||
158 | u8 in[6]; /* ro in0_input */ | ||
159 | u8 in_max[6]; /* rw in0_max */ | ||
160 | u8 in_min[6]; /* rw in0_min */ | ||
161 | u8 fan[2]; /* ro fan1_input */ | ||
162 | u8 fan_min[2]; /* rw fan1_min */ | ||
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | ||
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | ||
165 | s8 temp_high; /* rw temp1_max */ | ||
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | ||
168 | u8 aout; /* rw aout_output */ | ||
169 | u8 vid; /* ro vid */ | ||
170 | u8 vrm; /* -- vrm set on startup, no accessor */ | ||
171 | }; | ||
172 | |||
173 | /* i2c byte read/write interface */ | ||
174 | static int adm9240_read_value(struct i2c_client *client, u8 reg) | ||
175 | { | ||
176 | return i2c_smbus_read_byte_data(client, reg); | ||
177 | } | ||
178 | |||
179 | static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) | ||
180 | { | ||
181 | return i2c_smbus_write_byte_data(client, reg, value); | ||
182 | } | ||
183 | |||
184 | /*** sysfs accessors ***/ | ||
185 | |||
186 | /* temperature */ | ||
187 | #define show_temp(value, scale) \ | ||
188 | static ssize_t show_##value(struct device *dev, \ | ||
189 | struct device_attribute *attr, \ | ||
190 | char *buf) \ | ||
191 | { \ | ||
192 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
193 | return sprintf(buf, "%d\n", data->value * scale); \ | ||
194 | } | ||
195 | show_temp(temp_high, 1000); | ||
196 | show_temp(temp_hyst, 1000); | ||
197 | show_temp(temp, 500); /* 0.5'C per bit */ | ||
198 | |||
199 | #define set_temp(value, reg) \ | ||
200 | static ssize_t set_##value(struct device *dev, \ | ||
201 | struct device_attribute *attr, \ | ||
202 | const char *buf, size_t count) \ | ||
203 | { \ | ||
204 | struct i2c_client *client = to_i2c_client(dev); \ | ||
205 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
206 | long temp = simple_strtoul(buf, NULL, 10); \ | ||
207 | \ | ||
208 | down(&data->update_lock); \ | ||
209 | data->value = TEMP_TO_REG(temp); \ | ||
210 | adm9240_write_value(client, reg, data->value); \ | ||
211 | up(&data->update_lock); \ | ||
212 | return count; \ | ||
213 | } | ||
214 | |||
215 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | ||
216 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | ||
217 | |||
218 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
219 | show_temp_high, set_temp_high); | ||
220 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
221 | show_temp_hyst, set_temp_hyst); | ||
222 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | ||
223 | |||
224 | /* voltage */ | ||
225 | static ssize_t show_in(struct device *dev, char *buf, int nr) | ||
226 | { | ||
227 | struct adm9240_data *data = adm9240_update_device(dev); | ||
228 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | ||
229 | } | ||
230 | |||
231 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | ||
232 | { | ||
233 | struct adm9240_data *data = adm9240_update_device(dev); | ||
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | ||
235 | } | ||
236 | |||
237 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | ||
238 | { | ||
239 | struct adm9240_data *data = adm9240_update_device(dev); | ||
240 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | ||
241 | } | ||
242 | |||
243 | static ssize_t set_in_min(struct device *dev, const char *buf, | ||
244 | size_t count, int nr) | ||
245 | { | ||
246 | struct i2c_client *client = to_i2c_client(dev); | ||
247 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
248 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
249 | |||
250 | down(&data->update_lock); | ||
251 | data->in_min[nr] = IN_TO_REG(val, nr); | ||
252 | adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); | ||
253 | up(&data->update_lock); | ||
254 | return count; | ||
255 | } | ||
256 | |||
257 | static ssize_t set_in_max(struct device *dev, const char *buf, | ||
258 | size_t count, int nr) | ||
259 | { | ||
260 | struct i2c_client *client = to_i2c_client(dev); | ||
261 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
262 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
263 | |||
264 | down(&data->update_lock); | ||
265 | data->in_max[nr] = IN_TO_REG(val, nr); | ||
266 | adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); | ||
267 | up(&data->update_lock); | ||
268 | return count; | ||
269 | } | ||
270 | |||
271 | #define show_in_offset(offset) \ | ||
272 | static ssize_t show_in##offset(struct device *dev, \ | ||
273 | struct device_attribute *attr, \ | ||
274 | char *buf) \ | ||
275 | { \ | ||
276 | return show_in(dev, buf, offset); \ | ||
277 | } \ | ||
278 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | ||
279 | static ssize_t show_in##offset##_min(struct device *dev, \ | ||
280 | struct device_attribute *attr, \ | ||
281 | char *buf) \ | ||
282 | { \ | ||
283 | return show_in_min(dev, buf, offset); \ | ||
284 | } \ | ||
285 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
286 | struct device_attribute *attr, \ | ||
287 | char *buf) \ | ||
288 | { \ | ||
289 | return show_in_max(dev, buf, offset); \ | ||
290 | } \ | ||
291 | static ssize_t \ | ||
292 | set_in##offset##_min(struct device *dev, \ | ||
293 | struct device_attribute *attr, const char *buf, \ | ||
294 | size_t count) \ | ||
295 | { \ | ||
296 | return set_in_min(dev, buf, count, offset); \ | ||
297 | } \ | ||
298 | static ssize_t \ | ||
299 | set_in##offset##_max(struct device *dev, \ | ||
300 | struct device_attribute *attr, const char *buf, \ | ||
301 | size_t count) \ | ||
302 | { \ | ||
303 | return set_in_max(dev, buf, count, offset); \ | ||
304 | } \ | ||
305 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
306 | show_in##offset##_min, set_in##offset##_min); \ | ||
307 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
308 | show_in##offset##_max, set_in##offset##_max); | ||
309 | |||
310 | show_in_offset(0); | ||
311 | show_in_offset(1); | ||
312 | show_in_offset(2); | ||
313 | show_in_offset(3); | ||
314 | show_in_offset(4); | ||
315 | show_in_offset(5); | ||
316 | |||
317 | /* fans */ | ||
318 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | ||
319 | { | ||
320 | struct adm9240_data *data = adm9240_update_device(dev); | ||
321 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | ||
322 | 1 << data->fan_div[nr])); | ||
323 | } | ||
324 | |||
325 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | ||
326 | { | ||
327 | struct adm9240_data *data = adm9240_update_device(dev); | ||
328 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | ||
329 | 1 << data->fan_div[nr])); | ||
330 | } | ||
331 | |||
332 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | ||
333 | { | ||
334 | struct adm9240_data *data = adm9240_update_device(dev); | ||
335 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | ||
336 | } | ||
337 | |||
338 | /* write new fan div, callers must hold data->update_lock */ | ||
339 | static void adm9240_write_fan_div(struct i2c_client *client, int nr, | ||
340 | u8 fan_div) | ||
341 | { | ||
342 | u8 reg, old, shift = (nr + 2) * 2; | ||
343 | |||
344 | reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | ||
345 | old = (reg >> shift) & 3; | ||
346 | reg &= ~(3 << shift); | ||
347 | reg |= (fan_div << shift); | ||
348 | adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); | ||
349 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " | ||
350 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * set fan speed low limit: | ||
355 | * | ||
356 | * - value is zero: disable fan speed low limit alarm | ||
357 | * | ||
358 | * - value is below fan speed measurement range: enable fan speed low | ||
359 | * limit alarm to be asserted while fan speed too slow to measure | ||
360 | * | ||
361 | * - otherwise: select fan clock divider to suit fan speed low limit, | ||
362 | * measurement code may adjust registers to ensure fan speed reading | ||
363 | */ | ||
364 | static ssize_t set_fan_min(struct device *dev, const char *buf, | ||
365 | size_t count, int nr) | ||
366 | { | ||
367 | struct i2c_client *client = to_i2c_client(dev); | ||
368 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
370 | u8 new_div; | ||
371 | |||
372 | down(&data->update_lock); | ||
373 | |||
374 | if (!val) { | ||
375 | data->fan_min[nr] = 255; | ||
376 | new_div = data->fan_div[nr]; | ||
377 | |||
378 | dev_dbg(&client->dev, "fan%u low limit set disabled\n", | ||
379 | nr + 1); | ||
380 | |||
381 | } else if (val < 1350000 / (8 * 254)) { | ||
382 | new_div = 3; | ||
383 | data->fan_min[nr] = 254; | ||
384 | |||
385 | dev_dbg(&client->dev, "fan%u low limit set minimum %u\n", | ||
386 | nr + 1, FAN_FROM_REG(254, 1 << new_div)); | ||
387 | |||
388 | } else { | ||
389 | unsigned int new_min = 1350000 / val; | ||
390 | |||
391 | new_div = 0; | ||
392 | while (new_min > 192 && new_div < 3) { | ||
393 | new_div++; | ||
394 | new_min /= 2; | ||
395 | } | ||
396 | if (!new_min) /* keep > 0 */ | ||
397 | new_min++; | ||
398 | |||
399 | data->fan_min[nr] = new_min; | ||
400 | |||
401 | dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n", | ||
402 | nr + 1, FAN_FROM_REG(new_min, 1 << new_div)); | ||
403 | } | ||
404 | |||
405 | if (new_div != data->fan_div[nr]) { | ||
406 | data->fan_div[nr] = new_div; | ||
407 | adm9240_write_fan_div(client, nr, new_div); | ||
408 | } | ||
409 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), | ||
410 | data->fan_min[nr]); | ||
411 | |||
412 | up(&data->update_lock); | ||
413 | return count; | ||
414 | } | ||
415 | |||
416 | #define show_fan_offset(offset) \ | ||
417 | static ssize_t show_fan_##offset (struct device *dev, \ | ||
418 | struct device_attribute *attr, \ | ||
419 | char *buf) \ | ||
420 | { \ | ||
421 | return show_fan(dev, buf, offset - 1); \ | ||
422 | } \ | ||
423 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | ||
424 | struct device_attribute *attr, \ | ||
425 | char *buf) \ | ||
426 | { \ | ||
427 | return show_fan_div(dev, buf, offset - 1); \ | ||
428 | } \ | ||
429 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
430 | struct device_attribute *attr, \ | ||
431 | char *buf) \ | ||
432 | { \ | ||
433 | return show_fan_min(dev, buf, offset - 1); \ | ||
434 | } \ | ||
435 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
436 | struct device_attribute *attr, \ | ||
437 | const char *buf, size_t count) \ | ||
438 | { \ | ||
439 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
440 | } \ | ||
441 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
442 | show_fan_##offset, NULL); \ | ||
443 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
444 | show_fan_##offset##_div, NULL); \ | ||
445 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
446 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
447 | |||
448 | show_fan_offset(1); | ||
449 | show_fan_offset(2); | ||
450 | |||
451 | /* alarms */ | ||
452 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | ||
453 | { | ||
454 | struct adm9240_data *data = adm9240_update_device(dev); | ||
455 | return sprintf(buf, "%u\n", data->alarms); | ||
456 | } | ||
457 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | ||
458 | |||
459 | /* vid */ | ||
460 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | ||
461 | { | ||
462 | struct adm9240_data *data = adm9240_update_device(dev); | ||
463 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | ||
464 | } | ||
465 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
466 | |||
467 | /* analog output */ | ||
468 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) | ||
469 | { | ||
470 | struct adm9240_data *data = adm9240_update_device(dev); | ||
471 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | ||
472 | } | ||
473 | |||
474 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
475 | { | ||
476 | struct i2c_client *client = to_i2c_client(dev); | ||
477 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
478 | unsigned long val = simple_strtol(buf, NULL, 10); | ||
479 | |||
480 | down(&data->update_lock); | ||
481 | data->aout = AOUT_TO_REG(val); | ||
482 | adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); | ||
483 | up(&data->update_lock); | ||
484 | return count; | ||
485 | } | ||
486 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | ||
487 | |||
488 | /* chassis_clear */ | ||
489 | static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
490 | { | ||
491 | struct i2c_client *client = to_i2c_client(dev); | ||
492 | unsigned long val = simple_strtol(buf, NULL, 10); | ||
493 | |||
494 | if (val == 1) { | ||
495 | adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); | ||
496 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); | ||
497 | } | ||
498 | return count; | ||
499 | } | ||
500 | static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear); | ||
501 | |||
502 | |||
503 | /*** sensor chip detect and driver install ***/ | ||
504 | |||
505 | static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | ||
506 | { | ||
507 | struct i2c_client *new_client; | ||
508 | struct adm9240_data *data; | ||
509 | int err = 0; | ||
510 | const char *name = ""; | ||
511 | u8 man_id, die_rev; | ||
512 | |||
513 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
514 | goto exit; | ||
515 | |||
516 | if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { | ||
517 | err = -ENOMEM; | ||
518 | goto exit; | ||
519 | } | ||
520 | memset(data, 0, sizeof(struct adm9240_data)); | ||
521 | |||
522 | new_client = &data->client; | ||
523 | i2c_set_clientdata(new_client, data); | ||
524 | new_client->addr = address; | ||
525 | new_client->adapter = adapter; | ||
526 | new_client->driver = &adm9240_driver; | ||
527 | new_client->flags = 0; | ||
528 | |||
529 | if (kind == 0) { | ||
530 | kind = adm9240; | ||
531 | } | ||
532 | |||
533 | if (kind < 0) { | ||
534 | |||
535 | /* verify chip: reg address should match i2c address */ | ||
536 | if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) | ||
537 | != address) { | ||
538 | dev_err(&adapter->dev, "detect fail: address match, " | ||
539 | "0x%02x\n", address); | ||
540 | goto exit_free; | ||
541 | } | ||
542 | |||
543 | /* check known chip manufacturer */ | ||
544 | man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); | ||
545 | |||
546 | if (man_id == 0x23) { | ||
547 | kind = adm9240; | ||
548 | } else if (man_id == 0xda) { | ||
549 | kind = ds1780; | ||
550 | } else if (man_id == 0x01) { | ||
551 | kind = lm81; | ||
552 | } else { | ||
553 | dev_err(&adapter->dev, "detect fail: unknown manuf, " | ||
554 | "0x%02x\n", man_id); | ||
555 | goto exit_free; | ||
556 | } | ||
557 | |||
558 | /* successful detect, print chip info */ | ||
559 | die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); | ||
560 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
561 | man_id == 0x23 ? "ADM9240" : | ||
562 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
563 | } | ||
564 | |||
565 | /* either forced or detected chip kind */ | ||
566 | if (kind == adm9240) { | ||
567 | name = "adm9240"; | ||
568 | } else if (kind == ds1780) { | ||
569 | name = "ds1780"; | ||
570 | } else if (kind == lm81) { | ||
571 | name = "lm81"; | ||
572 | } | ||
573 | |||
574 | /* fill in the remaining client fields and attach */ | ||
575 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | ||
576 | data->type = kind; | ||
577 | init_MUTEX(&data->update_lock); | ||
578 | |||
579 | if ((err = i2c_attach_client(new_client))) | ||
580 | goto exit_free; | ||
581 | |||
582 | adm9240_init_client(new_client); | ||
583 | |||
584 | /* populate sysfs filesystem */ | ||
585 | device_create_file(&new_client->dev, &dev_attr_in0_input); | ||
586 | device_create_file(&new_client->dev, &dev_attr_in0_min); | ||
587 | device_create_file(&new_client->dev, &dev_attr_in0_max); | ||
588 | device_create_file(&new_client->dev, &dev_attr_in1_input); | ||
589 | device_create_file(&new_client->dev, &dev_attr_in1_min); | ||
590 | device_create_file(&new_client->dev, &dev_attr_in1_max); | ||
591 | device_create_file(&new_client->dev, &dev_attr_in2_input); | ||
592 | device_create_file(&new_client->dev, &dev_attr_in2_min); | ||
593 | device_create_file(&new_client->dev, &dev_attr_in2_max); | ||
594 | device_create_file(&new_client->dev, &dev_attr_in3_input); | ||
595 | device_create_file(&new_client->dev, &dev_attr_in3_min); | ||
596 | device_create_file(&new_client->dev, &dev_attr_in3_max); | ||
597 | device_create_file(&new_client->dev, &dev_attr_in4_input); | ||
598 | device_create_file(&new_client->dev, &dev_attr_in4_min); | ||
599 | device_create_file(&new_client->dev, &dev_attr_in4_max); | ||
600 | device_create_file(&new_client->dev, &dev_attr_in5_input); | ||
601 | device_create_file(&new_client->dev, &dev_attr_in5_min); | ||
602 | device_create_file(&new_client->dev, &dev_attr_in5_max); | ||
603 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
604 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | ||
605 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
606 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | ||
607 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | ||
608 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | ||
609 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | ||
610 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | ||
611 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | ||
612 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
613 | device_create_file(&new_client->dev, &dev_attr_aout_output); | ||
614 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | ||
615 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
616 | |||
617 | return 0; | ||
618 | exit_free: | ||
619 | kfree(new_client); | ||
620 | exit: | ||
621 | return err; | ||
622 | } | ||
623 | |||
624 | static int adm9240_attach_adapter(struct i2c_adapter *adapter) | ||
625 | { | ||
626 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
627 | return 0; | ||
628 | return i2c_detect(adapter, &addr_data, adm9240_detect); | ||
629 | } | ||
630 | |||
631 | static int adm9240_detach_client(struct i2c_client *client) | ||
632 | { | ||
633 | int err; | ||
634 | |||
635 | if ((err = i2c_detach_client(client))) { | ||
636 | dev_err(&client->dev, "Client deregistration failed, " | ||
637 | "client not detached.\n"); | ||
638 | return err; | ||
639 | } | ||
640 | |||
641 | kfree(i2c_get_clientdata(client)); | ||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | static void adm9240_init_client(struct i2c_client *client) | ||
646 | { | ||
647 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
648 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | ||
649 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | ||
650 | |||
651 | data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ | ||
652 | |||
653 | dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, | ||
654 | data->vrm % 10); | ||
655 | |||
656 | if (conf & 1) { /* measurement cycle running: report state */ | ||
657 | |||
658 | dev_info(&client->dev, "status: config 0x%02x mode %u\n", | ||
659 | conf, mode); | ||
660 | |||
661 | } else { /* cold start: open limits before starting chip */ | ||
662 | int i; | ||
663 | |||
664 | for (i = 0; i < 6; i++) | ||
665 | { | ||
666 | adm9240_write_value(client, | ||
667 | ADM9240_REG_IN_MIN(i), 0); | ||
668 | adm9240_write_value(client, | ||
669 | ADM9240_REG_IN_MAX(i), 255); | ||
670 | } | ||
671 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); | ||
672 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); | ||
673 | adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); | ||
674 | adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); | ||
675 | |||
676 | /* start measurement cycle */ | ||
677 | adm9240_write_value(client, ADM9240_REG_CONFIG, 1); | ||
678 | |||
679 | dev_info(&client->dev, "cold start: config was 0x%02x " | ||
680 | "mode %u\n", conf, mode); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | static struct adm9240_data *adm9240_update_device(struct device *dev) | ||
685 | { | ||
686 | struct i2c_client *client = to_i2c_client(dev); | ||
687 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
688 | int i; | ||
689 | |||
690 | down(&data->update_lock); | ||
691 | |||
692 | /* minimum measurement cycle: 1.75 seconds */ | ||
693 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) | ||
694 | || !data->valid) { | ||
695 | |||
696 | for (i = 0; i < 6; i++) /* read voltages */ | ||
697 | { | ||
698 | data->in[i] = adm9240_read_value(client, | ||
699 | ADM9240_REG_IN(i)); | ||
700 | } | ||
701 | data->alarms = adm9240_read_value(client, | ||
702 | ADM9240_REG_INT(0)) | | ||
703 | adm9240_read_value(client, | ||
704 | ADM9240_REG_INT(1)) << 8; | ||
705 | |||
706 | /* read temperature: assume temperature changes less than | ||
707 | * 0.5'C per two measurement cycles thus ignore possible | ||
708 | * but unlikely aliasing error on lsb reading. --Grant */ | ||
709 | data->temp = ((adm9240_read_value(client, | ||
710 | ADM9240_REG_TEMP) << 8) | | ||
711 | adm9240_read_value(client, | ||
712 | ADM9240_REG_TEMP_CONF)) / 128; | ||
713 | |||
714 | for (i = 0; i < 2; i++) /* read fans */ | ||
715 | { | ||
716 | data->fan[i] = adm9240_read_value(client, | ||
717 | ADM9240_REG_FAN(i)); | ||
718 | |||
719 | /* adjust fan clock divider on overflow */ | ||
720 | if (data->valid && data->fan[i] == 255 && | ||
721 | data->fan_div[i] < 3) { | ||
722 | |||
723 | adm9240_write_fan_div(client, i, | ||
724 | ++data->fan_div[i]); | ||
725 | |||
726 | /* adjust fan_min if active, but not to 0 */ | ||
727 | if (data->fan_min[i] < 255 && | ||
728 | data->fan_min[i] >= 2) | ||
729 | data->fan_min[i] /= 2; | ||
730 | } | ||
731 | } | ||
732 | data->last_updated_measure = jiffies; | ||
733 | } | ||
734 | |||
735 | /* minimum config reading cycle: 300 seconds */ | ||
736 | if (time_after(jiffies, data->last_updated_config + (HZ * 300)) | ||
737 | || !data->valid) { | ||
738 | |||
739 | for (i = 0; i < 6; i++) | ||
740 | { | ||
741 | data->in_min[i] = adm9240_read_value(client, | ||
742 | ADM9240_REG_IN_MIN(i)); | ||
743 | data->in_max[i] = adm9240_read_value(client, | ||
744 | ADM9240_REG_IN_MAX(i)); | ||
745 | } | ||
746 | for (i = 0; i < 2; i++) | ||
747 | { | ||
748 | data->fan_min[i] = adm9240_read_value(client, | ||
749 | ADM9240_REG_FAN_MIN(i)); | ||
750 | } | ||
751 | data->temp_high = adm9240_read_value(client, | ||
752 | ADM9240_REG_TEMP_HIGH); | ||
753 | data->temp_hyst = adm9240_read_value(client, | ||
754 | ADM9240_REG_TEMP_HYST); | ||
755 | |||
756 | /* read fan divs and 5-bit VID */ | ||
757 | i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | ||
758 | data->fan_div[0] = (i >> 4) & 3; | ||
759 | data->fan_div[1] = (i >> 6) & 3; | ||
760 | data->vid = i & 0x0f; | ||
761 | data->vid |= (adm9240_read_value(client, | ||
762 | ADM9240_REG_VID4) & 1) << 4; | ||
763 | /* read analog out */ | ||
764 | data->aout = adm9240_read_value(client, | ||
765 | ADM9240_REG_ANALOG_OUT); | ||
766 | |||
767 | data->last_updated_config = jiffies; | ||
768 | data->valid = 1; | ||
769 | } | ||
770 | up(&data->update_lock); | ||
771 | return data; | ||
772 | } | ||
773 | |||
774 | static int __init sensors_adm9240_init(void) | ||
775 | { | ||
776 | return i2c_add_driver(&adm9240_driver); | ||
777 | } | ||
778 | |||
779 | static void __exit sensors_adm9240_exit(void) | ||
780 | { | ||
781 | i2c_del_driver(&adm9240_driver); | ||
782 | } | ||
783 | |||
784 | MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, " | ||
785 | "Grant Coady <gcoady@gmail.com> and others"); | ||
786 | MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver"); | ||
787 | MODULE_LICENSE("GPL"); | ||
788 | |||
789 | module_init(sensors_adm9240_init); | ||
790 | module_exit(sensors_adm9240_exit); | ||
791 | |||
diff --git a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c index 7f899002bc54..70d996d6fe0a 100644 --- a/drivers/i2c/chips/asb100.c +++ b/drivers/i2c/chips/asb100.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/i2c-sensor.h> | 42 | #include <linux/i2c-sensor.h> |
43 | #include <linux/i2c-vid.h> | 43 | #include <linux/i2c-vid.h> |
44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
45 | #include <linux/jiffies.h> | ||
45 | #include "lm75.h" | 46 | #include "lm75.h" |
46 | 47 | ||
47 | /* | 48 | /* |
@@ -168,8 +169,6 @@ static int ASB100_PWM_FROM_REG(u8 reg) | |||
168 | return reg * 16; | 169 | return reg * 16; |
169 | } | 170 | } |
170 | 171 | ||
171 | #define ALARMS_FROM_REG(val) (val) | ||
172 | |||
173 | #define DIV_FROM_REG(val) (1 << (val)) | 172 | #define DIV_FROM_REG(val) (1 << (val)) |
174 | 173 | ||
175 | /* FAN DIV: 1, 2, 4, or 8 (defaults to 2) | 174 | /* FAN DIV: 1, 2, 4, or 8 (defaults to 2) |
@@ -260,28 +259,28 @@ set_in_reg(MAX, max) | |||
260 | 259 | ||
261 | #define sysfs_in(offset) \ | 260 | #define sysfs_in(offset) \ |
262 | static ssize_t \ | 261 | static ssize_t \ |
263 | show_in##offset (struct device *dev, char *buf) \ | 262 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
264 | { \ | 263 | { \ |
265 | return show_in(dev, buf, offset); \ | 264 | return show_in(dev, buf, offset); \ |
266 | } \ | 265 | } \ |
267 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 266 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
268 | show_in##offset, NULL); \ | 267 | show_in##offset, NULL); \ |
269 | static ssize_t \ | 268 | static ssize_t \ |
270 | show_in##offset##_min (struct device *dev, char *buf) \ | 269 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
271 | { \ | 270 | { \ |
272 | return show_in_min(dev, buf, offset); \ | 271 | return show_in_min(dev, buf, offset); \ |
273 | } \ | 272 | } \ |
274 | static ssize_t \ | 273 | static ssize_t \ |
275 | show_in##offset##_max (struct device *dev, char *buf) \ | 274 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
276 | { \ | 275 | { \ |
277 | return show_in_max(dev, buf, offset); \ | 276 | return show_in_max(dev, buf, offset); \ |
278 | } \ | 277 | } \ |
279 | static ssize_t set_in##offset##_min (struct device *dev, \ | 278 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ |
280 | const char *buf, size_t count) \ | 279 | const char *buf, size_t count) \ |
281 | { \ | 280 | { \ |
282 | return set_in_min(dev, buf, count, offset); \ | 281 | return set_in_min(dev, buf, count, offset); \ |
283 | } \ | 282 | } \ |
284 | static ssize_t set_in##offset##_max (struct device *dev, \ | 283 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ |
285 | const char *buf, size_t count) \ | 284 | const char *buf, size_t count) \ |
286 | { \ | 285 | { \ |
287 | return set_in_max(dev, buf, count, offset); \ | 286 | return set_in_max(dev, buf, count, offset); \ |
@@ -389,24 +388,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
389 | } | 388 | } |
390 | 389 | ||
391 | #define sysfs_fan(offset) \ | 390 | #define sysfs_fan(offset) \ |
392 | static ssize_t show_fan##offset(struct device *dev, char *buf) \ | 391 | static ssize_t show_fan##offset(struct device *dev, struct device_attribute *attr, char *buf) \ |
393 | { \ | 392 | { \ |
394 | return show_fan(dev, buf, offset - 1); \ | 393 | return show_fan(dev, buf, offset - 1); \ |
395 | } \ | 394 | } \ |
396 | static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ | 395 | static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
397 | { \ | 396 | { \ |
398 | return show_fan_min(dev, buf, offset - 1); \ | 397 | return show_fan_min(dev, buf, offset - 1); \ |
399 | } \ | 398 | } \ |
400 | static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ | 399 | static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ |
401 | { \ | 400 | { \ |
402 | return show_fan_div(dev, buf, offset - 1); \ | 401 | return show_fan_div(dev, buf, offset - 1); \ |
403 | } \ | 402 | } \ |
404 | static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ | 403 | static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
405 | size_t count) \ | 404 | size_t count) \ |
406 | { \ | 405 | { \ |
407 | return set_fan_min(dev, buf, count, offset - 1); \ | 406 | return set_fan_min(dev, buf, count, offset - 1); \ |
408 | } \ | 407 | } \ |
409 | static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \ | 408 | static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \ |
410 | size_t count) \ | 409 | size_t count) \ |
411 | { \ | 410 | { \ |
412 | return set_fan_div(dev, buf, count, offset - 1); \ | 411 | return set_fan_div(dev, buf, count, offset - 1); \ |
@@ -482,27 +481,27 @@ set_temp_reg(MAX, temp_max); | |||
482 | set_temp_reg(HYST, temp_hyst); | 481 | set_temp_reg(HYST, temp_hyst); |
483 | 482 | ||
484 | #define sysfs_temp(num) \ | 483 | #define sysfs_temp(num) \ |
485 | static ssize_t show_temp##num(struct device *dev, char *buf) \ | 484 | static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \ |
486 | { \ | 485 | { \ |
487 | return show_temp(dev, buf, num-1); \ | 486 | return show_temp(dev, buf, num-1); \ |
488 | } \ | 487 | } \ |
489 | static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \ | 488 | static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \ |
490 | static ssize_t show_temp_max##num(struct device *dev, char *buf) \ | 489 | static ssize_t show_temp_max##num(struct device *dev, struct device_attribute *attr, char *buf) \ |
491 | { \ | 490 | { \ |
492 | return show_temp_max(dev, buf, num-1); \ | 491 | return show_temp_max(dev, buf, num-1); \ |
493 | } \ | 492 | } \ |
494 | static ssize_t set_temp_max##num(struct device *dev, const char *buf, \ | 493 | static ssize_t set_temp_max##num(struct device *dev, struct device_attribute *attr, const char *buf, \ |
495 | size_t count) \ | 494 | size_t count) \ |
496 | { \ | 495 | { \ |
497 | return set_temp_max(dev, buf, count, num-1); \ | 496 | return set_temp_max(dev, buf, count, num-1); \ |
498 | } \ | 497 | } \ |
499 | static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \ | 498 | static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \ |
500 | show_temp_max##num, set_temp_max##num); \ | 499 | show_temp_max##num, set_temp_max##num); \ |
501 | static ssize_t show_temp_hyst##num(struct device *dev, char *buf) \ | 500 | static ssize_t show_temp_hyst##num(struct device *dev, struct device_attribute *attr, char *buf) \ |
502 | { \ | 501 | { \ |
503 | return show_temp_hyst(dev, buf, num-1); \ | 502 | return show_temp_hyst(dev, buf, num-1); \ |
504 | } \ | 503 | } \ |
505 | static ssize_t set_temp_hyst##num(struct device *dev, const char *buf, \ | 504 | static ssize_t set_temp_hyst##num(struct device *dev, struct device_attribute *attr, const char *buf, \ |
506 | size_t count) \ | 505 | size_t count) \ |
507 | { \ | 506 | { \ |
508 | return set_temp_hyst(dev, buf, count, num-1); \ | 507 | return set_temp_hyst(dev, buf, count, num-1); \ |
@@ -522,7 +521,7 @@ sysfs_temp(4); | |||
522 | device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \ | 521 | device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \ |
523 | } while (0) | 522 | } while (0) |
524 | 523 | ||
525 | static ssize_t show_vid(struct device *dev, char *buf) | 524 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
526 | { | 525 | { |
527 | struct asb100_data *data = asb100_update_device(dev); | 526 | struct asb100_data *data = asb100_update_device(dev); |
528 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | 527 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); |
@@ -533,13 +532,13 @@ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | |||
533 | device_create_file(&client->dev, &dev_attr_cpu0_vid) | 532 | device_create_file(&client->dev, &dev_attr_cpu0_vid) |
534 | 533 | ||
535 | /* VRM */ | 534 | /* VRM */ |
536 | static ssize_t show_vrm(struct device *dev, char *buf) | 535 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) |
537 | { | 536 | { |
538 | struct asb100_data *data = asb100_update_device(dev); | 537 | struct asb100_data *data = asb100_update_device(dev); |
539 | return sprintf(buf, "%d\n", data->vrm); | 538 | return sprintf(buf, "%d\n", data->vrm); |
540 | } | 539 | } |
541 | 540 | ||
542 | static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) | 541 | static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
543 | { | 542 | { |
544 | struct i2c_client *client = to_i2c_client(dev); | 543 | struct i2c_client *client = to_i2c_client(dev); |
545 | struct asb100_data *data = i2c_get_clientdata(client); | 544 | struct asb100_data *data = i2c_get_clientdata(client); |
@@ -553,10 +552,10 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); | |||
553 | #define device_create_file_vrm(client) \ | 552 | #define device_create_file_vrm(client) \ |
554 | device_create_file(&client->dev, &dev_attr_vrm); | 553 | device_create_file(&client->dev, &dev_attr_vrm); |
555 | 554 | ||
556 | static ssize_t show_alarms(struct device *dev, char *buf) | 555 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
557 | { | 556 | { |
558 | struct asb100_data *data = asb100_update_device(dev); | 557 | struct asb100_data *data = asb100_update_device(dev); |
559 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); | 558 | return sprintf(buf, "%u\n", data->alarms); |
560 | } | 559 | } |
561 | 560 | ||
562 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 561 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
@@ -564,13 +563,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | |||
564 | device_create_file(&client->dev, &dev_attr_alarms) | 563 | device_create_file(&client->dev, &dev_attr_alarms) |
565 | 564 | ||
566 | /* 1 PWM */ | 565 | /* 1 PWM */ |
567 | static ssize_t show_pwm1(struct device *dev, char *buf) | 566 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) |
568 | { | 567 | { |
569 | struct asb100_data *data = asb100_update_device(dev); | 568 | struct asb100_data *data = asb100_update_device(dev); |
570 | return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f)); | 569 | return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f)); |
571 | } | 570 | } |
572 | 571 | ||
573 | static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) | 572 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
574 | { | 573 | { |
575 | struct i2c_client *client = to_i2c_client(dev); | 574 | struct i2c_client *client = to_i2c_client(dev); |
576 | struct asb100_data *data = i2c_get_clientdata(client); | 575 | struct asb100_data *data = i2c_get_clientdata(client); |
@@ -584,13 +583,13 @@ static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) | |||
584 | return count; | 583 | return count; |
585 | } | 584 | } |
586 | 585 | ||
587 | static ssize_t show_pwm_enable1(struct device *dev, char *buf) | 586 | static ssize_t show_pwm_enable1(struct device *dev, struct device_attribute *attr, char *buf) |
588 | { | 587 | { |
589 | struct asb100_data *data = asb100_update_device(dev); | 588 | struct asb100_data *data = asb100_update_device(dev); |
590 | return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0); | 589 | return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0); |
591 | } | 590 | } |
592 | 591 | ||
593 | static ssize_t set_pwm_enable1(struct device *dev, const char *buf, | 592 | static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr, const char *buf, |
594 | size_t count) | 593 | size_t count) |
595 | { | 594 | { |
596 | struct i2c_client *client = to_i2c_client(dev); | 595 | struct i2c_client *client = to_i2c_client(dev); |
diff --git a/drivers/i2c/chips/atxp1.c b/drivers/i2c/chips/atxp1.c new file mode 100644 index 000000000000..5c6597aa2c7f --- /dev/null +++ b/drivers/i2c/chips/atxp1.c | |||
@@ -0,0 +1,361 @@ | |||
1 | /* | ||
2 | atxp1.c - kernel module for setting CPU VID and general purpose | ||
3 | I/Os using the Attansic ATXP1 chip. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | |||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/i2c-sensor.h> | ||
26 | #include <linux/i2c-vid.h> | ||
27 | |||
28 | MODULE_LICENSE("GPL"); | ||
29 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | ||
30 | MODULE_VERSION("0.6.2"); | ||
31 | MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); | ||
32 | |||
33 | #define ATXP1_VID 0x00 | ||
34 | #define ATXP1_CVID 0x01 | ||
35 | #define ATXP1_GPIO1 0x06 | ||
36 | #define ATXP1_GPIO2 0x0a | ||
37 | #define ATXP1_VIDENA 0x20 | ||
38 | #define ATXP1_VIDMASK 0x1f | ||
39 | #define ATXP1_GPIO1MASK 0x0f | ||
40 | |||
41 | static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; | ||
42 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
43 | |||
44 | SENSORS_INSMOD_1(atxp1); | ||
45 | |||
46 | static int atxp1_attach_adapter(struct i2c_adapter * adapter); | ||
47 | static int atxp1_detach_client(struct i2c_client * client); | ||
48 | static struct atxp1_data * atxp1_update_device(struct device *dev); | ||
49 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); | ||
50 | |||
51 | static struct i2c_driver atxp1_driver = { | ||
52 | .owner = THIS_MODULE, | ||
53 | .name = "atxp1", | ||
54 | .flags = I2C_DF_NOTIFY, | ||
55 | .attach_adapter = atxp1_attach_adapter, | ||
56 | .detach_client = atxp1_detach_client, | ||
57 | }; | ||
58 | |||
59 | struct atxp1_data { | ||
60 | struct i2c_client client; | ||
61 | struct semaphore update_lock; | ||
62 | unsigned long last_updated; | ||
63 | u8 valid; | ||
64 | struct { | ||
65 | u8 vid; /* VID output register */ | ||
66 | u8 cpu_vid; /* VID input from CPU */ | ||
67 | u8 gpio1; /* General purpose I/O register 1 */ | ||
68 | u8 gpio2; /* General purpose I/O register 2 */ | ||
69 | } reg; | ||
70 | u8 vrm; /* Detected CPU VRM */ | ||
71 | }; | ||
72 | |||
73 | static struct atxp1_data * atxp1_update_device(struct device *dev) | ||
74 | { | ||
75 | struct i2c_client *client; | ||
76 | struct atxp1_data *data; | ||
77 | |||
78 | client = to_i2c_client(dev); | ||
79 | data = i2c_get_clientdata(client); | ||
80 | |||
81 | down(&data->update_lock); | ||
82 | |||
83 | if ((jiffies - data->last_updated > HZ) || | ||
84 | (jiffies < data->last_updated) || | ||
85 | !data->valid) { | ||
86 | |||
87 | /* Update local register data */ | ||
88 | data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID); | ||
89 | data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID); | ||
90 | data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1); | ||
91 | data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2); | ||
92 | |||
93 | data->valid = 1; | ||
94 | } | ||
95 | |||
96 | up(&data->update_lock); | ||
97 | |||
98 | return(data); | ||
99 | } | ||
100 | |||
101 | /* sys file functions for cpu0_vid */ | ||
102 | static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf) | ||
103 | { | ||
104 | int size; | ||
105 | struct atxp1_data *data; | ||
106 | |||
107 | data = atxp1_update_device(dev); | ||
108 | |||
109 | size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm)); | ||
110 | |||
111 | return size; | ||
112 | } | ||
113 | |||
114 | static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
115 | { | ||
116 | struct atxp1_data *data; | ||
117 | struct i2c_client *client; | ||
118 | char vid; | ||
119 | char cvid; | ||
120 | unsigned int vcore; | ||
121 | |||
122 | client = to_i2c_client(dev); | ||
123 | data = atxp1_update_device(dev); | ||
124 | |||
125 | vcore = simple_strtoul(buf, NULL, 10); | ||
126 | vcore /= 25; | ||
127 | vcore *= 25; | ||
128 | |||
129 | /* Calculate VID */ | ||
130 | vid = vid_to_reg(vcore, data->vrm); | ||
131 | |||
132 | if (vid < 0) { | ||
133 | dev_err(dev, "VID calculation failed.\n"); | ||
134 | return -1; | ||
135 | } | ||
136 | |||
137 | /* If output enabled, use control register value. Otherwise original CPU VID */ | ||
138 | if (data->reg.vid & ATXP1_VIDENA) | ||
139 | cvid = data->reg.vid & ATXP1_VIDMASK; | ||
140 | else | ||
141 | cvid = data->reg.cpu_vid; | ||
142 | |||
143 | /* Nothing changed, aborting */ | ||
144 | if (vid == cvid) | ||
145 | return count; | ||
146 | |||
147 | dev_info(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid); | ||
148 | |||
149 | /* Write every 25 mV step to increase stability */ | ||
150 | if (cvid > vid) { | ||
151 | for (; cvid >= vid; cvid--) { | ||
152 | i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); | ||
153 | } | ||
154 | } | ||
155 | else { | ||
156 | for (; cvid <= vid; cvid++) { | ||
157 | i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | data->valid = 0; | ||
162 | |||
163 | return count; | ||
164 | } | ||
165 | |||
166 | /* CPU core reference voltage | ||
167 | unit: millivolt | ||
168 | */ | ||
169 | static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore); | ||
170 | |||
171 | /* sys file functions for GPIO1 */ | ||
172 | static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf) | ||
173 | { | ||
174 | int size; | ||
175 | struct atxp1_data *data; | ||
176 | |||
177 | data = atxp1_update_device(dev); | ||
178 | |||
179 | size = sprintf(buf, "0x%02x\n", data->reg.gpio1 & ATXP1_GPIO1MASK); | ||
180 | |||
181 | return size; | ||
182 | } | ||
183 | |||
184 | static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count) | ||
185 | { | ||
186 | struct atxp1_data *data; | ||
187 | struct i2c_client *client; | ||
188 | unsigned int value; | ||
189 | |||
190 | client = to_i2c_client(dev); | ||
191 | data = atxp1_update_device(dev); | ||
192 | |||
193 | value = simple_strtoul(buf, NULL, 16); | ||
194 | |||
195 | value &= ATXP1_GPIO1MASK; | ||
196 | |||
197 | if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) { | ||
198 | dev_info(dev, "Writing 0x%x to GPIO1.\n", value); | ||
199 | |||
200 | i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value); | ||
201 | |||
202 | data->valid = 0; | ||
203 | } | ||
204 | |||
205 | return count; | ||
206 | } | ||
207 | |||
208 | /* GPIO1 data register | ||
209 | unit: Four bit as hex (e.g. 0x0f) | ||
210 | */ | ||
211 | static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1); | ||
212 | |||
213 | /* sys file functions for GPIO2 */ | ||
214 | static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf) | ||
215 | { | ||
216 | int size; | ||
217 | struct atxp1_data *data; | ||
218 | |||
219 | data = atxp1_update_device(dev); | ||
220 | |||
221 | size = sprintf(buf, "0x%02x\n", data->reg.gpio2); | ||
222 | |||
223 | return size; | ||
224 | } | ||
225 | |||
226 | static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
227 | { | ||
228 | struct atxp1_data *data; | ||
229 | struct i2c_client *client; | ||
230 | unsigned int value; | ||
231 | |||
232 | client = to_i2c_client(dev); | ||
233 | data = atxp1_update_device(dev); | ||
234 | |||
235 | value = simple_strtoul(buf, NULL, 16) & 0xff; | ||
236 | |||
237 | if (value != data->reg.gpio2) { | ||
238 | dev_info(dev, "Writing 0x%x to GPIO1.\n", value); | ||
239 | |||
240 | i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value); | ||
241 | |||
242 | data->valid = 0; | ||
243 | } | ||
244 | |||
245 | return count; | ||
246 | } | ||
247 | |||
248 | /* GPIO2 data register | ||
249 | unit: Eight bit as hex (e.g. 0xff) | ||
250 | */ | ||
251 | static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | ||
252 | |||
253 | |||
254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | ||
255 | { | ||
256 | return i2c_detect(adapter, &addr_data, &atxp1_detect); | ||
257 | }; | ||
258 | |||
259 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | ||
260 | { | ||
261 | struct i2c_client * new_client; | ||
262 | struct atxp1_data * data; | ||
263 | int err = 0; | ||
264 | u8 temp; | ||
265 | |||
266 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
267 | goto exit; | ||
268 | |||
269 | if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { | ||
270 | err = -ENOMEM; | ||
271 | goto exit; | ||
272 | } | ||
273 | |||
274 | memset(data, 0, sizeof(struct atxp1_data)); | ||
275 | new_client = &data->client; | ||
276 | i2c_set_clientdata(new_client, data); | ||
277 | |||
278 | new_client->addr = address; | ||
279 | new_client->adapter = adapter; | ||
280 | new_client->driver = &atxp1_driver; | ||
281 | new_client->flags = 0; | ||
282 | |||
283 | /* Detect ATXP1, checking if vendor ID registers are all zero */ | ||
284 | if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) && | ||
285 | (i2c_smbus_read_byte_data(new_client, 0x3f) == 0) && | ||
286 | (i2c_smbus_read_byte_data(new_client, 0xfe) == 0) && | ||
287 | (i2c_smbus_read_byte_data(new_client, 0xff) == 0) )) { | ||
288 | |||
289 | /* No vendor ID, now checking if registers 0x10,0x11 (non-existent) | ||
290 | * showing the same as register 0x00 */ | ||
291 | temp = i2c_smbus_read_byte_data(new_client, 0x00); | ||
292 | |||
293 | if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) && | ||
294 | (i2c_smbus_read_byte_data(new_client, 0x11) == temp) )) | ||
295 | goto exit_free; | ||
296 | } | ||
297 | |||
298 | /* Get VRM */ | ||
299 | data->vrm = i2c_which_vrm(); | ||
300 | |||
301 | if ((data->vrm != 90) && (data->vrm != 91)) { | ||
302 | dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", | ||
303 | data->vrm / 10, data->vrm % 10); | ||
304 | goto exit_free; | ||
305 | } | ||
306 | |||
307 | strncpy(new_client->name, "atxp1", I2C_NAME_SIZE); | ||
308 | |||
309 | data->valid = 0; | ||
310 | |||
311 | init_MUTEX(&data->update_lock); | ||
312 | |||
313 | err = i2c_attach_client(new_client); | ||
314 | |||
315 | if (err) | ||
316 | { | ||
317 | dev_err(&new_client->dev, "Attach client error.\n"); | ||
318 | goto exit_free; | ||
319 | } | ||
320 | |||
321 | device_create_file(&new_client->dev, &dev_attr_gpio1); | ||
322 | device_create_file(&new_client->dev, &dev_attr_gpio2); | ||
323 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
324 | |||
325 | dev_info(&new_client->dev, "Using VRM: %d.%d\n", | ||
326 | data->vrm / 10, data->vrm % 10); | ||
327 | |||
328 | return 0; | ||
329 | |||
330 | exit_free: | ||
331 | kfree(data); | ||
332 | exit: | ||
333 | return err; | ||
334 | }; | ||
335 | |||
336 | static int atxp1_detach_client(struct i2c_client * client) | ||
337 | { | ||
338 | int err; | ||
339 | |||
340 | err = i2c_detach_client(client); | ||
341 | |||
342 | if (err) | ||
343 | dev_err(&client->dev, "Failed to detach client.\n"); | ||
344 | else | ||
345 | kfree(i2c_get_clientdata(client)); | ||
346 | |||
347 | return err; | ||
348 | }; | ||
349 | |||
350 | static int __init atxp1_init(void) | ||
351 | { | ||
352 | return i2c_add_driver(&atxp1_driver); | ||
353 | }; | ||
354 | |||
355 | static void __exit atxp1_exit(void) | ||
356 | { | ||
357 | i2c_del_driver(&atxp1_driver); | ||
358 | }; | ||
359 | |||
360 | module_init(atxp1_init); | ||
361 | module_exit(atxp1_exit); | ||
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 07f16c3fb084..74ece8ac1c23 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -3,17 +3,16 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2005 James Chapman <jchapman@katalix.com> | 4 | * Copyright (C) 2005 James Chapman <jchapman@katalix.com> |
5 | * | 5 | * |
6 | * based on linux/drivers/acron/char/pcf8583.c | 6 | * based on linux/drivers/acorn/char/pcf8583.c |
7 | * Copyright (C) 2000 Russell King | 7 | * Copyright (C) 2000 Russell King |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | * | 12 | * |
13 | * Driver for Dallas Semiconductor DS1337 real time clock chip | 13 | * Driver for Dallas Semiconductor DS1337 and DS1339 real time clock chip |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/config.h> | ||
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
19 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
@@ -69,13 +68,11 @@ static struct i2c_driver ds1337_driver = { | |||
69 | struct ds1337_data { | 68 | struct ds1337_data { |
70 | struct i2c_client client; | 69 | struct i2c_client client; |
71 | struct list_head list; | 70 | struct list_head list; |
72 | int id; | ||
73 | }; | 71 | }; |
74 | 72 | ||
75 | /* | 73 | /* |
76 | * Internal variables | 74 | * Internal variables |
77 | */ | 75 | */ |
78 | static int ds1337_id; | ||
79 | static LIST_HEAD(ds1337_clients); | 76 | static LIST_HEAD(ds1337_clients); |
80 | 77 | ||
81 | static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) | 78 | static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) |
@@ -95,7 +92,6 @@ static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) | |||
95 | */ | 92 | */ |
96 | static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | 93 | static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) |
97 | { | 94 | { |
98 | struct ds1337_data *data = i2c_get_clientdata(client); | ||
99 | int result; | 95 | int result; |
100 | u8 buf[7]; | 96 | u8 buf[7]; |
101 | u8 val; | 97 | u8 val; |
@@ -103,9 +99,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
103 | u8 offs = 0; | 99 | u8 offs = 0; |
104 | 100 | ||
105 | if (!dt) { | 101 | if (!dt) { |
106 | dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", | 102 | dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); |
107 | __FUNCTION__); | ||
108 | |||
109 | return -EINVAL; | 103 | return -EINVAL; |
110 | } | 104 | } |
111 | 105 | ||
@@ -119,98 +113,86 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
119 | msg[1].len = sizeof(buf); | 113 | msg[1].len = sizeof(buf); |
120 | msg[1].buf = &buf[0]; | 114 | msg[1].buf = &buf[0]; |
121 | 115 | ||
122 | result = client->adapter->algo->master_xfer(client->adapter, | 116 | result = i2c_transfer(client->adapter, msg, 2); |
123 | &msg[0], 2); | ||
124 | 117 | ||
125 | dev_dbg(&client->adapter->dev, | 118 | dev_dbg(&client->dev, "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", |
126 | "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", | ||
127 | __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], | 119 | __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], |
128 | buf[4], buf[5], buf[6]); | 120 | buf[4], buf[5], buf[6]); |
129 | 121 | ||
130 | if (result >= 0) { | 122 | if (result == 2) { |
131 | dt->tm_sec = BCD_TO_BIN(buf[0]); | 123 | dt->tm_sec = BCD2BIN(buf[0]); |
132 | dt->tm_min = BCD_TO_BIN(buf[1]); | 124 | dt->tm_min = BCD2BIN(buf[1]); |
133 | val = buf[2] & 0x3f; | 125 | val = buf[2] & 0x3f; |
134 | dt->tm_hour = BCD_TO_BIN(val); | 126 | dt->tm_hour = BCD2BIN(val); |
135 | dt->tm_wday = BCD_TO_BIN(buf[3]) - 1; | 127 | dt->tm_wday = BCD2BIN(buf[3]) - 1; |
136 | dt->tm_mday = BCD_TO_BIN(buf[4]); | 128 | dt->tm_mday = BCD2BIN(buf[4]); |
137 | val = buf[5] & 0x7f; | 129 | val = buf[5] & 0x7f; |
138 | dt->tm_mon = BCD_TO_BIN(val); | 130 | dt->tm_mon = BCD2BIN(val) - 1; |
139 | dt->tm_year = 1900 + BCD_TO_BIN(buf[6]); | 131 | dt->tm_year = BCD2BIN(buf[6]); |
140 | if (buf[5] & 0x80) | 132 | if (buf[5] & 0x80) |
141 | dt->tm_year += 100; | 133 | dt->tm_year += 100; |
142 | 134 | ||
143 | dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, " | 135 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, " |
144 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | 136 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", |
145 | __FUNCTION__, dt->tm_sec, dt->tm_min, | 137 | __FUNCTION__, dt->tm_sec, dt->tm_min, |
146 | dt->tm_hour, dt->tm_mday, | 138 | dt->tm_hour, dt->tm_mday, |
147 | dt->tm_mon, dt->tm_year, dt->tm_wday); | 139 | dt->tm_mon, dt->tm_year, dt->tm_wday); |
148 | } else { | 140 | |
149 | dev_err(&client->adapter->dev, "ds1337[%d]: error reading " | 141 | return 0; |
150 | "data! %d\n", data->id, result); | ||
151 | result = -EIO; | ||
152 | } | 142 | } |
153 | 143 | ||
154 | return result; | 144 | dev_err(&client->dev, "error reading data! %d\n", result); |
145 | return -EIO; | ||
155 | } | 146 | } |
156 | 147 | ||
157 | static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) | 148 | static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) |
158 | { | 149 | { |
159 | struct ds1337_data *data = i2c_get_clientdata(client); | ||
160 | int result; | 150 | int result; |
161 | u8 buf[8]; | 151 | u8 buf[8]; |
162 | u8 val; | 152 | u8 val; |
163 | struct i2c_msg msg[1]; | 153 | struct i2c_msg msg[1]; |
164 | 154 | ||
165 | if (!dt) { | 155 | if (!dt) { |
166 | dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", | 156 | dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); |
167 | __FUNCTION__); | ||
168 | |||
169 | return -EINVAL; | 157 | return -EINVAL; |
170 | } | 158 | } |
171 | 159 | ||
172 | dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, hours=%d, " | 160 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " |
173 | "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, | 161 | "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, |
174 | dt->tm_sec, dt->tm_min, dt->tm_hour, | 162 | dt->tm_sec, dt->tm_min, dt->tm_hour, |
175 | dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); | 163 | dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); |
176 | 164 | ||
177 | buf[0] = 0; /* reg offset */ | 165 | buf[0] = 0; /* reg offset */ |
178 | buf[1] = BIN_TO_BCD(dt->tm_sec); | 166 | buf[1] = BIN2BCD(dt->tm_sec); |
179 | buf[2] = BIN_TO_BCD(dt->tm_min); | 167 | buf[2] = BIN2BCD(dt->tm_min); |
180 | buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6); | 168 | buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6); |
181 | buf[4] = BIN_TO_BCD(dt->tm_wday) + 1; | 169 | buf[4] = BIN2BCD(dt->tm_wday) + 1; |
182 | buf[5] = BIN_TO_BCD(dt->tm_mday); | 170 | buf[5] = BIN2BCD(dt->tm_mday); |
183 | buf[6] = BIN_TO_BCD(dt->tm_mon); | 171 | buf[6] = BIN2BCD(dt->tm_mon) + 1; |
184 | if (dt->tm_year >= 2000) { | 172 | val = dt->tm_year; |
185 | val = dt->tm_year - 2000; | 173 | if (val >= 100) { |
174 | val -= 100; | ||
186 | buf[6] |= (1 << 7); | 175 | buf[6] |= (1 << 7); |
187 | } else { | ||
188 | val = dt->tm_year - 1900; | ||
189 | } | 176 | } |
190 | buf[7] = BIN_TO_BCD(val); | 177 | buf[7] = BIN2BCD(val); |
191 | 178 | ||
192 | msg[0].addr = client->addr; | 179 | msg[0].addr = client->addr; |
193 | msg[0].flags = 0; | 180 | msg[0].flags = 0; |
194 | msg[0].len = sizeof(buf); | 181 | msg[0].len = sizeof(buf); |
195 | msg[0].buf = &buf[0]; | 182 | msg[0].buf = &buf[0]; |
196 | 183 | ||
197 | result = client->adapter->algo->master_xfer(client->adapter, | 184 | result = i2c_transfer(client->adapter, msg, 1); |
198 | &msg[0], 1); | 185 | if (result == 1) |
199 | if (result < 0) { | 186 | return 0; |
200 | dev_err(&client->adapter->dev, "ds1337[%d]: error " | ||
201 | "writing data! %d\n", data->id, result); | ||
202 | result = -EIO; | ||
203 | } else { | ||
204 | result = 0; | ||
205 | } | ||
206 | 187 | ||
207 | return result; | 188 | dev_err(&client->dev, "error writing data! %d\n", result); |
189 | return -EIO; | ||
208 | } | 190 | } |
209 | 191 | ||
210 | static int ds1337_command(struct i2c_client *client, unsigned int cmd, | 192 | static int ds1337_command(struct i2c_client *client, unsigned int cmd, |
211 | void *arg) | 193 | void *arg) |
212 | { | 194 | { |
213 | dev_dbg(&client->adapter->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); | 195 | dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); |
214 | 196 | ||
215 | switch (cmd) { | 197 | switch (cmd) { |
216 | case DS1337_GET_DATE: | 198 | case DS1337_GET_DATE: |
@@ -228,7 +210,7 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, | |||
228 | * Public API for access to specific device. Useful for low-level | 210 | * Public API for access to specific device. Useful for low-level |
229 | * RTC access from kernel code. | 211 | * RTC access from kernel code. |
230 | */ | 212 | */ |
231 | int ds1337_do_command(int id, int cmd, void *arg) | 213 | int ds1337_do_command(int bus, int cmd, void *arg) |
232 | { | 214 | { |
233 | struct list_head *walk; | 215 | struct list_head *walk; |
234 | struct list_head *tmp; | 216 | struct list_head *tmp; |
@@ -236,7 +218,7 @@ int ds1337_do_command(int id, int cmd, void *arg) | |||
236 | 218 | ||
237 | list_for_each_safe(walk, tmp, &ds1337_clients) { | 219 | list_for_each_safe(walk, tmp, &ds1337_clients) { |
238 | data = list_entry(walk, struct ds1337_data, list); | 220 | data = list_entry(walk, struct ds1337_data, list); |
239 | if (data->id == id) | 221 | if (data->client.adapter->nr == bus) |
240 | return ds1337_command(&data->client, cmd, arg); | 222 | return ds1337_command(&data->client, cmd, arg); |
241 | } | 223 | } |
242 | 224 | ||
@@ -346,7 +328,6 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) | |||
346 | ds1337_init_client(new_client); | 328 | ds1337_init_client(new_client); |
347 | 329 | ||
348 | /* Add client to local list */ | 330 | /* Add client to local list */ |
349 | data->id = ds1337_id++; | ||
350 | list_add(&data->list, &ds1337_clients); | 331 | list_add(&data->list, &ds1337_clients); |
351 | 332 | ||
352 | return 0; | 333 | return 0; |
@@ -398,5 +379,7 @@ MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); | |||
398 | MODULE_DESCRIPTION("DS1337 RTC driver"); | 379 | MODULE_DESCRIPTION("DS1337 RTC driver"); |
399 | MODULE_LICENSE("GPL"); | 380 | MODULE_LICENSE("GPL"); |
400 | 381 | ||
382 | EXPORT_SYMBOL_GPL(ds1337_do_command); | ||
383 | |||
401 | module_init(ds1337_init); | 384 | module_init(ds1337_init); |
402 | module_exit(ds1337_exit); | 385 | module_exit(ds1337_exit); |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c new file mode 100644 index 000000000000..a445736d8838 --- /dev/null +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -0,0 +1,260 @@ | |||
1 | /* | ||
2 | * drivers/i2c/chips/ds1374.c | ||
3 | * | ||
4 | * I2C client/driver for the Maxim/Dallas DS1374 Real-Time Clock | ||
5 | * | ||
6 | * Author: Randy Vinson <rvinson@mvista.com> | ||
7 | * | ||
8 | * Based on the m41t00.c by Mark Greer <mgreer@mvista.com> | ||
9 | * | ||
10 | * 2005 (c) MontaVista Software, Inc. This file is licensed under | ||
11 | * the terms of the GNU General Public License version 2. This program | ||
12 | * is licensed "as is" without any warranty of any kind, whether express | ||
13 | * or implied. | ||
14 | */ | ||
15 | /* | ||
16 | * This i2c client/driver wedges between the drivers/char/genrtc.c RTC | ||
17 | * interface and the SMBus interface of the i2c subsystem. | ||
18 | * It would be more efficient to use i2c msgs/i2c_transfer directly but, as | ||
19 | * recommened in .../Documentation/i2c/writing-clients section | ||
20 | * "Sending and receiving", using SMBus level communication is preferred. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/i2c.h> | ||
27 | #include <linux/rtc.h> | ||
28 | #include <linux/bcd.h> | ||
29 | |||
30 | #define DS1374_REG_TOD0 0x00 | ||
31 | #define DS1374_REG_TOD1 0x01 | ||
32 | #define DS1374_REG_TOD2 0x02 | ||
33 | #define DS1374_REG_TOD3 0x03 | ||
34 | #define DS1374_REG_WDALM0 0x04 | ||
35 | #define DS1374_REG_WDALM1 0x05 | ||
36 | #define DS1374_REG_WDALM2 0x06 | ||
37 | #define DS1374_REG_CR 0x07 | ||
38 | #define DS1374_REG_SR 0x08 | ||
39 | #define DS1374_REG_SR_OSF 0x80 | ||
40 | #define DS1374_REG_TCR 0x09 | ||
41 | |||
42 | #define DS1374_DRV_NAME "ds1374" | ||
43 | |||
44 | static DECLARE_MUTEX(ds1374_mutex); | ||
45 | |||
46 | static struct i2c_driver ds1374_driver; | ||
47 | static struct i2c_client *save_client; | ||
48 | |||
49 | static unsigned short ignore[] = { I2C_CLIENT_END }; | ||
50 | static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; | ||
51 | |||
52 | static struct i2c_client_address_data addr_data = { | ||
53 | .normal_i2c = normal_addr, | ||
54 | .probe = ignore, | ||
55 | .ignore = ignore, | ||
56 | .force = ignore, | ||
57 | }; | ||
58 | |||
59 | static ulong ds1374_read_rtc(void) | ||
60 | { | ||
61 | ulong time = 0; | ||
62 | int reg = DS1374_REG_WDALM0; | ||
63 | |||
64 | while (reg--) { | ||
65 | s32 tmp; | ||
66 | if ((tmp = i2c_smbus_read_byte_data(save_client, reg)) < 0) { | ||
67 | dev_warn(&save_client->dev, | ||
68 | "can't read from rtc chip\n"); | ||
69 | return 0; | ||
70 | } | ||
71 | time = (time << 8) | (tmp & 0xff); | ||
72 | } | ||
73 | return time; | ||
74 | } | ||
75 | |||
76 | static void ds1374_write_rtc(ulong time) | ||
77 | { | ||
78 | int reg; | ||
79 | |||
80 | for (reg = DS1374_REG_TOD0; reg < DS1374_REG_WDALM0; reg++) { | ||
81 | if (i2c_smbus_write_byte_data(save_client, reg, time & 0xff) | ||
82 | < 0) { | ||
83 | dev_warn(&save_client->dev, | ||
84 | "can't write to rtc chip\n"); | ||
85 | break; | ||
86 | } | ||
87 | time = time >> 8; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | static void ds1374_check_rtc_status(void) | ||
92 | { | ||
93 | s32 tmp; | ||
94 | |||
95 | tmp = i2c_smbus_read_byte_data(save_client, DS1374_REG_SR); | ||
96 | if (tmp < 0) { | ||
97 | dev_warn(&save_client->dev, | ||
98 | "can't read status from rtc chip\n"); | ||
99 | return; | ||
100 | } | ||
101 | if (tmp & DS1374_REG_SR_OSF) { | ||
102 | dev_warn(&save_client->dev, | ||
103 | "oscillator discontinuity flagged, time unreliable\n"); | ||
104 | tmp &= ~DS1374_REG_SR_OSF; | ||
105 | tmp = i2c_smbus_write_byte_data(save_client, DS1374_REG_SR, | ||
106 | tmp & 0xff); | ||
107 | if (tmp < 0) | ||
108 | dev_warn(&save_client->dev, | ||
109 | "can't clear discontinuity notification\n"); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | ulong ds1374_get_rtc_time(void) | ||
114 | { | ||
115 | ulong t1, t2; | ||
116 | int limit = 10; /* arbitrary retry limit */ | ||
117 | |||
118 | down(&ds1374_mutex); | ||
119 | |||
120 | /* | ||
121 | * Since the reads are being performed one byte at a time using | ||
122 | * the SMBus vs a 4-byte i2c transfer, there is a chance that a | ||
123 | * carry will occur during the read. To detect this, 2 reads are | ||
124 | * performed and compared. | ||
125 | */ | ||
126 | do { | ||
127 | t1 = ds1374_read_rtc(); | ||
128 | t2 = ds1374_read_rtc(); | ||
129 | } while (t1 != t2 && limit--); | ||
130 | |||
131 | up(&ds1374_mutex); | ||
132 | |||
133 | if (t1 != t2) { | ||
134 | dev_warn(&save_client->dev, | ||
135 | "can't get consistent time from rtc chip\n"); | ||
136 | t1 = 0; | ||
137 | } | ||
138 | |||
139 | return t1; | ||
140 | } | ||
141 | |||
142 | static void ds1374_set_tlet(ulong arg) | ||
143 | { | ||
144 | ulong t1, t2; | ||
145 | int limit = 10; /* arbitrary retry limit */ | ||
146 | |||
147 | t1 = *(ulong *) arg; | ||
148 | |||
149 | down(&ds1374_mutex); | ||
150 | |||
151 | /* | ||
152 | * Since the writes are being performed one byte at a time using | ||
153 | * the SMBus vs a 4-byte i2c transfer, there is a chance that a | ||
154 | * carry will occur during the write. To detect this, the write | ||
155 | * value is read back and compared. | ||
156 | */ | ||
157 | do { | ||
158 | ds1374_write_rtc(t1); | ||
159 | t2 = ds1374_read_rtc(); | ||
160 | } while (t1 != t2 && limit--); | ||
161 | |||
162 | up(&ds1374_mutex); | ||
163 | |||
164 | if (t1 != t2) | ||
165 | dev_warn(&save_client->dev, | ||
166 | "can't confirm time set from rtc chip\n"); | ||
167 | } | ||
168 | |||
169 | ulong new_time; | ||
170 | |||
171 | DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); | ||
172 | |||
173 | int ds1374_set_rtc_time(ulong nowtime) | ||
174 | { | ||
175 | new_time = nowtime; | ||
176 | |||
177 | if (in_interrupt()) | ||
178 | tasklet_schedule(&ds1374_tasklet); | ||
179 | else | ||
180 | ds1374_set_tlet((ulong) & new_time); | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | ***************************************************************************** | ||
187 | * | ||
188 | * Driver Interface | ||
189 | * | ||
190 | ***************************************************************************** | ||
191 | */ | ||
192 | static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) | ||
193 | { | ||
194 | struct i2c_client *client; | ||
195 | int rc; | ||
196 | |||
197 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
198 | if (!client) | ||
199 | return -ENOMEM; | ||
200 | |||
201 | memset(client, 0, sizeof(struct i2c_client)); | ||
202 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); | ||
203 | client->flags = I2C_DF_NOTIFY; | ||
204 | client->addr = addr; | ||
205 | client->adapter = adap; | ||
206 | client->driver = &ds1374_driver; | ||
207 | |||
208 | if ((rc = i2c_attach_client(client)) != 0) { | ||
209 | kfree(client); | ||
210 | return rc; | ||
211 | } | ||
212 | |||
213 | save_client = client; | ||
214 | |||
215 | ds1374_check_rtc_status(); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int ds1374_attach(struct i2c_adapter *adap) | ||
221 | { | ||
222 | return i2c_probe(adap, &addr_data, ds1374_probe); | ||
223 | } | ||
224 | |||
225 | static int ds1374_detach(struct i2c_client *client) | ||
226 | { | ||
227 | int rc; | ||
228 | |||
229 | if ((rc = i2c_detach_client(client)) == 0) { | ||
230 | kfree(i2c_get_clientdata(client)); | ||
231 | tasklet_kill(&ds1374_tasklet); | ||
232 | } | ||
233 | return rc; | ||
234 | } | ||
235 | |||
236 | static struct i2c_driver ds1374_driver = { | ||
237 | .owner = THIS_MODULE, | ||
238 | .name = DS1374_DRV_NAME, | ||
239 | .id = I2C_DRIVERID_DS1374, | ||
240 | .flags = I2C_DF_NOTIFY, | ||
241 | .attach_adapter = ds1374_attach, | ||
242 | .detach_client = ds1374_detach, | ||
243 | }; | ||
244 | |||
245 | static int __init ds1374_init(void) | ||
246 | { | ||
247 | return i2c_add_driver(&ds1374_driver); | ||
248 | } | ||
249 | |||
250 | static void __exit ds1374_exit(void) | ||
251 | { | ||
252 | i2c_del_driver(&ds1374_driver); | ||
253 | } | ||
254 | |||
255 | module_init(ds1374_init); | ||
256 | module_exit(ds1374_exit); | ||
257 | |||
258 | MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>"); | ||
259 | MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver"); | ||
260 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c index bb1fefb2162e..5360d58804f6 100644 --- a/drivers/i2c/chips/ds1621.c +++ b/drivers/i2c/chips/ds1621.c | |||
@@ -121,7 +121,7 @@ static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value) | |||
121 | static void ds1621_init_client(struct i2c_client *client) | 121 | static void ds1621_init_client(struct i2c_client *client) |
122 | { | 122 | { |
123 | int reg = ds1621_read_value(client, DS1621_REG_CONF); | 123 | int reg = ds1621_read_value(client, DS1621_REG_CONF); |
124 | /* switch to continous conversion mode */ | 124 | /* switch to continuous conversion mode */ |
125 | reg &= ~ DS1621_REG_CONFIG_1SHOT; | 125 | reg &= ~ DS1621_REG_CONFIG_1SHOT; |
126 | 126 | ||
127 | /* setup output polarity */ | 127 | /* setup output polarity */ |
@@ -137,7 +137,7 @@ static void ds1621_init_client(struct i2c_client *client) | |||
137 | } | 137 | } |
138 | 138 | ||
139 | #define show(value) \ | 139 | #define show(value) \ |
140 | static ssize_t show_##value(struct device *dev, char *buf) \ | 140 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
141 | { \ | 141 | { \ |
142 | struct ds1621_data *data = ds1621_update_client(dev); \ | 142 | struct ds1621_data *data = ds1621_update_client(dev); \ |
143 | return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \ | 143 | return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \ |
@@ -148,7 +148,7 @@ show(temp_min); | |||
148 | show(temp_max); | 148 | show(temp_max); |
149 | 149 | ||
150 | #define set_temp(suffix, value, reg) \ | 150 | #define set_temp(suffix, value, reg) \ |
151 | static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ | 151 | static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ |
152 | size_t count) \ | 152 | size_t count) \ |
153 | { \ | 153 | { \ |
154 | struct i2c_client *client = to_i2c_client(dev); \ | 154 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -165,7 +165,7 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ | |||
165 | set_temp(min, temp_min, DS1621_REG_TEMP_MIN); | 165 | set_temp(min, temp_min, DS1621_REG_TEMP_MIN); |
166 | set_temp(max, temp_max, DS1621_REG_TEMP_MAX); | 166 | set_temp(max, temp_max, DS1621_REG_TEMP_MAX); |
167 | 167 | ||
168 | static ssize_t show_alarms(struct device *dev, char *buf) | 168 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
169 | { | 169 | { |
170 | struct ds1621_data *data = ds1621_update_client(dev); | 170 | struct ds1621_data *data = ds1621_update_client(dev); |
171 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf)); | 171 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf)); |
@@ -303,7 +303,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
303 | data->temp_max = ds1621_read_value(client, | 303 | data->temp_max = ds1621_read_value(client, |
304 | DS1621_REG_TEMP_MAX); | 304 | DS1621_REG_TEMP_MAX); |
305 | 305 | ||
306 | /* reset alarms if neccessary */ | 306 | /* reset alarms if necessary */ |
307 | new_conf = data->conf; | 307 | new_conf = data->conf; |
308 | if (data->temp < data->temp_min) | 308 | if (data->temp < data->temp_min) |
309 | new_conf &= ~DS1621_ALARM_TEMP_LOW; | 309 | new_conf &= ~DS1621_ALARM_TEMP_LOW; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index cbdfa2db6f7c..addf0adc24d4 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -26,7 +26,6 @@ | |||
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
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> |
diff --git a/drivers/i2c/chips/fscher.c b/drivers/i2c/chips/fscher.c index 18e33ac59d0c..da411741c2c5 100644 --- a/drivers/i2c/chips/fscher.c +++ b/drivers/i2c/chips/fscher.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * and Philip Edelbrock <phil@netroedge.com> | 26 | * and Philip Edelbrock <phil@netroedge.com> |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
@@ -157,8 +156,8 @@ struct fscher_data { | |||
157 | 156 | ||
158 | #define sysfs_r(kind, sub, offset, reg) \ | 157 | #define sysfs_r(kind, sub, offset, reg) \ |
159 | static ssize_t show_##kind##sub (struct fscher_data *, char *, int); \ | 158 | static ssize_t show_##kind##sub (struct fscher_data *, char *, int); \ |
160 | static ssize_t show_##kind##offset##sub (struct device *, char *); \ | 159 | static ssize_t show_##kind##offset##sub (struct device *, struct device_attribute *attr, char *); \ |
161 | static ssize_t show_##kind##offset##sub (struct device *dev, char *buf) \ | 160 | static ssize_t show_##kind##offset##sub (struct device *dev, struct device_attribute *attr, char *buf) \ |
162 | { \ | 161 | { \ |
163 | struct fscher_data *data = fscher_update_device(dev); \ | 162 | struct fscher_data *data = fscher_update_device(dev); \ |
164 | return show_##kind##sub(data, buf, (offset)); \ | 163 | return show_##kind##sub(data, buf, (offset)); \ |
@@ -166,8 +165,8 @@ static ssize_t show_##kind##offset##sub (struct device *dev, char *buf) \ | |||
166 | 165 | ||
167 | #define sysfs_w(kind, sub, offset, reg) \ | 166 | #define sysfs_w(kind, sub, offset, reg) \ |
168 | static ssize_t set_##kind##sub (struct i2c_client *, struct fscher_data *, const char *, size_t, int, int); \ | 167 | static ssize_t set_##kind##sub (struct i2c_client *, struct fscher_data *, const char *, size_t, int, int); \ |
169 | static ssize_t set_##kind##offset##sub (struct device *, const char *, size_t); \ | 168 | static ssize_t set_##kind##offset##sub (struct device *, struct device_attribute *attr, const char *, size_t); \ |
170 | static ssize_t set_##kind##offset##sub (struct device *dev, const char *buf, size_t count) \ | 169 | static ssize_t set_##kind##offset##sub (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
171 | { \ | 170 | { \ |
172 | struct i2c_client *client = to_i2c_client(dev); \ | 171 | struct i2c_client *client = to_i2c_client(dev); \ |
173 | struct fscher_data *data = i2c_get_clientdata(client); \ | 172 | struct fscher_data *data = i2c_get_clientdata(client); \ |
diff --git a/drivers/i2c/chips/fscpos.c b/drivers/i2c/chips/fscpos.c index 2cac79145c75..3beaa6191ef4 100644 --- a/drivers/i2c/chips/fscpos.c +++ b/drivers/i2c/chips/fscpos.c | |||
@@ -245,19 +245,19 @@ static void reset_fan_alarm(struct i2c_client *client, int nr) | |||
245 | /* Volts */ | 245 | /* Volts */ |
246 | #define VOLT_FROM_REG(val, mult) ((val) * (mult) / 255) | 246 | #define VOLT_FROM_REG(val, mult) ((val) * (mult) / 255) |
247 | 247 | ||
248 | static ssize_t show_volt_12(struct device *dev, char *buf) | 248 | static ssize_t show_volt_12(struct device *dev, struct device_attribute *attr, char *buf) |
249 | { | 249 | { |
250 | struct fscpos_data *data = fscpos_update_device(dev); | 250 | struct fscpos_data *data = fscpos_update_device(dev); |
251 | return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[0], 14200)); | 251 | return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[0], 14200)); |
252 | } | 252 | } |
253 | 253 | ||
254 | static ssize_t show_volt_5(struct device *dev, char *buf) | 254 | static ssize_t show_volt_5(struct device *dev, struct device_attribute *attr, char *buf) |
255 | { | 255 | { |
256 | struct fscpos_data *data = fscpos_update_device(dev); | 256 | struct fscpos_data *data = fscpos_update_device(dev); |
257 | return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[1], 6600)); | 257 | return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[1], 6600)); |
258 | } | 258 | } |
259 | 259 | ||
260 | static ssize_t show_volt_batt(struct device *dev, char *buf) | 260 | static ssize_t show_volt_batt(struct device *dev, struct device_attribute *attr, char *buf) |
261 | { | 261 | { |
262 | struct fscpos_data *data = fscpos_update_device(dev); | 262 | struct fscpos_data *data = fscpos_update_device(dev); |
263 | return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[2], 3300)); | 263 | return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[2], 3300)); |
@@ -327,7 +327,7 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data | |||
327 | } | 327 | } |
328 | 328 | ||
329 | /* Event */ | 329 | /* Event */ |
330 | static ssize_t show_event(struct device *dev, char *buf) | 330 | static ssize_t show_event(struct device *dev, struct device_attribute *attr, char *buf) |
331 | { | 331 | { |
332 | /* bits 5..7 reserved => mask with 0x1f */ | 332 | /* bits 5..7 reserved => mask with 0x1f */ |
333 | struct fscpos_data *data = fscpos_update_device(dev); | 333 | struct fscpos_data *data = fscpos_update_device(dev); |
@@ -338,14 +338,14 @@ static ssize_t show_event(struct device *dev, char *buf) | |||
338 | * Sysfs stuff | 338 | * Sysfs stuff |
339 | */ | 339 | */ |
340 | #define create_getter(kind, sub) \ | 340 | #define create_getter(kind, sub) \ |
341 | static ssize_t sysfs_show_##kind##sub(struct device *dev, char *buf) \ | 341 | static ssize_t sysfs_show_##kind##sub(struct device *dev, struct device_attribute *attr, char *buf) \ |
342 | { \ | 342 | { \ |
343 | struct fscpos_data *data = fscpos_update_device(dev); \ | 343 | struct fscpos_data *data = fscpos_update_device(dev); \ |
344 | return show_##kind##sub(data, buf); \ | 344 | return show_##kind##sub(data, buf); \ |
345 | } | 345 | } |
346 | 346 | ||
347 | #define create_getter_n(kind, offset, sub) \ | 347 | #define create_getter_n(kind, offset, sub) \ |
348 | static ssize_t sysfs_show_##kind##offset##sub(struct device *dev, char\ | 348 | static ssize_t sysfs_show_##kind##offset##sub(struct device *dev, struct device_attribute *attr, char\ |
349 | *buf) \ | 349 | *buf) \ |
350 | { \ | 350 | { \ |
351 | struct fscpos_data *data = fscpos_update_device(dev); \ | 351 | struct fscpos_data *data = fscpos_update_device(dev); \ |
@@ -353,7 +353,7 @@ static ssize_t show_event(struct device *dev, char *buf) | |||
353 | } | 353 | } |
354 | 354 | ||
355 | #define create_setter(kind, sub, reg) \ | 355 | #define create_setter(kind, sub, reg) \ |
356 | static ssize_t sysfs_set_##kind##sub (struct device *dev, const char \ | 356 | static ssize_t sysfs_set_##kind##sub (struct device *dev, struct device_attribute *attr, const char \ |
357 | *buf, size_t count) \ | 357 | *buf, size_t count) \ |
358 | { \ | 358 | { \ |
359 | struct i2c_client *client = to_i2c_client(dev); \ | 359 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -362,7 +362,7 @@ static ssize_t show_event(struct device *dev, char *buf) | |||
362 | } | 362 | } |
363 | 363 | ||
364 | #define create_setter_n(kind, offset, sub, reg) \ | 364 | #define create_setter_n(kind, offset, sub, reg) \ |
365 | static ssize_t sysfs_set_##kind##offset##sub (struct device *dev, \ | 365 | static ssize_t sysfs_set_##kind##offset##sub (struct device *dev, struct device_attribute *attr, \ |
366 | const char *buf, size_t count) \ | 366 | const char *buf, size_t count) \ |
367 | { \ | 367 | { \ |
368 | struct i2c_client *client = to_i2c_client(dev); \ | 368 | struct i2c_client *client = to_i2c_client(dev); \ |
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c index c82d6ce21205..6bedf729dcf5 100644 --- a/drivers/i2c/chips/gl518sm.c +++ b/drivers/i2c/chips/gl518sm.c | |||
@@ -36,7 +36,6 @@ | |||
36 | * 2004-01-31 Code review and approval. (Jean Delvare) | 36 | * 2004-01-31 Code review and approval. (Jean Delvare) |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <linux/config.h> | ||
40 | #include <linux/module.h> | 39 | #include <linux/module.h> |
41 | #include <linux/init.h> | 40 | #include <linux/init.h> |
42 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
@@ -164,14 +163,14 @@ static struct i2c_driver gl518_driver = { | |||
164 | */ | 163 | */ |
165 | 164 | ||
166 | #define show(type, suffix, value) \ | 165 | #define show(type, suffix, value) \ |
167 | static ssize_t show_##suffix(struct device *dev, char *buf) \ | 166 | static ssize_t show_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ |
168 | { \ | 167 | { \ |
169 | struct gl518_data *data = gl518_update_device(dev); \ | 168 | struct gl518_data *data = gl518_update_device(dev); \ |
170 | return sprintf(buf, "%d\n", type##_FROM_REG(data->value)); \ | 169 | return sprintf(buf, "%d\n", type##_FROM_REG(data->value)); \ |
171 | } | 170 | } |
172 | 171 | ||
173 | #define show_fan(suffix, value, index) \ | 172 | #define show_fan(suffix, value, index) \ |
174 | static ssize_t show_##suffix(struct device *dev, char *buf) \ | 173 | static ssize_t show_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ |
175 | { \ | 174 | { \ |
176 | struct gl518_data *data = gl518_update_device(dev); \ | 175 | struct gl518_data *data = gl518_update_device(dev); \ |
177 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value[index], \ | 176 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value[index], \ |
@@ -205,7 +204,7 @@ show(BOOL, beep_enable, beep_enable); | |||
205 | show(BEEP_MASK, beep_mask, beep_mask); | 204 | show(BEEP_MASK, beep_mask, beep_mask); |
206 | 205 | ||
207 | #define set(type, suffix, value, reg) \ | 206 | #define set(type, suffix, value, reg) \ |
208 | static ssize_t set_##suffix(struct device *dev, const char *buf, \ | 207 | static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ |
209 | size_t count) \ | 208 | size_t count) \ |
210 | { \ | 209 | { \ |
211 | struct i2c_client *client = to_i2c_client(dev); \ | 210 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -220,7 +219,7 @@ static ssize_t set_##suffix(struct device *dev, const char *buf, \ | |||
220 | } | 219 | } |
221 | 220 | ||
222 | #define set_bits(type, suffix, value, reg, mask, shift) \ | 221 | #define set_bits(type, suffix, value, reg, mask, shift) \ |
223 | static ssize_t set_##suffix(struct device *dev, const char *buf, \ | 222 | static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ |
224 | size_t count) \ | 223 | size_t count) \ |
225 | { \ | 224 | { \ |
226 | struct i2c_client *client = to_i2c_client(dev); \ | 225 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -258,7 +257,7 @@ set_high(IN, in_max3, voltage_max[3], GL518_REG_VIN3_LIMIT); | |||
258 | set_bits(BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2); | 257 | set_bits(BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2); |
259 | set(BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM); | 258 | set(BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM); |
260 | 259 | ||
261 | static ssize_t set_fan_min1(struct device *dev, const char *buf, size_t count) | 260 | static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
262 | { | 261 | { |
263 | struct i2c_client *client = to_i2c_client(dev); | 262 | struct i2c_client *client = to_i2c_client(dev); |
264 | struct gl518_data *data = i2c_get_clientdata(client); | 263 | struct gl518_data *data = i2c_get_clientdata(client); |
@@ -284,7 +283,7 @@ static ssize_t set_fan_min1(struct device *dev, const char *buf, size_t count) | |||
284 | return count; | 283 | return count; |
285 | } | 284 | } |
286 | 285 | ||
287 | static ssize_t set_fan_min2(struct device *dev, const char *buf, size_t count) | 286 | static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
288 | { | 287 | { |
289 | struct i2c_client *client = to_i2c_client(dev); | 288 | struct i2c_client *client = to_i2c_client(dev); |
290 | struct gl518_data *data = i2c_get_clientdata(client); | 289 | struct gl518_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/i2c/chips/gl520sm.c b/drivers/i2c/chips/gl520sm.c index 3fd17e46ffc6..a13a504f5bfa 100644 --- a/drivers/i2c/chips/gl520sm.c +++ b/drivers/i2c/chips/gl520sm.c | |||
@@ -148,8 +148,8 @@ struct gl520_data { | |||
148 | 148 | ||
149 | #define sysfs_r(type, n, item, reg) \ | 149 | #define sysfs_r(type, n, item, reg) \ |
150 | static ssize_t get_##type##item (struct gl520_data *, char *, int); \ | 150 | static ssize_t get_##type##item (struct gl520_data *, char *, int); \ |
151 | static ssize_t get_##type##n##item (struct device *, char *); \ | 151 | static ssize_t get_##type##n##item (struct device *, struct device_attribute *attr, char *); \ |
152 | static ssize_t get_##type##n##item (struct device *dev, char *buf) \ | 152 | static ssize_t get_##type##n##item (struct device *dev, struct device_attribute *attr, char *buf) \ |
153 | { \ | 153 | { \ |
154 | struct gl520_data *data = gl520_update_device(dev); \ | 154 | struct gl520_data *data = gl520_update_device(dev); \ |
155 | return get_##type##item(data, buf, (n)); \ | 155 | return get_##type##item(data, buf, (n)); \ |
@@ -157,8 +157,8 @@ static ssize_t get_##type##n##item (struct device *dev, char *buf) \ | |||
157 | 157 | ||
158 | #define sysfs_w(type, n, item, reg) \ | 158 | #define sysfs_w(type, n, item, reg) \ |
159 | static ssize_t set_##type##item (struct i2c_client *, struct gl520_data *, const char *, size_t, int, int); \ | 159 | static ssize_t set_##type##item (struct i2c_client *, struct gl520_data *, const char *, size_t, int, int); \ |
160 | static ssize_t set_##type##n##item (struct device *, const char *, size_t); \ | 160 | static ssize_t set_##type##n##item (struct device *, struct device_attribute *attr, const char *, size_t); \ |
161 | static ssize_t set_##type##n##item (struct device *dev, const char *buf, size_t count) \ | 161 | static ssize_t set_##type##n##item (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
162 | { \ | 162 | { \ |
163 | struct i2c_client *client = to_i2c_client(dev); \ | 163 | struct i2c_client *client = to_i2c_client(dev); \ |
164 | struct gl520_data *data = i2c_get_clientdata(client); \ | 164 | struct gl520_data *data = i2c_get_clientdata(client); \ |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 7f29a8aff165..354a26295672 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -145,7 +145,6 @@ static inline void notresponding(struct isp1301 *isp) | |||
145 | static unsigned short normal_i2c[] = { | 145 | static unsigned short normal_i2c[] = { |
146 | ISP_BASE, ISP_BASE + 1, | 146 | ISP_BASE, ISP_BASE + 1, |
147 | I2C_CLIENT_END }; | 147 | I2C_CLIENT_END }; |
148 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
149 | 148 | ||
150 | I2C_CLIENT_INSMOD; | 149 | I2C_CLIENT_INSMOD; |
151 | 150 | ||
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c index cf7e6898754f..db20c9e47393 100644 --- a/drivers/i2c/chips/it87.c +++ b/drivers/i2c/chips/it87.c | |||
@@ -31,7 +31,6 @@ | |||
31 | type at module load time. | 31 | type at module load time. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/config.h> | ||
35 | #include <linux/module.h> | 34 | #include <linux/module.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
@@ -39,6 +38,7 @@ | |||
39 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
40 | #include <linux/i2c-sensor.h> | 39 | #include <linux/i2c-sensor.h> |
41 | #include <linux/i2c-vid.h> | 40 | #include <linux/i2c-vid.h> |
41 | #include <linux/hwmon-sysfs.h> | ||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | 43 | ||
44 | 44 | ||
@@ -173,8 +173,6 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
173 | ((val)+500)/1000),-128,127)) | 173 | ((val)+500)/1000),-128,127)) |
174 | #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) | 174 | #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) |
175 | 175 | ||
176 | #define ALARMS_FROM_REG(val) (val) | ||
177 | |||
178 | #define PWM_TO_REG(val) ((val) >> 1) | 176 | #define PWM_TO_REG(val) ((val) >> 1) |
179 | #define PWM_FROM_REG(val) (((val)&0x7f) << 1) | 177 | #define PWM_FROM_REG(val) (((val)&0x7f) << 1) |
180 | 178 | ||
@@ -241,27 +239,42 @@ static struct i2c_driver it87_driver = { | |||
241 | .detach_client = it87_detach_client, | 239 | .detach_client = it87_detach_client, |
242 | }; | 240 | }; |
243 | 241 | ||
244 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 242 | static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
243 | char *buf) | ||
245 | { | 244 | { |
245 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
246 | int nr = sensor_attr->index; | ||
247 | |||
246 | struct it87_data *data = it87_update_device(dev); | 248 | struct it87_data *data = it87_update_device(dev); |
247 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); | 249 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); |
248 | } | 250 | } |
249 | 251 | ||
250 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 252 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
253 | char *buf) | ||
251 | { | 254 | { |
255 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
256 | int nr = sensor_attr->index; | ||
257 | |||
252 | struct it87_data *data = it87_update_device(dev); | 258 | struct it87_data *data = it87_update_device(dev); |
253 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); | 259 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); |
254 | } | 260 | } |
255 | 261 | ||
256 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 262 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
263 | char *buf) | ||
257 | { | 264 | { |
265 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
266 | int nr = sensor_attr->index; | ||
267 | |||
258 | struct it87_data *data = it87_update_device(dev); | 268 | struct it87_data *data = it87_update_device(dev); |
259 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); | 269 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); |
260 | } | 270 | } |
261 | 271 | ||
262 | static ssize_t set_in_min(struct device *dev, const char *buf, | 272 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
263 | size_t count, int nr) | 273 | const char *buf, size_t count) |
264 | { | 274 | { |
275 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
276 | int nr = sensor_attr->index; | ||
277 | |||
265 | struct i2c_client *client = to_i2c_client(dev); | 278 | struct i2c_client *client = to_i2c_client(dev); |
266 | struct it87_data *data = i2c_get_clientdata(client); | 279 | struct it87_data *data = i2c_get_clientdata(client); |
267 | unsigned long val = simple_strtoul(buf, NULL, 10); | 280 | unsigned long val = simple_strtoul(buf, NULL, 10); |
@@ -273,9 +286,12 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
273 | up(&data->update_lock); | 286 | up(&data->update_lock); |
274 | return count; | 287 | return count; |
275 | } | 288 | } |
276 | static ssize_t set_in_max(struct device *dev, const char *buf, | 289 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
277 | size_t count, int nr) | 290 | const char *buf, size_t count) |
278 | { | 291 | { |
292 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
293 | int nr = sensor_attr->index; | ||
294 | |||
279 | struct i2c_client *client = to_i2c_client(dev); | 295 | struct i2c_client *client = to_i2c_client(dev); |
280 | struct it87_data *data = i2c_get_clientdata(client); | 296 | struct it87_data *data = i2c_get_clientdata(client); |
281 | unsigned long val = simple_strtoul(buf, NULL, 10); | 297 | unsigned long val = simple_strtoul(buf, NULL, 10); |
@@ -289,38 +305,14 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
289 | } | 305 | } |
290 | 306 | ||
291 | #define show_in_offset(offset) \ | 307 | #define show_in_offset(offset) \ |
292 | static ssize_t \ | 308 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
293 | show_in##offset (struct device *dev, char *buf) \ | 309 | show_in, NULL, offset); |
294 | { \ | ||
295 | return show_in(dev, buf, offset); \ | ||
296 | } \ | ||
297 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); | ||
298 | 310 | ||
299 | #define limit_in_offset(offset) \ | 311 | #define limit_in_offset(offset) \ |
300 | static ssize_t \ | 312 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
301 | show_in##offset##_min (struct device *dev, char *buf) \ | 313 | show_in_min, set_in_min, offset); \ |
302 | { \ | 314 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
303 | return show_in_min(dev, buf, offset); \ | 315 | show_in_max, set_in_max, offset); |
304 | } \ | ||
305 | static ssize_t \ | ||
306 | show_in##offset##_max (struct device *dev, char *buf) \ | ||
307 | { \ | ||
308 | return show_in_max(dev, buf, offset); \ | ||
309 | } \ | ||
310 | static ssize_t set_in##offset##_min (struct device *dev, \ | ||
311 | const char *buf, size_t count) \ | ||
312 | { \ | ||
313 | return set_in_min(dev, buf, count, offset); \ | ||
314 | } \ | ||
315 | static ssize_t set_in##offset##_max (struct device *dev, \ | ||
316 | const char *buf, size_t count) \ | ||
317 | { \ | ||
318 | return set_in_max(dev, buf, count, offset); \ | ||
319 | } \ | ||
320 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
321 | show_in##offset##_min, set_in##offset##_min); \ | ||
322 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
323 | show_in##offset##_max, set_in##offset##_max); | ||
324 | 316 | ||
325 | show_in_offset(0); | 317 | show_in_offset(0); |
326 | limit_in_offset(0); | 318 | limit_in_offset(0); |
@@ -341,24 +333,39 @@ limit_in_offset(7); | |||
341 | show_in_offset(8); | 333 | show_in_offset(8); |
342 | 334 | ||
343 | /* 3 temperatures */ | 335 | /* 3 temperatures */ |
344 | static ssize_t show_temp(struct device *dev, char *buf, int nr) | 336 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
337 | char *buf) | ||
345 | { | 338 | { |
339 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
340 | int nr = sensor_attr->index; | ||
341 | |||
346 | struct it87_data *data = it87_update_device(dev); | 342 | struct it87_data *data = it87_update_device(dev); |
347 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); | 343 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); |
348 | } | 344 | } |
349 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 345 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
346 | char *buf) | ||
350 | { | 347 | { |
348 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
349 | int nr = sensor_attr->index; | ||
350 | |||
351 | struct it87_data *data = it87_update_device(dev); | 351 | struct it87_data *data = it87_update_device(dev); |
352 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); | 352 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); |
353 | } | 353 | } |
354 | static ssize_t show_temp_min(struct device *dev, char *buf, int nr) | 354 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
355 | char *buf) | ||
355 | { | 356 | { |
357 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
358 | int nr = sensor_attr->index; | ||
359 | |||
356 | struct it87_data *data = it87_update_device(dev); | 360 | struct it87_data *data = it87_update_device(dev); |
357 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); | 361 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); |
358 | } | 362 | } |
359 | static ssize_t set_temp_max(struct device *dev, const char *buf, | 363 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
360 | size_t count, int nr) | 364 | const char *buf, size_t count) |
361 | { | 365 | { |
366 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
367 | int nr = sensor_attr->index; | ||
368 | |||
362 | struct i2c_client *client = to_i2c_client(dev); | 369 | struct i2c_client *client = to_i2c_client(dev); |
363 | struct it87_data *data = i2c_get_clientdata(client); | 370 | struct it87_data *data = i2c_get_clientdata(client); |
364 | int val = simple_strtol(buf, NULL, 10); | 371 | int val = simple_strtol(buf, NULL, 10); |
@@ -369,9 +376,12 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
369 | up(&data->update_lock); | 376 | up(&data->update_lock); |
370 | return count; | 377 | return count; |
371 | } | 378 | } |
372 | static ssize_t set_temp_min(struct device *dev, const char *buf, | 379 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
373 | size_t count, int nr) | 380 | const char *buf, size_t count) |
374 | { | 381 | { |
382 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
383 | int nr = sensor_attr->index; | ||
384 | |||
375 | struct i2c_client *client = to_i2c_client(dev); | 385 | struct i2c_client *client = to_i2c_client(dev); |
376 | struct it87_data *data = i2c_get_clientdata(client); | 386 | struct it87_data *data = i2c_get_clientdata(client); |
377 | int val = simple_strtol(buf, NULL, 10); | 387 | int val = simple_strtol(buf, NULL, 10); |
@@ -383,42 +393,23 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
383 | return count; | 393 | return count; |
384 | } | 394 | } |
385 | #define show_temp_offset(offset) \ | 395 | #define show_temp_offset(offset) \ |
386 | static ssize_t show_temp_##offset (struct device *dev, char *buf) \ | 396 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
387 | { \ | 397 | show_temp, NULL, offset - 1); \ |
388 | return show_temp(dev, buf, offset - 1); \ | 398 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
389 | } \ | 399 | show_temp_max, set_temp_max, offset - 1); \ |
390 | static ssize_t \ | 400 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
391 | show_temp_##offset##_max (struct device *dev, char *buf) \ | 401 | show_temp_min, set_temp_min, offset - 1); |
392 | { \ | ||
393 | return show_temp_max(dev, buf, offset - 1); \ | ||
394 | } \ | ||
395 | static ssize_t \ | ||
396 | show_temp_##offset##_min (struct device *dev, char *buf) \ | ||
397 | { \ | ||
398 | return show_temp_min(dev, buf, offset - 1); \ | ||
399 | } \ | ||
400 | static ssize_t set_temp_##offset##_max (struct device *dev, \ | ||
401 | const char *buf, size_t count) \ | ||
402 | { \ | ||
403 | return set_temp_max(dev, buf, count, offset - 1); \ | ||
404 | } \ | ||
405 | static ssize_t set_temp_##offset##_min (struct device *dev, \ | ||
406 | const char *buf, size_t count) \ | ||
407 | { \ | ||
408 | return set_temp_min(dev, buf, count, offset - 1); \ | ||
409 | } \ | ||
410 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \ | ||
411 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
412 | show_temp_##offset##_max, set_temp_##offset##_max); \ | ||
413 | static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | ||
414 | show_temp_##offset##_min, set_temp_##offset##_min); | ||
415 | 402 | ||
416 | show_temp_offset(1); | 403 | show_temp_offset(1); |
417 | show_temp_offset(2); | 404 | show_temp_offset(2); |
418 | show_temp_offset(3); | 405 | show_temp_offset(3); |
419 | 406 | ||
420 | static ssize_t show_sensor(struct device *dev, char *buf, int nr) | 407 | static ssize_t show_sensor(struct device *dev, struct device_attribute *attr, |
408 | char *buf) | ||
421 | { | 409 | { |
410 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
411 | int nr = sensor_attr->index; | ||
412 | |||
422 | struct it87_data *data = it87_update_device(dev); | 413 | struct it87_data *data = it87_update_device(dev); |
423 | u8 reg = data->sensor; /* In case the value is updated while we use it */ | 414 | u8 reg = data->sensor; /* In case the value is updated while we use it */ |
424 | 415 | ||
@@ -428,9 +419,12 @@ static ssize_t show_sensor(struct device *dev, char *buf, int nr) | |||
428 | return sprintf(buf, "2\n"); /* thermistor */ | 419 | return sprintf(buf, "2\n"); /* thermistor */ |
429 | return sprintf(buf, "0\n"); /* disabled */ | 420 | return sprintf(buf, "0\n"); /* disabled */ |
430 | } | 421 | } |
431 | static ssize_t set_sensor(struct device *dev, const char *buf, | 422 | static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, |
432 | size_t count, int nr) | 423 | const char *buf, size_t count) |
433 | { | 424 | { |
425 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
426 | int nr = sensor_attr->index; | ||
427 | |||
434 | struct i2c_client *client = to_i2c_client(dev); | 428 | struct i2c_client *client = to_i2c_client(dev); |
435 | struct it87_data *data = i2c_get_clientdata(client); | 429 | struct it87_data *data = i2c_get_clientdata(client); |
436 | int val = simple_strtol(buf, NULL, 10); | 430 | int val = simple_strtol(buf, NULL, 10); |
@@ -453,53 +447,67 @@ static ssize_t set_sensor(struct device *dev, const char *buf, | |||
453 | return count; | 447 | return count; |
454 | } | 448 | } |
455 | #define show_sensor_offset(offset) \ | 449 | #define show_sensor_offset(offset) \ |
456 | static ssize_t show_sensor_##offset (struct device *dev, char *buf) \ | 450 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ |
457 | { \ | 451 | show_sensor, set_sensor, offset - 1); |
458 | return show_sensor(dev, buf, offset - 1); \ | ||
459 | } \ | ||
460 | static ssize_t set_sensor_##offset (struct device *dev, \ | ||
461 | const char *buf, size_t count) \ | ||
462 | { \ | ||
463 | return set_sensor(dev, buf, count, offset - 1); \ | ||
464 | } \ | ||
465 | static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ | ||
466 | show_sensor_##offset, set_sensor_##offset); | ||
467 | 452 | ||
468 | show_sensor_offset(1); | 453 | show_sensor_offset(1); |
469 | show_sensor_offset(2); | 454 | show_sensor_offset(2); |
470 | show_sensor_offset(3); | 455 | show_sensor_offset(3); |
471 | 456 | ||
472 | /* 3 Fans */ | 457 | /* 3 Fans */ |
473 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 458 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
459 | char *buf) | ||
474 | { | 460 | { |
461 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
462 | int nr = sensor_attr->index; | ||
463 | |||
475 | struct it87_data *data = it87_update_device(dev); | 464 | struct it87_data *data = it87_update_device(dev); |
476 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 465 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], |
477 | DIV_FROM_REG(data->fan_div[nr]))); | 466 | DIV_FROM_REG(data->fan_div[nr]))); |
478 | } | 467 | } |
479 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 468 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
469 | char *buf) | ||
480 | { | 470 | { |
471 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
472 | int nr = sensor_attr->index; | ||
473 | |||
481 | struct it87_data *data = it87_update_device(dev); | 474 | struct it87_data *data = it87_update_device(dev); |
482 | return sprintf(buf,"%d\n", | 475 | return sprintf(buf,"%d\n", |
483 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); | 476 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); |
484 | } | 477 | } |
485 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 478 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
479 | char *buf) | ||
486 | { | 480 | { |
481 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
482 | int nr = sensor_attr->index; | ||
483 | |||
487 | struct it87_data *data = it87_update_device(dev); | 484 | struct it87_data *data = it87_update_device(dev); |
488 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); | 485 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); |
489 | } | 486 | } |
490 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | 487 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, |
488 | char *buf) | ||
491 | { | 489 | { |
490 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
491 | int nr = sensor_attr->index; | ||
492 | |||
492 | struct it87_data *data = it87_update_device(dev); | 493 | struct it87_data *data = it87_update_device(dev); |
493 | return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); | 494 | return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); |
494 | } | 495 | } |
495 | static ssize_t show_pwm(struct device *dev, char *buf, int nr) | 496 | static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
497 | char *buf) | ||
496 | { | 498 | { |
499 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
500 | int nr = sensor_attr->index; | ||
501 | |||
497 | struct it87_data *data = it87_update_device(dev); | 502 | struct it87_data *data = it87_update_device(dev); |
498 | return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); | 503 | return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); |
499 | } | 504 | } |
500 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 505 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
501 | size_t count, int nr) | 506 | const char *buf, size_t count) |
502 | { | 507 | { |
508 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
509 | int nr = sensor_attr->index; | ||
510 | |||
503 | struct i2c_client *client = to_i2c_client(dev); | 511 | struct i2c_client *client = to_i2c_client(dev); |
504 | struct it87_data *data = i2c_get_clientdata(client); | 512 | struct it87_data *data = i2c_get_clientdata(client); |
505 | int val = simple_strtol(buf, NULL, 10); | 513 | int val = simple_strtol(buf, NULL, 10); |
@@ -510,9 +518,12 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
510 | up(&data->update_lock); | 518 | up(&data->update_lock); |
511 | return count; | 519 | return count; |
512 | } | 520 | } |
513 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 521 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
514 | size_t count, int nr) | 522 | const char *buf, size_t count) |
515 | { | 523 | { |
524 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
525 | int nr = sensor_attr->index; | ||
526 | |||
516 | struct i2c_client *client = to_i2c_client(dev); | 527 | struct i2c_client *client = to_i2c_client(dev); |
517 | struct it87_data *data = i2c_get_clientdata(client); | 528 | struct it87_data *data = i2c_get_clientdata(client); |
518 | int val = simple_strtol(buf, NULL, 10); | 529 | int val = simple_strtol(buf, NULL, 10); |
@@ -550,9 +561,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
550 | up(&data->update_lock); | 561 | up(&data->update_lock); |
551 | return count; | 562 | return count; |
552 | } | 563 | } |
553 | static ssize_t set_pwm_enable(struct device *dev, const char *buf, | 564 | static ssize_t set_pwm_enable(struct device *dev, |
554 | size_t count, int nr) | 565 | struct device_attribute *attr, const char *buf, size_t count) |
555 | { | 566 | { |
567 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
568 | int nr = sensor_attr->index; | ||
569 | |||
556 | struct i2c_client *client = to_i2c_client(dev); | 570 | struct i2c_client *client = to_i2c_client(dev); |
557 | struct it87_data *data = i2c_get_clientdata(client); | 571 | struct it87_data *data = i2c_get_clientdata(client); |
558 | int val = simple_strtol(buf, NULL, 10); | 572 | int val = simple_strtol(buf, NULL, 10); |
@@ -581,9 +595,12 @@ static ssize_t set_pwm_enable(struct device *dev, const char *buf, | |||
581 | up(&data->update_lock); | 595 | up(&data->update_lock); |
582 | return count; | 596 | return count; |
583 | } | 597 | } |
584 | static ssize_t set_pwm(struct device *dev, const char *buf, | 598 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
585 | size_t count, int nr) | 599 | const char *buf, size_t count) |
586 | { | 600 | { |
601 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
602 | int nr = sensor_attr->index; | ||
603 | |||
587 | struct i2c_client *client = to_i2c_client(dev); | 604 | struct i2c_client *client = to_i2c_client(dev); |
588 | struct it87_data *data = i2c_get_clientdata(client); | 605 | struct it87_data *data = i2c_get_clientdata(client); |
589 | int val = simple_strtol(buf, NULL, 10); | 606 | int val = simple_strtol(buf, NULL, 10); |
@@ -599,85 +616,44 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
599 | return count; | 616 | return count; |
600 | } | 617 | } |
601 | 618 | ||
602 | #define show_fan_offset(offset) \ | 619 | #define show_fan_offset(offset) \ |
603 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 620 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
604 | { \ | 621 | show_fan, NULL, offset - 1); \ |
605 | return show_fan(dev, buf, offset - 1); \ | 622 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
606 | } \ | 623 | show_fan_min, set_fan_min, offset - 1); \ |
607 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 624 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
608 | { \ | 625 | show_fan_div, set_fan_div, offset - 1); |
609 | return show_fan_min(dev, buf, offset - 1); \ | ||
610 | } \ | ||
611 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | ||
612 | { \ | ||
613 | return show_fan_div(dev, buf, offset - 1); \ | ||
614 | } \ | ||
615 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
616 | const char *buf, size_t count) \ | ||
617 | { \ | ||
618 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
619 | } \ | ||
620 | static ssize_t set_fan_##offset##_div (struct device *dev, \ | ||
621 | const char *buf, size_t count) \ | ||
622 | { \ | ||
623 | return set_fan_div(dev, buf, count, offset - 1); \ | ||
624 | } \ | ||
625 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \ | ||
626 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
627 | show_fan_##offset##_min, set_fan_##offset##_min); \ | ||
628 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | ||
629 | show_fan_##offset##_div, set_fan_##offset##_div); | ||
630 | 626 | ||
631 | show_fan_offset(1); | 627 | show_fan_offset(1); |
632 | show_fan_offset(2); | 628 | show_fan_offset(2); |
633 | show_fan_offset(3); | 629 | show_fan_offset(3); |
634 | 630 | ||
635 | #define show_pwm_offset(offset) \ | 631 | #define show_pwm_offset(offset) \ |
636 | static ssize_t show_pwm##offset##_enable (struct device *dev, \ | 632 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
637 | char *buf) \ | 633 | show_pwm_enable, set_pwm_enable, offset - 1); \ |
638 | { \ | 634 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
639 | return show_pwm_enable(dev, buf, offset - 1); \ | 635 | show_pwm, set_pwm, offset - 1); |
640 | } \ | ||
641 | static ssize_t show_pwm##offset (struct device *dev, char *buf) \ | ||
642 | { \ | ||
643 | return show_pwm(dev, buf, offset - 1); \ | ||
644 | } \ | ||
645 | static ssize_t set_pwm##offset##_enable (struct device *dev, \ | ||
646 | const char *buf, size_t count) \ | ||
647 | { \ | ||
648 | return set_pwm_enable(dev, buf, count, offset - 1); \ | ||
649 | } \ | ||
650 | static ssize_t set_pwm##offset (struct device *dev, \ | ||
651 | const char *buf, size_t count) \ | ||
652 | { \ | ||
653 | return set_pwm(dev, buf, count, offset - 1); \ | ||
654 | } \ | ||
655 | static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | ||
656 | show_pwm##offset##_enable, \ | ||
657 | set_pwm##offset##_enable); \ | ||
658 | static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | ||
659 | show_pwm##offset , set_pwm##offset ); | ||
660 | 636 | ||
661 | show_pwm_offset(1); | 637 | show_pwm_offset(1); |
662 | show_pwm_offset(2); | 638 | show_pwm_offset(2); |
663 | show_pwm_offset(3); | 639 | show_pwm_offset(3); |
664 | 640 | ||
665 | /* Alarms */ | 641 | /* Alarms */ |
666 | static ssize_t show_alarms(struct device *dev, char *buf) | 642 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
667 | { | 643 | { |
668 | struct it87_data *data = it87_update_device(dev); | 644 | struct it87_data *data = it87_update_device(dev); |
669 | return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); | 645 | return sprintf(buf, "%u\n", data->alarms); |
670 | } | 646 | } |
671 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 647 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
672 | 648 | ||
673 | static ssize_t | 649 | static ssize_t |
674 | show_vrm_reg(struct device *dev, char *buf) | 650 | show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
675 | { | 651 | { |
676 | struct it87_data *data = it87_update_device(dev); | 652 | struct it87_data *data = it87_update_device(dev); |
677 | return sprintf(buf, "%ld\n", (long) data->vrm); | 653 | return sprintf(buf, "%ld\n", (long) data->vrm); |
678 | } | 654 | } |
679 | static ssize_t | 655 | static ssize_t |
680 | store_vrm_reg(struct device *dev, const char *buf, size_t count) | 656 | store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
681 | { | 657 | { |
682 | struct i2c_client *client = to_i2c_client(dev); | 658 | struct i2c_client *client = to_i2c_client(dev); |
683 | struct it87_data *data = i2c_get_clientdata(client); | 659 | struct it87_data *data = i2c_get_clientdata(client); |
@@ -693,7 +669,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | |||
693 | device_create_file(&client->dev, &dev_attr_vrm) | 669 | device_create_file(&client->dev, &dev_attr_vrm) |
694 | 670 | ||
695 | static ssize_t | 671 | static ssize_t |
696 | show_vid_reg(struct device *dev, char *buf) | 672 | show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
697 | { | 673 | { |
698 | struct it87_data *data = it87_update_device(dev); | 674 | struct it87_data *data = it87_update_device(dev); |
699 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); | 675 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); |
@@ -864,60 +840,60 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
864 | it87_init_client(new_client, data); | 840 | it87_init_client(new_client, data); |
865 | 841 | ||
866 | /* Register sysfs hooks */ | 842 | /* Register sysfs hooks */ |
867 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 843 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); |
868 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 844 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); |
869 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 845 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); |
870 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 846 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); |
871 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 847 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); |
872 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 848 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); |
873 | device_create_file(&new_client->dev, &dev_attr_in6_input); | 849 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); |
874 | device_create_file(&new_client->dev, &dev_attr_in7_input); | 850 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); |
875 | device_create_file(&new_client->dev, &dev_attr_in8_input); | 851 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); |
876 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 852 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); |
877 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 853 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); |
878 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 854 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); |
879 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 855 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); |
880 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 856 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); |
881 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 857 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); |
882 | device_create_file(&new_client->dev, &dev_attr_in6_min); | 858 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); |
883 | device_create_file(&new_client->dev, &dev_attr_in7_min); | 859 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); |
884 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 860 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); |
885 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 861 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); |
886 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 862 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); |
887 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 863 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); |
888 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 864 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); |
889 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 865 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); |
890 | device_create_file(&new_client->dev, &dev_attr_in6_max); | 866 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); |
891 | device_create_file(&new_client->dev, &dev_attr_in7_max); | 867 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); |
892 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 868 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); |
893 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 869 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); |
894 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 870 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); |
895 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 871 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); |
896 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 872 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); |
897 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 873 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); |
898 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 874 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); |
899 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 875 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); |
900 | device_create_file(&new_client->dev, &dev_attr_temp3_min); | 876 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); |
901 | device_create_file(&new_client->dev, &dev_attr_temp1_type); | 877 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr); |
902 | device_create_file(&new_client->dev, &dev_attr_temp2_type); | 878 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr); |
903 | device_create_file(&new_client->dev, &dev_attr_temp3_type); | 879 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr); |
904 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 880 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); |
905 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 881 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr); |
906 | device_create_file(&new_client->dev, &dev_attr_fan3_input); | 882 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr); |
907 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 883 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr); |
908 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 884 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr); |
909 | device_create_file(&new_client->dev, &dev_attr_fan3_min); | 885 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr); |
910 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 886 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr); |
911 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 887 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr); |
912 | device_create_file(&new_client->dev, &dev_attr_fan3_div); | 888 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr); |
913 | device_create_file(&new_client->dev, &dev_attr_alarms); | 889 | device_create_file(&new_client->dev, &dev_attr_alarms); |
914 | if (enable_pwm_interface) { | 890 | if (enable_pwm_interface) { |
915 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 891 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr); |
916 | device_create_file(&new_client->dev, &dev_attr_pwm2_enable); | 892 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr); |
917 | device_create_file(&new_client->dev, &dev_attr_pwm3_enable); | 893 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr); |
918 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 894 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); |
919 | device_create_file(&new_client->dev, &dev_attr_pwm2); | 895 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); |
920 | device_create_file(&new_client->dev, &dev_attr_pwm3); | 896 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); |
921 | } | 897 | } |
922 | 898 | ||
923 | if (data->type == it8712) { | 899 | if (data->type == it8712) { |
@@ -954,7 +930,7 @@ static int it87_detach_client(struct i2c_client *client) | |||
954 | return 0; | 930 | return 0; |
955 | } | 931 | } |
956 | 932 | ||
957 | /* The SMBus locks itself, but ISA access must be locked explicitely! | 933 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
958 | We don't want to lock the whole ISA bus, so we lock each client | 934 | We don't want to lock the whole ISA bus, so we lock each client |
959 | separately. | 935 | separately. |
960 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 936 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
@@ -974,7 +950,7 @@ static int it87_read_value(struct i2c_client *client, u8 reg) | |||
974 | return i2c_smbus_read_byte_data(client, reg); | 950 | return i2c_smbus_read_byte_data(client, reg); |
975 | } | 951 | } |
976 | 952 | ||
977 | /* The SMBus locks itself, but ISA access muse be locked explicitely! | 953 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
978 | We don't want to lock the whole ISA bus, so we lock each client | 954 | We don't want to lock the whole ISA bus, so we lock each client |
979 | separately. | 955 | separately. |
980 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 956 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
diff --git a/drivers/i2c/chips/lm63.c b/drivers/i2c/chips/lm63.c index 14cc5af03739..7c6f9ea5a254 100644 --- a/drivers/i2c/chips/lm63.c +++ b/drivers/i2c/chips/lm63.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor | 2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor |
3 | * with integrated fan control | 3 | * with integrated fan control |
4 | * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org> |
5 | * Based on the lm90 driver. | 5 | * Based on the lm90 driver. |
6 | * | 6 | * |
7 | * The LM63 is a sensor chip made by National Semiconductor. It measures | 7 | * The LM63 is a sensor chip made by National Semiconductor. It measures |
@@ -37,13 +37,13 @@ | |||
37 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 37 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/init.h> | 41 | #include <linux/init.h> |
43 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
44 | #include <linux/jiffies.h> | 43 | #include <linux/jiffies.h> |
45 | #include <linux/i2c.h> | 44 | #include <linux/i2c.h> |
46 | #include <linux/i2c-sensor.h> | 45 | #include <linux/i2c-sensor.h> |
46 | #include <linux/hwmon-sysfs.h> | ||
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Addresses to scan | 49 | * Addresses to scan |
@@ -99,9 +99,9 @@ SENSORS_INSMOD_1(lm63); | |||
99 | * Conversions and various macros | 99 | * Conversions and various macros |
100 | * For tachometer counts, the LM63 uses 16-bit values. | 100 | * For tachometer counts, the LM63 uses 16-bit values. |
101 | * For local temperature and high limit, remote critical limit and hysteresis | 101 | * For local temperature and high limit, remote critical limit and hysteresis |
102 | * value, it uses signed 8-bit values with LSB = 1 degree Celcius. | 102 | * value, it uses signed 8-bit values with LSB = 1 degree Celsius. |
103 | * For remote temperature, low and high limits, it uses signed 11-bit values | 103 | * For remote temperature, low and high limits, it uses signed 11-bit values |
104 | * with LSB = 0.125 degree Celcius, left-justified in 16-bit registers. | 104 | * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
105 | */ | 105 | */ |
106 | 106 | ||
107 | #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ | 107 | #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ |
@@ -158,16 +158,16 @@ struct lm63_data { | |||
158 | 158 | ||
159 | /* registers values */ | 159 | /* registers values */ |
160 | u8 config, config_fan; | 160 | u8 config, config_fan; |
161 | u16 fan1_input; | 161 | u16 fan[2]; /* 0: input |
162 | u16 fan1_low; | 162 | 1: low limit */ |
163 | u8 pwm1_freq; | 163 | u8 pwm1_freq; |
164 | u8 pwm1_value; | 164 | u8 pwm1_value; |
165 | s8 temp1_input; | 165 | s8 temp8[3]; /* 0: local input |
166 | s8 temp1_high; | 166 | 1: local high limit |
167 | s16 temp2_input; | 167 | 2: remote critical limit */ |
168 | s16 temp2_high; | 168 | s16 temp11[3]; /* 0: remote input |
169 | s16 temp2_low; | 169 | 1: remote low limit |
170 | s8 temp2_crit; | 170 | 2: remote high limit */ |
171 | u8 temp2_crit_hyst; | 171 | u8 temp2_crit_hyst; |
172 | u8 alarms; | 172 | u8 alarms; |
173 | }; | 173 | }; |
@@ -176,33 +176,33 @@ struct lm63_data { | |||
176 | * Sysfs callback functions and files | 176 | * Sysfs callback functions and files |
177 | */ | 177 | */ |
178 | 178 | ||
179 | #define show_fan(value) \ | 179 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
180 | static ssize_t show_##value(struct device *dev, char *buf) \ | 180 | char *buf) |
181 | { \ | 181 | { |
182 | struct lm63_data *data = lm63_update_device(dev); \ | 182 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
183 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \ | 183 | struct lm63_data *data = lm63_update_device(dev); |
184 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index])); | ||
184 | } | 185 | } |
185 | show_fan(fan1_input); | ||
186 | show_fan(fan1_low); | ||
187 | 186 | ||
188 | static ssize_t set_fan1_low(struct device *dev, const char *buf, | 187 | static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, |
189 | size_t count) | 188 | const char *buf, size_t count) |
190 | { | 189 | { |
191 | struct i2c_client *client = to_i2c_client(dev); | 190 | struct i2c_client *client = to_i2c_client(dev); |
192 | struct lm63_data *data = i2c_get_clientdata(client); | 191 | struct lm63_data *data = i2c_get_clientdata(client); |
193 | unsigned long val = simple_strtoul(buf, NULL, 10); | 192 | unsigned long val = simple_strtoul(buf, NULL, 10); |
194 | 193 | ||
195 | down(&data->update_lock); | 194 | down(&data->update_lock); |
196 | data->fan1_low = FAN_TO_REG(val); | 195 | data->fan[1] = FAN_TO_REG(val); |
197 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, | 196 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, |
198 | data->fan1_low & 0xFF); | 197 | data->fan[1] & 0xFF); |
199 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, | 198 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, |
200 | data->fan1_low >> 8); | 199 | data->fan[1] >> 8); |
201 | up(&data->update_lock); | 200 | up(&data->update_lock); |
202 | return count; | 201 | return count; |
203 | } | 202 | } |
204 | 203 | ||
205 | static ssize_t show_pwm1(struct device *dev, char *buf) | 204 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, |
205 | char *buf) | ||
206 | { | 206 | { |
207 | struct lm63_data *data = lm63_update_device(dev); | 207 | struct lm63_data *data = lm63_update_device(dev); |
208 | return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? | 208 | return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? |
@@ -210,7 +210,8 @@ static ssize_t show_pwm1(struct device *dev, char *buf) | |||
210 | (2 * data->pwm1_freq)); | 210 | (2 * data->pwm1_freq)); |
211 | } | 211 | } |
212 | 212 | ||
213 | static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) | 213 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, |
214 | const char *buf, size_t count) | ||
214 | { | 215 | { |
215 | struct i2c_client *client = to_i2c_client(dev); | 216 | struct i2c_client *client = to_i2c_client(dev); |
216 | struct lm63_data *data = i2c_get_clientdata(client); | 217 | struct lm63_data *data = i2c_get_clientdata(client); |
@@ -229,77 +230,83 @@ static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) | |||
229 | return count; | 230 | return count; |
230 | } | 231 | } |
231 | 232 | ||
232 | static ssize_t show_pwm1_enable(struct device *dev, char *buf) | 233 | static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy, |
234 | char *buf) | ||
233 | { | 235 | { |
234 | struct lm63_data *data = lm63_update_device(dev); | 236 | struct lm63_data *data = lm63_update_device(dev); |
235 | return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); | 237 | return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); |
236 | } | 238 | } |
237 | 239 | ||
238 | #define show_temp8(value) \ | 240 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
239 | static ssize_t show_##value(struct device *dev, char *buf) \ | 241 | char *buf) |
240 | { \ | 242 | { |
241 | struct lm63_data *data = lm63_update_device(dev); \ | 243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
242 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \ | 244 | struct lm63_data *data = lm63_update_device(dev); |
245 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])); | ||
243 | } | 246 | } |
244 | #define show_temp11(value) \ | 247 | |
245 | static ssize_t show_##value(struct device *dev, char *buf) \ | 248 | static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, |
246 | { \ | 249 | const char *buf, size_t count) |
247 | struct lm63_data *data = lm63_update_device(dev); \ | 250 | { |
248 | return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \ | 251 | struct i2c_client *client = to_i2c_client(dev); |
252 | struct lm63_data *data = i2c_get_clientdata(client); | ||
253 | long val = simple_strtol(buf, NULL, 10); | ||
254 | |||
255 | down(&data->update_lock); | ||
256 | data->temp8[1] = TEMP8_TO_REG(val); | ||
257 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); | ||
258 | up(&data->update_lock); | ||
259 | return count; | ||
249 | } | 260 | } |
250 | show_temp8(temp1_input); | 261 | |
251 | show_temp8(temp1_high); | 262 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
252 | show_temp11(temp2_input); | 263 | char *buf) |
253 | show_temp11(temp2_high); | 264 | { |
254 | show_temp11(temp2_low); | 265 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
255 | show_temp8(temp2_crit); | 266 | struct lm63_data *data = lm63_update_device(dev); |
256 | 267 | return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])); | |
257 | #define set_temp8(value, reg) \ | ||
258 | static ssize_t set_##value(struct device *dev, const char *buf, \ | ||
259 | size_t count) \ | ||
260 | { \ | ||
261 | struct i2c_client *client = to_i2c_client(dev); \ | ||
262 | struct lm63_data *data = i2c_get_clientdata(client); \ | ||
263 | long val = simple_strtol(buf, NULL, 10); \ | ||
264 | \ | ||
265 | down(&data->update_lock); \ | ||
266 | data->value = TEMP8_TO_REG(val); \ | ||
267 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
268 | up(&data->update_lock); \ | ||
269 | return count; \ | ||
270 | } | 268 | } |
271 | #define set_temp11(value, reg_msb, reg_lsb) \ | 269 | |
272 | static ssize_t set_##value(struct device *dev, const char *buf, \ | 270 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
273 | size_t count) \ | 271 | const char *buf, size_t count) |
274 | { \ | 272 | { |
275 | struct i2c_client *client = to_i2c_client(dev); \ | 273 | static const u8 reg[4] = { |
276 | struct lm63_data *data = i2c_get_clientdata(client); \ | 274 | LM63_REG_REMOTE_LOW_MSB, |
277 | long val = simple_strtol(buf, NULL, 10); \ | 275 | LM63_REG_REMOTE_LOW_LSB, |
278 | \ | 276 | LM63_REG_REMOTE_HIGH_MSB, |
279 | down(&data->update_lock); \ | 277 | LM63_REG_REMOTE_HIGH_LSB, |
280 | data->value = TEMP11_TO_REG(val); \ | 278 | }; |
281 | i2c_smbus_write_byte_data(client, reg_msb, data->value >> 8); \ | 279 | |
282 | i2c_smbus_write_byte_data(client, reg_lsb, data->value & 0xff); \ | 280 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
283 | up(&data->update_lock); \ | 281 | struct i2c_client *client = to_i2c_client(dev); |
284 | return count; \ | 282 | struct lm63_data *data = i2c_get_clientdata(client); |
283 | long val = simple_strtol(buf, NULL, 10); | ||
284 | int nr = attr->index; | ||
285 | |||
286 | down(&data->update_lock); | ||
287 | data->temp11[nr] = TEMP11_TO_REG(val); | ||
288 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | ||
289 | data->temp11[nr] >> 8); | ||
290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | ||
291 | data->temp11[nr] & 0xff); | ||
292 | up(&data->update_lock); | ||
293 | return count; | ||
285 | } | 294 | } |
286 | set_temp8(temp1_high, LM63_REG_LOCAL_HIGH); | ||
287 | set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB); | ||
288 | set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB); | ||
289 | 295 | ||
290 | /* Hysteresis register holds a relative value, while we want to present | 296 | /* Hysteresis register holds a relative value, while we want to present |
291 | an absolute to user-space */ | 297 | an absolute to user-space */ |
292 | static ssize_t show_temp2_crit_hyst(struct device *dev, char *buf) | 298 | static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, |
299 | char *buf) | ||
293 | { | 300 | { |
294 | struct lm63_data *data = lm63_update_device(dev); | 301 | struct lm63_data *data = lm63_update_device(dev); |
295 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit) | 302 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2]) |
296 | - TEMP8_FROM_REG(data->temp2_crit_hyst)); | 303 | - TEMP8_FROM_REG(data->temp2_crit_hyst)); |
297 | } | 304 | } |
298 | 305 | ||
299 | /* And now the other way around, user-space provides an absolute | 306 | /* And now the other way around, user-space provides an absolute |
300 | hysteresis value and we have to store a relative one */ | 307 | hysteresis value and we have to store a relative one */ |
301 | static ssize_t set_temp2_crit_hyst(struct device *dev, const char *buf, | 308 | static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, |
302 | size_t count) | 309 | const char *buf, size_t count) |
303 | { | 310 | { |
304 | struct i2c_client *client = to_i2c_client(dev); | 311 | struct i2c_client *client = to_i2c_client(dev); |
305 | struct lm63_data *data = i2c_get_clientdata(client); | 312 | struct lm63_data *data = i2c_get_clientdata(client); |
@@ -307,36 +314,37 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, const char *buf, | |||
307 | long hyst; | 314 | long hyst; |
308 | 315 | ||
309 | down(&data->update_lock); | 316 | down(&data->update_lock); |
310 | hyst = TEMP8_FROM_REG(data->temp2_crit) - val; | 317 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; |
311 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, | 318 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, |
312 | HYST_TO_REG(hyst)); | 319 | HYST_TO_REG(hyst)); |
313 | up(&data->update_lock); | 320 | up(&data->update_lock); |
314 | return count; | 321 | return count; |
315 | } | 322 | } |
316 | 323 | ||
317 | static ssize_t show_alarms(struct device *dev, char *buf) | 324 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
325 | char *buf) | ||
318 | { | 326 | { |
319 | struct lm63_data *data = lm63_update_device(dev); | 327 | struct lm63_data *data = lm63_update_device(dev); |
320 | return sprintf(buf, "%u\n", data->alarms); | 328 | return sprintf(buf, "%u\n", data->alarms); |
321 | } | 329 | } |
322 | 330 | ||
323 | static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL); | 331 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
324 | static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low, | 332 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, |
325 | set_fan1_low); | 333 | set_fan, 1); |
326 | 334 | ||
327 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); | 335 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); |
328 | static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); | 336 | static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); |
329 | 337 | ||
330 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); | 338 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); |
331 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high, | 339 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
332 | set_temp1_high); | 340 | set_temp8, 1); |
333 | 341 | ||
334 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL); | 342 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
335 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low, | 343 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
336 | set_temp2_low); | 344 | set_temp11, 1); |
337 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high, | 345 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
338 | set_temp2_high); | 346 | set_temp11, 2); |
339 | static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL); | 347 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); |
340 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, | 348 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, |
341 | set_temp2_crit_hyst); | 349 | set_temp2_crit_hyst); |
342 | 350 | ||
@@ -430,17 +438,25 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
430 | 438 | ||
431 | /* Register sysfs hooks */ | 439 | /* Register sysfs hooks */ |
432 | if (data->config & 0x04) { /* tachometer enabled */ | 440 | if (data->config & 0x04) { /* tachometer enabled */ |
433 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 441 | device_create_file(&new_client->dev, |
434 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 442 | &sensor_dev_attr_fan1_input.dev_attr); |
443 | device_create_file(&new_client->dev, | ||
444 | &sensor_dev_attr_fan1_min.dev_attr); | ||
435 | } | 445 | } |
436 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 446 | device_create_file(&new_client->dev, &dev_attr_pwm1); |
437 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 447 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); |
438 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 448 | device_create_file(&new_client->dev, |
439 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 449 | &sensor_dev_attr_temp1_input.dev_attr); |
440 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 450 | device_create_file(&new_client->dev, |
441 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 451 | &sensor_dev_attr_temp2_input.dev_attr); |
442 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 452 | device_create_file(&new_client->dev, |
443 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 453 | &sensor_dev_attr_temp2_min.dev_attr); |
454 | device_create_file(&new_client->dev, | ||
455 | &sensor_dev_attr_temp1_max.dev_attr); | ||
456 | device_create_file(&new_client->dev, | ||
457 | &sensor_dev_attr_temp2_max.dev_attr); | ||
458 | device_create_file(&new_client->dev, | ||
459 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
444 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 460 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); |
445 | device_create_file(&new_client->dev, &dev_attr_alarms); | 461 | device_create_file(&new_client->dev, &dev_attr_alarms); |
446 | 462 | ||
@@ -511,14 +527,14 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
511 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 527 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
512 | if (data->config & 0x04) { /* tachometer enabled */ | 528 | if (data->config & 0x04) { /* tachometer enabled */ |
513 | /* order matters for fan1_input */ | 529 | /* order matters for fan1_input */ |
514 | data->fan1_input = i2c_smbus_read_byte_data(client, | 530 | data->fan[0] = i2c_smbus_read_byte_data(client, |
515 | LM63_REG_TACH_COUNT_LSB) & 0xFC; | 531 | LM63_REG_TACH_COUNT_LSB) & 0xFC; |
516 | data->fan1_input |= i2c_smbus_read_byte_data(client, | 532 | data->fan[0] |= i2c_smbus_read_byte_data(client, |
517 | LM63_REG_TACH_COUNT_MSB) << 8; | 533 | LM63_REG_TACH_COUNT_MSB) << 8; |
518 | data->fan1_low = (i2c_smbus_read_byte_data(client, | 534 | data->fan[1] = (i2c_smbus_read_byte_data(client, |
519 | LM63_REG_TACH_LIMIT_LSB) & 0xFC) | 535 | LM63_REG_TACH_LIMIT_LSB) & 0xFC) |
520 | | (i2c_smbus_read_byte_data(client, | 536 | | (i2c_smbus_read_byte_data(client, |
521 | LM63_REG_TACH_LIMIT_MSB) << 8); | 537 | LM63_REG_TACH_LIMIT_MSB) << 8); |
522 | } | 538 | } |
523 | 539 | ||
524 | data->pwm1_freq = i2c_smbus_read_byte_data(client, | 540 | data->pwm1_freq = i2c_smbus_read_byte_data(client, |
@@ -528,26 +544,26 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
528 | data->pwm1_value = i2c_smbus_read_byte_data(client, | 544 | data->pwm1_value = i2c_smbus_read_byte_data(client, |
529 | LM63_REG_PWM_VALUE); | 545 | LM63_REG_PWM_VALUE); |
530 | 546 | ||
531 | data->temp1_input = i2c_smbus_read_byte_data(client, | 547 | data->temp8[0] = i2c_smbus_read_byte_data(client, |
532 | LM63_REG_LOCAL_TEMP); | 548 | LM63_REG_LOCAL_TEMP); |
533 | data->temp1_high = i2c_smbus_read_byte_data(client, | 549 | data->temp8[1] = i2c_smbus_read_byte_data(client, |
534 | LM63_REG_LOCAL_HIGH); | 550 | LM63_REG_LOCAL_HIGH); |
535 | 551 | ||
536 | /* order matters for temp2_input */ | 552 | /* order matters for temp2_input */ |
537 | data->temp2_input = i2c_smbus_read_byte_data(client, | 553 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
538 | LM63_REG_REMOTE_TEMP_MSB) << 8; | 554 | LM63_REG_REMOTE_TEMP_MSB) << 8; |
539 | data->temp2_input |= i2c_smbus_read_byte_data(client, | 555 | data->temp11[0] |= i2c_smbus_read_byte_data(client, |
540 | LM63_REG_REMOTE_TEMP_LSB); | 556 | LM63_REG_REMOTE_TEMP_LSB); |
541 | data->temp2_high = (i2c_smbus_read_byte_data(client, | 557 | data->temp11[1] = (i2c_smbus_read_byte_data(client, |
542 | LM63_REG_REMOTE_HIGH_MSB) << 8) | ||
543 | | i2c_smbus_read_byte_data(client, | ||
544 | LM63_REG_REMOTE_HIGH_LSB); | ||
545 | data->temp2_low = (i2c_smbus_read_byte_data(client, | ||
546 | LM63_REG_REMOTE_LOW_MSB) << 8) | 558 | LM63_REG_REMOTE_LOW_MSB) << 8) |
547 | | i2c_smbus_read_byte_data(client, | 559 | | i2c_smbus_read_byte_data(client, |
548 | LM63_REG_REMOTE_LOW_LSB); | 560 | LM63_REG_REMOTE_LOW_LSB); |
549 | data->temp2_crit = i2c_smbus_read_byte_data(client, | 561 | data->temp11[2] = (i2c_smbus_read_byte_data(client, |
550 | LM63_REG_REMOTE_TCRIT); | 562 | LM63_REG_REMOTE_HIGH_MSB) << 8) |
563 | | i2c_smbus_read_byte_data(client, | ||
564 | LM63_REG_REMOTE_HIGH_LSB); | ||
565 | data->temp8[2] = i2c_smbus_read_byte_data(client, | ||
566 | LM63_REG_REMOTE_TCRIT); | ||
551 | data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, | 567 | data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, |
552 | LM63_REG_REMOTE_TCRIT_HYST); | 568 | LM63_REG_REMOTE_TCRIT_HYST); |
553 | 569 | ||
diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index 0e86cc893981..5be164ed278e 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -75,7 +74,7 @@ static struct i2c_driver lm75_driver = { | |||
75 | }; | 74 | }; |
76 | 75 | ||
77 | #define show(value) \ | 76 | #define show(value) \ |
78 | static ssize_t show_##value(struct device *dev, char *buf) \ | 77 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
79 | { \ | 78 | { \ |
80 | struct lm75_data *data = lm75_update_device(dev); \ | 79 | struct lm75_data *data = lm75_update_device(dev); \ |
81 | return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \ | 80 | return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \ |
@@ -85,7 +84,7 @@ show(temp_hyst); | |||
85 | show(temp_input); | 84 | show(temp_input); |
86 | 85 | ||
87 | #define set(value, reg) \ | 86 | #define set(value, reg) \ |
88 | static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ | 87 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
89 | { \ | 88 | { \ |
90 | struct i2c_client *client = to_i2c_client(dev); \ | 89 | struct i2c_client *client = to_i2c_client(dev); \ |
91 | struct lm75_data *data = i2c_get_clientdata(client); \ | 90 | struct lm75_data *data = i2c_get_clientdata(client); \ |
diff --git a/drivers/i2c/chips/lm77.c b/drivers/i2c/chips/lm77.c index f56b7a37de75..b98f44952997 100644 --- a/drivers/i2c/chips/lm77.c +++ b/drivers/i2c/chips/lm77.c | |||
@@ -25,7 +25,6 @@ | |||
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
31 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
@@ -103,7 +102,7 @@ static inline int LM77_TEMP_FROM_REG(u16 reg) | |||
103 | 102 | ||
104 | /* read routines for temperature limits */ | 103 | /* read routines for temperature limits */ |
105 | #define show(value) \ | 104 | #define show(value) \ |
106 | static ssize_t show_##value(struct device *dev, char *buf) \ | 105 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
107 | { \ | 106 | { \ |
108 | struct lm77_data *data = lm77_update_device(dev); \ | 107 | struct lm77_data *data = lm77_update_device(dev); \ |
109 | return sprintf(buf, "%d\n", data->value); \ | 108 | return sprintf(buf, "%d\n", data->value); \ |
@@ -116,17 +115,17 @@ show(temp_max); | |||
116 | show(alarms); | 115 | show(alarms); |
117 | 116 | ||
118 | /* read routines for hysteresis values */ | 117 | /* read routines for hysteresis values */ |
119 | static ssize_t show_temp_crit_hyst(struct device *dev, char *buf) | 118 | static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
120 | { | 119 | { |
121 | struct lm77_data *data = lm77_update_device(dev); | 120 | struct lm77_data *data = lm77_update_device(dev); |
122 | return sprintf(buf, "%d\n", data->temp_crit - data->temp_hyst); | 121 | return sprintf(buf, "%d\n", data->temp_crit - data->temp_hyst); |
123 | } | 122 | } |
124 | static ssize_t show_temp_min_hyst(struct device *dev, char *buf) | 123 | static ssize_t show_temp_min_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
125 | { | 124 | { |
126 | struct lm77_data *data = lm77_update_device(dev); | 125 | struct lm77_data *data = lm77_update_device(dev); |
127 | return sprintf(buf, "%d\n", data->temp_min + data->temp_hyst); | 126 | return sprintf(buf, "%d\n", data->temp_min + data->temp_hyst); |
128 | } | 127 | } |
129 | static ssize_t show_temp_max_hyst(struct device *dev, char *buf) | 128 | static ssize_t show_temp_max_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
130 | { | 129 | { |
131 | struct lm77_data *data = lm77_update_device(dev); | 130 | struct lm77_data *data = lm77_update_device(dev); |
132 | return sprintf(buf, "%d\n", data->temp_max - data->temp_hyst); | 131 | return sprintf(buf, "%d\n", data->temp_max - data->temp_hyst); |
@@ -134,7 +133,7 @@ static ssize_t show_temp_max_hyst(struct device *dev, char *buf) | |||
134 | 133 | ||
135 | /* write routines */ | 134 | /* write routines */ |
136 | #define set(value, reg) \ | 135 | #define set(value, reg) \ |
137 | static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ | 136 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
138 | { \ | 137 | { \ |
139 | struct i2c_client *client = to_i2c_client(dev); \ | 138 | struct i2c_client *client = to_i2c_client(dev); \ |
140 | struct lm77_data *data = i2c_get_clientdata(client); \ | 139 | struct lm77_data *data = i2c_get_clientdata(client); \ |
@@ -152,7 +151,7 @@ set(temp_max, LM77_REG_TEMP_MAX); | |||
152 | 151 | ||
153 | /* hysteresis is stored as a relative value on the chip, so it has to be | 152 | /* hysteresis is stored as a relative value on the chip, so it has to be |
154 | converted first */ | 153 | converted first */ |
155 | static ssize_t set_temp_crit_hyst(struct device *dev, const char *buf, size_t count) | 154 | static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
156 | { | 155 | { |
157 | struct i2c_client *client = to_i2c_client(dev); | 156 | struct i2c_client *client = to_i2c_client(dev); |
158 | struct lm77_data *data = i2c_get_clientdata(client); | 157 | struct lm77_data *data = i2c_get_clientdata(client); |
@@ -167,7 +166,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev, const char *buf, size_t co | |||
167 | } | 166 | } |
168 | 167 | ||
169 | /* preserve hysteresis when setting T_crit */ | 168 | /* preserve hysteresis when setting T_crit */ |
170 | static ssize_t set_temp_crit(struct device *dev, const char *buf, size_t count) | 169 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
171 | { | 170 | { |
172 | struct i2c_client *client = to_i2c_client(dev); | 171 | struct i2c_client *client = to_i2c_client(dev); |
173 | struct lm77_data *data = i2c_get_clientdata(client); | 172 | struct lm77_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c index 6d52d14eb31c..29241469dcba 100644 --- a/drivers/i2c/chips/lm78.c +++ b/drivers/i2c/chips/lm78.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -224,28 +223,28 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
224 | 223 | ||
225 | #define show_in_offset(offset) \ | 224 | #define show_in_offset(offset) \ |
226 | static ssize_t \ | 225 | static ssize_t \ |
227 | show_in##offset (struct device *dev, char *buf) \ | 226 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
228 | { \ | 227 | { \ |
229 | return show_in(dev, buf, offset); \ | 228 | return show_in(dev, buf, offset); \ |
230 | } \ | 229 | } \ |
231 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 230 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
232 | show_in##offset, NULL); \ | 231 | show_in##offset, NULL); \ |
233 | static ssize_t \ | 232 | static ssize_t \ |
234 | show_in##offset##_min (struct device *dev, char *buf) \ | 233 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
235 | { \ | 234 | { \ |
236 | return show_in_min(dev, buf, offset); \ | 235 | return show_in_min(dev, buf, offset); \ |
237 | } \ | 236 | } \ |
238 | static ssize_t \ | 237 | static ssize_t \ |
239 | show_in##offset##_max (struct device *dev, char *buf) \ | 238 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
240 | { \ | 239 | { \ |
241 | return show_in_max(dev, buf, offset); \ | 240 | return show_in_max(dev, buf, offset); \ |
242 | } \ | 241 | } \ |
243 | static ssize_t set_in##offset##_min (struct device *dev, \ | 242 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ |
244 | const char *buf, size_t count) \ | 243 | const char *buf, size_t count) \ |
245 | { \ | 244 | { \ |
246 | return set_in_min(dev, buf, count, offset); \ | 245 | return set_in_min(dev, buf, count, offset); \ |
247 | } \ | 246 | } \ |
248 | static ssize_t set_in##offset##_max (struct device *dev, \ | 247 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ |
249 | const char *buf, size_t count) \ | 248 | const char *buf, size_t count) \ |
250 | { \ | 249 | { \ |
251 | return set_in_max(dev, buf, count, offset); \ | 250 | return set_in_max(dev, buf, count, offset); \ |
@@ -264,19 +263,19 @@ show_in_offset(5); | |||
264 | show_in_offset(6); | 263 | show_in_offset(6); |
265 | 264 | ||
266 | /* Temperature */ | 265 | /* Temperature */ |
267 | static ssize_t show_temp(struct device *dev, char *buf) | 266 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) |
268 | { | 267 | { |
269 | struct lm78_data *data = lm78_update_device(dev); | 268 | struct lm78_data *data = lm78_update_device(dev); |
270 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); | 269 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); |
271 | } | 270 | } |
272 | 271 | ||
273 | static ssize_t show_temp_over(struct device *dev, char *buf) | 272 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) |
274 | { | 273 | { |
275 | struct lm78_data *data = lm78_update_device(dev); | 274 | struct lm78_data *data = lm78_update_device(dev); |
276 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); | 275 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); |
277 | } | 276 | } |
278 | 277 | ||
279 | static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count) | 278 | static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
280 | { | 279 | { |
281 | struct i2c_client *client = to_i2c_client(dev); | 280 | struct i2c_client *client = to_i2c_client(dev); |
282 | struct lm78_data *data = i2c_get_clientdata(client); | 281 | struct lm78_data *data = i2c_get_clientdata(client); |
@@ -289,13 +288,13 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count) | |||
289 | return count; | 288 | return count; |
290 | } | 289 | } |
291 | 290 | ||
292 | static ssize_t show_temp_hyst(struct device *dev, char *buf) | 291 | static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
293 | { | 292 | { |
294 | struct lm78_data *data = lm78_update_device(dev); | 293 | struct lm78_data *data = lm78_update_device(dev); |
295 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); | 294 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); |
296 | } | 295 | } |
297 | 296 | ||
298 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, size_t count) | 297 | static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
299 | { | 298 | { |
300 | struct i2c_client *client = to_i2c_client(dev); | 299 | struct i2c_client *client = to_i2c_client(dev); |
301 | struct lm78_data *data = i2c_get_clientdata(client); | 300 | struct lm78_data *data = i2c_get_clientdata(client); |
@@ -398,19 +397,19 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
398 | } | 397 | } |
399 | 398 | ||
400 | #define show_fan_offset(offset) \ | 399 | #define show_fan_offset(offset) \ |
401 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 400 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
402 | { \ | 401 | { \ |
403 | return show_fan(dev, buf, offset - 1); \ | 402 | return show_fan(dev, buf, offset - 1); \ |
404 | } \ | 403 | } \ |
405 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 404 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
406 | { \ | 405 | { \ |
407 | return show_fan_min(dev, buf, offset - 1); \ | 406 | return show_fan_min(dev, buf, offset - 1); \ |
408 | } \ | 407 | } \ |
409 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | 408 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
410 | { \ | 409 | { \ |
411 | return show_fan_div(dev, buf, offset - 1); \ | 410 | return show_fan_div(dev, buf, offset - 1); \ |
412 | } \ | 411 | } \ |
413 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | 412 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
414 | const char *buf, size_t count) \ | 413 | const char *buf, size_t count) \ |
415 | { \ | 414 | { \ |
416 | return set_fan_min(dev, buf, count, offset - 1); \ | 415 | return set_fan_min(dev, buf, count, offset - 1); \ |
@@ -419,13 +418,13 @@ static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\ | |||
419 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 418 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
420 | show_fan_##offset##_min, set_fan_##offset##_min); | 419 | show_fan_##offset##_min, set_fan_##offset##_min); |
421 | 420 | ||
422 | static ssize_t set_fan_1_div(struct device *dev, const char *buf, | 421 | static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf, |
423 | size_t count) | 422 | size_t count) |
424 | { | 423 | { |
425 | return set_fan_div(dev, buf, count, 0) ; | 424 | return set_fan_div(dev, buf, count, 0) ; |
426 | } | 425 | } |
427 | 426 | ||
428 | static ssize_t set_fan_2_div(struct device *dev, const char *buf, | 427 | static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf, |
429 | size_t count) | 428 | size_t count) |
430 | { | 429 | { |
431 | return set_fan_div(dev, buf, count, 1) ; | 430 | return set_fan_div(dev, buf, count, 1) ; |
@@ -443,7 +442,7 @@ static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, | |||
443 | static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL); | 442 | static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL); |
444 | 443 | ||
445 | /* VID */ | 444 | /* VID */ |
446 | static ssize_t show_vid(struct device *dev, char *buf) | 445 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
447 | { | 446 | { |
448 | struct lm78_data *data = lm78_update_device(dev); | 447 | struct lm78_data *data = lm78_update_device(dev); |
449 | return sprintf(buf, "%d\n", VID_FROM_REG(data->vid)); | 448 | return sprintf(buf, "%d\n", VID_FROM_REG(data->vid)); |
@@ -451,7 +450,7 @@ static ssize_t show_vid(struct device *dev, char *buf) | |||
451 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 450 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
452 | 451 | ||
453 | /* Alarms */ | 452 | /* Alarms */ |
454 | static ssize_t show_alarms(struct device *dev, char *buf) | 453 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
455 | { | 454 | { |
456 | struct lm78_data *data = lm78_update_device(dev); | 455 | struct lm78_data *data = lm78_update_device(dev); |
457 | return sprintf(buf, "%u\n", data->alarms); | 456 | return sprintf(buf, "%u\n", data->alarms); |
@@ -671,7 +670,7 @@ static int lm78_detach_client(struct i2c_client *client) | |||
671 | return 0; | 670 | return 0; |
672 | } | 671 | } |
673 | 672 | ||
674 | /* The SMBus locks itself, but ISA access must be locked explicitely! | 673 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
675 | We don't want to lock the whole ISA bus, so we lock each client | 674 | We don't want to lock the whole ISA bus, so we lock each client |
676 | separately. | 675 | separately. |
677 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, | 676 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
@@ -690,7 +689,7 @@ static int lm78_read_value(struct i2c_client *client, u8 reg) | |||
690 | return i2c_smbus_read_byte_data(client, reg); | 689 | return i2c_smbus_read_byte_data(client, reg); |
691 | } | 690 | } |
692 | 691 | ||
693 | /* The SMBus locks itself, but ISA access muse be locked explicitely! | 692 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
694 | We don't want to lock the whole ISA bus, so we lock each client | 693 | We don't want to lock the whole ISA bus, so we lock each client |
695 | separately. | 694 | separately. |
696 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, | 695 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
diff --git a/drivers/i2c/chips/lm80.c b/drivers/i2c/chips/lm80.c index a72f431971bb..8100595feb44 100644 --- a/drivers/i2c/chips/lm80.c +++ b/drivers/i2c/chips/lm80.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
@@ -156,7 +155,7 @@ static struct i2c_driver lm80_driver = { | |||
156 | */ | 155 | */ |
157 | 156 | ||
158 | #define show_in(suffix, value) \ | 157 | #define show_in(suffix, value) \ |
159 | static ssize_t show_in_##suffix(struct device *dev, char *buf) \ | 158 | static ssize_t show_in_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ |
160 | { \ | 159 | { \ |
161 | struct lm80_data *data = lm80_update_device(dev); \ | 160 | struct lm80_data *data = lm80_update_device(dev); \ |
162 | return sprintf(buf, "%d\n", IN_FROM_REG(data->value)); \ | 161 | return sprintf(buf, "%d\n", IN_FROM_REG(data->value)); \ |
@@ -184,7 +183,7 @@ show_in(input5, in[5]); | |||
184 | show_in(input6, in[6]); | 183 | show_in(input6, in[6]); |
185 | 184 | ||
186 | #define set_in(suffix, value, reg) \ | 185 | #define set_in(suffix, value, reg) \ |
187 | static ssize_t set_in_##suffix(struct device *dev, const char *buf, \ | 186 | static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ |
188 | size_t count) \ | 187 | size_t count) \ |
189 | { \ | 188 | { \ |
190 | struct i2c_client *client = to_i2c_client(dev); \ | 189 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -213,7 +212,7 @@ set_in(max5, in_max[5], LM80_REG_IN_MAX(5)); | |||
213 | set_in(max6, in_max[6], LM80_REG_IN_MAX(6)); | 212 | set_in(max6, in_max[6], LM80_REG_IN_MAX(6)); |
214 | 213 | ||
215 | #define show_fan(suffix, value, div) \ | 214 | #define show_fan(suffix, value, div) \ |
216 | static ssize_t show_fan_##suffix(struct device *dev, char *buf) \ | 215 | static ssize_t show_fan_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ |
217 | { \ | 216 | { \ |
218 | struct lm80_data *data = lm80_update_device(dev); \ | 217 | struct lm80_data *data = lm80_update_device(dev); \ |
219 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value, \ | 218 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value, \ |
@@ -225,7 +224,7 @@ show_fan(input1, fan[0], fan_div[0]); | |||
225 | show_fan(input2, fan[1], fan_div[1]); | 224 | show_fan(input2, fan[1], fan_div[1]); |
226 | 225 | ||
227 | #define show_fan_div(suffix, value) \ | 226 | #define show_fan_div(suffix, value) \ |
228 | static ssize_t show_fan_div##suffix(struct device *dev, char *buf) \ | 227 | static ssize_t show_fan_div##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ |
229 | { \ | 228 | { \ |
230 | struct lm80_data *data = lm80_update_device(dev); \ | 229 | struct lm80_data *data = lm80_update_device(dev); \ |
231 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->value)); \ | 230 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->value)); \ |
@@ -234,7 +233,7 @@ show_fan_div(1, fan_div[0]); | |||
234 | show_fan_div(2, fan_div[1]); | 233 | show_fan_div(2, fan_div[1]); |
235 | 234 | ||
236 | #define set_fan(suffix, value, reg, div) \ | 235 | #define set_fan(suffix, value, reg, div) \ |
237 | static ssize_t set_fan_##suffix(struct device *dev, const char *buf, \ | 236 | static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ |
238 | size_t count) \ | 237 | size_t count) \ |
239 | { \ | 238 | { \ |
240 | struct i2c_client *client = to_i2c_client(dev); \ | 239 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -292,7 +291,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
292 | } | 291 | } |
293 | 292 | ||
294 | #define set_fan_div(number) \ | 293 | #define set_fan_div(number) \ |
295 | static ssize_t set_fan_div##number(struct device *dev, const char *buf, \ | 294 | static ssize_t set_fan_div##number(struct device *dev, struct device_attribute *attr, const char *buf, \ |
296 | size_t count) \ | 295 | size_t count) \ |
297 | { \ | 296 | { \ |
298 | return set_fan_div(dev, buf, count, number - 1); \ | 297 | return set_fan_div(dev, buf, count, number - 1); \ |
@@ -300,14 +299,14 @@ static ssize_t set_fan_div##number(struct device *dev, const char *buf, \ | |||
300 | set_fan_div(1); | 299 | set_fan_div(1); |
301 | set_fan_div(2); | 300 | set_fan_div(2); |
302 | 301 | ||
303 | static ssize_t show_temp_input1(struct device *dev, char *buf) | 302 | static ssize_t show_temp_input1(struct device *dev, struct device_attribute *attr, char *buf) |
304 | { | 303 | { |
305 | struct lm80_data *data = lm80_update_device(dev); | 304 | struct lm80_data *data = lm80_update_device(dev); |
306 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp)); | 305 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp)); |
307 | } | 306 | } |
308 | 307 | ||
309 | #define show_temp(suffix, value) \ | 308 | #define show_temp(suffix, value) \ |
310 | static ssize_t show_temp_##suffix(struct device *dev, char *buf) \ | 309 | static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ |
311 | { \ | 310 | { \ |
312 | struct lm80_data *data = lm80_update_device(dev); \ | 311 | struct lm80_data *data = lm80_update_device(dev); \ |
313 | return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \ | 312 | return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \ |
@@ -318,7 +317,7 @@ show_temp(os_max, temp_os_max); | |||
318 | show_temp(os_hyst, temp_os_hyst); | 317 | show_temp(os_hyst, temp_os_hyst); |
319 | 318 | ||
320 | #define set_temp(suffix, value, reg) \ | 319 | #define set_temp(suffix, value, reg) \ |
321 | static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ | 320 | static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ |
322 | size_t count) \ | 321 | size_t count) \ |
323 | { \ | 322 | { \ |
324 | struct i2c_client *client = to_i2c_client(dev); \ | 323 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -336,7 +335,7 @@ set_temp(hot_hyst, temp_hot_hyst, LM80_REG_TEMP_HOT_HYST); | |||
336 | set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX); | 335 | set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX); |
337 | set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST); | 336 | set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST); |
338 | 337 | ||
339 | static ssize_t show_alarms(struct device *dev, char *buf) | 338 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
340 | { | 339 | { |
341 | struct lm80_data *data = lm80_update_device(dev); | 340 | struct lm80_data *data = lm80_update_device(dev); |
342 | return sprintf(buf, "%u\n", data->alarms); | 341 | return sprintf(buf, "%u\n", data->alarms); |
diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c index 3dafe60766ad..a49008b444c8 100644 --- a/drivers/i2c/chips/lm83.c +++ b/drivers/i2c/chips/lm83.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is | 6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is |
7 | * a sensor chip made by National Semiconductor. It reports up to four | 7 | * a sensor chip made by National Semiconductor. It reports up to four |
@@ -27,13 +27,13 @@ | |||
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/module.h> | 30 | #include <linux/module.h> |
32 | #include <linux/init.h> | 31 | #include <linux/init.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/jiffies.h> | 33 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
36 | #include <linux/i2c-sensor.h> | 35 | #include <linux/i2c-sensor.h> |
36 | #include <linux/hwmon-sysfs.h> | ||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Addresses to scan | 39 | * Addresses to scan |
@@ -81,7 +81,7 @@ SENSORS_INSMOD_1(lm83); | |||
81 | 81 | ||
82 | /* | 82 | /* |
83 | * Conversions and various macros | 83 | * Conversions and various macros |
84 | * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius. | 84 | * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius. |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #define TEMP_FROM_REG(val) ((val) * 1000) | 87 | #define TEMP_FROM_REG(val) ((val) * 1000) |
@@ -94,21 +94,20 @@ static const u8 LM83_REG_R_TEMP[] = { | |||
94 | LM83_REG_R_LOCAL_TEMP, | 94 | LM83_REG_R_LOCAL_TEMP, |
95 | LM83_REG_R_REMOTE1_TEMP, | 95 | LM83_REG_R_REMOTE1_TEMP, |
96 | LM83_REG_R_REMOTE2_TEMP, | 96 | LM83_REG_R_REMOTE2_TEMP, |
97 | LM83_REG_R_REMOTE3_TEMP | 97 | LM83_REG_R_REMOTE3_TEMP, |
98 | }; | ||
99 | |||
100 | static const u8 LM83_REG_R_HIGH[] = { | ||
101 | LM83_REG_R_LOCAL_HIGH, | 98 | LM83_REG_R_LOCAL_HIGH, |
102 | LM83_REG_R_REMOTE1_HIGH, | 99 | LM83_REG_R_REMOTE1_HIGH, |
103 | LM83_REG_R_REMOTE2_HIGH, | 100 | LM83_REG_R_REMOTE2_HIGH, |
104 | LM83_REG_R_REMOTE3_HIGH | 101 | LM83_REG_R_REMOTE3_HIGH, |
102 | LM83_REG_R_TCRIT, | ||
105 | }; | 103 | }; |
106 | 104 | ||
107 | static const u8 LM83_REG_W_HIGH[] = { | 105 | static const u8 LM83_REG_W_HIGH[] = { |
108 | LM83_REG_W_LOCAL_HIGH, | 106 | LM83_REG_W_LOCAL_HIGH, |
109 | LM83_REG_W_REMOTE1_HIGH, | 107 | LM83_REG_W_REMOTE1_HIGH, |
110 | LM83_REG_W_REMOTE2_HIGH, | 108 | LM83_REG_W_REMOTE2_HIGH, |
111 | LM83_REG_W_REMOTE3_HIGH | 109 | LM83_REG_W_REMOTE3_HIGH, |
110 | LM83_REG_W_TCRIT, | ||
112 | }; | 111 | }; |
113 | 112 | ||
114 | /* | 113 | /* |
@@ -144,9 +143,9 @@ struct lm83_data { | |||
144 | unsigned long last_updated; /* in jiffies */ | 143 | unsigned long last_updated; /* in jiffies */ |
145 | 144 | ||
146 | /* registers values */ | 145 | /* registers values */ |
147 | s8 temp_input[4]; | 146 | s8 temp[9]; /* 0..3: input 1-4, |
148 | s8 temp_high[4]; | 147 | 4..7: high limit 1-4, |
149 | s8 temp_crit; | 148 | 8 : critical limit */ |
150 | u16 alarms; /* bitvector, combined */ | 149 | u16 alarms; /* bitvector, combined */ |
151 | }; | 150 | }; |
152 | 151 | ||
@@ -154,65 +153,55 @@ struct lm83_data { | |||
154 | * Sysfs stuff | 153 | * Sysfs stuff |
155 | */ | 154 | */ |
156 | 155 | ||
157 | #define show_temp(suffix, value) \ | 156 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
158 | static ssize_t show_temp_##suffix(struct device *dev, char *buf) \ | 157 | char *buf) |
159 | { \ | 158 | { |
160 | struct lm83_data *data = lm83_update_device(dev); \ | 159 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
161 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ | 160 | struct lm83_data *data = lm83_update_device(dev); |
161 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); | ||
162 | } | 162 | } |
163 | show_temp(input1, temp_input[0]); | 163 | |
164 | show_temp(input2, temp_input[1]); | 164 | static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, |
165 | show_temp(input3, temp_input[2]); | 165 | const char *buf, size_t count) |
166 | show_temp(input4, temp_input[3]); | 166 | { |
167 | show_temp(high1, temp_high[0]); | 167 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
168 | show_temp(high2, temp_high[1]); | 168 | struct i2c_client *client = to_i2c_client(dev); |
169 | show_temp(high3, temp_high[2]); | 169 | struct lm83_data *data = i2c_get_clientdata(client); |
170 | show_temp(high4, temp_high[3]); | 170 | long val = simple_strtol(buf, NULL, 10); |
171 | show_temp(crit, temp_crit); | 171 | int nr = attr->index; |
172 | 172 | ||
173 | #define set_temp(suffix, value, reg) \ | 173 | down(&data->update_lock); |
174 | static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ | 174 | data->temp[nr] = TEMP_TO_REG(val); |
175 | size_t count) \ | 175 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], |
176 | { \ | 176 | data->temp[nr]); |
177 | struct i2c_client *client = to_i2c_client(dev); \ | 177 | up(&data->update_lock); |
178 | struct lm83_data *data = i2c_get_clientdata(client); \ | 178 | return count; |
179 | long val = simple_strtol(buf, NULL, 10); \ | ||
180 | \ | ||
181 | down(&data->update_lock); \ | ||
182 | data->value = TEMP_TO_REG(val); \ | ||
183 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
184 | up(&data->update_lock); \ | ||
185 | return count; \ | ||
186 | } | 179 | } |
187 | set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH); | ||
188 | set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH); | ||
189 | set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH); | ||
190 | set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH); | ||
191 | set_temp(crit, temp_crit, LM83_REG_W_TCRIT); | ||
192 | 180 | ||
193 | static ssize_t show_alarms(struct device *dev, char *buf) | 181 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
182 | char *buf) | ||
194 | { | 183 | { |
195 | struct lm83_data *data = lm83_update_device(dev); | 184 | struct lm83_data *data = lm83_update_device(dev); |
196 | return sprintf(buf, "%d\n", data->alarms); | 185 | return sprintf(buf, "%d\n", data->alarms); |
197 | } | 186 | } |
198 | 187 | ||
199 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 188 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
200 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 189 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
201 | static DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input3, NULL); | 190 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
202 | static DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input4, NULL); | 191 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
203 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, | 192 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, |
204 | set_temp_high1); | 193 | set_temp, 4); |
205 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, | 194 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp, |
206 | set_temp_high2); | 195 | set_temp, 5); |
207 | static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_high3, | 196 | static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp, |
208 | set_temp_high3); | 197 | set_temp, 6); |
209 | static DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_high4, | 198 | static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp, |
210 | set_temp_high4); | 199 | set_temp, 7); |
211 | static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL); | 200 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8); |
212 | static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL); | 201 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8); |
213 | static DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp_crit, | 202 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, |
214 | set_temp_crit); | 203 | set_temp, 8); |
215 | static DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL); | 204 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); |
216 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 205 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
217 | 206 | ||
218 | /* | 207 | /* |
@@ -323,18 +312,30 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
323 | */ | 312 | */ |
324 | 313 | ||
325 | /* Register sysfs hooks */ | 314 | /* Register sysfs hooks */ |
326 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 315 | device_create_file(&new_client->dev, |
327 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 316 | &sensor_dev_attr_temp1_input.dev_attr); |
328 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 317 | device_create_file(&new_client->dev, |
329 | device_create_file(&new_client->dev, &dev_attr_temp4_input); | 318 | &sensor_dev_attr_temp2_input.dev_attr); |
330 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 319 | device_create_file(&new_client->dev, |
331 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 320 | &sensor_dev_attr_temp3_input.dev_attr); |
332 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 321 | device_create_file(&new_client->dev, |
333 | device_create_file(&new_client->dev, &dev_attr_temp4_max); | 322 | &sensor_dev_attr_temp4_input.dev_attr); |
334 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 323 | device_create_file(&new_client->dev, |
335 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 324 | &sensor_dev_attr_temp1_max.dev_attr); |
336 | device_create_file(&new_client->dev, &dev_attr_temp3_crit); | 325 | device_create_file(&new_client->dev, |
337 | device_create_file(&new_client->dev, &dev_attr_temp4_crit); | 326 | &sensor_dev_attr_temp2_max.dev_attr); |
327 | device_create_file(&new_client->dev, | ||
328 | &sensor_dev_attr_temp3_max.dev_attr); | ||
329 | device_create_file(&new_client->dev, | ||
330 | &sensor_dev_attr_temp4_max.dev_attr); | ||
331 | device_create_file(&new_client->dev, | ||
332 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
333 | device_create_file(&new_client->dev, | ||
334 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
335 | device_create_file(&new_client->dev, | ||
336 | &sensor_dev_attr_temp3_crit.dev_attr); | ||
337 | device_create_file(&new_client->dev, | ||
338 | &sensor_dev_attr_temp4_crit.dev_attr); | ||
338 | device_create_file(&new_client->dev, &dev_attr_alarms); | 339 | device_create_file(&new_client->dev, &dev_attr_alarms); |
339 | 340 | ||
340 | return 0; | 341 | return 0; |
@@ -370,16 +371,11 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
370 | int nr; | 371 | int nr; |
371 | 372 | ||
372 | dev_dbg(&client->dev, "Updating lm83 data.\n"); | 373 | dev_dbg(&client->dev, "Updating lm83 data.\n"); |
373 | for (nr = 0; nr < 4 ; nr++) { | 374 | for (nr = 0; nr < 9; nr++) { |
374 | data->temp_input[nr] = | 375 | data->temp[nr] = |
375 | i2c_smbus_read_byte_data(client, | 376 | i2c_smbus_read_byte_data(client, |
376 | LM83_REG_R_TEMP[nr]); | 377 | LM83_REG_R_TEMP[nr]); |
377 | data->temp_high[nr] = | ||
378 | i2c_smbus_read_byte_data(client, | ||
379 | LM83_REG_R_HIGH[nr]); | ||
380 | } | 378 | } |
381 | data->temp_crit = | ||
382 | i2c_smbus_read_byte_data(client, LM83_REG_R_TCRIT); | ||
383 | data->alarms = | 379 | data->alarms = |
384 | i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) | 380 | i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) |
385 | + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) | 381 | + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) |
diff --git a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c index b1a0dc5f6b34..b4d7fd418264 100644 --- a/drivers/i2c/chips/lm85.c +++ b/drivers/i2c/chips/lm85.c | |||
@@ -23,7 +23,6 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -285,8 +284,6 @@ static int ZONE_TO_REG( int zone ) | |||
285 | /* i2c-vid.h defines vid_from_reg() */ | 284 | /* i2c-vid.h defines vid_from_reg() */ |
286 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) | 285 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) |
287 | 286 | ||
288 | #define ALARMS_FROM_REG(val) (val) | ||
289 | |||
290 | /* Unlike some other drivers we DO NOT set initial limits. Use | 287 | /* Unlike some other drivers we DO NOT set initial limits. Use |
291 | * the config file to set limits. Some users have reported | 288 | * the config file to set limits. Some users have reported |
292 | * motherboards shutting down when we set limits in a previous | 289 | * motherboards shutting down when we set limits in a previous |
@@ -426,15 +423,15 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
426 | } | 423 | } |
427 | 424 | ||
428 | #define show_fan_offset(offset) \ | 425 | #define show_fan_offset(offset) \ |
429 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 426 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
430 | { \ | 427 | { \ |
431 | return show_fan(dev, buf, offset - 1); \ | 428 | return show_fan(dev, buf, offset - 1); \ |
432 | } \ | 429 | } \ |
433 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 430 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
434 | { \ | 431 | { \ |
435 | return show_fan_min(dev, buf, offset - 1); \ | 432 | return show_fan_min(dev, buf, offset - 1); \ |
436 | } \ | 433 | } \ |
437 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | 434 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
438 | const char *buf, size_t count) \ | 435 | const char *buf, size_t count) \ |
439 | { \ | 436 | { \ |
440 | return set_fan_min(dev, buf, count, offset - 1); \ | 437 | return set_fan_min(dev, buf, count, offset - 1); \ |
@@ -451,7 +448,7 @@ show_fan_offset(4); | |||
451 | 448 | ||
452 | /* vid, vrm, alarms */ | 449 | /* vid, vrm, alarms */ |
453 | 450 | ||
454 | static ssize_t show_vid_reg(struct device *dev, char *buf) | 451 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
455 | { | 452 | { |
456 | struct lm85_data *data = lm85_update_device(dev); | 453 | struct lm85_data *data = lm85_update_device(dev); |
457 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); | 454 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); |
@@ -459,13 +456,13 @@ static ssize_t show_vid_reg(struct device *dev, char *buf) | |||
459 | 456 | ||
460 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | 457 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); |
461 | 458 | ||
462 | static ssize_t show_vrm_reg(struct device *dev, char *buf) | 459 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
463 | { | 460 | { |
464 | struct lm85_data *data = lm85_update_device(dev); | 461 | struct lm85_data *data = lm85_update_device(dev); |
465 | return sprintf(buf, "%ld\n", (long) data->vrm); | 462 | return sprintf(buf, "%ld\n", (long) data->vrm); |
466 | } | 463 | } |
467 | 464 | ||
468 | static ssize_t store_vrm_reg(struct device *dev, const char *buf, size_t count) | 465 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
469 | { | 466 | { |
470 | struct i2c_client *client = to_i2c_client(dev); | 467 | struct i2c_client *client = to_i2c_client(dev); |
471 | struct lm85_data *data = i2c_get_clientdata(client); | 468 | struct lm85_data *data = i2c_get_clientdata(client); |
@@ -478,10 +475,10 @@ static ssize_t store_vrm_reg(struct device *dev, const char *buf, size_t count) | |||
478 | 475 | ||
479 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | 476 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); |
480 | 477 | ||
481 | static ssize_t show_alarms_reg(struct device *dev, char *buf) | 478 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
482 | { | 479 | { |
483 | struct lm85_data *data = lm85_update_device(dev); | 480 | struct lm85_data *data = lm85_update_device(dev); |
484 | return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); | 481 | return sprintf(buf, "%u\n", data->alarms); |
485 | } | 482 | } |
486 | 483 | ||
487 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 484 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
@@ -516,16 +513,16 @@ static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | |||
516 | } | 513 | } |
517 | 514 | ||
518 | #define show_pwm_reg(offset) \ | 515 | #define show_pwm_reg(offset) \ |
519 | static ssize_t show_pwm_##offset (struct device *dev, char *buf) \ | 516 | static ssize_t show_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
520 | { \ | 517 | { \ |
521 | return show_pwm(dev, buf, offset - 1); \ | 518 | return show_pwm(dev, buf, offset - 1); \ |
522 | } \ | 519 | } \ |
523 | static ssize_t set_pwm_##offset (struct device *dev, \ | 520 | static ssize_t set_pwm_##offset (struct device *dev, struct device_attribute *attr, \ |
524 | const char *buf, size_t count) \ | 521 | const char *buf, size_t count) \ |
525 | { \ | 522 | { \ |
526 | return set_pwm(dev, buf, count, offset - 1); \ | 523 | return set_pwm(dev, buf, count, offset - 1); \ |
527 | } \ | 524 | } \ |
528 | static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \ | 525 | static ssize_t show_pwm_enable##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
529 | { \ | 526 | { \ |
530 | return show_pwm_enable(dev, buf, offset - 1); \ | 527 | return show_pwm_enable(dev, buf, offset - 1); \ |
531 | } \ | 528 | } \ |
@@ -585,24 +582,24 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
585 | return count; | 582 | return count; |
586 | } | 583 | } |
587 | #define show_in_reg(offset) \ | 584 | #define show_in_reg(offset) \ |
588 | static ssize_t show_in_##offset (struct device *dev, char *buf) \ | 585 | static ssize_t show_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
589 | { \ | 586 | { \ |
590 | return show_in(dev, buf, offset); \ | 587 | return show_in(dev, buf, offset); \ |
591 | } \ | 588 | } \ |
592 | static ssize_t show_in_##offset##_min (struct device *dev, char *buf) \ | 589 | static ssize_t show_in_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
593 | { \ | 590 | { \ |
594 | return show_in_min(dev, buf, offset); \ | 591 | return show_in_min(dev, buf, offset); \ |
595 | } \ | 592 | } \ |
596 | static ssize_t show_in_##offset##_max (struct device *dev, char *buf) \ | 593 | static ssize_t show_in_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
597 | { \ | 594 | { \ |
598 | return show_in_max(dev, buf, offset); \ | 595 | return show_in_max(dev, buf, offset); \ |
599 | } \ | 596 | } \ |
600 | static ssize_t set_in_##offset##_min (struct device *dev, \ | 597 | static ssize_t set_in_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
601 | const char *buf, size_t count) \ | 598 | const char *buf, size_t count) \ |
602 | { \ | 599 | { \ |
603 | return set_in_min(dev, buf, count, offset); \ | 600 | return set_in_min(dev, buf, count, offset); \ |
604 | } \ | 601 | } \ |
605 | static ssize_t set_in_##offset##_max (struct device *dev, \ | 602 | static ssize_t set_in_##offset##_max (struct device *dev, struct device_attribute *attr, \ |
606 | const char *buf, size_t count) \ | 603 | const char *buf, size_t count) \ |
607 | { \ | 604 | { \ |
608 | return set_in_max(dev, buf, count, offset); \ | 605 | return set_in_max(dev, buf, count, offset); \ |
@@ -666,24 +663,24 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
666 | return count; | 663 | return count; |
667 | } | 664 | } |
668 | #define show_temp_reg(offset) \ | 665 | #define show_temp_reg(offset) \ |
669 | static ssize_t show_temp_##offset (struct device *dev, char *buf) \ | 666 | static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
670 | { \ | 667 | { \ |
671 | return show_temp(dev, buf, offset - 1); \ | 668 | return show_temp(dev, buf, offset - 1); \ |
672 | } \ | 669 | } \ |
673 | static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \ | 670 | static ssize_t show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
674 | { \ | 671 | { \ |
675 | return show_temp_min(dev, buf, offset - 1); \ | 672 | return show_temp_min(dev, buf, offset - 1); \ |
676 | } \ | 673 | } \ |
677 | static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \ | 674 | static ssize_t show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
678 | { \ | 675 | { \ |
679 | return show_temp_max(dev, buf, offset - 1); \ | 676 | return show_temp_max(dev, buf, offset - 1); \ |
680 | } \ | 677 | } \ |
681 | static ssize_t set_temp_##offset##_min (struct device *dev, \ | 678 | static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
682 | const char *buf, size_t count) \ | 679 | const char *buf, size_t count) \ |
683 | { \ | 680 | { \ |
684 | return set_temp_min(dev, buf, count, offset - 1); \ | 681 | return set_temp_min(dev, buf, count, offset - 1); \ |
685 | } \ | 682 | } \ |
686 | static ssize_t set_temp_##offset##_max (struct device *dev, \ | 683 | static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \ |
687 | const char *buf, size_t count) \ | 684 | const char *buf, size_t count) \ |
688 | { \ | 685 | { \ |
689 | return set_temp_max(dev, buf, count, offset - 1); \ | 686 | return set_temp_max(dev, buf, count, offset - 1); \ |
@@ -786,42 +783,42 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf, | |||
786 | return count; | 783 | return count; |
787 | } | 784 | } |
788 | #define pwm_auto(offset) \ | 785 | #define pwm_auto(offset) \ |
789 | static ssize_t show_pwm##offset##_auto_channels (struct device *dev, \ | 786 | static ssize_t show_pwm##offset##_auto_channels (struct device *dev, struct device_attribute *attr, \ |
790 | char *buf) \ | 787 | char *buf) \ |
791 | { \ | 788 | { \ |
792 | return show_pwm_auto_channels(dev, buf, offset - 1); \ | 789 | return show_pwm_auto_channels(dev, buf, offset - 1); \ |
793 | } \ | 790 | } \ |
794 | static ssize_t set_pwm##offset##_auto_channels (struct device *dev, \ | 791 | static ssize_t set_pwm##offset##_auto_channels (struct device *dev, struct device_attribute *attr, \ |
795 | const char *buf, size_t count) \ | 792 | const char *buf, size_t count) \ |
796 | { \ | 793 | { \ |
797 | return set_pwm_auto_channels(dev, buf, count, offset - 1); \ | 794 | return set_pwm_auto_channels(dev, buf, count, offset - 1); \ |
798 | } \ | 795 | } \ |
799 | static ssize_t show_pwm##offset##_auto_pwm_min (struct device *dev, \ | 796 | static ssize_t show_pwm##offset##_auto_pwm_min (struct device *dev, struct device_attribute *attr, \ |
800 | char *buf) \ | 797 | char *buf) \ |
801 | { \ | 798 | { \ |
802 | return show_pwm_auto_pwm_min(dev, buf, offset - 1); \ | 799 | return show_pwm_auto_pwm_min(dev, buf, offset - 1); \ |
803 | } \ | 800 | } \ |
804 | static ssize_t set_pwm##offset##_auto_pwm_min (struct device *dev, \ | 801 | static ssize_t set_pwm##offset##_auto_pwm_min (struct device *dev, struct device_attribute *attr, \ |
805 | const char *buf, size_t count) \ | 802 | const char *buf, size_t count) \ |
806 | { \ | 803 | { \ |
807 | return set_pwm_auto_pwm_min(dev, buf, count, offset - 1); \ | 804 | return set_pwm_auto_pwm_min(dev, buf, count, offset - 1); \ |
808 | } \ | 805 | } \ |
809 | static ssize_t show_pwm##offset##_auto_pwm_minctl (struct device *dev, \ | 806 | static ssize_t show_pwm##offset##_auto_pwm_minctl (struct device *dev, struct device_attribute *attr, \ |
810 | char *buf) \ | 807 | char *buf) \ |
811 | { \ | 808 | { \ |
812 | return show_pwm_auto_pwm_minctl(dev, buf, offset - 1); \ | 809 | return show_pwm_auto_pwm_minctl(dev, buf, offset - 1); \ |
813 | } \ | 810 | } \ |
814 | static ssize_t set_pwm##offset##_auto_pwm_minctl (struct device *dev, \ | 811 | static ssize_t set_pwm##offset##_auto_pwm_minctl (struct device *dev, struct device_attribute *attr, \ |
815 | const char *buf, size_t count) \ | 812 | const char *buf, size_t count) \ |
816 | { \ | 813 | { \ |
817 | return set_pwm_auto_pwm_minctl(dev, buf, count, offset - 1); \ | 814 | return set_pwm_auto_pwm_minctl(dev, buf, count, offset - 1); \ |
818 | } \ | 815 | } \ |
819 | static ssize_t show_pwm##offset##_auto_pwm_freq (struct device *dev, \ | 816 | static ssize_t show_pwm##offset##_auto_pwm_freq (struct device *dev, struct device_attribute *attr, \ |
820 | char *buf) \ | 817 | char *buf) \ |
821 | { \ | 818 | { \ |
822 | return show_pwm_auto_pwm_freq(dev, buf, offset - 1); \ | 819 | return show_pwm_auto_pwm_freq(dev, buf, offset - 1); \ |
823 | } \ | 820 | } \ |
824 | static ssize_t set_pwm##offset##_auto_pwm_freq(struct device *dev, \ | 821 | static ssize_t set_pwm##offset##_auto_pwm_freq(struct device *dev, struct device_attribute *attr, \ |
825 | const char *buf, size_t count) \ | 822 | const char *buf, size_t count) \ |
826 | { \ | 823 | { \ |
827 | return set_pwm_auto_pwm_freq(dev, buf, count, offset - 1); \ | 824 | return set_pwm_auto_pwm_freq(dev, buf, count, offset - 1); \ |
@@ -962,42 +959,42 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf, | |||
962 | return count; | 959 | return count; |
963 | } | 960 | } |
964 | #define temp_auto(offset) \ | 961 | #define temp_auto(offset) \ |
965 | static ssize_t show_temp##offset##_auto_temp_off (struct device *dev, \ | 962 | static ssize_t show_temp##offset##_auto_temp_off (struct device *dev, struct device_attribute *attr, \ |
966 | char *buf) \ | 963 | char *buf) \ |
967 | { \ | 964 | { \ |
968 | return show_temp_auto_temp_off(dev, buf, offset - 1); \ | 965 | return show_temp_auto_temp_off(dev, buf, offset - 1); \ |
969 | } \ | 966 | } \ |
970 | static ssize_t set_temp##offset##_auto_temp_off (struct device *dev, \ | 967 | static ssize_t set_temp##offset##_auto_temp_off (struct device *dev, struct device_attribute *attr, \ |
971 | const char *buf, size_t count) \ | 968 | const char *buf, size_t count) \ |
972 | { \ | 969 | { \ |
973 | return set_temp_auto_temp_off(dev, buf, count, offset - 1); \ | 970 | return set_temp_auto_temp_off(dev, buf, count, offset - 1); \ |
974 | } \ | 971 | } \ |
975 | static ssize_t show_temp##offset##_auto_temp_min (struct device *dev, \ | 972 | static ssize_t show_temp##offset##_auto_temp_min (struct device *dev, struct device_attribute *attr, \ |
976 | char *buf) \ | 973 | char *buf) \ |
977 | { \ | 974 | { \ |
978 | return show_temp_auto_temp_min(dev, buf, offset - 1); \ | 975 | return show_temp_auto_temp_min(dev, buf, offset - 1); \ |
979 | } \ | 976 | } \ |
980 | static ssize_t set_temp##offset##_auto_temp_min (struct device *dev, \ | 977 | static ssize_t set_temp##offset##_auto_temp_min (struct device *dev, struct device_attribute *attr, \ |
981 | const char *buf, size_t count) \ | 978 | const char *buf, size_t count) \ |
982 | { \ | 979 | { \ |
983 | return set_temp_auto_temp_min(dev, buf, count, offset - 1); \ | 980 | return set_temp_auto_temp_min(dev, buf, count, offset - 1); \ |
984 | } \ | 981 | } \ |
985 | static ssize_t show_temp##offset##_auto_temp_max (struct device *dev, \ | 982 | static ssize_t show_temp##offset##_auto_temp_max (struct device *dev, struct device_attribute *attr, \ |
986 | char *buf) \ | 983 | char *buf) \ |
987 | { \ | 984 | { \ |
988 | return show_temp_auto_temp_max(dev, buf, offset - 1); \ | 985 | return show_temp_auto_temp_max(dev, buf, offset - 1); \ |
989 | } \ | 986 | } \ |
990 | static ssize_t set_temp##offset##_auto_temp_max (struct device *dev, \ | 987 | static ssize_t set_temp##offset##_auto_temp_max (struct device *dev, struct device_attribute *attr, \ |
991 | const char *buf, size_t count) \ | 988 | const char *buf, size_t count) \ |
992 | { \ | 989 | { \ |
993 | return set_temp_auto_temp_max(dev, buf, count, offset - 1); \ | 990 | return set_temp_auto_temp_max(dev, buf, count, offset - 1); \ |
994 | } \ | 991 | } \ |
995 | static ssize_t show_temp##offset##_auto_temp_crit (struct device *dev, \ | 992 | static ssize_t show_temp##offset##_auto_temp_crit (struct device *dev, struct device_attribute *attr, \ |
996 | char *buf) \ | 993 | char *buf) \ |
997 | { \ | 994 | { \ |
998 | return show_temp_auto_temp_crit(dev, buf, offset - 1); \ | 995 | return show_temp_auto_temp_crit(dev, buf, offset - 1); \ |
999 | } \ | 996 | } \ |
1000 | static ssize_t set_temp##offset##_auto_temp_crit (struct device *dev, \ | 997 | static ssize_t set_temp##offset##_auto_temp_crit (struct device *dev, struct device_attribute *attr, \ |
1001 | const char *buf, size_t count) \ | 998 | const char *buf, size_t count) \ |
1002 | { \ | 999 | { \ |
1003 | return set_temp_auto_temp_crit(dev, buf, count, offset - 1); \ | 1000 | return set_temp_auto_temp_crit(dev, buf, count, offset - 1); \ |
diff --git a/drivers/i2c/chips/lm87.c b/drivers/i2c/chips/lm87.c index 98cabd665063..1921ed1af182 100644 --- a/drivers/i2c/chips/lm87.c +++ b/drivers/i2c/chips/lm87.c | |||
@@ -52,7 +52,6 @@ | |||
52 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 52 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
53 | */ | 53 | */ |
54 | 54 | ||
55 | #include <linux/config.h> | ||
56 | #include <linux/module.h> | 55 | #include <linux/module.h> |
57 | #include <linux/init.h> | 56 | #include <linux/init.h> |
58 | #include <linux/slab.h> | 57 | #include <linux/slab.h> |
@@ -218,19 +217,19 @@ static inline int lm87_write_value(struct i2c_client *client, u8 reg, u8 value) | |||
218 | } | 217 | } |
219 | 218 | ||
220 | #define show_in(offset) \ | 219 | #define show_in(offset) \ |
221 | static ssize_t show_in##offset##_input(struct device *dev, char *buf) \ | 220 | static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
222 | { \ | 221 | { \ |
223 | struct lm87_data *data = lm87_update_device(dev); \ | 222 | struct lm87_data *data = lm87_update_device(dev); \ |
224 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ | 223 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ |
225 | data->in_scale[offset])); \ | 224 | data->in_scale[offset])); \ |
226 | } \ | 225 | } \ |
227 | static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ | 226 | static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
228 | { \ | 227 | { \ |
229 | struct lm87_data *data = lm87_update_device(dev); \ | 228 | struct lm87_data *data = lm87_update_device(dev); \ |
230 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ | 229 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ |
231 | data->in_scale[offset])); \ | 230 | data->in_scale[offset])); \ |
232 | } \ | 231 | } \ |
233 | static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ | 232 | static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ |
234 | { \ | 233 | { \ |
235 | struct lm87_data *data = lm87_update_device(dev); \ | 234 | struct lm87_data *data = lm87_update_device(dev); \ |
236 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ | 235 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ |
@@ -274,13 +273,13 @@ static void set_in_max(struct device *dev, const char *buf, int nr) | |||
274 | } | 273 | } |
275 | 274 | ||
276 | #define set_in(offset) \ | 275 | #define set_in(offset) \ |
277 | static ssize_t set_in##offset##_min(struct device *dev, \ | 276 | static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, \ |
278 | const char *buf, size_t count) \ | 277 | const char *buf, size_t count) \ |
279 | { \ | 278 | { \ |
280 | set_in_min(dev, buf, offset); \ | 279 | set_in_min(dev, buf, offset); \ |
281 | return count; \ | 280 | return count; \ |
282 | } \ | 281 | } \ |
283 | static ssize_t set_in##offset##_max(struct device *dev, \ | 282 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, \ |
284 | const char *buf, size_t count) \ | 283 | const char *buf, size_t count) \ |
285 | { \ | 284 | { \ |
286 | set_in_max(dev, buf, offset); \ | 285 | set_in_max(dev, buf, offset); \ |
@@ -300,17 +299,17 @@ set_in(6); | |||
300 | set_in(7); | 299 | set_in(7); |
301 | 300 | ||
302 | #define show_temp(offset) \ | 301 | #define show_temp(offset) \ |
303 | static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \ | 302 | static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
304 | { \ | 303 | { \ |
305 | struct lm87_data *data = lm87_update_device(dev); \ | 304 | struct lm87_data *data = lm87_update_device(dev); \ |
306 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ | 305 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ |
307 | } \ | 306 | } \ |
308 | static ssize_t show_temp##offset##_low(struct device *dev, char *buf) \ | 307 | static ssize_t show_temp##offset##_low(struct device *dev, struct device_attribute *attr, char *buf) \ |
309 | { \ | 308 | { \ |
310 | struct lm87_data *data = lm87_update_device(dev); \ | 309 | struct lm87_data *data = lm87_update_device(dev); \ |
311 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[offset-1])); \ | 310 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[offset-1])); \ |
312 | } \ | 311 | } \ |
313 | static ssize_t show_temp##offset##_high(struct device *dev, char *buf) \ | 312 | static ssize_t show_temp##offset##_high(struct device *dev, struct device_attribute *attr, char *buf) \ |
314 | { \ | 313 | { \ |
315 | struct lm87_data *data = lm87_update_device(dev); \ | 314 | struct lm87_data *data = lm87_update_device(dev); \ |
316 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[offset-1])); \ | 315 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[offset-1])); \ |
@@ -346,13 +345,13 @@ static void set_temp_high(struct device *dev, const char *buf, int nr) | |||
346 | } | 345 | } |
347 | 346 | ||
348 | #define set_temp(offset) \ | 347 | #define set_temp(offset) \ |
349 | static ssize_t set_temp##offset##_low(struct device *dev, \ | 348 | static ssize_t set_temp##offset##_low(struct device *dev, struct device_attribute *attr, \ |
350 | const char *buf, size_t count) \ | 349 | const char *buf, size_t count) \ |
351 | { \ | 350 | { \ |
352 | set_temp_low(dev, buf, offset-1); \ | 351 | set_temp_low(dev, buf, offset-1); \ |
353 | return count; \ | 352 | return count; \ |
354 | } \ | 353 | } \ |
355 | static ssize_t set_temp##offset##_high(struct device *dev, \ | 354 | static ssize_t set_temp##offset##_high(struct device *dev, struct device_attribute *attr, \ |
356 | const char *buf, size_t count) \ | 355 | const char *buf, size_t count) \ |
357 | { \ | 356 | { \ |
358 | set_temp_high(dev, buf, offset-1); \ | 357 | set_temp_high(dev, buf, offset-1); \ |
@@ -366,13 +365,13 @@ set_temp(1); | |||
366 | set_temp(2); | 365 | set_temp(2); |
367 | set_temp(3); | 366 | set_temp(3); |
368 | 367 | ||
369 | static ssize_t show_temp_crit_int(struct device *dev, char *buf) | 368 | static ssize_t show_temp_crit_int(struct device *dev, struct device_attribute *attr, char *buf) |
370 | { | 369 | { |
371 | struct lm87_data *data = lm87_update_device(dev); | 370 | struct lm87_data *data = lm87_update_device(dev); |
372 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_int)); | 371 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_int)); |
373 | } | 372 | } |
374 | 373 | ||
375 | static ssize_t show_temp_crit_ext(struct device *dev, char *buf) | 374 | static ssize_t show_temp_crit_ext(struct device *dev, struct device_attribute *attr, char *buf) |
376 | { | 375 | { |
377 | struct lm87_data *data = lm87_update_device(dev); | 376 | struct lm87_data *data = lm87_update_device(dev); |
378 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_ext)); | 377 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_ext)); |
@@ -383,19 +382,19 @@ static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit_ext, NULL); | |||
383 | static DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit_ext, NULL); | 382 | static DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit_ext, NULL); |
384 | 383 | ||
385 | #define show_fan(offset) \ | 384 | #define show_fan(offset) \ |
386 | static ssize_t show_fan##offset##_input(struct device *dev, char *buf) \ | 385 | static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
387 | { \ | 386 | { \ |
388 | struct lm87_data *data = lm87_update_device(dev); \ | 387 | struct lm87_data *data = lm87_update_device(dev); \ |
389 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[offset-1], \ | 388 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[offset-1], \ |
390 | FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \ | 389 | FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \ |
391 | } \ | 390 | } \ |
392 | static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ | 391 | static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
393 | { \ | 392 | { \ |
394 | struct lm87_data *data = lm87_update_device(dev); \ | 393 | struct lm87_data *data = lm87_update_device(dev); \ |
395 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[offset-1], \ | 394 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[offset-1], \ |
396 | FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \ | 395 | FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \ |
397 | } \ | 396 | } \ |
398 | static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ | 397 | static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ |
399 | { \ | 398 | { \ |
400 | struct lm87_data *data = lm87_update_device(dev); \ | 399 | struct lm87_data *data = lm87_update_device(dev); \ |
401 | return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[offset-1])); \ | 400 | return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[offset-1])); \ |
@@ -465,13 +464,13 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
465 | } | 464 | } |
466 | 465 | ||
467 | #define set_fan(offset) \ | 466 | #define set_fan(offset) \ |
468 | static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ | 467 | static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
469 | size_t count) \ | 468 | size_t count) \ |
470 | { \ | 469 | { \ |
471 | set_fan_min(dev, buf, offset-1); \ | 470 | set_fan_min(dev, buf, offset-1); \ |
472 | return count; \ | 471 | return count; \ |
473 | } \ | 472 | } \ |
474 | static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \ | 473 | static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \ |
475 | size_t count) \ | 474 | size_t count) \ |
476 | { \ | 475 | { \ |
477 | return set_fan_div(dev, buf, count, offset-1); \ | 476 | return set_fan_div(dev, buf, count, offset-1); \ |
@@ -483,26 +482,26 @@ static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | |||
483 | set_fan(1); | 482 | set_fan(1); |
484 | set_fan(2); | 483 | set_fan(2); |
485 | 484 | ||
486 | static ssize_t show_alarms(struct device *dev, char *buf) | 485 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
487 | { | 486 | { |
488 | struct lm87_data *data = lm87_update_device(dev); | 487 | struct lm87_data *data = lm87_update_device(dev); |
489 | return sprintf(buf, "%d\n", data->alarms); | 488 | return sprintf(buf, "%d\n", data->alarms); |
490 | } | 489 | } |
491 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 490 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
492 | 491 | ||
493 | static ssize_t show_vid(struct device *dev, char *buf) | 492 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
494 | { | 493 | { |
495 | struct lm87_data *data = lm87_update_device(dev); | 494 | struct lm87_data *data = lm87_update_device(dev); |
496 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | 495 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); |
497 | } | 496 | } |
498 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 497 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
499 | 498 | ||
500 | static ssize_t show_vrm(struct device *dev, char *buf) | 499 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) |
501 | { | 500 | { |
502 | struct lm87_data *data = lm87_update_device(dev); | 501 | struct lm87_data *data = lm87_update_device(dev); |
503 | return sprintf(buf, "%d\n", data->vrm); | 502 | return sprintf(buf, "%d\n", data->vrm); |
504 | } | 503 | } |
505 | static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) | 504 | static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
506 | { | 505 | { |
507 | struct i2c_client *client = to_i2c_client(dev); | 506 | struct i2c_client *client = to_i2c_client(dev); |
508 | struct lm87_data *data = i2c_get_clientdata(client); | 507 | struct lm87_data *data = i2c_get_clientdata(client); |
@@ -511,12 +510,12 @@ static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) | |||
511 | } | 510 | } |
512 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); | 511 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); |
513 | 512 | ||
514 | static ssize_t show_aout(struct device *dev, char *buf) | 513 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) |
515 | { | 514 | { |
516 | struct lm87_data *data = lm87_update_device(dev); | 515 | struct lm87_data *data = lm87_update_device(dev); |
517 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | 516 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); |
518 | } | 517 | } |
519 | static ssize_t set_aout(struct device *dev, const char *buf, size_t count) | 518 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
520 | { | 519 | { |
521 | struct i2c_client *client = to_i2c_client(dev); | 520 | struct i2c_client *client = to_i2c_client(dev); |
522 | struct lm87_data *data = i2c_get_clientdata(client); | 521 | struct lm87_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c index 2c00ff83babc..a67dcadf7cb0 100644 --- a/drivers/i2c/chips/lm90.c +++ b/drivers/i2c/chips/lm90.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Based on the lm83 driver. The LM90 is a sensor chip made by National | 6 | * Based on the lm83 driver. The LM90 is a sensor chip made by National |
7 | * Semiconductor. It reports up to two temperatures (its own plus up to | 7 | * Semiconductor. It reports up to two temperatures (its own plus up to |
@@ -19,7 +19,7 @@ | |||
19 | * Complete datasheets can be obtained from National's website at: | 19 | * Complete datasheets can be obtained from National's website at: |
20 | * http://www.national.com/pf/LM/LM89.html | 20 | * http://www.national.com/pf/LM/LM89.html |
21 | * http://www.national.com/pf/LM/LM99.html | 21 | * http://www.national.com/pf/LM/LM99.html |
22 | * Note that there is no way to differenciate between both chips. | 22 | * Note that there is no way to differentiate between both chips. |
23 | * | 23 | * |
24 | * This driver also supports the LM86, another sensor chip made by | 24 | * This driver also supports the LM86, another sensor chip made by |
25 | * National Semiconductor. It is exactly similar to the LM90 except it | 25 | * National Semiconductor. It is exactly similar to the LM90 except it |
@@ -39,7 +39,7 @@ | |||
39 | * chips made by Maxim. These chips are similar to the LM86. Complete | 39 | * chips made by Maxim. These chips are similar to the LM86. Complete |
40 | * datasheet can be obtained at Maxim's website at: | 40 | * datasheet can be obtained at Maxim's website at: |
41 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 | 41 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 |
42 | * Note that there is no easy way to differenciate between the three | 42 | * Note that there is no easy way to differentiate between the three |
43 | * variants. The extra address and features of the MAX6659 are not | 43 | * variants. The extra address and features of the MAX6659 are not |
44 | * supported by this driver. | 44 | * supported by this driver. |
45 | * | 45 | * |
@@ -70,13 +70,13 @@ | |||
70 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 70 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
71 | */ | 71 | */ |
72 | 72 | ||
73 | #include <linux/config.h> | ||
74 | #include <linux/module.h> | 73 | #include <linux/module.h> |
75 | #include <linux/init.h> | 74 | #include <linux/init.h> |
76 | #include <linux/slab.h> | 75 | #include <linux/slab.h> |
77 | #include <linux/jiffies.h> | 76 | #include <linux/jiffies.h> |
78 | #include <linux/i2c.h> | 77 | #include <linux/i2c.h> |
79 | #include <linux/i2c-sensor.h> | 78 | #include <linux/i2c-sensor.h> |
79 | #include <linux/hwmon-sysfs.h> | ||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Addresses to scan | 82 | * Addresses to scan |
@@ -139,9 +139,9 @@ SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); | |||
139 | /* | 139 | /* |
140 | * Conversions and various macros | 140 | * Conversions and various macros |
141 | * For local temperatures and limits, critical limits and the hysteresis | 141 | * For local temperatures and limits, critical limits and the hysteresis |
142 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius. | 142 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius. |
143 | * For remote temperatures and limits, it uses signed 11-bit values with | 143 | * For remote temperatures and limits, it uses signed 11-bit values with |
144 | * LSB = 0.125 degree Celcius, left-justified in 16-bit registers. | 144 | * LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
145 | */ | 145 | */ |
146 | 146 | ||
147 | #define TEMP1_FROM_REG(val) ((val) * 1000) | 147 | #define TEMP1_FROM_REG(val) ((val) * 1000) |
@@ -206,9 +206,14 @@ struct lm90_data { | |||
206 | int kind; | 206 | int kind; |
207 | 207 | ||
208 | /* registers values */ | 208 | /* registers values */ |
209 | s8 temp_input1, temp_low1, temp_high1; /* local */ | 209 | s8 temp8[5]; /* 0: local input |
210 | s16 temp_input2, temp_low2, temp_high2; /* remote, combined */ | 210 | 1: local low limit |
211 | s8 temp_crit1, temp_crit2; | 211 | 2: local high limit |
212 | 3: local critical limit | ||
213 | 4: remote critical limit */ | ||
214 | s16 temp11[3]; /* 0: remote input | ||
215 | 1: remote low limit | ||
216 | 2: remote high limit */ | ||
212 | u8 temp_hyst; | 217 | u8 temp_hyst; |
213 | u8 alarms; /* bitvector */ | 218 | u8 alarms; /* bitvector */ |
214 | }; | 219 | }; |
@@ -217,75 +222,88 @@ struct lm90_data { | |||
217 | * Sysfs stuff | 222 | * Sysfs stuff |
218 | */ | 223 | */ |
219 | 224 | ||
220 | #define show_temp(value, converter) \ | 225 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
221 | static ssize_t show_##value(struct device *dev, char *buf) \ | 226 | char *buf) |
222 | { \ | 227 | { |
223 | struct lm90_data *data = lm90_update_device(dev); \ | 228 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
224 | return sprintf(buf, "%d\n", converter(data->value)); \ | 229 | struct lm90_data *data = lm90_update_device(dev); |
230 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index])); | ||
231 | } | ||
232 | |||
233 | static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | ||
234 | const char *buf, size_t count) | ||
235 | { | ||
236 | static const u8 reg[4] = { | ||
237 | LM90_REG_W_LOCAL_LOW, | ||
238 | LM90_REG_W_LOCAL_HIGH, | ||
239 | LM90_REG_W_LOCAL_CRIT, | ||
240 | LM90_REG_W_REMOTE_CRIT, | ||
241 | }; | ||
242 | |||
243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
244 | struct i2c_client *client = to_i2c_client(dev); | ||
245 | struct lm90_data *data = i2c_get_clientdata(client); | ||
246 | long val = simple_strtol(buf, NULL, 10); | ||
247 | int nr = attr->index; | ||
248 | |||
249 | down(&data->update_lock); | ||
250 | if (data->kind == adt7461) | ||
251 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | ||
252 | else | ||
253 | data->temp8[nr] = TEMP1_TO_REG(val); | ||
254 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | ||
255 | up(&data->update_lock); | ||
256 | return count; | ||
225 | } | 257 | } |
226 | show_temp(temp_input1, TEMP1_FROM_REG); | 258 | |
227 | show_temp(temp_input2, TEMP2_FROM_REG); | 259 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
228 | show_temp(temp_low1, TEMP1_FROM_REG); | 260 | char *buf) |
229 | show_temp(temp_low2, TEMP2_FROM_REG); | 261 | { |
230 | show_temp(temp_high1, TEMP1_FROM_REG); | 262 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
231 | show_temp(temp_high2, TEMP2_FROM_REG); | 263 | struct lm90_data *data = lm90_update_device(dev); |
232 | show_temp(temp_crit1, TEMP1_FROM_REG); | 264 | return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index])); |
233 | show_temp(temp_crit2, TEMP1_FROM_REG); | ||
234 | |||
235 | #define set_temp1(value, reg) \ | ||
236 | static ssize_t set_##value(struct device *dev, const char *buf, \ | ||
237 | size_t count) \ | ||
238 | { \ | ||
239 | struct i2c_client *client = to_i2c_client(dev); \ | ||
240 | struct lm90_data *data = i2c_get_clientdata(client); \ | ||
241 | long val = simple_strtol(buf, NULL, 10); \ | ||
242 | \ | ||
243 | down(&data->update_lock); \ | ||
244 | if (data->kind == adt7461) \ | ||
245 | data->value = TEMP1_TO_REG_ADT7461(val); \ | ||
246 | else \ | ||
247 | data->value = TEMP1_TO_REG(val); \ | ||
248 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
249 | up(&data->update_lock); \ | ||
250 | return count; \ | ||
251 | } | 265 | } |
252 | #define set_temp2(value, regh, regl) \ | 266 | |
253 | static ssize_t set_##value(struct device *dev, const char *buf, \ | 267 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
254 | size_t count) \ | 268 | const char *buf, size_t count) |
255 | { \ | 269 | { |
256 | struct i2c_client *client = to_i2c_client(dev); \ | 270 | static const u8 reg[4] = { |
257 | struct lm90_data *data = i2c_get_clientdata(client); \ | 271 | LM90_REG_W_REMOTE_LOWH, |
258 | long val = simple_strtol(buf, NULL, 10); \ | 272 | LM90_REG_W_REMOTE_LOWL, |
259 | \ | 273 | LM90_REG_W_REMOTE_HIGHH, |
260 | down(&data->update_lock); \ | 274 | LM90_REG_W_REMOTE_HIGHL, |
261 | if (data->kind == adt7461) \ | 275 | }; |
262 | data->value = TEMP2_TO_REG_ADT7461(val); \ | 276 | |
263 | else \ | 277 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
264 | data->value = TEMP2_TO_REG(val); \ | 278 | struct i2c_client *client = to_i2c_client(dev); |
265 | i2c_smbus_write_byte_data(client, regh, data->value >> 8); \ | 279 | struct lm90_data *data = i2c_get_clientdata(client); |
266 | i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \ | 280 | long val = simple_strtol(buf, NULL, 10); |
267 | up(&data->update_lock); \ | 281 | int nr = attr->index; |
268 | return count; \ | 282 | |
283 | down(&data->update_lock); | ||
284 | if (data->kind == adt7461) | ||
285 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | ||
286 | else | ||
287 | data->temp11[nr] = TEMP2_TO_REG(val); | ||
288 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | ||
289 | data->temp11[nr] >> 8); | ||
290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | ||
291 | data->temp11[nr] & 0xff); | ||
292 | up(&data->update_lock); | ||
293 | return count; | ||
269 | } | 294 | } |
270 | set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW); | 295 | |
271 | set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL); | 296 | static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr, |
272 | set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH); | 297 | char *buf) |
273 | set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL); | 298 | { |
274 | set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT); | 299 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
275 | set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT); | 300 | struct lm90_data *data = lm90_update_device(dev); |
276 | 301 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index]) | |
277 | #define show_temp_hyst(value, basereg) \ | 302 | - TEMP1_FROM_REG(data->temp_hyst)); |
278 | static ssize_t show_##value(struct device *dev, char *buf) \ | ||
279 | { \ | ||
280 | struct lm90_data *data = lm90_update_device(dev); \ | ||
281 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \ | ||
282 | - TEMP1_FROM_REG(data->temp_hyst)); \ | ||
283 | } | 303 | } |
284 | show_temp_hyst(temp_hyst1, temp_crit1); | ||
285 | show_temp_hyst(temp_hyst2, temp_crit2); | ||
286 | 304 | ||
287 | static ssize_t set_temp_hyst1(struct device *dev, const char *buf, | 305 | static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, |
288 | size_t count) | 306 | const char *buf, size_t count) |
289 | { | 307 | { |
290 | struct i2c_client *client = to_i2c_client(dev); | 308 | struct i2c_client *client = to_i2c_client(dev); |
291 | struct lm90_data *data = i2c_get_clientdata(client); | 309 | struct lm90_data *data = i2c_get_clientdata(client); |
@@ -293,36 +311,37 @@ static ssize_t set_temp_hyst1(struct device *dev, const char *buf, | |||
293 | long hyst; | 311 | long hyst; |
294 | 312 | ||
295 | down(&data->update_lock); | 313 | down(&data->update_lock); |
296 | hyst = TEMP1_FROM_REG(data->temp_crit1) - val; | 314 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
297 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 315 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
298 | HYST_TO_REG(hyst)); | 316 | HYST_TO_REG(hyst)); |
299 | up(&data->update_lock); | 317 | up(&data->update_lock); |
300 | return count; | 318 | return count; |
301 | } | 319 | } |
302 | 320 | ||
303 | static ssize_t show_alarms(struct device *dev, char *buf) | 321 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
322 | char *buf) | ||
304 | { | 323 | { |
305 | struct lm90_data *data = lm90_update_device(dev); | 324 | struct lm90_data *data = lm90_update_device(dev); |
306 | return sprintf(buf, "%d\n", data->alarms); | 325 | return sprintf(buf, "%d\n", data->alarms); |
307 | } | 326 | } |
308 | 327 | ||
309 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 328 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); |
310 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 329 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
311 | static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1, | 330 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8, |
312 | set_temp_low1); | 331 | set_temp8, 1); |
313 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, | 332 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
314 | set_temp_low2); | 333 | set_temp11, 1); |
315 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, | 334 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
316 | set_temp_high1); | 335 | set_temp8, 2); |
317 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, | 336 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
318 | set_temp_high2); | 337 | set_temp11, 2); |
319 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1, | 338 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8, |
320 | set_temp_crit1); | 339 | set_temp8, 3); |
321 | static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, | 340 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8, |
322 | set_temp_crit2); | 341 | set_temp8, 4); |
323 | static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1, | 342 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, |
324 | set_temp_hyst1); | 343 | set_temphyst, 3); |
325 | static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL); | 344 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); |
326 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 345 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
327 | 346 | ||
328 | /* | 347 | /* |
@@ -481,16 +500,26 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
481 | lm90_init_client(new_client); | 500 | lm90_init_client(new_client); |
482 | 501 | ||
483 | /* Register sysfs hooks */ | 502 | /* Register sysfs hooks */ |
484 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 503 | device_create_file(&new_client->dev, |
485 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 504 | &sensor_dev_attr_temp1_input.dev_attr); |
486 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 505 | device_create_file(&new_client->dev, |
487 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 506 | &sensor_dev_attr_temp2_input.dev_attr); |
488 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 507 | device_create_file(&new_client->dev, |
489 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 508 | &sensor_dev_attr_temp1_min.dev_attr); |
490 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 509 | device_create_file(&new_client->dev, |
491 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 510 | &sensor_dev_attr_temp2_min.dev_attr); |
492 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); | 511 | device_create_file(&new_client->dev, |
493 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 512 | &sensor_dev_attr_temp1_max.dev_attr); |
513 | device_create_file(&new_client->dev, | ||
514 | &sensor_dev_attr_temp2_max.dev_attr); | ||
515 | device_create_file(&new_client->dev, | ||
516 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
517 | device_create_file(&new_client->dev, | ||
518 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
519 | device_create_file(&new_client->dev, | ||
520 | &sensor_dev_attr_temp1_crit_hyst.dev_attr); | ||
521 | device_create_file(&new_client->dev, | ||
522 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | ||
494 | device_create_file(&new_client->dev, &dev_attr_alarms); | 523 | device_create_file(&new_client->dev, &dev_attr_alarms); |
495 | 524 | ||
496 | return 0; | 525 | return 0; |
@@ -541,16 +570,16 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
541 | u8 oldh, newh; | 570 | u8 oldh, newh; |
542 | 571 | ||
543 | dev_dbg(&client->dev, "Updating lm90 data.\n"); | 572 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
544 | data->temp_input1 = i2c_smbus_read_byte_data(client, | 573 | data->temp8[0] = i2c_smbus_read_byte_data(client, |
545 | LM90_REG_R_LOCAL_TEMP); | 574 | LM90_REG_R_LOCAL_TEMP); |
546 | data->temp_high1 = i2c_smbus_read_byte_data(client, | 575 | data->temp8[1] = i2c_smbus_read_byte_data(client, |
547 | LM90_REG_R_LOCAL_HIGH); | 576 | LM90_REG_R_LOCAL_LOW); |
548 | data->temp_low1 = i2c_smbus_read_byte_data(client, | 577 | data->temp8[2] = i2c_smbus_read_byte_data(client, |
549 | LM90_REG_R_LOCAL_LOW); | 578 | LM90_REG_R_LOCAL_HIGH); |
550 | data->temp_crit1 = i2c_smbus_read_byte_data(client, | 579 | data->temp8[3] = i2c_smbus_read_byte_data(client, |
551 | LM90_REG_R_LOCAL_CRIT); | 580 | LM90_REG_R_LOCAL_CRIT); |
552 | data->temp_crit2 = i2c_smbus_read_byte_data(client, | 581 | data->temp8[4] = i2c_smbus_read_byte_data(client, |
553 | LM90_REG_R_REMOTE_CRIT); | 582 | LM90_REG_R_REMOTE_CRIT); |
554 | data->temp_hyst = i2c_smbus_read_byte_data(client, | 583 | data->temp_hyst = i2c_smbus_read_byte_data(client, |
555 | LM90_REG_R_TCRIT_HYST); | 584 | LM90_REG_R_TCRIT_HYST); |
556 | 585 | ||
@@ -570,13 +599,13 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
570 | */ | 599 | */ |
571 | oldh = i2c_smbus_read_byte_data(client, | 600 | oldh = i2c_smbus_read_byte_data(client, |
572 | LM90_REG_R_REMOTE_TEMPH); | 601 | LM90_REG_R_REMOTE_TEMPH); |
573 | data->temp_input2 = i2c_smbus_read_byte_data(client, | 602 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
574 | LM90_REG_R_REMOTE_TEMPL); | 603 | LM90_REG_R_REMOTE_TEMPL); |
575 | newh = i2c_smbus_read_byte_data(client, | 604 | newh = i2c_smbus_read_byte_data(client, |
576 | LM90_REG_R_REMOTE_TEMPH); | 605 | LM90_REG_R_REMOTE_TEMPH); |
577 | if (newh != oldh) { | 606 | if (newh != oldh) { |
578 | data->temp_input2 = i2c_smbus_read_byte_data(client, | 607 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
579 | LM90_REG_R_REMOTE_TEMPL); | 608 | LM90_REG_R_REMOTE_TEMPL); |
580 | #ifdef DEBUG | 609 | #ifdef DEBUG |
581 | oldh = i2c_smbus_read_byte_data(client, | 610 | oldh = i2c_smbus_read_byte_data(client, |
582 | LM90_REG_R_REMOTE_TEMPH); | 611 | LM90_REG_R_REMOTE_TEMPH); |
@@ -586,16 +615,16 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
586 | "wrong.\n"); | 615 | "wrong.\n"); |
587 | #endif | 616 | #endif |
588 | } | 617 | } |
589 | data->temp_input2 |= (newh << 8); | 618 | data->temp11[0] |= (newh << 8); |
590 | 619 | ||
591 | data->temp_high2 = (i2c_smbus_read_byte_data(client, | 620 | data->temp11[1] = (i2c_smbus_read_byte_data(client, |
621 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
622 | i2c_smbus_read_byte_data(client, | ||
623 | LM90_REG_R_REMOTE_LOWL); | ||
624 | data->temp11[2] = (i2c_smbus_read_byte_data(client, | ||
592 | LM90_REG_R_REMOTE_HIGHH) << 8) + | 625 | LM90_REG_R_REMOTE_HIGHH) << 8) + |
593 | i2c_smbus_read_byte_data(client, | 626 | i2c_smbus_read_byte_data(client, |
594 | LM90_REG_R_REMOTE_HIGHL); | 627 | LM90_REG_R_REMOTE_HIGHL); |
595 | data->temp_low2 = (i2c_smbus_read_byte_data(client, | ||
596 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
597 | i2c_smbus_read_byte_data(client, | ||
598 | LM90_REG_R_REMOTE_LOWL); | ||
599 | data->alarms = i2c_smbus_read_byte_data(client, | 628 | data->alarms = i2c_smbus_read_byte_data(client, |
600 | LM90_REG_R_STATUS); | 629 | LM90_REG_R_STATUS); |
601 | 630 | ||
diff --git a/drivers/i2c/chips/lm92.c b/drivers/i2c/chips/lm92.c index fe6e83d70a72..215c8e40ffdd 100644 --- a/drivers/i2c/chips/lm92.c +++ b/drivers/i2c/chips/lm92.c | |||
@@ -140,7 +140,7 @@ static struct lm92_data *lm92_update_device(struct device *dev) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | #define show_temp(value) \ | 142 | #define show_temp(value) \ |
143 | static ssize_t show_##value(struct device *dev, char *buf) \ | 143 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
144 | { \ | 144 | { \ |
145 | struct lm92_data *data = lm92_update_device(dev); \ | 145 | struct lm92_data *data = lm92_update_device(dev); \ |
146 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ | 146 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ |
@@ -151,7 +151,7 @@ show_temp(temp1_min); | |||
151 | show_temp(temp1_max); | 151 | show_temp(temp1_max); |
152 | 152 | ||
153 | #define set_temp(value, reg) \ | 153 | #define set_temp(value, reg) \ |
154 | static ssize_t set_##value(struct device *dev, const char *buf, \ | 154 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ |
155 | size_t count) \ | 155 | size_t count) \ |
156 | { \ | 156 | { \ |
157 | struct i2c_client *client = to_i2c_client(dev); \ | 157 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -168,26 +168,26 @@ set_temp(temp1_crit, LM92_REG_TEMP_CRIT); | |||
168 | set_temp(temp1_min, LM92_REG_TEMP_LOW); | 168 | set_temp(temp1_min, LM92_REG_TEMP_LOW); |
169 | set_temp(temp1_max, LM92_REG_TEMP_HIGH); | 169 | set_temp(temp1_max, LM92_REG_TEMP_HIGH); |
170 | 170 | ||
171 | static ssize_t show_temp1_crit_hyst(struct device *dev, char *buf) | 171 | static ssize_t show_temp1_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
172 | { | 172 | { |
173 | struct lm92_data *data = lm92_update_device(dev); | 173 | struct lm92_data *data = lm92_update_device(dev); |
174 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_crit) | 174 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_crit) |
175 | - TEMP_FROM_REG(data->temp1_hyst)); | 175 | - TEMP_FROM_REG(data->temp1_hyst)); |
176 | } | 176 | } |
177 | static ssize_t show_temp1_max_hyst(struct device *dev, char *buf) | 177 | static ssize_t show_temp1_max_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
178 | { | 178 | { |
179 | struct lm92_data *data = lm92_update_device(dev); | 179 | struct lm92_data *data = lm92_update_device(dev); |
180 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_max) | 180 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_max) |
181 | - TEMP_FROM_REG(data->temp1_hyst)); | 181 | - TEMP_FROM_REG(data->temp1_hyst)); |
182 | } | 182 | } |
183 | static ssize_t show_temp1_min_hyst(struct device *dev, char *buf) | 183 | static ssize_t show_temp1_min_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
184 | { | 184 | { |
185 | struct lm92_data *data = lm92_update_device(dev); | 185 | struct lm92_data *data = lm92_update_device(dev); |
186 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_min) | 186 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_min) |
187 | + TEMP_FROM_REG(data->temp1_hyst)); | 187 | + TEMP_FROM_REG(data->temp1_hyst)); |
188 | } | 188 | } |
189 | 189 | ||
190 | static ssize_t set_temp1_crit_hyst(struct device *dev, const char *buf, | 190 | static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, |
191 | size_t count) | 191 | size_t count) |
192 | { | 192 | { |
193 | struct i2c_client *client = to_i2c_client(dev); | 193 | struct i2c_client *client = to_i2c_client(dev); |
@@ -202,7 +202,7 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, const char *buf, | |||
202 | return count; | 202 | return count; |
203 | } | 203 | } |
204 | 204 | ||
205 | static ssize_t show_alarms(struct device *dev, char *buf) | 205 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
206 | { | 206 | { |
207 | struct lm92_data *data = lm92_update_device(dev); | 207 | struct lm92_data *data = lm92_update_device(dev); |
208 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); | 208 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index e771566dffa8..5e463c47bfbc 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -40,11 +40,8 @@ static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; | |||
40 | 40 | ||
41 | static struct i2c_client_address_data addr_data = { | 41 | static struct i2c_client_address_data addr_data = { |
42 | .normal_i2c = normal_addr, | 42 | .normal_i2c = normal_addr, |
43 | .normal_i2c_range = ignore, | ||
44 | .probe = ignore, | 43 | .probe = ignore, |
45 | .probe_range = ignore, | ||
46 | .ignore = ignore, | 44 | .ignore = ignore, |
47 | .ignore_range = ignore, | ||
48 | .force = ignore, | 45 | .force = ignore, |
49 | }; | 46 | }; |
50 | 47 | ||
diff --git a/drivers/i2c/chips/max1619.c b/drivers/i2c/chips/max1619.c index 5afa961a5e10..bf553dcd97d6 100644 --- a/drivers/i2c/chips/max1619.c +++ b/drivers/i2c/chips/max1619.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
@@ -122,7 +121,7 @@ struct max1619_data { | |||
122 | */ | 121 | */ |
123 | 122 | ||
124 | #define show_temp(value) \ | 123 | #define show_temp(value) \ |
125 | static ssize_t show_##value(struct device *dev, char *buf) \ | 124 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ |
126 | { \ | 125 | { \ |
127 | struct max1619_data *data = max1619_update_device(dev); \ | 126 | struct max1619_data *data = max1619_update_device(dev); \ |
128 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ | 127 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ |
@@ -135,7 +134,7 @@ show_temp(temp_crit2); | |||
135 | show_temp(temp_hyst2); | 134 | show_temp(temp_hyst2); |
136 | 135 | ||
137 | #define set_temp2(value, reg) \ | 136 | #define set_temp2(value, reg) \ |
138 | static ssize_t set_##value(struct device *dev, const char *buf, \ | 137 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ |
139 | size_t count) \ | 138 | size_t count) \ |
140 | { \ | 139 | { \ |
141 | struct i2c_client *client = to_i2c_client(dev); \ | 140 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -154,7 +153,7 @@ set_temp2(temp_high2, MAX1619_REG_W_REMOTE_HIGH); | |||
154 | set_temp2(temp_crit2, MAX1619_REG_W_REMOTE_CRIT); | 153 | set_temp2(temp_crit2, MAX1619_REG_W_REMOTE_CRIT); |
155 | set_temp2(temp_hyst2, MAX1619_REG_W_TCRIT_HYST); | 154 | set_temp2(temp_hyst2, MAX1619_REG_W_TCRIT_HYST); |
156 | 155 | ||
157 | static ssize_t show_alarms(struct device *dev, char *buf) | 156 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
158 | { | 157 | { |
159 | struct max1619_data *data = max1619_update_device(dev); | 158 | struct max1619_data *data = max1619_update_device(dev); |
160 | return sprintf(buf, "%d\n", data->alarms); | 159 | return sprintf(buf, "%d\n", data->alarms); |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c new file mode 100644 index 000000000000..fe6b150ec4c2 --- /dev/null +++ b/drivers/i2c/chips/max6875.c | |||
@@ -0,0 +1,473 @@ | |||
1 | /* | ||
2 | max6875.c - driver for MAX6874/MAX6875 | ||
3 | |||
4 | Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> | ||
5 | |||
6 | Based on i2c/chips/eeprom.c | ||
7 | |||
8 | The MAX6875 has two EEPROM sections: config and user. | ||
9 | At reset, the config EEPROM is read into the registers. | ||
10 | |||
11 | This driver make 3 binary files available in sysfs: | ||
12 | reg_config - direct access to the registers | ||
13 | eeprom_config - acesses configuration eeprom space | ||
14 | eeprom_user - free for application use | ||
15 | |||
16 | In our application, we put device serial & model numbers in user eeprom. | ||
17 | |||
18 | Notes: | ||
19 | 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT | ||
20 | be overwritten, so the driver explicitly prevents that. | ||
21 | 2) It's a good idea to keep the config (0x45) locked in config EEPROM. | ||
22 | You can temporarily enable config writes by changing register 0x45. | ||
23 | |||
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 | ||
26 | the Free Software Foundation; version 2 of the License. | ||
27 | */ | ||
28 | |||
29 | #include <linux/config.h> | ||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/sched.h> | ||
35 | #include <linux/delay.h> | ||
36 | #include <linux/i2c.h> | ||
37 | #include <linux/i2c-sensor.h> | ||
38 | |||
39 | /* Addresses to scan */ | ||
40 | static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END}; | ||
41 | static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; | ||
42 | |||
43 | /* Insmod parameters */ | ||
44 | SENSORS_INSMOD_1(max6875); | ||
45 | |||
46 | /* this param will prevent 'accidental' writes to the eeprom */ | ||
47 | static int allow_write = 0; | ||
48 | module_param(allow_write, int, 0); | ||
49 | MODULE_PARM_DESC(allow_write, | ||
50 | "Enable write access:\n" | ||
51 | "*0: Read only\n" | ||
52 | " 1: Read/Write access"); | ||
53 | |||
54 | /* The MAX6875 can only read/write 16 bytes at a time */ | ||
55 | #define SLICE_SIZE 16 | ||
56 | #define SLICE_BITS 4 | ||
57 | |||
58 | /* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */ | ||
59 | #define CONFIG_EEPROM_BASE 0x8000 | ||
60 | #define CONFIG_EEPROM_SIZE 0x0046 | ||
61 | #define CONFIG_EEPROM_SLICES 5 | ||
62 | |||
63 | /* USER EEPROM is at addresses 0x8100 - 0x82FF */ | ||
64 | #define USER_EEPROM_BASE 0x8100 | ||
65 | #define USER_EEPROM_SIZE 0x0200 | ||
66 | #define USER_EEPROM_SLICES 32 | ||
67 | |||
68 | /* MAX6875 commands */ | ||
69 | #define MAX6875_CMD_BLOCK_WRITE 0x83 | ||
70 | #define MAX6875_CMD_BLOCK_READ 0x84 | ||
71 | #define MAX6875_CMD_REBOOT 0x88 | ||
72 | |||
73 | enum max6875_area_type { | ||
74 | max6875_register_config=0, | ||
75 | max6875_eeprom_config, | ||
76 | max6875_eeprom_user, | ||
77 | max6857_max | ||
78 | }; | ||
79 | |||
80 | struct eeprom_block { | ||
81 | enum max6875_area_type type; | ||
82 | u8 slices; | ||
83 | u32 size; | ||
84 | u32 valid; | ||
85 | u32 base; | ||
86 | unsigned long *updated; | ||
87 | u8 *data; | ||
88 | }; | ||
89 | |||
90 | /* Each client has this additional data */ | ||
91 | struct max6875_data { | ||
92 | struct i2c_client client; | ||
93 | struct semaphore update_lock; | ||
94 | struct eeprom_block blocks[max6857_max]; | ||
95 | /* the above structs point into the arrays below */ | ||
96 | u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)]; | ||
97 | unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)]; | ||
98 | }; | ||
99 | |||
100 | static int max6875_attach_adapter(struct i2c_adapter *adapter); | ||
101 | static int max6875_detect(struct i2c_adapter *adapter, int address, int kind); | ||
102 | static int max6875_detach_client(struct i2c_client *client); | ||
103 | |||
104 | /* This is the driver that will be inserted */ | ||
105 | static struct i2c_driver max6875_driver = { | ||
106 | .owner = THIS_MODULE, | ||
107 | .name = "max6875", | ||
108 | .flags = I2C_DF_NOTIFY, | ||
109 | .attach_adapter = max6875_attach_adapter, | ||
110 | .detach_client = max6875_detach_client, | ||
111 | }; | ||
112 | |||
113 | static int max6875_update_slice(struct i2c_client *client, | ||
114 | struct eeprom_block *blk, | ||
115 | int slice) | ||
116 | { | ||
117 | struct max6875_data *data = i2c_get_clientdata(client); | ||
118 | int i, j, addr, count; | ||
119 | u8 rdbuf[SLICE_SIZE]; | ||
120 | int retval = 0; | ||
121 | |||
122 | if (slice >= blk->slices) | ||
123 | return -1; | ||
124 | |||
125 | down(&data->update_lock); | ||
126 | |||
127 | if (!(blk->valid & (1 << slice)) || | ||
128 | (jiffies - blk->updated[slice] > 300 * HZ) || | ||
129 | (jiffies < blk->updated[slice])) { | ||
130 | dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n", | ||
131 | slice, blk->base); | ||
132 | |||
133 | addr = blk->base + (slice << SLICE_BITS); | ||
134 | count = blk->size - (slice << SLICE_BITS); | ||
135 | if (count > SLICE_SIZE) { | ||
136 | count = SLICE_SIZE; | ||
137 | } | ||
138 | |||
139 | /* Preset the read address */ | ||
140 | if (addr < 0x100) { | ||
141 | /* select the register */ | ||
142 | if (i2c_smbus_write_byte(client, addr & 0xFF)) { | ||
143 | dev_dbg(&client->dev, "max6875 register select has failed!\n"); | ||
144 | retval = -1; | ||
145 | goto exit; | ||
146 | } | ||
147 | } else { | ||
148 | /* select the eeprom */ | ||
149 | if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { | ||
150 | dev_dbg(&client->dev, "max6875 address set has failed!\n"); | ||
151 | retval = -1; | ||
152 | goto exit; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { | ||
157 | if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ, | ||
158 | rdbuf) != SLICE_SIZE) | ||
159 | { | ||
160 | retval = -1; | ||
161 | goto exit; | ||
162 | } | ||
163 | |||
164 | memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count); | ||
165 | } else { | ||
166 | for (i = 0; i < count; i++) { | ||
167 | j = i2c_smbus_read_byte(client); | ||
168 | if (j < 0) | ||
169 | { | ||
170 | retval = -1; | ||
171 | goto exit; | ||
172 | } | ||
173 | blk->data[(slice << SLICE_BITS) + i] = (u8) j; | ||
174 | } | ||
175 | } | ||
176 | blk->updated[slice] = jiffies; | ||
177 | blk->valid |= (1 << slice); | ||
178 | } | ||
179 | exit: | ||
180 | up(&data->update_lock); | ||
181 | return retval; | ||
182 | } | ||
183 | |||
184 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count, | ||
185 | enum max6875_area_type area_type) | ||
186 | { | ||
187 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | ||
188 | struct max6875_data *data = i2c_get_clientdata(client); | ||
189 | struct eeprom_block *blk; | ||
190 | int slice; | ||
191 | |||
192 | blk = &data->blocks[area_type]; | ||
193 | |||
194 | if (off > blk->size) | ||
195 | return 0; | ||
196 | if (off + count > blk->size) | ||
197 | count = blk->size - off; | ||
198 | |||
199 | /* Only refresh slices which contain requested bytes */ | ||
200 | for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) | ||
201 | max6875_update_slice(client, blk, slice); | ||
202 | |||
203 | memcpy(buf, &blk->data[off], count); | ||
204 | |||
205 | return count; | ||
206 | } | ||
207 | |||
208 | static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
209 | { | ||
210 | return max6875_read(kobj, buf, off, count, max6875_eeprom_user); | ||
211 | } | ||
212 | |||
213 | static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
214 | { | ||
215 | return max6875_read(kobj, buf, off, count, max6875_eeprom_config); | ||
216 | } | ||
217 | |||
218 | static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
219 | { | ||
220 | return max6875_read(kobj, buf, off, count, max6875_register_config); | ||
221 | } | ||
222 | |||
223 | |||
224 | static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count, | ||
225 | enum max6875_area_type area_type) | ||
226 | { | ||
227 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | ||
228 | struct max6875_data *data = i2c_get_clientdata(client); | ||
229 | struct eeprom_block *blk; | ||
230 | int slice, addr, retval; | ||
231 | ssize_t sent = 0; | ||
232 | |||
233 | blk = &data->blocks[area_type]; | ||
234 | |||
235 | if (off > blk->size) | ||
236 | return 0; | ||
237 | if ((off + count) > blk->size) | ||
238 | count = blk->size - off; | ||
239 | |||
240 | if (down_interruptible(&data->update_lock)) | ||
241 | return -EAGAIN; | ||
242 | |||
243 | /* writing to a register is done with i2c_smbus_write_byte_data() */ | ||
244 | if (blk->type == max6875_register_config) { | ||
245 | for (sent = 0; sent < count; sent++) { | ||
246 | addr = off + sent; | ||
247 | if (addr == 0x44) | ||
248 | continue; | ||
249 | |||
250 | retval = i2c_smbus_write_byte_data(client, addr, buf[sent]); | ||
251 | } | ||
252 | } else { | ||
253 | int cmd, val; | ||
254 | |||
255 | /* We are writing to EEPROM */ | ||
256 | for (sent = 0; sent < count; sent++) { | ||
257 | addr = blk->base + off + sent; | ||
258 | cmd = addr >> 8; | ||
259 | val = (addr & 0xff) | (buf[sent] << 8); // reversed | ||
260 | |||
261 | if (addr == 0x8044) | ||
262 | continue; | ||
263 | |||
264 | retval = i2c_smbus_write_word_data(client, cmd, val); | ||
265 | |||
266 | if (retval) { | ||
267 | goto error_exit; | ||
268 | } | ||
269 | |||
270 | /* A write takes up to 11 ms */ | ||
271 | msleep(11); | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /* Invalidate the scratch buffer */ | ||
276 | for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) | ||
277 | blk->valid &= ~(1 << slice); | ||
278 | |||
279 | error_exit: | ||
280 | up(&data->update_lock); | ||
281 | |||
282 | return sent; | ||
283 | } | ||
284 | |||
285 | static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
286 | { | ||
287 | return max6875_write(kobj, buf, off, count, max6875_eeprom_user); | ||
288 | } | ||
289 | |||
290 | static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
291 | { | ||
292 | return max6875_write(kobj, buf, off, count, max6875_eeprom_config); | ||
293 | } | ||
294 | |||
295 | static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
296 | { | ||
297 | return max6875_write(kobj, buf, off, count, max6875_register_config); | ||
298 | } | ||
299 | |||
300 | static struct bin_attribute user_eeprom_attr = { | ||
301 | .attr = { | ||
302 | .name = "eeprom_user", | ||
303 | .mode = S_IRUGO | S_IWUSR | S_IWGRP, | ||
304 | .owner = THIS_MODULE, | ||
305 | }, | ||
306 | .size = USER_EEPROM_SIZE, | ||
307 | .read = max6875_user_read, | ||
308 | .write = max6875_user_write, | ||
309 | }; | ||
310 | |||
311 | static struct bin_attribute config_eeprom_attr = { | ||
312 | .attr = { | ||
313 | .name = "eeprom_config", | ||
314 | .mode = S_IRUGO | S_IWUSR, | ||
315 | .owner = THIS_MODULE, | ||
316 | }, | ||
317 | .size = CONFIG_EEPROM_SIZE, | ||
318 | .read = max6875_config_read, | ||
319 | .write = max6875_config_write, | ||
320 | }; | ||
321 | |||
322 | static struct bin_attribute config_register_attr = { | ||
323 | .attr = { | ||
324 | .name = "reg_config", | ||
325 | .mode = S_IRUGO | S_IWUSR, | ||
326 | .owner = THIS_MODULE, | ||
327 | }, | ||
328 | .size = CONFIG_EEPROM_SIZE, | ||
329 | .read = max6875_cfgreg_read, | ||
330 | .write = max6875_cfgreg_write, | ||
331 | }; | ||
332 | |||
333 | static int max6875_attach_adapter(struct i2c_adapter *adapter) | ||
334 | { | ||
335 | return i2c_detect(adapter, &addr_data, max6875_detect); | ||
336 | } | ||
337 | |||
338 | /* This function is called by i2c_detect */ | ||
339 | static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | ||
340 | { | ||
341 | struct i2c_client *new_client; | ||
342 | struct max6875_data *data; | ||
343 | int err = 0; | ||
344 | |||
345 | /* There are three ways we can read the EEPROM data: | ||
346 | (1) I2C block reads (faster, but unsupported by most adapters) | ||
347 | (2) Consecutive byte reads (100% overhead) | ||
348 | (3) Regular byte data reads (200% overhead) | ||
349 | The third method is not implemented by this driver because all | ||
350 | known adapters support at least the second. */ | ||
351 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA | | ||
352 | I2C_FUNC_SMBUS_BYTE | | ||
353 | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | ||
354 | goto exit; | ||
355 | |||
356 | /* OK. For now, we presume we have a valid client. We now create the | ||
357 | client structure, even though we cannot fill it completely yet. | ||
358 | But it allows us to access eeprom_{read,write}_value. */ | ||
359 | if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) { | ||
360 | err = -ENOMEM; | ||
361 | goto exit; | ||
362 | } | ||
363 | memset(data, 0, sizeof(struct max6875_data)); | ||
364 | |||
365 | new_client = &data->client; | ||
366 | i2c_set_clientdata(new_client, data); | ||
367 | new_client->addr = address; | ||
368 | new_client->adapter = adapter; | ||
369 | new_client->driver = &max6875_driver; | ||
370 | new_client->flags = 0; | ||
371 | |||
372 | /* Setup the user section */ | ||
373 | data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; | ||
374 | data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; | ||
375 | data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE; | ||
376 | data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE; | ||
377 | data->blocks[max6875_eeprom_user].data = data->data; | ||
378 | data->blocks[max6875_eeprom_user].updated = data->last_updated; | ||
379 | |||
380 | /* Setup the config section */ | ||
381 | data->blocks[max6875_eeprom_config].type = max6875_eeprom_config; | ||
382 | data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES; | ||
383 | data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE; | ||
384 | data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE; | ||
385 | data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE]; | ||
386 | data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES]; | ||
387 | |||
388 | /* Setup the register section */ | ||
389 | data->blocks[max6875_register_config].type = max6875_register_config; | ||
390 | data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES; | ||
391 | data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE; | ||
392 | data->blocks[max6875_register_config].base = 0; | ||
393 | data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE]; | ||
394 | data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES]; | ||
395 | |||
396 | /* Init the data */ | ||
397 | memset(data->data, 0xff, sizeof(data->data)); | ||
398 | |||
399 | /* Fill in the remaining client fields */ | ||
400 | strlcpy(new_client->name, "max6875", I2C_NAME_SIZE); | ||
401 | init_MUTEX(&data->update_lock); | ||
402 | |||
403 | /* Verify that the chip is really what we think it is */ | ||
404 | if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) || | ||
405 | (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0)) | ||
406 | goto exit_kfree; | ||
407 | |||
408 | /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */ | ||
409 | if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) || | ||
410 | (data->blocks[max6875_eeprom_config].data[0x42] != 0) || | ||
411 | (data->blocks[max6875_register_config].data[0x41] != 0) || | ||
412 | (data->blocks[max6875_register_config].data[0x42] != 0) || | ||
413 | (data->blocks[max6875_eeprom_config].data[0x40] != | ||
414 | data->blocks[max6875_register_config].data[0x40])) | ||
415 | goto exit_kfree; | ||
416 | |||
417 | /* Tell the I2C layer a new client has arrived */ | ||
418 | if ((err = i2c_attach_client(new_client))) | ||
419 | goto exit_kfree; | ||
420 | |||
421 | /* create the sysfs eeprom files with the correct permissions */ | ||
422 | if (allow_write == 0) { | ||
423 | user_eeprom_attr.attr.mode &= ~S_IWUGO; | ||
424 | user_eeprom_attr.write = NULL; | ||
425 | config_eeprom_attr.attr.mode &= ~S_IWUGO; | ||
426 | config_eeprom_attr.write = NULL; | ||
427 | config_register_attr.attr.mode &= ~S_IWUGO; | ||
428 | config_register_attr.write = NULL; | ||
429 | } | ||
430 | sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr); | ||
431 | sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr); | ||
432 | sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr); | ||
433 | |||
434 | return 0; | ||
435 | |||
436 | exit_kfree: | ||
437 | kfree(data); | ||
438 | exit: | ||
439 | return err; | ||
440 | } | ||
441 | |||
442 | static int max6875_detach_client(struct i2c_client *client) | ||
443 | { | ||
444 | int err; | ||
445 | |||
446 | err = i2c_detach_client(client); | ||
447 | if (err) { | ||
448 | dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); | ||
449 | return err; | ||
450 | } | ||
451 | |||
452 | kfree(i2c_get_clientdata(client)); | ||
453 | |||
454 | return 0; | ||
455 | } | ||
456 | |||
457 | static int __init max6875_init(void) | ||
458 | { | ||
459 | return i2c_add_driver(&max6875_driver); | ||
460 | } | ||
461 | |||
462 | static void __exit max6875_exit(void) | ||
463 | { | ||
464 | i2c_del_driver(&max6875_driver); | ||
465 | } | ||
466 | |||
467 | |||
468 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); | ||
469 | MODULE_DESCRIPTION("MAX6875 driver"); | ||
470 | MODULE_LICENSE("GPL"); | ||
471 | |||
472 | module_init(max6875_init); | ||
473 | module_exit(max6875_exit); | ||
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/i2c/chips/pc87360.c index 6d94c36c9218..876c68f3af31 100644 --- a/drivers/i2c/chips/pc87360.c +++ b/drivers/i2c/chips/pc87360.c | |||
@@ -33,7 +33,6 @@ | |||
33 | * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). | 33 | * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
@@ -282,31 +281,31 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
282 | } | 281 | } |
283 | 282 | ||
284 | #define show_and_set_fan(offset) \ | 283 | #define show_and_set_fan(offset) \ |
285 | static ssize_t show_fan##offset##_input(struct device *dev, char *buf) \ | 284 | static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
286 | { \ | 285 | { \ |
287 | struct pc87360_data *data = pc87360_update_device(dev); \ | 286 | struct pc87360_data *data = pc87360_update_device(dev); \ |
288 | return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \ | 287 | return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \ |
289 | FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ | 288 | FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ |
290 | } \ | 289 | } \ |
291 | static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ | 290 | static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
292 | { \ | 291 | { \ |
293 | struct pc87360_data *data = pc87360_update_device(dev); \ | 292 | struct pc87360_data *data = pc87360_update_device(dev); \ |
294 | return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \ | 293 | return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \ |
295 | FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ | 294 | FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ |
296 | } \ | 295 | } \ |
297 | static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ | 296 | static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ |
298 | { \ | 297 | { \ |
299 | struct pc87360_data *data = pc87360_update_device(dev); \ | 298 | struct pc87360_data *data = pc87360_update_device(dev); \ |
300 | return sprintf(buf, "%u\n", \ | 299 | return sprintf(buf, "%u\n", \ |
301 | FAN_DIV_FROM_REG(data->fan_status[offset-1])); \ | 300 | FAN_DIV_FROM_REG(data->fan_status[offset-1])); \ |
302 | } \ | 301 | } \ |
303 | static ssize_t show_fan##offset##_status(struct device *dev, char *buf) \ | 302 | static ssize_t show_fan##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ |
304 | { \ | 303 | { \ |
305 | struct pc87360_data *data = pc87360_update_device(dev); \ | 304 | struct pc87360_data *data = pc87360_update_device(dev); \ |
306 | return sprintf(buf, "%u\n", \ | 305 | return sprintf(buf, "%u\n", \ |
307 | FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \ | 306 | FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \ |
308 | } \ | 307 | } \ |
309 | static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ | 308 | static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
310 | size_t count) \ | 309 | size_t count) \ |
311 | { \ | 310 | { \ |
312 | return set_fan_min(dev, buf, count, offset-1); \ | 311 | return set_fan_min(dev, buf, count, offset-1); \ |
@@ -324,7 +323,7 @@ show_and_set_fan(2) | |||
324 | show_and_set_fan(3) | 323 | show_and_set_fan(3) |
325 | 324 | ||
326 | #define show_and_set_pwm(offset) \ | 325 | #define show_and_set_pwm(offset) \ |
327 | static ssize_t show_pwm##offset(struct device *dev, char *buf) \ | 326 | static ssize_t show_pwm##offset(struct device *dev, struct device_attribute *attr, char *buf) \ |
328 | { \ | 327 | { \ |
329 | struct pc87360_data *data = pc87360_update_device(dev); \ | 328 | struct pc87360_data *data = pc87360_update_device(dev); \ |
330 | return sprintf(buf, "%u\n", \ | 329 | return sprintf(buf, "%u\n", \ |
@@ -332,7 +331,7 @@ static ssize_t show_pwm##offset(struct device *dev, char *buf) \ | |||
332 | FAN_CONFIG_INVERT(data->fan_conf, \ | 331 | FAN_CONFIG_INVERT(data->fan_conf, \ |
333 | offset-1))); \ | 332 | offset-1))); \ |
334 | } \ | 333 | } \ |
335 | static ssize_t set_pwm##offset(struct device *dev, const char *buf, \ | 334 | static ssize_t set_pwm##offset(struct device *dev, struct device_attribute *attr, const char *buf, \ |
336 | size_t count) \ | 335 | size_t count) \ |
337 | { \ | 336 | { \ |
338 | struct i2c_client *client = to_i2c_client(dev); \ | 337 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -354,30 +353,30 @@ show_and_set_pwm(2) | |||
354 | show_and_set_pwm(3) | 353 | show_and_set_pwm(3) |
355 | 354 | ||
356 | #define show_and_set_in(offset) \ | 355 | #define show_and_set_in(offset) \ |
357 | static ssize_t show_in##offset##_input(struct device *dev, char *buf) \ | 356 | static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
358 | { \ | 357 | { \ |
359 | struct pc87360_data *data = pc87360_update_device(dev); \ | 358 | struct pc87360_data *data = pc87360_update_device(dev); \ |
360 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ | 359 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ |
361 | data->in_vref)); \ | 360 | data->in_vref)); \ |
362 | } \ | 361 | } \ |
363 | static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ | 362 | static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
364 | { \ | 363 | { \ |
365 | struct pc87360_data *data = pc87360_update_device(dev); \ | 364 | struct pc87360_data *data = pc87360_update_device(dev); \ |
366 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ | 365 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ |
367 | data->in_vref)); \ | 366 | data->in_vref)); \ |
368 | } \ | 367 | } \ |
369 | static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ | 368 | static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ |
370 | { \ | 369 | { \ |
371 | struct pc87360_data *data = pc87360_update_device(dev); \ | 370 | struct pc87360_data *data = pc87360_update_device(dev); \ |
372 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ | 371 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ |
373 | data->in_vref)); \ | 372 | data->in_vref)); \ |
374 | } \ | 373 | } \ |
375 | static ssize_t show_in##offset##_status(struct device *dev, char *buf) \ | 374 | static ssize_t show_in##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ |
376 | { \ | 375 | { \ |
377 | struct pc87360_data *data = pc87360_update_device(dev); \ | 376 | struct pc87360_data *data = pc87360_update_device(dev); \ |
378 | return sprintf(buf, "%u\n", data->in_status[offset]); \ | 377 | return sprintf(buf, "%u\n", data->in_status[offset]); \ |
379 | } \ | 378 | } \ |
380 | static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \ | 379 | static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
381 | size_t count) \ | 380 | size_t count) \ |
382 | { \ | 381 | { \ |
383 | struct i2c_client *client = to_i2c_client(dev); \ | 382 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -391,7 +390,7 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \ | |||
391 | up(&data->update_lock); \ | 390 | up(&data->update_lock); \ |
392 | return count; \ | 391 | return count; \ |
393 | } \ | 392 | } \ |
394 | static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \ | 393 | static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
395 | size_t count) \ | 394 | size_t count) \ |
396 | { \ | 395 | { \ |
397 | struct i2c_client *client = to_i2c_client(dev); \ | 396 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -427,36 +426,36 @@ show_and_set_in(9) | |||
427 | show_and_set_in(10) | 426 | show_and_set_in(10) |
428 | 427 | ||
429 | #define show_and_set_therm(offset) \ | 428 | #define show_and_set_therm(offset) \ |
430 | static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \ | 429 | static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
431 | { \ | 430 | { \ |
432 | struct pc87360_data *data = pc87360_update_device(dev); \ | 431 | struct pc87360_data *data = pc87360_update_device(dev); \ |
433 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \ | 432 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \ |
434 | data->in_vref)); \ | 433 | data->in_vref)); \ |
435 | } \ | 434 | } \ |
436 | static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \ | 435 | static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
437 | { \ | 436 | { \ |
438 | struct pc87360_data *data = pc87360_update_device(dev); \ | 437 | struct pc87360_data *data = pc87360_update_device(dev); \ |
439 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \ | 438 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \ |
440 | data->in_vref)); \ | 439 | data->in_vref)); \ |
441 | } \ | 440 | } \ |
442 | static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \ | 441 | static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ |
443 | { \ | 442 | { \ |
444 | struct pc87360_data *data = pc87360_update_device(dev); \ | 443 | struct pc87360_data *data = pc87360_update_device(dev); \ |
445 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \ | 444 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \ |
446 | data->in_vref)); \ | 445 | data->in_vref)); \ |
447 | } \ | 446 | } \ |
448 | static ssize_t show_temp##offset##_crit(struct device *dev, char *buf) \ | 447 | static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \ |
449 | { \ | 448 | { \ |
450 | struct pc87360_data *data = pc87360_update_device(dev); \ | 449 | struct pc87360_data *data = pc87360_update_device(dev); \ |
451 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \ | 450 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \ |
452 | data->in_vref)); \ | 451 | data->in_vref)); \ |
453 | } \ | 452 | } \ |
454 | static ssize_t show_temp##offset##_status(struct device *dev, char *buf) \ | 453 | static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ |
455 | { \ | 454 | { \ |
456 | struct pc87360_data *data = pc87360_update_device(dev); \ | 455 | struct pc87360_data *data = pc87360_update_device(dev); \ |
457 | return sprintf(buf, "%u\n", data->in_status[offset+7]); \ | 456 | return sprintf(buf, "%u\n", data->in_status[offset+7]); \ |
458 | } \ | 457 | } \ |
459 | static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ | 458 | static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
460 | size_t count) \ | 459 | size_t count) \ |
461 | { \ | 460 | { \ |
462 | struct i2c_client *client = to_i2c_client(dev); \ | 461 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -470,7 +469,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ | |||
470 | up(&data->update_lock); \ | 469 | up(&data->update_lock); \ |
471 | return count; \ | 470 | return count; \ |
472 | } \ | 471 | } \ |
473 | static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ | 472 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
474 | size_t count) \ | 473 | size_t count) \ |
475 | { \ | 474 | { \ |
476 | struct i2c_client *client = to_i2c_client(dev); \ | 475 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -484,7 +483,7 @@ static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ | |||
484 | up(&data->update_lock); \ | 483 | up(&data->update_lock); \ |
485 | return count; \ | 484 | return count; \ |
486 | } \ | 485 | } \ |
487 | static ssize_t set_temp##offset##_crit(struct device *dev, const char *buf, \ | 486 | static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \ |
488 | size_t count) \ | 487 | size_t count) \ |
489 | { \ | 488 | { \ |
490 | struct i2c_client *client = to_i2c_client(dev); \ | 489 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -512,19 +511,19 @@ show_and_set_therm(4) | |||
512 | show_and_set_therm(5) | 511 | show_and_set_therm(5) |
513 | show_and_set_therm(6) | 512 | show_and_set_therm(6) |
514 | 513 | ||
515 | static ssize_t show_vid(struct device *dev, char *buf) | 514 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
516 | { | 515 | { |
517 | struct pc87360_data *data = pc87360_update_device(dev); | 516 | struct pc87360_data *data = pc87360_update_device(dev); |
518 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); | 517 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); |
519 | } | 518 | } |
520 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 519 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
521 | 520 | ||
522 | static ssize_t show_vrm(struct device *dev, char *buf) | 521 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) |
523 | { | 522 | { |
524 | struct pc87360_data *data = pc87360_update_device(dev); | 523 | struct pc87360_data *data = pc87360_update_device(dev); |
525 | return sprintf(buf, "%u\n", data->vrm); | 524 | return sprintf(buf, "%u\n", data->vrm); |
526 | } | 525 | } |
527 | static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) | 526 | static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
528 | { | 527 | { |
529 | struct i2c_client *client = to_i2c_client(dev); | 528 | struct i2c_client *client = to_i2c_client(dev); |
530 | struct pc87360_data *data = i2c_get_clientdata(client); | 529 | struct pc87360_data *data = i2c_get_clientdata(client); |
@@ -533,7 +532,7 @@ static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) | |||
533 | } | 532 | } |
534 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); | 533 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); |
535 | 534 | ||
536 | static ssize_t show_in_alarms(struct device *dev, char *buf) | 535 | static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
537 | { | 536 | { |
538 | struct pc87360_data *data = pc87360_update_device(dev); | 537 | struct pc87360_data *data = pc87360_update_device(dev); |
539 | return sprintf(buf, "%u\n", data->in_alarms); | 538 | return sprintf(buf, "%u\n", data->in_alarms); |
@@ -541,32 +540,32 @@ static ssize_t show_in_alarms(struct device *dev, char *buf) | |||
541 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); | 540 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); |
542 | 541 | ||
543 | #define show_and_set_temp(offset) \ | 542 | #define show_and_set_temp(offset) \ |
544 | static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \ | 543 | static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
545 | { \ | 544 | { \ |
546 | struct pc87360_data *data = pc87360_update_device(dev); \ | 545 | struct pc87360_data *data = pc87360_update_device(dev); \ |
547 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ | 546 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ |
548 | } \ | 547 | } \ |
549 | static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \ | 548 | static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ |
550 | { \ | 549 | { \ |
551 | struct pc87360_data *data = pc87360_update_device(dev); \ | 550 | struct pc87360_data *data = pc87360_update_device(dev); \ |
552 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ | 551 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ |
553 | } \ | 552 | } \ |
554 | static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \ | 553 | static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ |
555 | { \ | 554 | { \ |
556 | struct pc87360_data *data = pc87360_update_device(dev); \ | 555 | struct pc87360_data *data = pc87360_update_device(dev); \ |
557 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ | 556 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ |
558 | }\ | 557 | }\ |
559 | static ssize_t show_temp##offset##_crit(struct device *dev, char *buf) \ | 558 | static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \ |
560 | { \ | 559 | { \ |
561 | struct pc87360_data *data = pc87360_update_device(dev); \ | 560 | struct pc87360_data *data = pc87360_update_device(dev); \ |
562 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \ | 561 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \ |
563 | }\ | 562 | }\ |
564 | static ssize_t show_temp##offset##_status(struct device *dev, char *buf) \ | 563 | static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ |
565 | { \ | 564 | { \ |
566 | struct pc87360_data *data = pc87360_update_device(dev); \ | 565 | struct pc87360_data *data = pc87360_update_device(dev); \ |
567 | return sprintf(buf, "%d\n", data->temp_status[offset-1]); \ | 566 | return sprintf(buf, "%d\n", data->temp_status[offset-1]); \ |
568 | }\ | 567 | }\ |
569 | static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ | 568 | static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ |
570 | size_t count) \ | 569 | size_t count) \ |
571 | { \ | 570 | { \ |
572 | struct i2c_client *client = to_i2c_client(dev); \ | 571 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -580,7 +579,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ | |||
580 | up(&data->update_lock); \ | 579 | up(&data->update_lock); \ |
581 | return count; \ | 580 | return count; \ |
582 | } \ | 581 | } \ |
583 | static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ | 582 | static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ |
584 | size_t count) \ | 583 | size_t count) \ |
585 | { \ | 584 | { \ |
586 | struct i2c_client *client = to_i2c_client(dev); \ | 585 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -594,7 +593,7 @@ static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ | |||
594 | up(&data->update_lock); \ | 593 | up(&data->update_lock); \ |
595 | return count; \ | 594 | return count; \ |
596 | } \ | 595 | } \ |
597 | static ssize_t set_temp##offset##_crit(struct device *dev, const char *buf, \ | 596 | static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \ |
598 | size_t count) \ | 597 | size_t count) \ |
599 | { \ | 598 | { \ |
600 | struct i2c_client *client = to_i2c_client(dev); \ | 599 | struct i2c_client *client = to_i2c_client(dev); \ |
@@ -622,7 +621,7 @@ show_and_set_temp(1) | |||
622 | show_and_set_temp(2) | 621 | show_and_set_temp(2) |
623 | show_and_set_temp(3) | 622 | show_and_set_temp(3) |
624 | 623 | ||
625 | static ssize_t show_temp_alarms(struct device *dev, char *buf) | 624 | static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
626 | { | 625 | { |
627 | struct pc87360_data *data = pc87360_update_device(dev); | 626 | struct pc87360_data *data = pc87360_update_device(dev); |
628 | return sprintf(buf, "%u\n", data->temp_alarms); | 627 | return sprintf(buf, "%u\n", data->temp_alarms); |
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c new file mode 100644 index 000000000000..9f3ad45daae2 --- /dev/null +++ b/drivers/i2c/chips/pca9539.c | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | pca9539.c - 16-bit I/O port with interrupt and reset | ||
3 | |||
4 | Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> | ||
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; version 2 of the License. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/hwmon-sysfs.h> | ||
16 | #include <linux/i2c-sensor.h> | ||
17 | |||
18 | /* Addresses to scan */ | ||
19 | static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END}; | ||
20 | static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; | ||
21 | |||
22 | /* Insmod parameters */ | ||
23 | SENSORS_INSMOD_1(pca9539); | ||
24 | |||
25 | enum pca9539_cmd | ||
26 | { | ||
27 | PCA9539_INPUT_0 = 0, | ||
28 | PCA9539_INPUT_1 = 1, | ||
29 | PCA9539_OUTPUT_0 = 2, | ||
30 | PCA9539_OUTPUT_1 = 3, | ||
31 | PCA9539_INVERT_0 = 4, | ||
32 | PCA9539_INVERT_1 = 5, | ||
33 | PCA9539_DIRECTION_0 = 6, | ||
34 | PCA9539_DIRECTION_1 = 7, | ||
35 | }; | ||
36 | |||
37 | static int pca9539_attach_adapter(struct i2c_adapter *adapter); | ||
38 | static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind); | ||
39 | static int pca9539_detach_client(struct i2c_client *client); | ||
40 | |||
41 | /* This is the driver that will be inserted */ | ||
42 | static struct i2c_driver pca9539_driver = { | ||
43 | .owner = THIS_MODULE, | ||
44 | .name = "pca9539", | ||
45 | .flags = I2C_DF_NOTIFY, | ||
46 | .attach_adapter = pca9539_attach_adapter, | ||
47 | .detach_client = pca9539_detach_client, | ||
48 | }; | ||
49 | |||
50 | struct pca9539_data { | ||
51 | struct i2c_client client; | ||
52 | }; | ||
53 | |||
54 | /* following are the sysfs callback functions */ | ||
55 | static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr, | ||
56 | char *buf) | ||
57 | { | ||
58 | struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); | ||
59 | struct i2c_client *client = to_i2c_client(dev); | ||
60 | return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client, | ||
61 | psa->index)); | ||
62 | } | ||
63 | |||
64 | static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr, | ||
65 | const char *buf, size_t count) | ||
66 | { | ||
67 | struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); | ||
68 | struct i2c_client *client = to_i2c_client(dev); | ||
69 | unsigned long val = simple_strtoul(buf, NULL, 0); | ||
70 | if (val > 0xff) | ||
71 | return -EINVAL; | ||
72 | i2c_smbus_write_byte_data(client, psa->index, val); | ||
73 | return count; | ||
74 | } | ||
75 | |||
76 | /* Define the device attributes */ | ||
77 | |||
78 | #define PCA9539_ENTRY_RO(name, cmd_idx) \ | ||
79 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx) | ||
80 | |||
81 | #define PCA9539_ENTRY_RW(name, cmd_idx) \ | ||
82 | static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \ | ||
83 | pca9539_store, cmd_idx) | ||
84 | |||
85 | PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0); | ||
86 | PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1); | ||
87 | PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0); | ||
88 | PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1); | ||
89 | PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0); | ||
90 | PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1); | ||
91 | PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0); | ||
92 | PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1); | ||
93 | |||
94 | static struct attribute *pca9539_attributes[] = { | ||
95 | &sensor_dev_attr_input0.dev_attr.attr, | ||
96 | &sensor_dev_attr_input1.dev_attr.attr, | ||
97 | &sensor_dev_attr_output0.dev_attr.attr, | ||
98 | &sensor_dev_attr_output1.dev_attr.attr, | ||
99 | &sensor_dev_attr_invert0.dev_attr.attr, | ||
100 | &sensor_dev_attr_invert1.dev_attr.attr, | ||
101 | &sensor_dev_attr_direction0.dev_attr.attr, | ||
102 | &sensor_dev_attr_direction1.dev_attr.attr, | ||
103 | NULL | ||
104 | }; | ||
105 | |||
106 | static struct attribute_group pca9539_defattr_group = { | ||
107 | .attrs = pca9539_attributes, | ||
108 | }; | ||
109 | |||
110 | static int pca9539_attach_adapter(struct i2c_adapter *adapter) | ||
111 | { | ||
112 | return i2c_detect(adapter, &addr_data, pca9539_detect); | ||
113 | } | ||
114 | |||
115 | /* This function is called by i2c_detect */ | ||
116 | static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) | ||
117 | { | ||
118 | struct i2c_client *new_client; | ||
119 | struct pca9539_data *data; | ||
120 | int err = 0; | ||
121 | |||
122 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
123 | goto exit; | ||
124 | |||
125 | /* OK. For now, we presume we have a valid client. We now create the | ||
126 | client structure, even though we cannot fill it completely yet. */ | ||
127 | if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { | ||
128 | err = -ENOMEM; | ||
129 | goto exit; | ||
130 | } | ||
131 | memset(data, 0, sizeof(struct pca9539_data)); | ||
132 | |||
133 | new_client = &data->client; | ||
134 | i2c_set_clientdata(new_client, data); | ||
135 | new_client->addr = address; | ||
136 | new_client->adapter = adapter; | ||
137 | new_client->driver = &pca9539_driver; | ||
138 | new_client->flags = 0; | ||
139 | |||
140 | /* Detection: the pca9539 only has 8 registers (0-7). | ||
141 | A read of 7 should succeed, but a read of 8 should fail. */ | ||
142 | if ((i2c_smbus_read_byte_data(new_client, 7) < 0) || | ||
143 | (i2c_smbus_read_byte_data(new_client, 8) >= 0)) | ||
144 | goto exit_kfree; | ||
145 | |||
146 | strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE); | ||
147 | |||
148 | /* Tell the I2C layer a new client has arrived */ | ||
149 | if ((err = i2c_attach_client(new_client))) | ||
150 | goto exit_kfree; | ||
151 | |||
152 | /* Register sysfs hooks (don't care about failure) */ | ||
153 | sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group); | ||
154 | |||
155 | return 0; | ||
156 | |||
157 | exit_kfree: | ||
158 | kfree(data); | ||
159 | exit: | ||
160 | return err; | ||
161 | } | ||
162 | |||
163 | static int pca9539_detach_client(struct i2c_client *client) | ||
164 | { | ||
165 | int err; | ||
166 | |||
167 | if ((err = i2c_detach_client(client))) { | ||
168 | dev_err(&client->dev, "Client deregistration failed.\n"); | ||
169 | return err; | ||
170 | } | ||
171 | |||
172 | kfree(i2c_get_clientdata(client)); | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int __init pca9539_init(void) | ||
177 | { | ||
178 | return i2c_add_driver(&pca9539_driver); | ||
179 | } | ||
180 | |||
181 | static void __exit pca9539_exit(void) | ||
182 | { | ||
183 | i2c_del_driver(&pca9539_driver); | ||
184 | } | ||
185 | |||
186 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); | ||
187 | MODULE_DESCRIPTION("PCA9539 driver"); | ||
188 | MODULE_LICENSE("GPL"); | ||
189 | |||
190 | module_init(pca9539_init); | ||
191 | module_exit(pca9539_exit); | ||
192 | |||
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 48b4e22eaffe..cfcf64654080 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c | |||
@@ -57,7 +57,7 @@ SENSORS_INSMOD_2(pcf8574, pcf8574a); | |||
57 | struct pcf8574_data { | 57 | struct pcf8574_data { |
58 | struct i2c_client client; | 58 | struct i2c_client client; |
59 | 59 | ||
60 | u8 read, write; /* Register values */ | 60 | u8 write; /* Remember last written value */ |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); | 63 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); |
@@ -76,23 +76,21 @@ static struct i2c_driver pcf8574_driver = { | |||
76 | }; | 76 | }; |
77 | 77 | ||
78 | /* following are the sysfs callback functions */ | 78 | /* following are the sysfs callback functions */ |
79 | static ssize_t show_read(struct device *dev, char *buf) | 79 | static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) |
80 | { | 80 | { |
81 | struct i2c_client *client = to_i2c_client(dev); | 81 | struct i2c_client *client = to_i2c_client(dev); |
82 | struct pcf8574_data *data = i2c_get_clientdata(client); | 82 | return sprintf(buf, "%u\n", i2c_smbus_read_byte(client)); |
83 | data->read = i2c_smbus_read_byte(client); | ||
84 | return sprintf(buf, "%u\n", data->read); | ||
85 | } | 83 | } |
86 | 84 | ||
87 | static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); | 85 | static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); |
88 | 86 | ||
89 | static ssize_t show_write(struct device *dev, char *buf) | 87 | static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf) |
90 | { | 88 | { |
91 | struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev)); | 89 | struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev)); |
92 | return sprintf(buf, "%u\n", data->write); | 90 | return sprintf(buf, "%u\n", data->write); |
93 | } | 91 | } |
94 | 92 | ||
95 | static ssize_t set_write(struct device *dev, const char *buf, | 93 | static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf, |
96 | size_t count) | 94 | size_t count) |
97 | { | 95 | { |
98 | struct i2c_client *client = to_i2c_client(dev); | 96 | struct i2c_client *client = to_i2c_client(dev); |
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index b6b927d8b372..db812ade8564 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c | |||
@@ -100,7 +100,7 @@ static struct i2c_driver pcf8591_driver = { | |||
100 | 100 | ||
101 | /* following are the sysfs callback functions */ | 101 | /* following are the sysfs callback functions */ |
102 | #define show_in_channel(channel) \ | 102 | #define show_in_channel(channel) \ |
103 | static ssize_t show_in##channel##_input(struct device *dev, char *buf) \ | 103 | static ssize_t show_in##channel##_input(struct device *dev, struct device_attribute *attr, char *buf) \ |
104 | { \ | 104 | { \ |
105 | return sprintf(buf, "%d\n", pcf8591_read_channel(dev, channel));\ | 105 | return sprintf(buf, "%d\n", pcf8591_read_channel(dev, channel));\ |
106 | } \ | 106 | } \ |
@@ -112,13 +112,13 @@ show_in_channel(1); | |||
112 | show_in_channel(2); | 112 | show_in_channel(2); |
113 | show_in_channel(3); | 113 | show_in_channel(3); |
114 | 114 | ||
115 | static ssize_t show_out0_ouput(struct device *dev, char *buf) | 115 | static ssize_t show_out0_ouput(struct device *dev, struct device_attribute *attr, char *buf) |
116 | { | 116 | { |
117 | struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev)); | 117 | struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev)); |
118 | return sprintf(buf, "%d\n", data->aout * 10); | 118 | return sprintf(buf, "%d\n", data->aout * 10); |
119 | } | 119 | } |
120 | 120 | ||
121 | static ssize_t set_out0_output(struct device *dev, const char *buf, size_t count) | 121 | static ssize_t set_out0_output(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
122 | { | 122 | { |
123 | unsigned int value; | 123 | unsigned int value; |
124 | struct i2c_client *client = to_i2c_client(dev); | 124 | struct i2c_client *client = to_i2c_client(dev); |
@@ -134,13 +134,13 @@ static ssize_t set_out0_output(struct device *dev, const char *buf, size_t count | |||
134 | static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO, | 134 | static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO, |
135 | show_out0_ouput, set_out0_output); | 135 | show_out0_ouput, set_out0_output); |
136 | 136 | ||
137 | static ssize_t show_out0_enable(struct device *dev, char *buf) | 137 | static ssize_t show_out0_enable(struct device *dev, struct device_attribute *attr, char *buf) |
138 | { | 138 | { |
139 | struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev)); | 139 | struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev)); |
140 | return sprintf(buf, "%u\n", !(!(data->control & PCF8591_CONTROL_AOEF))); | 140 | return sprintf(buf, "%u\n", !(!(data->control & PCF8591_CONTROL_AOEF))); |
141 | } | 141 | } |
142 | 142 | ||
143 | static ssize_t set_out0_enable(struct device *dev, const char *buf, size_t count) | 143 | static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
144 | { | 144 | { |
145 | struct i2c_client *client = to_i2c_client(dev); | 145 | struct i2c_client *client = to_i2c_client(dev); |
146 | struct pcf8591_data *data = i2c_get_clientdata(client); | 146 | struct pcf8591_data *data = i2c_get_clientdata(client); |
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 5a9deddb626b..588fc2261a91 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/rtc.h> /* get the user-level API */ | 20 | #include <linux/rtc.h> /* get the user-level API */ |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/init.h> | ||
23 | 22 | ||
24 | #include "rtc8564.h" | 23 | #include "rtc8564.h" |
25 | 24 | ||
@@ -66,11 +65,8 @@ static unsigned short normal_addr[] = { 0x51, I2C_CLIENT_END }; | |||
66 | 65 | ||
67 | static struct i2c_client_address_data addr_data = { | 66 | static struct i2c_client_address_data addr_data = { |
68 | .normal_i2c = normal_addr, | 67 | .normal_i2c = normal_addr, |
69 | .normal_i2c_range = ignore, | ||
70 | .probe = ignore, | 68 | .probe = ignore, |
71 | .probe_range = ignore, | ||
72 | .ignore = ignore, | 69 | .ignore = ignore, |
73 | .ignore_range = ignore, | ||
74 | .force = ignore, | 70 | .force = ignore, |
75 | }; | 71 | }; |
76 | 72 | ||
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/i2c/chips/sis5595.c index 7ea84532df32..6bbfc8fb4f13 100644 --- a/drivers/i2c/chips/sis5595.c +++ b/drivers/i2c/chips/sis5595.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/i2c.h> | 57 | #include <linux/i2c.h> |
58 | #include <linux/i2c-sensor.h> | 58 | #include <linux/i2c-sensor.h> |
59 | #include <linux/init.h> | 59 | #include <linux/init.h> |
60 | #include <linux/jiffies.h> | ||
60 | #include <asm/io.h> | 61 | #include <asm/io.h> |
61 | 62 | ||
62 | 63 | ||
@@ -256,28 +257,28 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
256 | 257 | ||
257 | #define show_in_offset(offset) \ | 258 | #define show_in_offset(offset) \ |
258 | static ssize_t \ | 259 | static ssize_t \ |
259 | show_in##offset (struct device *dev, char *buf) \ | 260 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
260 | { \ | 261 | { \ |
261 | return show_in(dev, buf, offset); \ | 262 | return show_in(dev, buf, offset); \ |
262 | } \ | 263 | } \ |
263 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | 264 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
264 | show_in##offset, NULL); \ | 265 | show_in##offset, NULL); \ |
265 | static ssize_t \ | 266 | static ssize_t \ |
266 | show_in##offset##_min (struct device *dev, char *buf) \ | 267 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
267 | { \ | 268 | { \ |
268 | return show_in_min(dev, buf, offset); \ | 269 | return show_in_min(dev, buf, offset); \ |
269 | } \ | 270 | } \ |
270 | static ssize_t \ | 271 | static ssize_t \ |
271 | show_in##offset##_max (struct device *dev, char *buf) \ | 272 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
272 | { \ | 273 | { \ |
273 | return show_in_max(dev, buf, offset); \ | 274 | return show_in_max(dev, buf, offset); \ |
274 | } \ | 275 | } \ |
275 | static ssize_t set_in##offset##_min (struct device *dev, \ | 276 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ |
276 | const char *buf, size_t count) \ | 277 | const char *buf, size_t count) \ |
277 | { \ | 278 | { \ |
278 | return set_in_min(dev, buf, count, offset); \ | 279 | return set_in_min(dev, buf, count, offset); \ |
279 | } \ | 280 | } \ |
280 | static ssize_t set_in##offset##_max (struct device *dev, \ | 281 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ |
281 | const char *buf, size_t count) \ | 282 | const char *buf, size_t count) \ |
282 | { \ | 283 | { \ |
283 | return set_in_max(dev, buf, count, offset); \ | 284 | return set_in_max(dev, buf, count, offset); \ |
@@ -294,19 +295,19 @@ show_in_offset(3); | |||
294 | show_in_offset(4); | 295 | show_in_offset(4); |
295 | 296 | ||
296 | /* Temperature */ | 297 | /* Temperature */ |
297 | static ssize_t show_temp(struct device *dev, char *buf) | 298 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) |
298 | { | 299 | { |
299 | struct sis5595_data *data = sis5595_update_device(dev); | 300 | struct sis5595_data *data = sis5595_update_device(dev); |
300 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); | 301 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); |
301 | } | 302 | } |
302 | 303 | ||
303 | static ssize_t show_temp_over(struct device *dev, char *buf) | 304 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) |
304 | { | 305 | { |
305 | struct sis5595_data *data = sis5595_update_device(dev); | 306 | struct sis5595_data *data = sis5595_update_device(dev); |
306 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); | 307 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); |
307 | } | 308 | } |
308 | 309 | ||
309 | static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count) | 310 | static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
310 | { | 311 | { |
311 | struct i2c_client *client = to_i2c_client(dev); | 312 | struct i2c_client *client = to_i2c_client(dev); |
312 | struct sis5595_data *data = i2c_get_clientdata(client); | 313 | struct sis5595_data *data = i2c_get_clientdata(client); |
@@ -319,13 +320,13 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count) | |||
319 | return count; | 320 | return count; |
320 | } | 321 | } |
321 | 322 | ||
322 | static ssize_t show_temp_hyst(struct device *dev, char *buf) | 323 | static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
323 | { | 324 | { |
324 | struct sis5595_data *data = sis5595_update_device(dev); | 325 | struct sis5595_data *data = sis5595_update_device(dev); |
325 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); | 326 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); |
326 | } | 327 | } |
327 | 328 | ||
328 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, size_t count) | 329 | static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
329 | { | 330 | { |
330 | struct i2c_client *client = to_i2c_client(dev); | 331 | struct i2c_client *client = to_i2c_client(dev); |
331 | struct sis5595_data *data = i2c_get_clientdata(client); | 332 | struct sis5595_data *data = i2c_get_clientdata(client); |
@@ -426,19 +427,19 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
426 | } | 427 | } |
427 | 428 | ||
428 | #define show_fan_offset(offset) \ | 429 | #define show_fan_offset(offset) \ |
429 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 430 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
430 | { \ | 431 | { \ |
431 | return show_fan(dev, buf, offset - 1); \ | 432 | return show_fan(dev, buf, offset - 1); \ |
432 | } \ | 433 | } \ |
433 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 434 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
434 | { \ | 435 | { \ |
435 | return show_fan_min(dev, buf, offset - 1); \ | 436 | return show_fan_min(dev, buf, offset - 1); \ |
436 | } \ | 437 | } \ |
437 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | 438 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
438 | { \ | 439 | { \ |
439 | return show_fan_div(dev, buf, offset - 1); \ | 440 | return show_fan_div(dev, buf, offset - 1); \ |
440 | } \ | 441 | } \ |
441 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | 442 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
442 | const char *buf, size_t count) \ | 443 | const char *buf, size_t count) \ |
443 | { \ | 444 | { \ |
444 | return set_fan_min(dev, buf, count, offset - 1); \ | 445 | return set_fan_min(dev, buf, count, offset - 1); \ |
@@ -450,13 +451,13 @@ static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | |||
450 | show_fan_offset(1); | 451 | show_fan_offset(1); |
451 | show_fan_offset(2); | 452 | show_fan_offset(2); |
452 | 453 | ||
453 | static ssize_t set_fan_1_div(struct device *dev, const char *buf, | 454 | static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf, |
454 | size_t count) | 455 | size_t count) |
455 | { | 456 | { |
456 | return set_fan_div(dev, buf, count, 0) ; | 457 | return set_fan_div(dev, buf, count, 0) ; |
457 | } | 458 | } |
458 | 459 | ||
459 | static ssize_t set_fan_2_div(struct device *dev, const char *buf, | 460 | static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf, |
460 | size_t count) | 461 | size_t count) |
461 | { | 462 | { |
462 | return set_fan_div(dev, buf, count, 1) ; | 463 | return set_fan_div(dev, buf, count, 1) ; |
@@ -467,7 +468,7 @@ static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, | |||
467 | show_fan_2_div, set_fan_2_div); | 468 | show_fan_2_div, set_fan_2_div); |
468 | 469 | ||
469 | /* Alarms */ | 470 | /* Alarms */ |
470 | static ssize_t show_alarms(struct device *dev, char *buf) | 471 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
471 | { | 472 | { |
472 | struct sis5595_data *data = sis5595_update_device(dev); | 473 | struct sis5595_data *data = sis5595_update_device(dev); |
473 | return sprintf(buf, "%d\n", data->alarms); | 474 | return sprintf(buf, "%d\n", data->alarms); |
diff --git a/drivers/i2c/chips/smsc47b397.c b/drivers/i2c/chips/smsc47b397.c index 1119c76791d9..251ac2659554 100644 --- a/drivers/i2c/chips/smsc47b397.c +++ b/drivers/i2c/chips/smsc47b397.c | |||
@@ -172,7 +172,7 @@ static ssize_t show_temp(struct device *dev, char *buf, int nr) | |||
172 | } | 172 | } |
173 | 173 | ||
174 | #define sysfs_temp(num) \ | 174 | #define sysfs_temp(num) \ |
175 | static ssize_t show_temp##num(struct device *dev, char *buf) \ | 175 | static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \ |
176 | { \ | 176 | { \ |
177 | return show_temp(dev, buf, num-1); \ | 177 | return show_temp(dev, buf, num-1); \ |
178 | } \ | 178 | } \ |
@@ -201,7 +201,7 @@ static ssize_t show_fan(struct device *dev, char *buf, int nr) | |||
201 | } | 201 | } |
202 | 202 | ||
203 | #define sysfs_fan(num) \ | 203 | #define sysfs_fan(num) \ |
204 | static ssize_t show_fan##num(struct device *dev, char *buf) \ | 204 | static ssize_t show_fan##num(struct device *dev, struct device_attribute *attr, char *buf) \ |
205 | { \ | 205 | { \ |
206 | return show_fan(dev, buf, num-1); \ | 206 | return show_fan(dev, buf, num-1); \ |
207 | } \ | 207 | } \ |
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/i2c/chips/smsc47m1.c index 0e12ca369413..897117a7213f 100644 --- a/drivers/i2c/chips/smsc47m1.c +++ b/drivers/i2c/chips/smsc47m1.c | |||
@@ -184,7 +184,7 @@ static ssize_t get_pwm_en(struct device *dev, char *buf, int nr) | |||
184 | return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr])); | 184 | return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr])); |
185 | } | 185 | } |
186 | 186 | ||
187 | static ssize_t get_alarms(struct device *dev, char *buf) | 187 | static ssize_t get_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
188 | { | 188 | { |
189 | struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); | 189 | struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); |
190 | return sprintf(buf, "%d\n", data->alarms); | 190 | return sprintf(buf, "%d\n", data->alarms); |
@@ -298,42 +298,42 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf, | |||
298 | } | 298 | } |
299 | 299 | ||
300 | #define fan_present(offset) \ | 300 | #define fan_present(offset) \ |
301 | static ssize_t get_fan##offset (struct device *dev, char *buf) \ | 301 | static ssize_t get_fan##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
302 | { \ | 302 | { \ |
303 | return get_fan(dev, buf, offset - 1); \ | 303 | return get_fan(dev, buf, offset - 1); \ |
304 | } \ | 304 | } \ |
305 | static ssize_t get_fan##offset##_min (struct device *dev, char *buf) \ | 305 | static ssize_t get_fan##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
306 | { \ | 306 | { \ |
307 | return get_fan_min(dev, buf, offset - 1); \ | 307 | return get_fan_min(dev, buf, offset - 1); \ |
308 | } \ | 308 | } \ |
309 | static ssize_t set_fan##offset##_min (struct device *dev, \ | 309 | static ssize_t set_fan##offset##_min (struct device *dev, struct device_attribute *attr, \ |
310 | const char *buf, size_t count) \ | 310 | const char *buf, size_t count) \ |
311 | { \ | 311 | { \ |
312 | return set_fan_min(dev, buf, count, offset - 1); \ | 312 | return set_fan_min(dev, buf, count, offset - 1); \ |
313 | } \ | 313 | } \ |
314 | static ssize_t get_fan##offset##_div (struct device *dev, char *buf) \ | 314 | static ssize_t get_fan##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
315 | { \ | 315 | { \ |
316 | return get_fan_div(dev, buf, offset - 1); \ | 316 | return get_fan_div(dev, buf, offset - 1); \ |
317 | } \ | 317 | } \ |
318 | static ssize_t set_fan##offset##_div (struct device *dev, \ | 318 | static ssize_t set_fan##offset##_div (struct device *dev, struct device_attribute *attr, \ |
319 | const char *buf, size_t count) \ | 319 | const char *buf, size_t count) \ |
320 | { \ | 320 | { \ |
321 | return set_fan_div(dev, buf, count, offset - 1); \ | 321 | return set_fan_div(dev, buf, count, offset - 1); \ |
322 | } \ | 322 | } \ |
323 | static ssize_t get_pwm##offset (struct device *dev, char *buf) \ | 323 | static ssize_t get_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
324 | { \ | 324 | { \ |
325 | return get_pwm(dev, buf, offset - 1); \ | 325 | return get_pwm(dev, buf, offset - 1); \ |
326 | } \ | 326 | } \ |
327 | static ssize_t set_pwm##offset (struct device *dev, \ | 327 | static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \ |
328 | const char *buf, size_t count) \ | 328 | const char *buf, size_t count) \ |
329 | { \ | 329 | { \ |
330 | return set_pwm(dev, buf, count, offset - 1); \ | 330 | return set_pwm(dev, buf, count, offset - 1); \ |
331 | } \ | 331 | } \ |
332 | static ssize_t get_pwm##offset##_en (struct device *dev, char *buf) \ | 332 | static ssize_t get_pwm##offset##_en (struct device *dev, struct device_attribute *attr, char *buf) \ |
333 | { \ | 333 | { \ |
334 | return get_pwm_en(dev, buf, offset - 1); \ | 334 | return get_pwm_en(dev, buf, offset - 1); \ |
335 | } \ | 335 | } \ |
336 | static ssize_t set_pwm##offset##_en (struct device *dev, \ | 336 | static ssize_t set_pwm##offset##_en (struct device *dev, struct device_attribute *attr, \ |
337 | const char *buf, size_t count) \ | 337 | const char *buf, size_t count) \ |
338 | { \ | 338 | { \ |
339 | return set_pwm_en(dev, buf, count, offset - 1); \ | 339 | return set_pwm_en(dev, buf, count, offset - 1); \ |
@@ -372,14 +372,16 @@ static int smsc47m1_find(int *address) | |||
372 | * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id | 372 | * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id |
373 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. | 373 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. |
374 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" | 374 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" |
375 | * can do much more besides (device id 0x60, unsupported). | 375 | * can do much more besides (device id 0x60). |
376 | */ | 376 | */ |
377 | if (val == 0x51) | 377 | if (val == 0x51) |
378 | printk(KERN_INFO "smsc47m1: Found SMSC47B27x\n"); | 378 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); |
379 | else if (val == 0x59) | 379 | else if (val == 0x59) |
380 | printk(KERN_INFO "smsc47m1: Found SMSC47M10x/SMSC47M13x\n"); | 380 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n"); |
381 | else if (val == 0x5F) | 381 | else if (val == 0x5F) |
382 | printk(KERN_INFO "smsc47m1: Found SMSC47M14x\n"); | 382 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); |
383 | else if (val == 0x60) | ||
384 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); | ||
383 | else { | 385 | else { |
384 | superio_exit(); | 386 | superio_exit(); |
385 | return -ENODEV; | 387 | return -ENODEV; |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c new file mode 100644 index 000000000000..c0ac01b60039 --- /dev/null +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -0,0 +1,1072 @@ | |||
1 | /* | ||
2 | * tps65010 - driver for tps6501x power management chips | ||
3 | * | ||
4 | * Copyright (C) 2004 Texas Instruments | ||
5 | * Copyright (C) 2004-2005 David Brownell | ||
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 | #undef DEBUG | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/device.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/workqueue.h> | ||
33 | #include <linux/suspend.h> | ||
34 | #include <linux/debugfs.h> | ||
35 | #include <linux/seq_file.h> | ||
36 | |||
37 | #include <asm/irq.h> | ||
38 | #include <asm/mach-types.h> | ||
39 | |||
40 | #include <asm/arch/gpio.h> | ||
41 | #include <asm/arch/mux.h> | ||
42 | #include <asm/arch/tps65010.h> | ||
43 | |||
44 | /*-------------------------------------------------------------------------*/ | ||
45 | |||
46 | #define DRIVER_VERSION "2 May 2005" | ||
47 | #define DRIVER_NAME (tps65010_driver.name) | ||
48 | |||
49 | MODULE_DESCRIPTION("TPS6501x Power Management Driver"); | ||
50 | MODULE_LICENSE("GPL"); | ||
51 | |||
52 | /* only two addresses possible */ | ||
53 | #define TPS_BASE 0x48 | ||
54 | static unsigned short normal_i2c[] = { | ||
55 | TPS_BASE, | ||
56 | I2C_CLIENT_END }; | ||
57 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
58 | |||
59 | I2C_CLIENT_INSMOD; | ||
60 | |||
61 | static struct i2c_driver tps65010_driver; | ||
62 | |||
63 | /*-------------------------------------------------------------------------*/ | ||
64 | |||
65 | /* This driver handles a family of multipurpose chips, which incorporate | ||
66 | * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs, | ||
67 | * and other features often needed in portable devices like cell phones | ||
68 | * or digital cameras. | ||
69 | * | ||
70 | * The tps65011 and tps65013 have different voltage settings compared | ||
71 | * to tps65010 and tps65012. The tps65013 has a NO_CHG status/irq. | ||
72 | * All except tps65010 have "wait" mode, possibly defaulted so that | ||
73 | * battery-insert != device-on. | ||
74 | * | ||
75 | * We could distinguish between some models by checking VDCDC1.UVLO or | ||
76 | * other registers, unless they've been changed already after powerup | ||
77 | * as part of board setup by a bootloader. | ||
78 | */ | ||
79 | enum tps_model { | ||
80 | TPS_UNKNOWN = 0, | ||
81 | TPS65010, | ||
82 | TPS65011, | ||
83 | TPS65012, | ||
84 | TPS65013, | ||
85 | }; | ||
86 | |||
87 | struct tps65010 { | ||
88 | struct i2c_client client; | ||
89 | struct semaphore lock; | ||
90 | int irq; | ||
91 | struct work_struct work; | ||
92 | struct dentry *file; | ||
93 | unsigned charging:1; | ||
94 | unsigned por:1; | ||
95 | unsigned model:8; | ||
96 | u16 vbus; | ||
97 | unsigned long flags; | ||
98 | #define FLAG_VBUS_CHANGED 0 | ||
99 | #define FLAG_IRQ_ENABLE 1 | ||
100 | |||
101 | /* copies of last register state */ | ||
102 | u8 chgstatus, regstatus, chgconf; | ||
103 | u8 nmask1, nmask2; | ||
104 | |||
105 | /* plus four GPIOs, probably used to switch power */ | ||
106 | }; | ||
107 | |||
108 | #define POWER_POLL_DELAY msecs_to_jiffies(800) | ||
109 | |||
110 | /*-------------------------------------------------------------------------*/ | ||
111 | |||
112 | #if defined(DEBUG) || defined(CONFIG_DEBUG_FS) | ||
113 | |||
114 | static void dbg_chgstat(char *buf, size_t len, u8 chgstatus) | ||
115 | { | ||
116 | snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n", | ||
117 | chgstatus, | ||
118 | (chgstatus & TPS_CHG_USB) ? " USB" : "", | ||
119 | (chgstatus & TPS_CHG_AC) ? " AC" : "", | ||
120 | (chgstatus & TPS_CHG_THERM) ? " therm" : "", | ||
121 | (chgstatus & TPS_CHG_TERM) ? " done" : | ||
122 | ((chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
123 | ? " (charging)" : ""), | ||
124 | (chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "", | ||
125 | (chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "", | ||
126 | (chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "", | ||
127 | (chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : ""); | ||
128 | } | ||
129 | |||
130 | static void dbg_regstat(char *buf, size_t len, u8 regstatus) | ||
131 | { | ||
132 | snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n", | ||
133 | regstatus, | ||
134 | (regstatus & TPS_REG_ONOFF) ? "off" : "(on)", | ||
135 | (regstatus & TPS_REG_COVER) ? " uncover" : "", | ||
136 | (regstatus & TPS_REG_UVLO) ? " UVLO" : "", | ||
137 | (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", | ||
138 | (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "", | ||
139 | (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", | ||
140 | (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", | ||
141 | (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); | ||
142 | } | ||
143 | |||
144 | static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) | ||
145 | { | ||
146 | char *hibit; | ||
147 | |||
148 | if (por) | ||
149 | hibit = (chgconfig & TPS_CHARGE_POR) | ||
150 | ? "POR=69ms" : "POR=1sec"; | ||
151 | else | ||
152 | hibit = (chgconfig & TPS65013_AUA) ? "AUA" : ""; | ||
153 | |||
154 | snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n", | ||
155 | chgconfig, hibit, | ||
156 | (chgconfig & TPS_CHARGE_RESET) ? " reset" : "", | ||
157 | (chgconfig & TPS_CHARGE_FAST) ? " fast" : "", | ||
158 | ({int p; switch ((chgconfig >> 3) & 3) { | ||
159 | case 3: p = 100; break; | ||
160 | case 2: p = 75; break; | ||
161 | case 1: p = 50; break; | ||
162 | default: p = 25; break; | ||
163 | }; p; }), | ||
164 | (chgconfig & TPS_VBUS_CHARGING) | ||
165 | ? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100) | ||
166 | : 0, | ||
167 | (chgconfig & TPS_CHARGE_ENABLE) ? "" : "No"); | ||
168 | } | ||
169 | |||
170 | #endif | ||
171 | |||
172 | #ifdef DEBUG | ||
173 | |||
174 | static void show_chgstatus(const char *label, u8 chgstatus) | ||
175 | { | ||
176 | char buf [100]; | ||
177 | |||
178 | dbg_chgstat(buf, sizeof buf, chgstatus); | ||
179 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
180 | } | ||
181 | |||
182 | static void show_regstatus(const char *label, u8 regstatus) | ||
183 | { | ||
184 | char buf [100]; | ||
185 | |||
186 | dbg_regstat(buf, sizeof buf, regstatus); | ||
187 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
188 | } | ||
189 | |||
190 | static void show_chgconfig(int por, const char *label, u8 chgconfig) | ||
191 | { | ||
192 | char buf [100]; | ||
193 | |||
194 | dbg_chgconf(por, buf, sizeof buf, chgconfig); | ||
195 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
196 | } | ||
197 | |||
198 | #else | ||
199 | |||
200 | static inline void show_chgstatus(const char *label, u8 chgstatus) { } | ||
201 | static inline void show_regstatus(const char *label, u8 chgstatus) { } | ||
202 | static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { } | ||
203 | |||
204 | #endif | ||
205 | |||
206 | #ifdef CONFIG_DEBUG_FS | ||
207 | |||
208 | static int dbg_show(struct seq_file *s, void *_) | ||
209 | { | ||
210 | struct tps65010 *tps = s->private; | ||
211 | u8 value, v2; | ||
212 | unsigned i; | ||
213 | char buf[100]; | ||
214 | const char *chip; | ||
215 | |||
216 | switch (tps->model) { | ||
217 | case TPS65010: chip = "tps65010"; break; | ||
218 | case TPS65011: chip = "tps65011"; break; | ||
219 | case TPS65012: chip = "tps65012"; break; | ||
220 | case TPS65013: chip = "tps65013"; break; | ||
221 | default: chip = NULL; break; | ||
222 | } | ||
223 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", | ||
224 | DRIVER_NAME, DRIVER_VERSION, chip); | ||
225 | |||
226 | down(&tps->lock); | ||
227 | |||
228 | /* FIXME how can we tell whether a battery is present? | ||
229 | * likely involves a charge gauging chip (like BQ26501). | ||
230 | */ | ||
231 | |||
232 | seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) "); | ||
233 | |||
234 | |||
235 | /* registers for monitoring battery charging and status; note | ||
236 | * that reading chgstat and regstat may ack IRQs... | ||
237 | */ | ||
238 | value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
239 | dbg_chgconf(tps->por, buf, sizeof buf, value); | ||
240 | seq_printf(s, "chgconfig %s", buf); | ||
241 | |||
242 | value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); | ||
243 | dbg_chgstat(buf, sizeof buf, value); | ||
244 | seq_printf(s, "chgstat %s", buf); | ||
245 | value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK1); | ||
246 | dbg_chgstat(buf, sizeof buf, value); | ||
247 | seq_printf(s, "mask1 %s", buf); | ||
248 | /* ignore ackint1 */ | ||
249 | |||
250 | value = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); | ||
251 | dbg_regstat(buf, sizeof buf, value); | ||
252 | seq_printf(s, "regstat %s", buf); | ||
253 | value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK2); | ||
254 | dbg_regstat(buf, sizeof buf, value); | ||
255 | seq_printf(s, "mask2 %s\n", buf); | ||
256 | /* ignore ackint2 */ | ||
257 | |||
258 | (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | ||
259 | |||
260 | |||
261 | /* VMAIN voltage, enable lowpower, etc */ | ||
262 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1); | ||
263 | seq_printf(s, "vdcdc1 %02x\n", value); | ||
264 | |||
265 | /* VCORE voltage, vibrator on/off */ | ||
266 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2); | ||
267 | seq_printf(s, "vdcdc2 %02x\n", value); | ||
268 | |||
269 | /* both LD0s, and their lowpower behavior */ | ||
270 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1); | ||
271 | seq_printf(s, "vregs1 %02x\n\n", value); | ||
272 | |||
273 | |||
274 | /* LEDs and GPIOs */ | ||
275 | value = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_ON); | ||
276 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_PER); | ||
277 | seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n", | ||
278 | (value & 0x80) | ||
279 | ? ((v2 & 0x80) ? "on" : "off") | ||
280 | : ((v2 & 0x80) ? "blink" : "(nPG)"), | ||
281 | value, v2, | ||
282 | (value & 0x7f) * 10, (v2 & 0x7f) * 100); | ||
283 | |||
284 | value = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_ON); | ||
285 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_PER); | ||
286 | seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n", | ||
287 | (value & 0x80) | ||
288 | ? ((v2 & 0x80) ? "on" : "off") | ||
289 | : ((v2 & 0x80) ? "blink" : "off"), | ||
290 | value, v2, | ||
291 | (value & 0x7f) * 10, (v2 & 0x7f) * 100); | ||
292 | |||
293 | value = i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO); | ||
294 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_MASK3); | ||
295 | seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); | ||
296 | |||
297 | for (i = 0; i < 4; i++) { | ||
298 | if (value & (1 << (4 +i))) | ||
299 | seq_printf(s, " gpio%d-out %s\n", i + 1, | ||
300 | (value & (1 << i)) ? "low" : "hi "); | ||
301 | else | ||
302 | seq_printf(s, " gpio%d-in %s %s %s\n", i + 1, | ||
303 | (value & (1 << i)) ? "hi " : "low", | ||
304 | (v2 & (1 << i)) ? "no-irq" : "irq", | ||
305 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); | ||
306 | } | ||
307 | |||
308 | up(&tps->lock); | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static int dbg_tps_open(struct inode *inode, struct file *file) | ||
313 | { | ||
314 | return single_open(file, dbg_show, inode->u.generic_ip); | ||
315 | } | ||
316 | |||
317 | static struct file_operations debug_fops = { | ||
318 | .open = dbg_tps_open, | ||
319 | .read = seq_read, | ||
320 | .llseek = seq_lseek, | ||
321 | .release = single_release, | ||
322 | }; | ||
323 | |||
324 | #define DEBUG_FOPS &debug_fops | ||
325 | |||
326 | #else | ||
327 | #define DEBUG_FOPS NULL | ||
328 | #endif | ||
329 | |||
330 | /*-------------------------------------------------------------------------*/ | ||
331 | |||
332 | /* handle IRQS in a task context, so we can use I2C calls */ | ||
333 | static void tps65010_interrupt(struct tps65010 *tps) | ||
334 | { | ||
335 | u8 tmp = 0, mask, poll; | ||
336 | |||
337 | /* IRQs won't trigger irqs for certain events, but we can get | ||
338 | * others by polling (normally, with external power applied). | ||
339 | */ | ||
340 | poll = 0; | ||
341 | |||
342 | /* regstatus irqs */ | ||
343 | if (tps->nmask2) { | ||
344 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); | ||
345 | mask = tmp ^ tps->regstatus; | ||
346 | tps->regstatus = tmp; | ||
347 | mask &= tps->nmask2; | ||
348 | } else | ||
349 | mask = 0; | ||
350 | if (mask) { | ||
351 | tps->regstatus = tmp; | ||
352 | /* may need to shut something down ... */ | ||
353 | |||
354 | /* "off" usually means deep sleep */ | ||
355 | if (tmp & TPS_REG_ONOFF) { | ||
356 | pr_info("%s: power off button\n", DRIVER_NAME); | ||
357 | #if 0 | ||
358 | /* REVISIT: this might need its own workqueue | ||
359 | * plus tweaks including deadlock avoidance ... | ||
360 | */ | ||
361 | software_suspend(); | ||
362 | #endif | ||
363 | poll = 1; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | /* chgstatus irqs */ | ||
368 | if (tps->nmask1) { | ||
369 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); | ||
370 | mask = tmp ^ tps->chgstatus; | ||
371 | tps->chgstatus = tmp; | ||
372 | mask &= tps->nmask1; | ||
373 | } else | ||
374 | mask = 0; | ||
375 | if (mask) { | ||
376 | unsigned charging = 0; | ||
377 | |||
378 | show_chgstatus("chg/irq", tmp); | ||
379 | if (tmp & (TPS_CHG_USB|TPS_CHG_AC)) | ||
380 | show_chgconfig(tps->por, "conf", tps->chgconf); | ||
381 | |||
382 | /* Unless it was turned off or disabled, we charge any | ||
383 | * battery whenever there's power available for it | ||
384 | * and the charger hasn't been disabled. | ||
385 | */ | ||
386 | if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC)) | ||
387 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
388 | && (tps->chgconf & TPS_CHARGE_ENABLE) | ||
389 | ) { | ||
390 | if (tps->chgstatus & TPS_CHG_USB) { | ||
391 | /* VBUS options are readonly until reconnect */ | ||
392 | if (mask & TPS_CHG_USB) | ||
393 | set_bit(FLAG_VBUS_CHANGED, &tps->flags); | ||
394 | charging = 1; | ||
395 | } else if (tps->chgstatus & TPS_CHG_AC) | ||
396 | charging = 1; | ||
397 | } | ||
398 | if (charging != tps->charging) { | ||
399 | tps->charging = charging; | ||
400 | pr_info("%s: battery %scharging\n", | ||
401 | DRIVER_NAME, charging ? "" : | ||
402 | ((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
403 | ? "NOT " : "dis")); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | /* always poll to detect (a) power removal, without tps65013 | ||
408 | * NO_CHG IRQ; or (b) restart of charging after stop. | ||
409 | */ | ||
410 | if ((tps->model != TPS65013 || !tps->charging) | ||
411 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) | ||
412 | poll = 1; | ||
413 | if (poll) | ||
414 | (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | ||
415 | |||
416 | /* also potentially gpio-in rise or fall */ | ||
417 | } | ||
418 | |||
419 | /* handle IRQs and polling using keventd for now */ | ||
420 | static void tps65010_work(void *_tps) | ||
421 | { | ||
422 | struct tps65010 *tps = _tps; | ||
423 | |||
424 | down(&tps->lock); | ||
425 | |||
426 | tps65010_interrupt(tps); | ||
427 | |||
428 | if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) { | ||
429 | int status; | ||
430 | u8 chgconfig, tmp; | ||
431 | |||
432 | chgconfig = i2c_smbus_read_byte_data(&tps->client, | ||
433 | TPS_CHGCONFIG); | ||
434 | chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING); | ||
435 | if (tps->vbus == 500) | ||
436 | chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING; | ||
437 | else if (tps->vbus >= 100) | ||
438 | chgconfig |= TPS_VBUS_CHARGING; | ||
439 | |||
440 | status = i2c_smbus_write_byte_data(&tps->client, | ||
441 | TPS_CHGCONFIG, chgconfig); | ||
442 | |||
443 | /* vbus update fails unless VBUS is connected! */ | ||
444 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
445 | tps->chgconf = tmp; | ||
446 | show_chgconfig(tps->por, "update vbus", tmp); | ||
447 | } | ||
448 | |||
449 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) | ||
450 | enable_irq(tps->irq); | ||
451 | |||
452 | up(&tps->lock); | ||
453 | } | ||
454 | |||
455 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) | ||
456 | { | ||
457 | struct tps65010 *tps = _tps; | ||
458 | |||
459 | disable_irq_nosync(irq); | ||
460 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | ||
461 | (void) schedule_work(&tps->work); | ||
462 | return IRQ_HANDLED; | ||
463 | } | ||
464 | |||
465 | /*-------------------------------------------------------------------------*/ | ||
466 | |||
467 | static struct tps65010 *the_tps; | ||
468 | |||
469 | static int __exit tps65010_detach_client(struct i2c_client *client) | ||
470 | { | ||
471 | struct tps65010 *tps; | ||
472 | |||
473 | tps = container_of(client, struct tps65010, client); | ||
474 | #ifdef CONFIG_ARM | ||
475 | if (machine_is_omap_h2()) | ||
476 | omap_free_gpio(58); | ||
477 | if (machine_is_omap_osk()) | ||
478 | omap_free_gpio(OMAP_MPUIO(1)); | ||
479 | #endif | ||
480 | free_irq(tps->irq, tps); | ||
481 | debugfs_remove(tps->file); | ||
482 | if (i2c_detach_client(client) == 0) | ||
483 | kfree(tps); | ||
484 | the_tps = 0; | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | static int tps65010_noscan(struct i2c_adapter *bus) | ||
489 | { | ||
490 | /* pure paranoia, in case someone adds another i2c bus | ||
491 | * after our init section's gone... | ||
492 | */ | ||
493 | return -ENODEV; | ||
494 | } | ||
495 | |||
496 | /* no error returns, they'd just make bus scanning stop */ | ||
497 | static int __init | ||
498 | tps65010_probe(struct i2c_adapter *bus, int address, int kind) | ||
499 | { | ||
500 | struct tps65010 *tps; | ||
501 | int status; | ||
502 | |||
503 | if (the_tps) { | ||
504 | dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME); | ||
505 | return 0; | ||
506 | } | ||
507 | |||
508 | tps = kmalloc(sizeof *tps, GFP_KERNEL); | ||
509 | if (!tps) | ||
510 | return 0; | ||
511 | |||
512 | memset(tps, 0, sizeof *tps); | ||
513 | init_MUTEX(&tps->lock); | ||
514 | INIT_WORK(&tps->work, tps65010_work, tps); | ||
515 | tps->irq = -1; | ||
516 | tps->client.addr = address; | ||
517 | i2c_set_clientdata(&tps->client, tps); | ||
518 | tps->client.adapter = bus; | ||
519 | tps->client.driver = &tps65010_driver; | ||
520 | strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); | ||
521 | |||
522 | status = i2c_attach_client(&tps->client); | ||
523 | if (status < 0) { | ||
524 | dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", | ||
525 | DRIVER_NAME, address, status); | ||
526 | fail1: | ||
527 | kfree(tps); | ||
528 | return 0; | ||
529 | } | ||
530 | |||
531 | #ifdef CONFIG_ARM | ||
532 | if (machine_is_omap_h2()) { | ||
533 | tps->model = TPS65010; | ||
534 | omap_cfg_reg(W4_GPIO58); | ||
535 | tps->irq = OMAP_GPIO_IRQ(58); | ||
536 | omap_request_gpio(58); | ||
537 | omap_set_gpio_direction(58, 1); | ||
538 | omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE); | ||
539 | } | ||
540 | if (machine_is_omap_osk()) { | ||
541 | tps->model = TPS65010; | ||
542 | // omap_cfg_reg(U19_1610_MPUIO1); | ||
543 | tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); | ||
544 | omap_request_gpio(OMAP_MPUIO(1)); | ||
545 | omap_set_gpio_direction(OMAP_MPUIO(1), 1); | ||
546 | omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE); | ||
547 | } | ||
548 | if (machine_is_omap_h3()) { | ||
549 | tps->model = TPS65013; | ||
550 | |||
551 | // FIXME set up this board's IRQ ... | ||
552 | } | ||
553 | #else | ||
554 | #define set_irq_type(num,trigger) do{}while(0) | ||
555 | #endif | ||
556 | |||
557 | if (tps->irq > 0) { | ||
558 | set_irq_type(tps->irq, IRQT_LOW); | ||
559 | status = request_irq(tps->irq, tps65010_irq, | ||
560 | SA_SAMPLE_RANDOM, DRIVER_NAME, tps); | ||
561 | if (status < 0) { | ||
562 | dev_dbg(&tps->client.dev, "can't get IRQ %d, err %d\n", | ||
563 | tps->irq, status); | ||
564 | i2c_detach_client(&tps->client); | ||
565 | goto fail1; | ||
566 | } | ||
567 | #ifdef CONFIG_ARM | ||
568 | /* annoying race here, ideally we'd have an option | ||
569 | * to claim the irq now and enable it later. | ||
570 | */ | ||
571 | disable_irq(tps->irq); | ||
572 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | ||
573 | #endif | ||
574 | } else | ||
575 | printk(KERN_WARNING "%s: IRQ not configured!\n", | ||
576 | DRIVER_NAME); | ||
577 | |||
578 | |||
579 | switch (tps->model) { | ||
580 | case TPS65010: | ||
581 | case TPS65012: | ||
582 | tps->por = 1; | ||
583 | break; | ||
584 | case TPS_UNKNOWN: | ||
585 | printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); | ||
586 | break; | ||
587 | /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ | ||
588 | } | ||
589 | tps->chgconf = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
590 | show_chgconfig(tps->por, "conf/init", tps->chgconf); | ||
591 | |||
592 | show_chgstatus("chg/init", | ||
593 | i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS)); | ||
594 | show_regstatus("reg/init", | ||
595 | i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS)); | ||
596 | |||
597 | pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME, | ||
598 | i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1), | ||
599 | i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2), | ||
600 | i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1)); | ||
601 | pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME, | ||
602 | i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO), | ||
603 | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | ||
604 | |||
605 | tps65010_driver.attach_adapter = tps65010_noscan; | ||
606 | the_tps = tps; | ||
607 | |||
608 | #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) | ||
609 | /* USB hosts can't draw VBUS. OTG devices could, later | ||
610 | * when OTG infrastructure enables it. USB peripherals | ||
611 | * could be relying on VBUS while booting, though. | ||
612 | */ | ||
613 | tps->vbus = 100; | ||
614 | #endif | ||
615 | |||
616 | /* unmask the "interesting" irqs, then poll once to | ||
617 | * kickstart monitoring, initialize shadowed status | ||
618 | * registers, and maybe disable VBUS draw. | ||
619 | */ | ||
620 | tps->nmask1 = ~0; | ||
621 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK1, ~tps->nmask1); | ||
622 | |||
623 | tps->nmask2 = TPS_REG_ONOFF; | ||
624 | if (tps->model == TPS65013) | ||
625 | tps->nmask2 |= TPS_REG_NO_CHG; | ||
626 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK2, ~tps->nmask2); | ||
627 | |||
628 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f | ||
629 | | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | ||
630 | |||
631 | tps65010_work(tps); | ||
632 | |||
633 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, | ||
634 | tps, DEBUG_FOPS); | ||
635 | return 0; | ||
636 | } | ||
637 | |||
638 | static int __init tps65010_scan_bus(struct i2c_adapter *bus) | ||
639 | { | ||
640 | if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
641 | return -EINVAL; | ||
642 | return i2c_probe(bus, &addr_data, tps65010_probe); | ||
643 | } | ||
644 | |||
645 | static struct i2c_driver tps65010_driver = { | ||
646 | .owner = THIS_MODULE, | ||
647 | .name = "tps65010", | ||
648 | .id = 888, /* FIXME assign "official" value */ | ||
649 | .flags = I2C_DF_NOTIFY, | ||
650 | .attach_adapter = tps65010_scan_bus, | ||
651 | .detach_client = __exit_p(tps65010_detach_client), | ||
652 | }; | ||
653 | |||
654 | /*-------------------------------------------------------------------------*/ | ||
655 | |||
656 | /* Draw from VBUS: | ||
657 | * 0 mA -- DON'T DRAW (might supply power instead) | ||
658 | * 100 mA -- usb unit load (slowest charge rate) | ||
659 | * 500 mA -- usb high power (fast battery charge) | ||
660 | */ | ||
661 | int tps65010_set_vbus_draw(unsigned mA) | ||
662 | { | ||
663 | unsigned long flags; | ||
664 | |||
665 | if (!the_tps) | ||
666 | return -ENODEV; | ||
667 | |||
668 | /* assumes non-SMP */ | ||
669 | local_irq_save(flags); | ||
670 | if (mA >= 500) | ||
671 | mA = 500; | ||
672 | else if (mA >= 100) | ||
673 | mA = 100; | ||
674 | else | ||
675 | mA = 0; | ||
676 | the_tps->vbus = mA; | ||
677 | if ((the_tps->chgstatus & TPS_CHG_USB) | ||
678 | && test_and_set_bit( | ||
679 | FLAG_VBUS_CHANGED, &the_tps->flags)) { | ||
680 | /* gadget drivers call this in_irq() */ | ||
681 | (void) schedule_work(&the_tps->work); | ||
682 | } | ||
683 | local_irq_restore(flags); | ||
684 | |||
685 | return 0; | ||
686 | } | ||
687 | EXPORT_SYMBOL(tps65010_set_vbus_draw); | ||
688 | |||
689 | /*-------------------------------------------------------------------------*/ | ||
690 | /* tps65010_set_gpio_out_value parameter: | ||
691 | * gpio: GPIO1, GPIO2, GPIO3 or GPIO4 | ||
692 | * value: LOW or HIGH | ||
693 | */ | ||
694 | int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | ||
695 | { | ||
696 | int status; | ||
697 | unsigned defgpio; | ||
698 | |||
699 | if (!the_tps) | ||
700 | return -ENODEV; | ||
701 | if ((gpio < GPIO1) || (gpio > GPIO4)) | ||
702 | return -EINVAL; | ||
703 | |||
704 | down(&the_tps->lock); | ||
705 | |||
706 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); | ||
707 | |||
708 | /* Configure GPIO for output */ | ||
709 | defgpio |= 1 << (gpio + 3); | ||
710 | |||
711 | /* Writing 1 forces a logic 0 on that GPIO and vice versa */ | ||
712 | switch (value) { | ||
713 | case LOW: | ||
714 | defgpio |= 1 << (gpio - 1); /* set GPIO low by writing 1 */ | ||
715 | break; | ||
716 | /* case HIGH: */ | ||
717 | default: | ||
718 | defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */ | ||
719 | break; | ||
720 | } | ||
721 | |||
722 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
723 | TPS_DEFGPIO, defgpio); | ||
724 | |||
725 | pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME, | ||
726 | gpio, value ? "high" : "low", | ||
727 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); | ||
728 | |||
729 | up(&the_tps->lock); | ||
730 | return status; | ||
731 | } | ||
732 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); | ||
733 | |||
734 | /*-------------------------------------------------------------------------*/ | ||
735 | /* tps65010_set_led parameter: | ||
736 | * led: LED1 or LED2 | ||
737 | * mode: ON, OFF or BLINK | ||
738 | */ | ||
739 | int tps65010_set_led(unsigned led, unsigned mode) | ||
740 | { | ||
741 | int status; | ||
742 | unsigned led_on, led_per, offs; | ||
743 | |||
744 | if (!the_tps) | ||
745 | return -ENODEV; | ||
746 | |||
747 | if(led == LED1) | ||
748 | offs = 0; | ||
749 | else { | ||
750 | offs = 2; | ||
751 | led = LED2; | ||
752 | } | ||
753 | |||
754 | down(&the_tps->lock); | ||
755 | |||
756 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | ||
757 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | ||
758 | |||
759 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | ||
760 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | ||
761 | |||
762 | switch (mode) { | ||
763 | case OFF: | ||
764 | led_on = 1 << 7; | ||
765 | led_per = 0 << 7; | ||
766 | break; | ||
767 | case ON: | ||
768 | led_on = 1 << 7; | ||
769 | led_per = 1 << 7; | ||
770 | break; | ||
771 | case BLINK: | ||
772 | led_on = 0x30 | (0 << 7); | ||
773 | led_per = 0x08 | (1 << 7); | ||
774 | break; | ||
775 | default: | ||
776 | printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n", | ||
777 | DRIVER_NAME); | ||
778 | up(&the_tps->lock); | ||
779 | return -EINVAL; | ||
780 | } | ||
781 | |||
782 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
783 | TPS_LED1_ON + offs, led_on); | ||
784 | |||
785 | if (status != 0) { | ||
786 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", | ||
787 | DRIVER_NAME, led); | ||
788 | up(&the_tps->lock); | ||
789 | return status; | ||
790 | } | ||
791 | |||
792 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | ||
793 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | ||
794 | |||
795 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
796 | TPS_LED1_PER + offs, led_per); | ||
797 | |||
798 | if (status != 0) { | ||
799 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", | ||
800 | DRIVER_NAME, led); | ||
801 | up(&the_tps->lock); | ||
802 | return status; | ||
803 | } | ||
804 | |||
805 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | ||
806 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | ||
807 | |||
808 | up(&the_tps->lock); | ||
809 | |||
810 | return status; | ||
811 | } | ||
812 | EXPORT_SYMBOL(tps65010_set_led); | ||
813 | |||
814 | /*-------------------------------------------------------------------------*/ | ||
815 | /* tps65010_set_vib parameter: | ||
816 | * value: ON or OFF | ||
817 | */ | ||
818 | int tps65010_set_vib(unsigned value) | ||
819 | { | ||
820 | int status; | ||
821 | unsigned vdcdc2; | ||
822 | |||
823 | if (!the_tps) | ||
824 | return -ENODEV; | ||
825 | |||
826 | down(&the_tps->lock); | ||
827 | |||
828 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); | ||
829 | vdcdc2 &= ~(1 << 1); | ||
830 | if (value) | ||
831 | vdcdc2 |= (1 << 1); | ||
832 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
833 | TPS_VDCDC2, vdcdc2); | ||
834 | |||
835 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); | ||
836 | |||
837 | up(&the_tps->lock); | ||
838 | return status; | ||
839 | } | ||
840 | EXPORT_SYMBOL(tps65010_set_vib); | ||
841 | |||
842 | /*-------------------------------------------------------------------------*/ | ||
843 | /* tps65010_set_low_pwr parameter: | ||
844 | * mode: ON or OFF | ||
845 | */ | ||
846 | int tps65010_set_low_pwr(unsigned mode) | ||
847 | { | ||
848 | int status; | ||
849 | unsigned vdcdc1; | ||
850 | |||
851 | if (!the_tps) | ||
852 | return -ENODEV; | ||
853 | |||
854 | down(&the_tps->lock); | ||
855 | |||
856 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, | ||
857 | mode ? "enable" : "disable", | ||
858 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
859 | |||
860 | vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); | ||
861 | |||
862 | switch (mode) { | ||
863 | case OFF: | ||
864 | vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ | ||
865 | break; | ||
866 | /* case ON: */ | ||
867 | default: | ||
868 | vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ | ||
869 | break; | ||
870 | } | ||
871 | |||
872 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
873 | TPS_VDCDC1, vdcdc1); | ||
874 | |||
875 | if (status != 0) | ||
876 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | ||
877 | DRIVER_NAME); | ||
878 | else | ||
879 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | ||
880 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
881 | |||
882 | up(&the_tps->lock); | ||
883 | |||
884 | return status; | ||
885 | } | ||
886 | EXPORT_SYMBOL(tps65010_set_low_pwr); | ||
887 | |||
888 | /*-------------------------------------------------------------------------*/ | ||
889 | /* tps65010_config_vregs1 parameter: | ||
890 | * value to be written to VREGS1 register | ||
891 | * Note: The complete register is written, set all bits you need | ||
892 | */ | ||
893 | int tps65010_config_vregs1(unsigned value) | ||
894 | { | ||
895 | int status; | ||
896 | |||
897 | if (!the_tps) | ||
898 | return -ENODEV; | ||
899 | |||
900 | down(&the_tps->lock); | ||
901 | |||
902 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | ||
903 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | ||
904 | |||
905 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
906 | TPS_VREGS1, value); | ||
907 | |||
908 | if (status != 0) | ||
909 | printk(KERN_ERR "%s: Failed to write vregs1 register\n", | ||
910 | DRIVER_NAME); | ||
911 | else | ||
912 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | ||
913 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | ||
914 | |||
915 | up(&the_tps->lock); | ||
916 | |||
917 | return status; | ||
918 | } | ||
919 | EXPORT_SYMBOL(tps65010_config_vregs1); | ||
920 | |||
921 | /*-------------------------------------------------------------------------*/ | ||
922 | /* tps65013_set_low_pwr parameter: | ||
923 | * mode: ON or OFF | ||
924 | */ | ||
925 | |||
926 | /* FIXME: Assumes AC or USB power is present. Setting AUA bit is not | ||
927 | required if power supply is through a battery */ | ||
928 | |||
929 | int tps65013_set_low_pwr(unsigned mode) | ||
930 | { | ||
931 | int status; | ||
932 | unsigned vdcdc1, chgconfig; | ||
933 | |||
934 | if (!the_tps || the_tps->por) | ||
935 | return -ENODEV; | ||
936 | |||
937 | down(&the_tps->lock); | ||
938 | |||
939 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", | ||
940 | DRIVER_NAME, | ||
941 | mode ? "enable" : "disable", | ||
942 | i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG), | ||
943 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
944 | |||
945 | chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); | ||
946 | vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); | ||
947 | |||
948 | switch (mode) { | ||
949 | case OFF: | ||
950 | chgconfig &= ~TPS65013_AUA; /* disable AUA bit */ | ||
951 | vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ | ||
952 | break; | ||
953 | /* case ON: */ | ||
954 | default: | ||
955 | chgconfig |= TPS65013_AUA; /* enable AUA bit */ | ||
956 | vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ | ||
957 | break; | ||
958 | } | ||
959 | |||
960 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
961 | TPS_CHGCONFIG, chgconfig); | ||
962 | if (status != 0) { | ||
963 | printk(KERN_ERR "%s: Failed to write chconfig register\n", | ||
964 | DRIVER_NAME); | ||
965 | up(&the_tps->lock); | ||
966 | return status; | ||
967 | } | ||
968 | |||
969 | chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); | ||
970 | the_tps->chgconf = chgconfig; | ||
971 | show_chgconfig(0, "chgconf", chgconfig); | ||
972 | |||
973 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
974 | TPS_VDCDC1, vdcdc1); | ||
975 | |||
976 | if (status != 0) | ||
977 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | ||
978 | DRIVER_NAME); | ||
979 | else | ||
980 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | ||
981 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
982 | |||
983 | up(&the_tps->lock); | ||
984 | |||
985 | return status; | ||
986 | } | ||
987 | EXPORT_SYMBOL(tps65013_set_low_pwr); | ||
988 | |||
989 | /*-------------------------------------------------------------------------*/ | ||
990 | |||
991 | static int __init tps_init(void) | ||
992 | { | ||
993 | u32 tries = 3; | ||
994 | int status = -ENODEV; | ||
995 | |||
996 | printk(KERN_INFO "%s: version %s\n", DRIVER_NAME, DRIVER_VERSION); | ||
997 | |||
998 | /* some boards have startup glitches */ | ||
999 | while (tries--) { | ||
1000 | status = i2c_add_driver(&tps65010_driver); | ||
1001 | if (the_tps) | ||
1002 | break; | ||
1003 | i2c_del_driver(&tps65010_driver); | ||
1004 | if (!tries) { | ||
1005 | printk(KERN_ERR "%s: no chip?\n", DRIVER_NAME); | ||
1006 | return -ENODEV; | ||
1007 | } | ||
1008 | pr_debug("%s: re-probe ...\n", DRIVER_NAME); | ||
1009 | msleep(10); | ||
1010 | } | ||
1011 | |||
1012 | #if defined(CONFIG_ARM) | ||
1013 | if (machine_is_omap_osk()) { | ||
1014 | |||
1015 | // FIXME: More should be placed in the initialization code | ||
1016 | // of the submodules (DSP, ethernet, power management, | ||
1017 | // board-osk.c). Careful: I2C is initialized "late". | ||
1018 | |||
1019 | /* Let LED1 (D9) blink */ | ||
1020 | tps65010_set_led(LED1, BLINK); | ||
1021 | |||
1022 | /* Disable LED 2 (D2) */ | ||
1023 | tps65010_set_led(LED2, OFF); | ||
1024 | |||
1025 | /* Set GPIO 1 HIGH to disable VBUS power supply; | ||
1026 | * OHCI driver powers it up/down as needed. | ||
1027 | */ | ||
1028 | tps65010_set_gpio_out_value(GPIO1, HIGH); | ||
1029 | |||
1030 | /* Set GPIO 2 low to turn on LED D3 */ | ||
1031 | tps65010_set_gpio_out_value(GPIO2, HIGH); | ||
1032 | |||
1033 | /* Set GPIO 3 low to take ethernet out of reset */ | ||
1034 | tps65010_set_gpio_out_value(GPIO3, LOW); | ||
1035 | |||
1036 | /* gpio4 for VDD_DSP */ | ||
1037 | |||
1038 | /* Enable LOW_PWR */ | ||
1039 | tps65010_set_low_pwr(ON); | ||
1040 | |||
1041 | /* Switch VLDO2 to 3.0V for AIC23 */ | ||
1042 | tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | TPS_LDO1_ENABLE); | ||
1043 | |||
1044 | } else if (machine_is_omap_h2()) { | ||
1045 | /* gpio3 for SD, gpio4 for VDD_DSP */ | ||
1046 | |||
1047 | /* Enable LOW_PWR */ | ||
1048 | tps65010_set_low_pwr(ON); | ||
1049 | } else if (machine_is_omap_h3()) { | ||
1050 | /* gpio4 for SD, gpio3 for VDD_DSP */ | ||
1051 | #ifdef CONFIG_PM | ||
1052 | /* Enable LOW_PWR */ | ||
1053 | tps65013_set_low_pwr(ON); | ||
1054 | #endif | ||
1055 | } | ||
1056 | #endif | ||
1057 | |||
1058 | return status; | ||
1059 | } | ||
1060 | /* NOTE: this MUST be initialized before the other parts of the system | ||
1061 | * that rely on it ... but after the i2c bus on which this relies. | ||
1062 | * That is, much earlier than on PC-type systems, which don't often use | ||
1063 | * I2C as a core system bus. | ||
1064 | */ | ||
1065 | subsys_initcall(tps_init); | ||
1066 | |||
1067 | static void __exit tps_exit(void) | ||
1068 | { | ||
1069 | i2c_del_driver(&tps65010_driver); | ||
1070 | } | ||
1071 | module_exit(tps_exit); | ||
1072 | |||
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index 6614a59cecd4..137d9b7cacd4 100644 --- a/drivers/i2c/chips/via686a.c +++ b/drivers/i2c/chips/via686a.c | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | via686a.c - Part of lm_sensors, Linux kernel modules | 2 | via686a.c - Part of lm_sensors, Linux kernel modules |
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 5 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
6 | Kyösti Mälkki <kmalkki@cc.hut.fi>, | 6 | Kyösti Mälkki <kmalkki@cc.hut.fi>, |
7 | Mark Studebaker <mdsxyz123@yahoo.com>, | 7 | Mark Studebaker <mdsxyz123@yahoo.com>, |
8 | and Bob Dougherty <bobd@stanford.edu> | 8 | and Bob Dougherty <bobd@stanford.edu> |
9 | (Some conversion-factor data were contributed by Jonathan Teh Soon Yew | 9 | (Some conversion-factor data were contributed by Jonathan Teh Soon Yew |
10 | <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) | 10 | <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
@@ -30,11 +30,9 @@ | |||
30 | Warning - only supports a single device. | 30 | Warning - only supports a single device. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/config.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
36 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
37 | #include <linux/delay.h> | ||
38 | #include <linux/jiffies.h> | 36 | #include <linux/jiffies.h> |
39 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
40 | #include <linux/i2c-sensor.h> | 38 | #include <linux/i2c-sensor.h> |
@@ -66,49 +64,46 @@ SENSORS_INSMOD_1(via686a); | |||
66 | /* Many VIA686A constants specified below */ | 64 | /* Many VIA686A constants specified below */ |
67 | 65 | ||
68 | /* Length of ISA address segment */ | 66 | /* Length of ISA address segment */ |
69 | #define VIA686A_EXTENT 0x80 | 67 | #define VIA686A_EXTENT 0x80 |
70 | #define VIA686A_BASE_REG 0x70 | 68 | #define VIA686A_BASE_REG 0x70 |
71 | #define VIA686A_ENABLE_REG 0x74 | 69 | #define VIA686A_ENABLE_REG 0x74 |
72 | 70 | ||
73 | /* The VIA686A registers */ | 71 | /* The VIA686A registers */ |
74 | /* ins numbered 0-4 */ | 72 | /* ins numbered 0-4 */ |
75 | #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) | 73 | #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) |
76 | #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) | 74 | #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) |
77 | #define VIA686A_REG_IN(nr) (0x22 + (nr)) | 75 | #define VIA686A_REG_IN(nr) (0x22 + (nr)) |
78 | 76 | ||
79 | /* fans numbered 1-2 */ | 77 | /* fans numbered 1-2 */ |
80 | #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) | 78 | #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) |
81 | #define VIA686A_REG_FAN(nr) (0x28 + (nr)) | 79 | #define VIA686A_REG_FAN(nr) (0x28 + (nr)) |
82 | |||
83 | /* the following values are as speced by VIA: */ | ||
84 | static const u8 regtemp[] = { 0x20, 0x21, 0x1f }; | ||
85 | static const u8 regover[] = { 0x39, 0x3d, 0x1d }; | ||
86 | static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; | ||
87 | 80 | ||
88 | /* temps numbered 1-3 */ | 81 | /* temps numbered 1-3 */ |
89 | #define VIA686A_REG_TEMP(nr) (regtemp[nr]) | 82 | static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f }; |
90 | #define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) | 83 | static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d }; |
91 | #define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) | 84 | static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e }; |
92 | #define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-6 | 85 | /* bits 7-6 */ |
93 | #define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-6 | 86 | #define VIA686A_REG_TEMP_LOW1 0x4b |
94 | 87 | /* 2 = bits 5-4, 3 = bits 7-6 */ | |
95 | #define VIA686A_REG_ALARM1 0x41 | 88 | #define VIA686A_REG_TEMP_LOW23 0x49 |
96 | #define VIA686A_REG_ALARM2 0x42 | 89 | |
97 | #define VIA686A_REG_FANDIV 0x47 | 90 | #define VIA686A_REG_ALARM1 0x41 |
98 | #define VIA686A_REG_CONFIG 0x40 | 91 | #define VIA686A_REG_ALARM2 0x42 |
99 | /* The following register sets temp interrupt mode (bits 1-0 for temp1, | 92 | #define VIA686A_REG_FANDIV 0x47 |
93 | #define VIA686A_REG_CONFIG 0x40 | ||
94 | /* The following register sets temp interrupt mode (bits 1-0 for temp1, | ||
100 | 3-2 for temp2, 5-4 for temp3). Modes are: | 95 | 3-2 for temp2, 5-4 for temp3). Modes are: |
101 | 00 interrupt stays as long as value is out-of-range | 96 | 00 interrupt stays as long as value is out-of-range |
102 | 01 interrupt is cleared once register is read (default) | 97 | 01 interrupt is cleared once register is read (default) |
103 | 10 comparator mode- like 00, but ignores hysteresis | 98 | 10 comparator mode- like 00, but ignores hysteresis |
104 | 11 same as 00 */ | 99 | 11 same as 00 */ |
105 | #define VIA686A_REG_TEMP_MODE 0x4b | 100 | #define VIA686A_REG_TEMP_MODE 0x4b |
106 | /* We'll just assume that you want to set all 3 simultaneously: */ | 101 | /* We'll just assume that you want to set all 3 simultaneously: */ |
107 | #define VIA686A_TEMP_MODE_MASK 0x3F | 102 | #define VIA686A_TEMP_MODE_MASK 0x3F |
108 | #define VIA686A_TEMP_MODE_CONTINUOUS (0x00) | 103 | #define VIA686A_TEMP_MODE_CONTINUOUS 0x00 |
109 | 104 | ||
110 | /* Conversions. Limit checking is only done on the TO_REG | 105 | /* Conversions. Limit checking is only done on the TO_REG |
111 | variants. | 106 | variants. |
112 | 107 | ||
113 | ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** | 108 | ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** |
114 | From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): | 109 | From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): |
@@ -121,7 +116,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; | |||
121 | That is: | 116 | That is: |
122 | volts = (25*regVal+133)*factor | 117 | volts = (25*regVal+133)*factor |
123 | regVal = (volts/factor-133)/25 | 118 | regVal = (volts/factor-133)/25 |
124 | (These conversions were contributed by Jonathan Teh Soon Yew | 119 | (These conversions were contributed by Jonathan Teh Soon Yew |
125 | <j.teh@iname.com>) */ | 120 | <j.teh@iname.com>) */ |
126 | static inline u8 IN_TO_REG(long val, int inNum) | 121 | static inline u8 IN_TO_REG(long val, int inNum) |
127 | { | 122 | { |
@@ -182,55 +177,55 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
182 | else | 177 | else |
183 | return double(temp)*0.924-127.33; | 178 | return double(temp)*0.924-127.33; |
184 | 179 | ||
185 | A fifth-order polynomial fits the unofficial data (provided by Alex van | 180 | A fifth-order polynomial fits the unofficial data (provided by Alex van |
186 | Kaam <darkside@chello.nl>) a bit better. It also give more reasonable | 181 | Kaam <darkside@chello.nl>) a bit better. It also give more reasonable |
187 | numbers on my machine (ie. they agree with what my BIOS tells me). | 182 | numbers on my machine (ie. they agree with what my BIOS tells me). |
188 | Here's the fifth-order fit to the 8-bit data: | 183 | Here's the fifth-order fit to the 8-bit data: |
189 | temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - | 184 | temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - |
190 | 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. | 185 | 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. |
191 | 186 | ||
192 | (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for | 187 | (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for |
193 | finding my typos in this formula!) | 188 | finding my typos in this formula!) |
194 | 189 | ||
195 | Alas, none of the elegant function-fit solutions will work because we | 190 | Alas, none of the elegant function-fit solutions will work because we |
196 | aren't allowed to use floating point in the kernel and doing it with | 191 | aren't allowed to use floating point in the kernel and doing it with |
197 | integers doesn't rpovide enough precision. So we'll do boring old | 192 | integers doesn't provide enough precision. So we'll do boring old |
198 | look-up table stuff. The unofficial data (see below) have effectively | 193 | look-up table stuff. The unofficial data (see below) have effectively |
199 | 7-bit resolution (they are rounded to the nearest degree). I'm assuming | 194 | 7-bit resolution (they are rounded to the nearest degree). I'm assuming |
200 | that the transfer function of the device is monotonic and smooth, so a | 195 | that the transfer function of the device is monotonic and smooth, so a |
201 | smooth function fit to the data will allow us to get better precision. | 196 | smooth function fit to the data will allow us to get better precision. |
202 | I used the 5th-order poly fit described above and solved for | 197 | I used the 5th-order poly fit described above and solved for |
203 | VIA register values 0-255. I *10 before rounding, so we get tenth-degree | 198 | VIA register values 0-255. I *10 before rounding, so we get tenth-degree |
204 | precision. (I could have done all 1024 values for our 10-bit readings, | 199 | precision. (I could have done all 1024 values for our 10-bit readings, |
205 | but the function is very linear in the useful range (0-80 deg C), so | 200 | but the function is very linear in the useful range (0-80 deg C), so |
206 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT | 201 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT |
207 | is the temp at via register values 0-255: */ | 202 | is the temp at via register values 0-255: */ |
208 | static const long tempLUT[] = | 203 | static const long tempLUT[] = |
209 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, | 204 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, |
210 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, | 205 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, |
211 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, | 206 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, |
212 | -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, | 207 | -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, |
213 | -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, | 208 | -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, |
214 | -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, | 209 | -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, |
215 | -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, | 210 | -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, |
216 | 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, | 211 | 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, |
217 | 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, | 212 | 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, |
218 | 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, | 213 | 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, |
219 | 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, | 214 | 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, |
220 | 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, | 215 | 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, |
221 | 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, | 216 | 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, |
222 | 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, | 217 | 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, |
223 | 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, | 218 | 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, |
224 | 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, | 219 | 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, |
225 | 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, | 220 | 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, |
226 | 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, | 221 | 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, |
227 | 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, | 222 | 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, |
228 | 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, | 223 | 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, |
229 | 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, | 224 | 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, |
230 | 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 | 225 | 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 |
231 | }; | 226 | }; |
232 | 227 | ||
233 | /* the original LUT values from Alex van Kaam <darkside@chello.nl> | 228 | /* the original LUT values from Alex van Kaam <darkside@chello.nl> |
234 | (for via register values 12-240): | 229 | (for via register values 12-240): |
235 | {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, | 230 | {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, |
236 | -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, | 231 | -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, |
@@ -245,26 +240,26 @@ static const long tempLUT[] = | |||
245 | 240 | ||
246 | 241 | ||
247 | Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed | 242 | Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed |
248 | an extra term for a good fit to these inverse data!) and then | 243 | an extra term for a good fit to these inverse data!) and then |
249 | solving for each temp value from -50 to 110 (the useable range for | 244 | solving for each temp value from -50 to 110 (the useable range for |
250 | this chip). Here's the fit: | 245 | this chip). Here's the fit: |
251 | viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 | 246 | viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 |
252 | - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) | 247 | - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) |
253 | Note that n=161: */ | 248 | Note that n=161: */ |
254 | static const u8 viaLUT[] = | 249 | static const u8 viaLUT[] = |
255 | { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, | 250 | { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, |
256 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, | 251 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, |
257 | 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, | 252 | 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, |
258 | 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, | 253 | 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, |
259 | 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, | 254 | 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, |
260 | 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, | 255 | 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, |
261 | 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, | 256 | 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, |
262 | 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, | 257 | 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, |
263 | 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, | 258 | 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, |
264 | 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, | 259 | 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, |
265 | 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, | 260 | 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, |
266 | 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, | 261 | 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, |
267 | 239, 240 | 262 | 239, 240 |
268 | }; | 263 | }; |
269 | 264 | ||
270 | /* Converting temps to (8-bit) hyst and over registers | 265 | /* Converting temps to (8-bit) hyst and over registers |
@@ -272,7 +267,7 @@ static const u8 viaLUT[] = | |||
272 | The +50 is because the temps start at -50 */ | 267 | The +50 is because the temps start at -50 */ |
273 | static inline u8 TEMP_TO_REG(long val) | 268 | static inline u8 TEMP_TO_REG(long val) |
274 | { | 269 | { |
275 | return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : | 270 | return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : |
276 | (val < 0 ? val - 500 : val + 500) / 1000 + 50]; | 271 | (val < 0 ? val - 500 : val + 500) / 1000 + 50]; |
277 | } | 272 | } |
278 | 273 | ||
@@ -291,11 +286,9 @@ static inline long TEMP_FROM_REG10(u16 val) | |||
291 | 286 | ||
292 | /* do some linear interpolation */ | 287 | /* do some linear interpolation */ |
293 | return (tempLUT[eightBits] * (4 - twoBits) + | 288 | return (tempLUT[eightBits] * (4 - twoBits) + |
294 | tempLUT[eightBits + 1] * twoBits) * 25; | 289 | tempLUT[eightBits + 1] * twoBits) * 25; |
295 | } | 290 | } |
296 | 291 | ||
297 | #define ALARMS_FROM_REG(val) (val) | ||
298 | |||
299 | #define DIV_FROM_REG(val) (1 << (val)) | 292 | #define DIV_FROM_REG(val) (1 << (val)) |
300 | #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) | 293 | #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) |
301 | 294 | ||
@@ -358,54 +351,54 @@ static ssize_t show_in_max(struct device *dev, char *buf, int nr) { | |||
358 | return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); | 351 | return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); |
359 | } | 352 | } |
360 | 353 | ||
361 | static ssize_t set_in_min(struct device *dev, const char *buf, | 354 | static ssize_t set_in_min(struct device *dev, const char *buf, |
362 | size_t count, int nr) { | 355 | size_t count, int nr) { |
363 | struct i2c_client *client = to_i2c_client(dev); | 356 | struct i2c_client *client = to_i2c_client(dev); |
364 | struct via686a_data *data = i2c_get_clientdata(client); | 357 | struct via686a_data *data = i2c_get_clientdata(client); |
365 | unsigned long val = simple_strtoul(buf, NULL, 10); | 358 | unsigned long val = simple_strtoul(buf, NULL, 10); |
366 | 359 | ||
367 | down(&data->update_lock); | 360 | down(&data->update_lock); |
368 | data->in_min[nr] = IN_TO_REG(val,nr); | 361 | data->in_min[nr] = IN_TO_REG(val, nr); |
369 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), | 362 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), |
370 | data->in_min[nr]); | 363 | data->in_min[nr]); |
371 | up(&data->update_lock); | 364 | up(&data->update_lock); |
372 | return count; | 365 | return count; |
373 | } | 366 | } |
374 | static ssize_t set_in_max(struct device *dev, const char *buf, | 367 | static ssize_t set_in_max(struct device *dev, const char *buf, |
375 | size_t count, int nr) { | 368 | size_t count, int nr) { |
376 | struct i2c_client *client = to_i2c_client(dev); | 369 | struct i2c_client *client = to_i2c_client(dev); |
377 | struct via686a_data *data = i2c_get_clientdata(client); | 370 | struct via686a_data *data = i2c_get_clientdata(client); |
378 | unsigned long val = simple_strtoul(buf, NULL, 10); | 371 | unsigned long val = simple_strtoul(buf, NULL, 10); |
379 | 372 | ||
380 | down(&data->update_lock); | 373 | down(&data->update_lock); |
381 | data->in_max[nr] = IN_TO_REG(val,nr); | 374 | data->in_max[nr] = IN_TO_REG(val, nr); |
382 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), | 375 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), |
383 | data->in_max[nr]); | 376 | data->in_max[nr]); |
384 | up(&data->update_lock); | 377 | up(&data->update_lock); |
385 | return count; | 378 | return count; |
386 | } | 379 | } |
387 | #define show_in_offset(offset) \ | 380 | #define show_in_offset(offset) \ |
388 | static ssize_t \ | 381 | static ssize_t \ |
389 | show_in##offset (struct device *dev, char *buf) \ | 382 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
390 | { \ | 383 | { \ |
391 | return show_in(dev, buf, offset); \ | 384 | return show_in(dev, buf, offset); \ |
392 | } \ | 385 | } \ |
393 | static ssize_t \ | 386 | static ssize_t \ |
394 | show_in##offset##_min (struct device *dev, char *buf) \ | 387 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
395 | { \ | 388 | { \ |
396 | return show_in_min(dev, buf, offset); \ | 389 | return show_in_min(dev, buf, offset); \ |
397 | } \ | 390 | } \ |
398 | static ssize_t \ | 391 | static ssize_t \ |
399 | show_in##offset##_max (struct device *dev, char *buf) \ | 392 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
400 | { \ | 393 | { \ |
401 | return show_in_max(dev, buf, offset); \ | 394 | return show_in_max(dev, buf, offset); \ |
402 | } \ | 395 | } \ |
403 | static ssize_t set_in##offset##_min (struct device *dev, \ | 396 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ |
404 | const char *buf, size_t count) \ | 397 | const char *buf, size_t count) \ |
405 | { \ | 398 | { \ |
406 | return set_in_min(dev, buf, count, offset); \ | 399 | return set_in_min(dev, buf, count, offset); \ |
407 | } \ | 400 | } \ |
408 | static ssize_t set_in##offset##_max (struct device *dev, \ | 401 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ |
409 | const char *buf, size_t count) \ | 402 | const char *buf, size_t count) \ |
410 | { \ | 403 | { \ |
411 | return set_in_max(dev, buf, count, offset); \ | 404 | return set_in_max(dev, buf, count, offset); \ |
@@ -435,7 +428,7 @@ static ssize_t show_temp_hyst(struct device *dev, char *buf, int nr) { | |||
435 | struct via686a_data *data = via686a_update_device(dev); | 428 | struct via686a_data *data = via686a_update_device(dev); |
436 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); | 429 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); |
437 | } | 430 | } |
438 | static ssize_t set_temp_over(struct device *dev, const char *buf, | 431 | static ssize_t set_temp_over(struct device *dev, const char *buf, |
439 | size_t count, int nr) { | 432 | size_t count, int nr) { |
440 | struct i2c_client *client = to_i2c_client(dev); | 433 | struct i2c_client *client = to_i2c_client(dev); |
441 | struct via686a_data *data = i2c_get_clientdata(client); | 434 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -443,11 +436,12 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, | |||
443 | 436 | ||
444 | down(&data->update_lock); | 437 | down(&data->update_lock); |
445 | data->temp_over[nr] = TEMP_TO_REG(val); | 438 | data->temp_over[nr] = TEMP_TO_REG(val); |
446 | via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]); | 439 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], |
440 | data->temp_over[nr]); | ||
447 | up(&data->update_lock); | 441 | up(&data->update_lock); |
448 | return count; | 442 | return count; |
449 | } | 443 | } |
450 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, | 444 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, |
451 | size_t count, int nr) { | 445 | size_t count, int nr) { |
452 | struct i2c_client *client = to_i2c_client(dev); | 446 | struct i2c_client *client = to_i2c_client(dev); |
453 | struct via686a_data *data = i2c_get_clientdata(client); | 447 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -455,31 +449,32 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf, | |||
455 | 449 | ||
456 | down(&data->update_lock); | 450 | down(&data->update_lock); |
457 | data->temp_hyst[nr] = TEMP_TO_REG(val); | 451 | data->temp_hyst[nr] = TEMP_TO_REG(val); |
458 | via686a_write_value(client, VIA686A_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 452 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], |
453 | data->temp_hyst[nr]); | ||
459 | up(&data->update_lock); | 454 | up(&data->update_lock); |
460 | return count; | 455 | return count; |
461 | } | 456 | } |
462 | #define show_temp_offset(offset) \ | 457 | #define show_temp_offset(offset) \ |
463 | static ssize_t show_temp_##offset (struct device *dev, char *buf) \ | 458 | static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
464 | { \ | 459 | { \ |
465 | return show_temp(dev, buf, offset - 1); \ | 460 | return show_temp(dev, buf, offset - 1); \ |
466 | } \ | 461 | } \ |
467 | static ssize_t \ | 462 | static ssize_t \ |
468 | show_temp_##offset##_over (struct device *dev, char *buf) \ | 463 | show_temp_##offset##_over (struct device *dev, struct device_attribute *attr, char *buf) \ |
469 | { \ | 464 | { \ |
470 | return show_temp_over(dev, buf, offset - 1); \ | 465 | return show_temp_over(dev, buf, offset - 1); \ |
471 | } \ | 466 | } \ |
472 | static ssize_t \ | 467 | static ssize_t \ |
473 | show_temp_##offset##_hyst (struct device *dev, char *buf) \ | 468 | show_temp_##offset##_hyst (struct device *dev, struct device_attribute *attr, char *buf) \ |
474 | { \ | 469 | { \ |
475 | return show_temp_hyst(dev, buf, offset - 1); \ | 470 | return show_temp_hyst(dev, buf, offset - 1); \ |
476 | } \ | 471 | } \ |
477 | static ssize_t set_temp_##offset##_over (struct device *dev, \ | 472 | static ssize_t set_temp_##offset##_over (struct device *dev, struct device_attribute *attr, \ |
478 | const char *buf, size_t count) \ | 473 | const char *buf, size_t count) \ |
479 | { \ | 474 | { \ |
480 | return set_temp_over(dev, buf, count, offset - 1); \ | 475 | return set_temp_over(dev, buf, count, offset - 1); \ |
481 | } \ | 476 | } \ |
482 | static ssize_t set_temp_##offset##_hyst (struct device *dev, \ | 477 | static ssize_t set_temp_##offset##_hyst (struct device *dev, struct device_attribute *attr, \ |
483 | const char *buf, size_t count) \ | 478 | const char *buf, size_t count) \ |
484 | { \ | 479 | { \ |
485 | return set_temp_hyst(dev, buf, count, offset - 1); \ | 480 | return set_temp_hyst(dev, buf, count, offset - 1); \ |
@@ -488,7 +483,7 @@ static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\ | |||
488 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | 483 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
489 | show_temp_##offset##_over, set_temp_##offset##_over); \ | 484 | show_temp_##offset##_over, set_temp_##offset##_over); \ |
490 | static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | 485 | static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ |
491 | show_temp_##offset##_hyst, set_temp_##offset##_hyst); | 486 | show_temp_##offset##_hyst, set_temp_##offset##_hyst); |
492 | 487 | ||
493 | show_temp_offset(1); | 488 | show_temp_offset(1); |
494 | show_temp_offset(2); | 489 | show_temp_offset(2); |
@@ -497,19 +492,19 @@ show_temp_offset(3); | |||
497 | /* 2 Fans */ | 492 | /* 2 Fans */ |
498 | static ssize_t show_fan(struct device *dev, char *buf, int nr) { | 493 | static ssize_t show_fan(struct device *dev, char *buf, int nr) { |
499 | struct via686a_data *data = via686a_update_device(dev); | 494 | struct via686a_data *data = via686a_update_device(dev); |
500 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 495 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
501 | DIV_FROM_REG(data->fan_div[nr])) ); | 496 | DIV_FROM_REG(data->fan_div[nr])) ); |
502 | } | 497 | } |
503 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { | 498 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { |
504 | struct via686a_data *data = via686a_update_device(dev); | 499 | struct via686a_data *data = via686a_update_device(dev); |
505 | return sprintf(buf,"%d\n", | 500 | return sprintf(buf, "%d\n", |
506 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); | 501 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); |
507 | } | 502 | } |
508 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { | 503 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { |
509 | struct via686a_data *data = via686a_update_device(dev); | 504 | struct via686a_data *data = via686a_update_device(dev); |
510 | return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) ); | 505 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) ); |
511 | } | 506 | } |
512 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 507 | static ssize_t set_fan_min(struct device *dev, const char *buf, |
513 | size_t count, int nr) { | 508 | size_t count, int nr) { |
514 | struct i2c_client *client = to_i2c_client(dev); | 509 | struct i2c_client *client = to_i2c_client(dev); |
515 | struct via686a_data *data = i2c_get_clientdata(client); | 510 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -521,7 +516,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
521 | up(&data->update_lock); | 516 | up(&data->update_lock); |
522 | return count; | 517 | return count; |
523 | } | 518 | } |
524 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 519 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
525 | size_t count, int nr) { | 520 | size_t count, int nr) { |
526 | struct i2c_client *client = to_i2c_client(dev); | 521 | struct i2c_client *client = to_i2c_client(dev); |
527 | struct via686a_data *data = i2c_get_clientdata(client); | 522 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -538,24 +533,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
538 | } | 533 | } |
539 | 534 | ||
540 | #define show_fan_offset(offset) \ | 535 | #define show_fan_offset(offset) \ |
541 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 536 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
542 | { \ | 537 | { \ |
543 | return show_fan(dev, buf, offset - 1); \ | 538 | return show_fan(dev, buf, offset - 1); \ |
544 | } \ | 539 | } \ |
545 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 540 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
546 | { \ | 541 | { \ |
547 | return show_fan_min(dev, buf, offset - 1); \ | 542 | return show_fan_min(dev, buf, offset - 1); \ |
548 | } \ | 543 | } \ |
549 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | 544 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
550 | { \ | 545 | { \ |
551 | return show_fan_div(dev, buf, offset - 1); \ | 546 | return show_fan_div(dev, buf, offset - 1); \ |
552 | } \ | 547 | } \ |
553 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | 548 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
554 | const char *buf, size_t count) \ | 549 | const char *buf, size_t count) \ |
555 | { \ | 550 | { \ |
556 | return set_fan_min(dev, buf, count, offset - 1); \ | 551 | return set_fan_min(dev, buf, count, offset - 1); \ |
557 | } \ | 552 | } \ |
558 | static ssize_t set_fan_##offset##_div (struct device *dev, \ | 553 | static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \ |
559 | const char *buf, size_t count) \ | 554 | const char *buf, size_t count) \ |
560 | { \ | 555 | { \ |
561 | return set_fan_div(dev, buf, count, offset - 1); \ | 556 | return set_fan_div(dev, buf, count, offset - 1); \ |
@@ -570,9 +565,9 @@ show_fan_offset(1); | |||
570 | show_fan_offset(2); | 565 | show_fan_offset(2); |
571 | 566 | ||
572 | /* Alarms */ | 567 | /* Alarms */ |
573 | static ssize_t show_alarms(struct device *dev, char *buf) { | 568 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { |
574 | struct via686a_data *data = via686a_update_device(dev); | 569 | struct via686a_data *data = via686a_update_device(dev); |
575 | return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); | 570 | return sprintf(buf, "%u\n", data->alarms); |
576 | } | 571 | } |
577 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 572 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
578 | 573 | ||
@@ -612,11 +607,12 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
612 | } | 607 | } |
613 | 608 | ||
614 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ | 609 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ |
615 | if(force_addr) | 610 | if (force_addr) |
616 | address = force_addr & 0xFF00; | 611 | address = force_addr & 0xFF00; |
617 | 612 | ||
618 | if(force_addr) { | 613 | if (force_addr) { |
619 | dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address); | 614 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", |
615 | address); | ||
620 | if (PCIBIOS_SUCCESSFUL != | 616 | if (PCIBIOS_SUCCESSFUL != |
621 | pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) | 617 | pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) |
622 | return -ENODEV; | 618 | return -ENODEV; |
@@ -625,17 +621,17 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
625 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) | 621 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) |
626 | return -ENODEV; | 622 | return -ENODEV; |
627 | if (!(val & 0x0001)) { | 623 | if (!(val & 0x0001)) { |
628 | dev_warn(&adapter->dev,"enabling sensors\n"); | 624 | dev_warn(&adapter->dev, "enabling sensors\n"); |
629 | if (PCIBIOS_SUCCESSFUL != | 625 | if (PCIBIOS_SUCCESSFUL != |
630 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, | 626 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, |
631 | val | 0x0001)) | 627 | val | 0x0001)) |
632 | return -ENODEV; | 628 | return -ENODEV; |
633 | } | 629 | } |
634 | 630 | ||
635 | /* Reserve the ISA region */ | 631 | /* Reserve the ISA region */ |
636 | if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { | 632 | if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { |
637 | dev_err(&adapter->dev,"region 0x%x already in use!\n", | 633 | dev_err(&adapter->dev, "region 0x%x already in use!\n", |
638 | address); | 634 | address); |
639 | return -ENODEV; | 635 | return -ENODEV; |
640 | } | 636 | } |
641 | 637 | ||
@@ -660,7 +656,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
660 | /* Tell the I2C layer a new client has arrived */ | 656 | /* Tell the I2C layer a new client has arrived */ |
661 | if ((err = i2c_attach_client(new_client))) | 657 | if ((err = i2c_attach_client(new_client))) |
662 | goto ERROR3; | 658 | goto ERROR3; |
663 | 659 | ||
664 | /* Initialize the VIA686A chip */ | 660 | /* Initialize the VIA686A chip */ |
665 | via686a_init_client(new_client); | 661 | via686a_init_client(new_client); |
666 | 662 | ||
@@ -699,9 +695,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
699 | 695 | ||
700 | return 0; | 696 | return 0; |
701 | 697 | ||
702 | ERROR3: | 698 | ERROR3: |
703 | kfree(data); | 699 | kfree(data); |
704 | ERROR0: | 700 | ERROR0: |
705 | release_region(address, VIA686A_EXTENT); | 701 | release_region(address, VIA686A_EXTENT); |
706 | return err; | 702 | return err; |
707 | } | 703 | } |
@@ -732,7 +728,7 @@ static void via686a_init_client(struct i2c_client *client) | |||
732 | via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); | 728 | via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); |
733 | 729 | ||
734 | /* Configure temp interrupt mode for continuous-interrupt operation */ | 730 | /* Configure temp interrupt mode for continuous-interrupt operation */ |
735 | via686a_write_value(client, VIA686A_REG_TEMP_MODE, | 731 | via686a_write_value(client, VIA686A_REG_TEMP_MODE, |
736 | via686a_read_value(client, VIA686A_REG_TEMP_MODE) & | 732 | via686a_read_value(client, VIA686A_REG_TEMP_MODE) & |
737 | !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); | 733 | !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); |
738 | } | 734 | } |
@@ -764,15 +760,15 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
764 | } | 760 | } |
765 | for (i = 0; i <= 2; i++) { | 761 | for (i = 0; i <= 2; i++) { |
766 | data->temp[i] = via686a_read_value(client, | 762 | data->temp[i] = via686a_read_value(client, |
767 | VIA686A_REG_TEMP(i)) << 2; | 763 | VIA686A_REG_TEMP[i]) << 2; |
768 | data->temp_over[i] = | 764 | data->temp_over[i] = |
769 | via686a_read_value(client, | 765 | via686a_read_value(client, |
770 | VIA686A_REG_TEMP_OVER(i)); | 766 | VIA686A_REG_TEMP_OVER[i]); |
771 | data->temp_hyst[i] = | 767 | data->temp_hyst[i] = |
772 | via686a_read_value(client, | 768 | via686a_read_value(client, |
773 | VIA686A_REG_TEMP_HYST(i)); | 769 | VIA686A_REG_TEMP_HYST[i]); |
774 | } | 770 | } |
775 | /* add in lower 2 bits | 771 | /* add in lower 2 bits |
776 | temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 | 772 | temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 |
777 | temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 | 773 | temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 |
778 | temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 | 774 | temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 |
@@ -804,35 +800,36 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
804 | } | 800 | } |
805 | 801 | ||
806 | static struct pci_device_id via686a_pci_ids[] = { | 802 | static struct pci_device_id via686a_pci_ids[] = { |
807 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, | 803 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, |
808 | { 0, } | 804 | { 0, } |
809 | }; | 805 | }; |
810 | 806 | ||
811 | MODULE_DEVICE_TABLE(pci, via686a_pci_ids); | 807 | MODULE_DEVICE_TABLE(pci, via686a_pci_ids); |
812 | 808 | ||
813 | static int __devinit via686a_pci_probe(struct pci_dev *dev, | 809 | static int __devinit via686a_pci_probe(struct pci_dev *dev, |
814 | const struct pci_device_id *id) | 810 | const struct pci_device_id *id) |
815 | { | 811 | { |
816 | u16 val; | 812 | u16 val; |
817 | int addr = 0; | 813 | int addr = 0; |
818 | 814 | ||
819 | if (PCIBIOS_SUCCESSFUL != | 815 | if (PCIBIOS_SUCCESSFUL != |
820 | pci_read_config_word(dev, VIA686A_BASE_REG, &val)) | 816 | pci_read_config_word(dev, VIA686A_BASE_REG, &val)) |
821 | return -ENODEV; | 817 | return -ENODEV; |
822 | 818 | ||
823 | addr = val & ~(VIA686A_EXTENT - 1); | 819 | addr = val & ~(VIA686A_EXTENT - 1); |
824 | if (addr == 0 && force_addr == 0) { | 820 | if (addr == 0 && force_addr == 0) { |
825 | dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n"); | 821 | dev_err(&dev->dev, "base address not set - upgrade BIOS " |
826 | return -ENODEV; | 822 | "or use force_addr=0xaddr\n"); |
827 | } | 823 | return -ENODEV; |
828 | if (force_addr) | 824 | } |
829 | addr = force_addr; /* so detect will get called */ | 825 | if (force_addr) |
830 | 826 | addr = force_addr; /* so detect will get called */ | |
831 | if (!addr) { | 827 | |
832 | dev_err(&dev->dev,"No Via 686A sensors found.\n"); | 828 | if (!addr) { |
833 | return -ENODEV; | 829 | dev_err(&dev->dev, "No Via 686A sensors found.\n"); |
834 | } | 830 | return -ENODEV; |
835 | normal_isa[0] = addr; | 831 | } |
832 | normal_isa[0] = addr; | ||
836 | 833 | ||
837 | s_bridge = pci_dev_get(dev); | 834 | s_bridge = pci_dev_get(dev); |
838 | if (i2c_add_driver(&via686a_driver)) { | 835 | if (i2c_add_driver(&via686a_driver)) { |
@@ -848,14 +845,14 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, | |||
848 | } | 845 | } |
849 | 846 | ||
850 | static struct pci_driver via686a_pci_driver = { | 847 | static struct pci_driver via686a_pci_driver = { |
851 | .name = "via686a", | 848 | .name = "via686a", |
852 | .id_table = via686a_pci_ids, | 849 | .id_table = via686a_pci_ids, |
853 | .probe = via686a_pci_probe, | 850 | .probe = via686a_pci_probe, |
854 | }; | 851 | }; |
855 | 852 | ||
856 | static int __init sm_via686a_init(void) | 853 | static int __init sm_via686a_init(void) |
857 | { | 854 | { |
858 | return pci_register_driver(&via686a_pci_driver); | 855 | return pci_register_driver(&via686a_pci_driver); |
859 | } | 856 | } |
860 | 857 | ||
861 | static void __exit sm_via686a_exit(void) | 858 | static void __exit sm_via686a_exit(void) |
@@ -869,8 +866,8 @@ static void __exit sm_via686a_exit(void) | |||
869 | } | 866 | } |
870 | 867 | ||
871 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " | 868 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " |
872 | "Mark Studebaker <mdsxyz123@yahoo.com> " | 869 | "Mark Studebaker <mdsxyz123@yahoo.com> " |
873 | "and Bob Dougherty <bobd@stanford.edu>"); | 870 | "and Bob Dougherty <bobd@stanford.edu>"); |
874 | MODULE_DESCRIPTION("VIA 686A Sensor device"); | 871 | MODULE_DESCRIPTION("VIA 686A Sensor device"); |
875 | MODULE_LICENSE("GPL"); | 872 | MODULE_LICENSE("GPL"); |
876 | 873 | ||
diff --git a/drivers/i2c/chips/w83627ehf.c b/drivers/i2c/chips/w83627ehf.c new file mode 100644 index 000000000000..8a40b6976e1a --- /dev/null +++ b/drivers/i2c/chips/w83627ehf.c | |||
@@ -0,0 +1,846 @@ | |||
1 | /* | ||
2 | w83627ehf - Driver for the hardware monitoring functionality of | ||
3 | the Winbond W83627EHF Super-I/O chip | ||
4 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | ||
5 | |||
6 | Shamelessly ripped from the w83627hf driver | ||
7 | Copyright (C) 2003 Mark Studebaker | ||
8 | |||
9 | Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help | ||
10 | in testing and debugging this driver. | ||
11 | |||
12 | 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 | ||
14 | the Free Software Foundation; either version 2 of the License, or | ||
15 | (at your option) any later version. | ||
16 | |||
17 | This program is distributed in the hope that it will be useful, | ||
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | GNU General Public License for more details. | ||
21 | |||
22 | You should have received a copy of the GNU General Public License | ||
23 | along with this program; if not, write to the Free Software | ||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | |||
26 | |||
27 | Supports the following chips: | ||
28 | |||
29 | Chip #vin #fan #pwm #temp chip_id man_id | ||
30 | w83627ehf - 5 - 3 0x88 0x5ca3 | ||
31 | |||
32 | This is a preliminary version of the driver, only supporting the | ||
33 | fan and temperature inputs. The chip does much more than that. | ||
34 | */ | ||
35 | |||
36 | #include <linux/module.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/i2c.h> | ||
40 | #include <linux/i2c-sensor.h> | ||
41 | #include <asm/io.h> | ||
42 | #include "lm75.h" | ||
43 | |||
44 | /* Addresses to scan | ||
45 | The actual ISA address is read from Super-I/O configuration space */ | ||
46 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
47 | static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; | ||
48 | |||
49 | /* Insmod parameters */ | ||
50 | SENSORS_INSMOD_1(w83627ehf); | ||
51 | |||
52 | /* | ||
53 | * Super-I/O constants and functions | ||
54 | */ | ||
55 | |||
56 | static int REG; /* The register to read/write */ | ||
57 | static int VAL; /* The value to read/write */ | ||
58 | |||
59 | #define W83627EHF_LD_HWM 0x0b | ||
60 | |||
61 | #define SIO_REG_LDSEL 0x07 /* Logical device select */ | ||
62 | #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ | ||
63 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ | ||
64 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ | ||
65 | |||
66 | #define SIO_W83627EHF_ID 0x8840 | ||
67 | #define SIO_ID_MASK 0xFFC0 | ||
68 | |||
69 | static inline void | ||
70 | superio_outb(int reg, int val) | ||
71 | { | ||
72 | outb(reg, REG); | ||
73 | outb(val, VAL); | ||
74 | } | ||
75 | |||
76 | static inline int | ||
77 | superio_inb(int reg) | ||
78 | { | ||
79 | outb(reg, REG); | ||
80 | return inb(VAL); | ||
81 | } | ||
82 | |||
83 | static inline void | ||
84 | superio_select(int ld) | ||
85 | { | ||
86 | outb(SIO_REG_LDSEL, REG); | ||
87 | outb(ld, VAL); | ||
88 | } | ||
89 | |||
90 | static inline void | ||
91 | superio_enter(void) | ||
92 | { | ||
93 | outb(0x87, REG); | ||
94 | outb(0x87, REG); | ||
95 | } | ||
96 | |||
97 | static inline void | ||
98 | superio_exit(void) | ||
99 | { | ||
100 | outb(0x02, REG); | ||
101 | outb(0x02, VAL); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * ISA constants | ||
106 | */ | ||
107 | |||
108 | #define REGION_LENGTH 8 | ||
109 | #define ADDR_REG_OFFSET 5 | ||
110 | #define DATA_REG_OFFSET 6 | ||
111 | |||
112 | #define W83627EHF_REG_BANK 0x4E | ||
113 | #define W83627EHF_REG_CONFIG 0x40 | ||
114 | #define W83627EHF_REG_CHIP_ID 0x49 | ||
115 | #define W83627EHF_REG_MAN_ID 0x4F | ||
116 | |||
117 | static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 }; | ||
118 | static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c }; | ||
119 | |||
120 | #define W83627EHF_REG_TEMP1 0x27 | ||
121 | #define W83627EHF_REG_TEMP1_HYST 0x3a | ||
122 | #define W83627EHF_REG_TEMP1_OVER 0x39 | ||
123 | static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 }; | ||
124 | static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 }; | ||
125 | static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 }; | ||
126 | static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 }; | ||
127 | |||
128 | /* Fan clock dividers are spread over the following five registers */ | ||
129 | #define W83627EHF_REG_FANDIV1 0x47 | ||
130 | #define W83627EHF_REG_FANDIV2 0x4B | ||
131 | #define W83627EHF_REG_VBAT 0x5D | ||
132 | #define W83627EHF_REG_DIODE 0x59 | ||
133 | #define W83627EHF_REG_SMI_OVT 0x4C | ||
134 | |||
135 | /* | ||
136 | * Conversions | ||
137 | */ | ||
138 | |||
139 | static inline unsigned int | ||
140 | fan_from_reg(u8 reg, unsigned int div) | ||
141 | { | ||
142 | if (reg == 0 || reg == 255) | ||
143 | return 0; | ||
144 | return 1350000U / (reg * div); | ||
145 | } | ||
146 | |||
147 | static inline unsigned int | ||
148 | div_from_reg(u8 reg) | ||
149 | { | ||
150 | return 1 << reg; | ||
151 | } | ||
152 | |||
153 | static inline int | ||
154 | temp1_from_reg(s8 reg) | ||
155 | { | ||
156 | return reg * 1000; | ||
157 | } | ||
158 | |||
159 | static inline s8 | ||
160 | temp1_to_reg(int temp) | ||
161 | { | ||
162 | if (temp <= -128000) | ||
163 | return -128; | ||
164 | if (temp >= 127000) | ||
165 | return 127; | ||
166 | if (temp < 0) | ||
167 | return (temp - 500) / 1000; | ||
168 | return (temp + 500) / 1000; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Data structures and manipulation thereof | ||
173 | */ | ||
174 | |||
175 | struct w83627ehf_data { | ||
176 | struct i2c_client client; | ||
177 | struct semaphore lock; | ||
178 | |||
179 | struct semaphore update_lock; | ||
180 | char valid; /* !=0 if following fields are valid */ | ||
181 | unsigned long last_updated; /* In jiffies */ | ||
182 | |||
183 | /* Register values */ | ||
184 | u8 fan[5]; | ||
185 | u8 fan_min[5]; | ||
186 | u8 fan_div[5]; | ||
187 | u8 has_fan; /* some fan inputs can be disabled */ | ||
188 | s8 temp1; | ||
189 | s8 temp1_max; | ||
190 | s8 temp1_max_hyst; | ||
191 | s16 temp[2]; | ||
192 | s16 temp_max[2]; | ||
193 | s16 temp_max_hyst[2]; | ||
194 | }; | ||
195 | |||
196 | static inline int is_word_sized(u16 reg) | ||
197 | { | ||
198 | return (((reg & 0xff00) == 0x100 | ||
199 | || (reg & 0xff00) == 0x200) | ||
200 | && ((reg & 0x00ff) == 0x50 | ||
201 | || (reg & 0x00ff) == 0x53 | ||
202 | || (reg & 0x00ff) == 0x55)); | ||
203 | } | ||
204 | |||
205 | /* We assume that the default bank is 0, thus the following two functions do | ||
206 | nothing for registers which live in bank 0. For others, they respectively | ||
207 | set the bank register to the correct value (before the register is | ||
208 | accessed), and back to 0 (afterwards). */ | ||
209 | static inline void w83627ehf_set_bank(struct i2c_client *client, u16 reg) | ||
210 | { | ||
211 | if (reg & 0xff00) { | ||
212 | outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); | ||
213 | outb_p(reg >> 8, client->addr + DATA_REG_OFFSET); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | static inline void w83627ehf_reset_bank(struct i2c_client *client, u16 reg) | ||
218 | { | ||
219 | if (reg & 0xff00) { | ||
220 | outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); | ||
221 | outb_p(0, client->addr + DATA_REG_OFFSET); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | ||
226 | { | ||
227 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
228 | int res, word_sized = is_word_sized(reg); | ||
229 | |||
230 | down(&data->lock); | ||
231 | |||
232 | w83627ehf_set_bank(client, reg); | ||
233 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | ||
234 | res = inb_p(client->addr + DATA_REG_OFFSET); | ||
235 | if (word_sized) { | ||
236 | outb_p((reg & 0xff) + 1, | ||
237 | client->addr + ADDR_REG_OFFSET); | ||
238 | res = (res << 8) + inb_p(client->addr + DATA_REG_OFFSET); | ||
239 | } | ||
240 | w83627ehf_reset_bank(client, reg); | ||
241 | |||
242 | up(&data->lock); | ||
243 | |||
244 | return res; | ||
245 | } | ||
246 | |||
247 | static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | ||
248 | { | ||
249 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
250 | int word_sized = is_word_sized(reg); | ||
251 | |||
252 | down(&data->lock); | ||
253 | |||
254 | w83627ehf_set_bank(client, reg); | ||
255 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | ||
256 | if (word_sized) { | ||
257 | outb_p(value >> 8, client->addr + DATA_REG_OFFSET); | ||
258 | outb_p((reg & 0xff) + 1, | ||
259 | client->addr + ADDR_REG_OFFSET); | ||
260 | } | ||
261 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | ||
262 | w83627ehf_reset_bank(client, reg); | ||
263 | |||
264 | up(&data->lock); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | /* This function assumes that the caller holds data->update_lock */ | ||
269 | static void w83627ehf_write_fan_div(struct i2c_client *client, int nr) | ||
270 | { | ||
271 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
272 | u8 reg; | ||
273 | |||
274 | switch (nr) { | ||
275 | case 0: | ||
276 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf) | ||
277 | | ((data->fan_div[0] & 0x03) << 4); | ||
278 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); | ||
279 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf) | ||
280 | | ((data->fan_div[0] & 0x04) << 3); | ||
281 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
282 | break; | ||
283 | case 1: | ||
284 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f) | ||
285 | | ((data->fan_div[1] & 0x03) << 6); | ||
286 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); | ||
287 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf) | ||
288 | | ((data->fan_div[1] & 0x04) << 4); | ||
289 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
290 | break; | ||
291 | case 2: | ||
292 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV2) & 0x3f) | ||
293 | | ((data->fan_div[2] & 0x03) << 6); | ||
294 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV2, reg); | ||
295 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0x7f) | ||
296 | | ((data->fan_div[2] & 0x04) << 5); | ||
297 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
298 | break; | ||
299 | case 3: | ||
300 | reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0xfc) | ||
301 | | (data->fan_div[3] & 0x03); | ||
302 | w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); | ||
303 | reg = (w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT) & 0x7f) | ||
304 | | ((data->fan_div[3] & 0x04) << 5); | ||
305 | w83627ehf_write_value(client, W83627EHF_REG_SMI_OVT, reg); | ||
306 | break; | ||
307 | case 4: | ||
308 | reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73) | ||
309 | | ((data->fan_div[4] & 0x03) << 3) | ||
310 | | ((data->fan_div[4] & 0x04) << 5); | ||
311 | w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); | ||
312 | break; | ||
313 | } | ||
314 | } | ||
315 | |||
316 | static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | ||
317 | { | ||
318 | struct i2c_client *client = to_i2c_client(dev); | ||
319 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
320 | int i; | ||
321 | |||
322 | down(&data->update_lock); | ||
323 | |||
324 | if (time_after(jiffies, data->last_updated + HZ) | ||
325 | || !data->valid) { | ||
326 | /* Fan clock dividers */ | ||
327 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); | ||
328 | data->fan_div[0] = (i >> 4) & 0x03; | ||
329 | data->fan_div[1] = (i >> 6) & 0x03; | ||
330 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV2); | ||
331 | data->fan_div[2] = (i >> 6) & 0x03; | ||
332 | i = w83627ehf_read_value(client, W83627EHF_REG_VBAT); | ||
333 | data->fan_div[0] |= (i >> 3) & 0x04; | ||
334 | data->fan_div[1] |= (i >> 4) & 0x04; | ||
335 | data->fan_div[2] |= (i >> 5) & 0x04; | ||
336 | if (data->has_fan & ((1 << 3) | (1 << 4))) { | ||
337 | i = w83627ehf_read_value(client, W83627EHF_REG_DIODE); | ||
338 | data->fan_div[3] = i & 0x03; | ||
339 | data->fan_div[4] = ((i >> 2) & 0x03) | ||
340 | | ((i >> 5) & 0x04); | ||
341 | } | ||
342 | if (data->has_fan & (1 << 3)) { | ||
343 | i = w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT); | ||
344 | data->fan_div[3] |= (i >> 5) & 0x04; | ||
345 | } | ||
346 | |||
347 | /* Measured fan speeds and limits */ | ||
348 | for (i = 0; i < 5; i++) { | ||
349 | if (!(data->has_fan & (1 << i))) | ||
350 | continue; | ||
351 | |||
352 | data->fan[i] = w83627ehf_read_value(client, | ||
353 | W83627EHF_REG_FAN[i]); | ||
354 | data->fan_min[i] = w83627ehf_read_value(client, | ||
355 | W83627EHF_REG_FAN_MIN[i]); | ||
356 | |||
357 | /* If we failed to measure the fan speed and clock | ||
358 | divider can be increased, let's try that for next | ||
359 | time */ | ||
360 | if (data->fan[i] == 0xff | ||
361 | && data->fan_div[i] < 0x07) { | ||
362 | dev_dbg(&client->dev, "Increasing fan %d " | ||
363 | "clock divider from %u to %u\n", | ||
364 | i, div_from_reg(data->fan_div[i]), | ||
365 | div_from_reg(data->fan_div[i] + 1)); | ||
366 | data->fan_div[i]++; | ||
367 | w83627ehf_write_fan_div(client, i); | ||
368 | /* Preserve min limit if possible */ | ||
369 | if (data->fan_min[i] >= 2 | ||
370 | && data->fan_min[i] != 255) | ||
371 | w83627ehf_write_value(client, | ||
372 | W83627EHF_REG_FAN_MIN[i], | ||
373 | (data->fan_min[i] /= 2)); | ||
374 | } | ||
375 | } | ||
376 | |||
377 | /* Measured temperatures and limits */ | ||
378 | data->temp1 = w83627ehf_read_value(client, | ||
379 | W83627EHF_REG_TEMP1); | ||
380 | data->temp1_max = w83627ehf_read_value(client, | ||
381 | W83627EHF_REG_TEMP1_OVER); | ||
382 | data->temp1_max_hyst = w83627ehf_read_value(client, | ||
383 | W83627EHF_REG_TEMP1_HYST); | ||
384 | for (i = 0; i < 2; i++) { | ||
385 | data->temp[i] = w83627ehf_read_value(client, | ||
386 | W83627EHF_REG_TEMP[i]); | ||
387 | data->temp_max[i] = w83627ehf_read_value(client, | ||
388 | W83627EHF_REG_TEMP_OVER[i]); | ||
389 | data->temp_max_hyst[i] = w83627ehf_read_value(client, | ||
390 | W83627EHF_REG_TEMP_HYST[i]); | ||
391 | } | ||
392 | |||
393 | data->last_updated = jiffies; | ||
394 | data->valid = 1; | ||
395 | } | ||
396 | |||
397 | up(&data->update_lock); | ||
398 | return data; | ||
399 | } | ||
400 | |||
401 | /* | ||
402 | * Sysfs callback functions | ||
403 | */ | ||
404 | |||
405 | #define show_fan_reg(reg) \ | ||
406 | static ssize_t \ | ||
407 | show_##reg(struct device *dev, char *buf, int nr) \ | ||
408 | { \ | ||
409 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
410 | return sprintf(buf, "%d\n", \ | ||
411 | fan_from_reg(data->reg[nr], \ | ||
412 | div_from_reg(data->fan_div[nr]))); \ | ||
413 | } | ||
414 | show_fan_reg(fan); | ||
415 | show_fan_reg(fan_min); | ||
416 | |||
417 | static ssize_t | ||
418 | show_fan_div(struct device *dev, char *buf, int nr) | ||
419 | { | ||
420 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | ||
421 | return sprintf(buf, "%u\n", | ||
422 | div_from_reg(data->fan_div[nr])); | ||
423 | } | ||
424 | |||
425 | static ssize_t | ||
426 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | ||
427 | { | ||
428 | struct i2c_client *client = to_i2c_client(dev); | ||
429 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
430 | unsigned int val = simple_strtoul(buf, NULL, 10); | ||
431 | unsigned int reg; | ||
432 | u8 new_div; | ||
433 | |||
434 | down(&data->update_lock); | ||
435 | if (!val) { | ||
436 | /* No min limit, alarm disabled */ | ||
437 | data->fan_min[nr] = 255; | ||
438 | new_div = data->fan_div[nr]; /* No change */ | ||
439 | dev_info(dev, "fan%u low limit and alarm disabled\n", nr + 1); | ||
440 | } else if ((reg = 1350000U / val) >= 128 * 255) { | ||
441 | /* Speed below this value cannot possibly be represented, | ||
442 | even with the highest divider (128) */ | ||
443 | data->fan_min[nr] = 254; | ||
444 | new_div = 7; /* 128 == (1 << 7) */ | ||
445 | dev_warn(dev, "fan%u low limit %u below minimum %u, set to " | ||
446 | "minimum\n", nr + 1, val, fan_from_reg(254, 128)); | ||
447 | } else if (!reg) { | ||
448 | /* Speed above this value cannot possibly be represented, | ||
449 | even with the lowest divider (1) */ | ||
450 | data->fan_min[nr] = 1; | ||
451 | new_div = 0; /* 1 == (1 << 0) */ | ||
452 | dev_warn(dev, "fan%u low limit %u above maximum %u, set to " | ||
453 | "maximum\n", nr + 1, val, fan_from_reg(1, 1)); | ||
454 | } else { | ||
455 | /* Automatically pick the best divider, i.e. the one such | ||
456 | that the min limit will correspond to a register value | ||
457 | in the 96..192 range */ | ||
458 | new_div = 0; | ||
459 | while (reg > 192 && new_div < 7) { | ||
460 | reg >>= 1; | ||
461 | new_div++; | ||
462 | } | ||
463 | data->fan_min[nr] = reg; | ||
464 | } | ||
465 | |||
466 | /* Write both the fan clock divider (if it changed) and the new | ||
467 | fan min (unconditionally) */ | ||
468 | if (new_div != data->fan_div[nr]) { | ||
469 | if (new_div > data->fan_div[nr]) | ||
470 | data->fan[nr] >>= (data->fan_div[nr] - new_div); | ||
471 | else | ||
472 | data->fan[nr] <<= (new_div - data->fan_div[nr]); | ||
473 | |||
474 | dev_dbg(dev, "fan%u clock divider changed from %u to %u\n", | ||
475 | nr + 1, div_from_reg(data->fan_div[nr]), | ||
476 | div_from_reg(new_div)); | ||
477 | data->fan_div[nr] = new_div; | ||
478 | w83627ehf_write_fan_div(client, nr); | ||
479 | } | ||
480 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | ||
481 | data->fan_min[nr]); | ||
482 | up(&data->update_lock); | ||
483 | |||
484 | return count; | ||
485 | } | ||
486 | |||
487 | #define sysfs_fan_offset(offset) \ | ||
488 | static ssize_t \ | ||
489 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | ||
490 | char *buf) \ | ||
491 | { \ | ||
492 | return show_fan(dev, buf, offset-1); \ | ||
493 | } \ | ||
494 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
495 | show_reg_fan_##offset, NULL); | ||
496 | |||
497 | #define sysfs_fan_min_offset(offset) \ | ||
498 | static ssize_t \ | ||
499 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | ||
500 | char *buf) \ | ||
501 | { \ | ||
502 | return show_fan_min(dev, buf, offset-1); \ | ||
503 | } \ | ||
504 | static ssize_t \ | ||
505 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | ||
506 | const char *buf, size_t count) \ | ||
507 | { \ | ||
508 | return store_fan_min(dev, buf, count, offset-1); \ | ||
509 | } \ | ||
510 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
511 | show_reg_fan##offset##_min, \ | ||
512 | store_reg_fan##offset##_min); | ||
513 | |||
514 | #define sysfs_fan_div_offset(offset) \ | ||
515 | static ssize_t \ | ||
516 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | ||
517 | char *buf) \ | ||
518 | { \ | ||
519 | return show_fan_div(dev, buf, offset - 1); \ | ||
520 | } \ | ||
521 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
522 | show_reg_fan##offset##_div, NULL); | ||
523 | |||
524 | sysfs_fan_offset(1); | ||
525 | sysfs_fan_min_offset(1); | ||
526 | sysfs_fan_div_offset(1); | ||
527 | sysfs_fan_offset(2); | ||
528 | sysfs_fan_min_offset(2); | ||
529 | sysfs_fan_div_offset(2); | ||
530 | sysfs_fan_offset(3); | ||
531 | sysfs_fan_min_offset(3); | ||
532 | sysfs_fan_div_offset(3); | ||
533 | sysfs_fan_offset(4); | ||
534 | sysfs_fan_min_offset(4); | ||
535 | sysfs_fan_div_offset(4); | ||
536 | sysfs_fan_offset(5); | ||
537 | sysfs_fan_min_offset(5); | ||
538 | sysfs_fan_div_offset(5); | ||
539 | |||
540 | #define show_temp1_reg(reg) \ | ||
541 | static ssize_t \ | ||
542 | show_##reg(struct device *dev, struct device_attribute *attr, \ | ||
543 | char *buf) \ | ||
544 | { \ | ||
545 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
546 | return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \ | ||
547 | } | ||
548 | show_temp1_reg(temp1); | ||
549 | show_temp1_reg(temp1_max); | ||
550 | show_temp1_reg(temp1_max_hyst); | ||
551 | |||
552 | #define store_temp1_reg(REG, reg) \ | ||
553 | static ssize_t \ | ||
554 | store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | ||
555 | const char *buf, size_t count) \ | ||
556 | { \ | ||
557 | struct i2c_client *client = to_i2c_client(dev); \ | ||
558 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | ||
559 | u32 val = simple_strtoul(buf, NULL, 10); \ | ||
560 | \ | ||
561 | down(&data->update_lock); \ | ||
562 | data->temp1_##reg = temp1_to_reg(val); \ | ||
563 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | ||
564 | data->temp1_##reg); \ | ||
565 | up(&data->update_lock); \ | ||
566 | return count; \ | ||
567 | } | ||
568 | store_temp1_reg(OVER, max); | ||
569 | store_temp1_reg(HYST, max_hyst); | ||
570 | |||
571 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
572 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
573 | show_temp1_max, store_temp1_max); | ||
574 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
575 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
576 | |||
577 | #define show_temp_reg(reg) \ | ||
578 | static ssize_t \ | ||
579 | show_##reg (struct device *dev, char *buf, int nr) \ | ||
580 | { \ | ||
581 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
582 | return sprintf(buf, "%d\n", \ | ||
583 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | ||
584 | } | ||
585 | show_temp_reg(temp); | ||
586 | show_temp_reg(temp_max); | ||
587 | show_temp_reg(temp_max_hyst); | ||
588 | |||
589 | #define store_temp_reg(REG, reg) \ | ||
590 | static ssize_t \ | ||
591 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | ||
592 | { \ | ||
593 | struct i2c_client *client = to_i2c_client(dev); \ | ||
594 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | ||
595 | u32 val = simple_strtoul(buf, NULL, 10); \ | ||
596 | \ | ||
597 | down(&data->update_lock); \ | ||
598 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | ||
599 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | ||
600 | data->reg[nr]); \ | ||
601 | up(&data->update_lock); \ | ||
602 | return count; \ | ||
603 | } | ||
604 | store_temp_reg(OVER, temp_max); | ||
605 | store_temp_reg(HYST, temp_max_hyst); | ||
606 | |||
607 | #define sysfs_temp_offset(offset) \ | ||
608 | static ssize_t \ | ||
609 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | ||
610 | char *buf) \ | ||
611 | { \ | ||
612 | return show_temp(dev, buf, offset - 2); \ | ||
613 | } \ | ||
614 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
615 | show_reg_temp##offset, NULL); | ||
616 | |||
617 | #define sysfs_temp_reg_offset(reg, offset) \ | ||
618 | static ssize_t \ | ||
619 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
620 | char *buf) \ | ||
621 | { \ | ||
622 | return show_temp_##reg(dev, buf, offset - 2); \ | ||
623 | } \ | ||
624 | static ssize_t \ | ||
625 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
626 | const char *buf, size_t count) \ | ||
627 | { \ | ||
628 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
629 | } \ | ||
630 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
631 | show_reg_temp##offset##_##reg, \ | ||
632 | store_reg_temp##offset##_##reg); | ||
633 | |||
634 | sysfs_temp_offset(2); | ||
635 | sysfs_temp_reg_offset(max, 2); | ||
636 | sysfs_temp_reg_offset(max_hyst, 2); | ||
637 | sysfs_temp_offset(3); | ||
638 | sysfs_temp_reg_offset(max, 3); | ||
639 | sysfs_temp_reg_offset(max_hyst, 3); | ||
640 | |||
641 | /* | ||
642 | * Driver and client management | ||
643 | */ | ||
644 | |||
645 | static struct i2c_driver w83627ehf_driver; | ||
646 | |||
647 | static void w83627ehf_init_client(struct i2c_client *client) | ||
648 | { | ||
649 | int i; | ||
650 | u8 tmp; | ||
651 | |||
652 | /* Start monitoring is needed */ | ||
653 | tmp = w83627ehf_read_value(client, W83627EHF_REG_CONFIG); | ||
654 | if (!(tmp & 0x01)) | ||
655 | w83627ehf_write_value(client, W83627EHF_REG_CONFIG, | ||
656 | tmp | 0x01); | ||
657 | |||
658 | /* Enable temp2 and temp3 if needed */ | ||
659 | for (i = 0; i < 2; i++) { | ||
660 | tmp = w83627ehf_read_value(client, | ||
661 | W83627EHF_REG_TEMP_CONFIG[i]); | ||
662 | if (tmp & 0x01) | ||
663 | w83627ehf_write_value(client, | ||
664 | W83627EHF_REG_TEMP_CONFIG[i], | ||
665 | tmp & 0xfe); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) | ||
670 | { | ||
671 | struct i2c_client *client; | ||
672 | struct w83627ehf_data *data; | ||
673 | int i, err = 0; | ||
674 | |||
675 | if (!i2c_is_isa_adapter(adapter)) | ||
676 | return 0; | ||
677 | |||
678 | if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { | ||
679 | err = -EBUSY; | ||
680 | goto exit; | ||
681 | } | ||
682 | |||
683 | if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { | ||
684 | err = -ENOMEM; | ||
685 | goto exit_release; | ||
686 | } | ||
687 | memset(data, 0, sizeof(struct w83627ehf_data)); | ||
688 | |||
689 | client = &data->client; | ||
690 | i2c_set_clientdata(client, data); | ||
691 | client->addr = address; | ||
692 | init_MUTEX(&data->lock); | ||
693 | client->adapter = adapter; | ||
694 | client->driver = &w83627ehf_driver; | ||
695 | client->flags = 0; | ||
696 | |||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | ||
698 | data->valid = 0; | ||
699 | init_MUTEX(&data->update_lock); | ||
700 | |||
701 | /* Tell the i2c layer a new client has arrived */ | ||
702 | if ((err = i2c_attach_client(client))) | ||
703 | goto exit_free; | ||
704 | |||
705 | /* Initialize the chip */ | ||
706 | w83627ehf_init_client(client); | ||
707 | |||
708 | /* A few vars need to be filled upon startup */ | ||
709 | for (i = 0; i < 5; i++) | ||
710 | data->fan_min[i] = w83627ehf_read_value(client, | ||
711 | W83627EHF_REG_FAN_MIN[i]); | ||
712 | |||
713 | /* It looks like fan4 and fan5 pins can be alternatively used | ||
714 | as fan on/off switches */ | ||
715 | data->has_fan = 0x07; /* fan1, fan2 and fan3 */ | ||
716 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); | ||
717 | if (i & (1 << 2)) | ||
718 | data->has_fan |= (1 << 3); | ||
719 | if (i & (1 << 0)) | ||
720 | data->has_fan |= (1 << 4); | ||
721 | |||
722 | /* Register sysfs hooks */ | ||
723 | device_create_file(&client->dev, &dev_attr_fan1_input); | ||
724 | device_create_file(&client->dev, &dev_attr_fan1_min); | ||
725 | device_create_file(&client->dev, &dev_attr_fan1_div); | ||
726 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
727 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
728 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
729 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
730 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
731 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
732 | |||
733 | if (data->has_fan & (1 << 3)) { | ||
734 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
735 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
736 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
737 | } | ||
738 | if (data->has_fan & (1 << 4)) { | ||
739 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
740 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
741 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
742 | } | ||
743 | |||
744 | device_create_file(&client->dev, &dev_attr_temp1_input); | ||
745 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
746 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
747 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
748 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
749 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
750 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
751 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
753 | |||
754 | return 0; | ||
755 | |||
756 | exit_free: | ||
757 | kfree(data); | ||
758 | exit_release: | ||
759 | release_region(address, REGION_LENGTH); | ||
760 | exit: | ||
761 | return err; | ||
762 | } | ||
763 | |||
764 | static 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 | |||
771 | static int w83627ehf_detach_client(struct i2c_client *client) | ||
772 | { | ||
773 | int err; | ||
774 | |||
775 | if ((err = i2c_detach_client(client))) { | ||
776 | dev_err(&client->dev, "Client deregistration failed, " | ||
777 | "client not detached.\n"); | ||
778 | return err; | ||
779 | } | ||
780 | release_region(client->addr, REGION_LENGTH); | ||
781 | kfree(i2c_get_clientdata(client)); | ||
782 | |||
783 | return 0; | ||
784 | } | ||
785 | |||
786 | static struct i2c_driver w83627ehf_driver = { | ||
787 | .owner = THIS_MODULE, | ||
788 | .name = "w83627ehf", | ||
789 | .flags = I2C_DF_NOTIFY, | ||
790 | .attach_adapter = w83627ehf_attach_adapter, | ||
791 | .detach_client = w83627ehf_detach_client, | ||
792 | }; | ||
793 | |||
794 | static int __init w83627ehf_find(int sioaddr, int *address) | ||
795 | { | ||
796 | u16 val; | ||
797 | |||
798 | REG = sioaddr; | ||
799 | VAL = sioaddr + 1; | ||
800 | superio_enter(); | ||
801 | |||
802 | val = (superio_inb(SIO_REG_DEVID) << 8) | ||
803 | | superio_inb(SIO_REG_DEVID + 1); | ||
804 | if ((val & SIO_ID_MASK) != SIO_W83627EHF_ID) { | ||
805 | superio_exit(); | ||
806 | return -ENODEV; | ||
807 | } | ||
808 | |||
809 | superio_select(W83627EHF_LD_HWM); | ||
810 | val = (superio_inb(SIO_REG_ADDR) << 8) | ||
811 | | superio_inb(SIO_REG_ADDR + 1); | ||
812 | *address = val & ~(REGION_LENGTH - 1); | ||
813 | if (*address == 0) { | ||
814 | superio_exit(); | ||
815 | return -ENODEV; | ||
816 | } | ||
817 | |||
818 | /* Activate logical device if needed */ | ||
819 | val = superio_inb(SIO_REG_ENABLE); | ||
820 | if (!(val & 0x01)) | ||
821 | superio_outb(SIO_REG_ENABLE, val | 0x01); | ||
822 | |||
823 | superio_exit(); | ||
824 | return 0; | ||
825 | } | ||
826 | |||
827 | static int __init sensors_w83627ehf_init(void) | ||
828 | { | ||
829 | if (w83627ehf_find(0x2e, &normal_isa[0]) | ||
830 | && w83627ehf_find(0x4e, &normal_isa[0])) | ||
831 | return -ENODEV; | ||
832 | |||
833 | return i2c_add_driver(&w83627ehf_driver); | ||
834 | } | ||
835 | |||
836 | static void __exit sensors_w83627ehf_exit(void) | ||
837 | { | ||
838 | i2c_del_driver(&w83627ehf_driver); | ||
839 | } | ||
840 | |||
841 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | ||
842 | MODULE_DESCRIPTION("W83627EHF driver"); | ||
843 | MODULE_LICENSE("GPL"); | ||
844 | |||
845 | module_init(sensors_w83627ehf_init); | ||
846 | module_exit(sensors_w83627ehf_exit); | ||
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c index b1da5ed696d3..bd87a42e068a 100644 --- a/drivers/i2c/chips/w83627hf.c +++ b/drivers/i2c/chips/w83627hf.c | |||
@@ -264,7 +264,7 @@ static inline u8 DIV_TO_REG(long val) | |||
264 | { | 264 | { |
265 | int i; | 265 | int i; |
266 | val = SENSORS_LIMIT(val, 1, 128) >> 1; | 266 | val = SENSORS_LIMIT(val, 1, 128) >> 1; |
267 | for (i = 0; i < 6; i++) { | 267 | for (i = 0; i < 7; i++) { |
268 | if (val == 0) | 268 | if (val == 0) |
269 | break; | 269 | break; |
270 | val >>= 1; | 270 | val >>= 1; |
@@ -368,19 +368,19 @@ store_in_reg(MAX, max) | |||
368 | 368 | ||
369 | #define sysfs_in_offset(offset) \ | 369 | #define sysfs_in_offset(offset) \ |
370 | static ssize_t \ | 370 | static ssize_t \ |
371 | show_regs_in_##offset (struct device *dev, char *buf) \ | 371 | show_regs_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
372 | { \ | 372 | { \ |
373 | return show_in(dev, buf, offset); \ | 373 | return show_in(dev, buf, offset); \ |
374 | } \ | 374 | } \ |
375 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL); | 375 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL); |
376 | 376 | ||
377 | #define sysfs_in_reg_offset(reg, offset) \ | 377 | #define sysfs_in_reg_offset(reg, offset) \ |
378 | static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \ | 378 | static ssize_t show_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
379 | { \ | 379 | { \ |
380 | return show_in_##reg (dev, buf, offset); \ | 380 | return show_in_##reg (dev, buf, offset); \ |
381 | } \ | 381 | } \ |
382 | static ssize_t \ | 382 | static ssize_t \ |
383 | store_regs_in_##reg##offset (struct device *dev, \ | 383 | store_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, \ |
384 | const char *buf, size_t count) \ | 384 | const char *buf, size_t count) \ |
385 | { \ | 385 | { \ |
386 | return store_in_##reg (dev, buf, count, offset); \ | 386 | return store_in_##reg (dev, buf, count, offset); \ |
@@ -419,25 +419,25 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg) | |||
419 | return sprintf(buf,"%ld\n", in0); | 419 | return sprintf(buf,"%ld\n", in0); |
420 | } | 420 | } |
421 | 421 | ||
422 | static ssize_t show_regs_in_0(struct device *dev, char *buf) | 422 | static ssize_t show_regs_in_0(struct device *dev, struct device_attribute *attr, char *buf) |
423 | { | 423 | { |
424 | struct w83627hf_data *data = w83627hf_update_device(dev); | 424 | struct w83627hf_data *data = w83627hf_update_device(dev); |
425 | return show_in_0(data, buf, data->in[0]); | 425 | return show_in_0(data, buf, data->in[0]); |
426 | } | 426 | } |
427 | 427 | ||
428 | static ssize_t show_regs_in_min0(struct device *dev, char *buf) | 428 | static ssize_t show_regs_in_min0(struct device *dev, struct device_attribute *attr, char *buf) |
429 | { | 429 | { |
430 | struct w83627hf_data *data = w83627hf_update_device(dev); | 430 | struct w83627hf_data *data = w83627hf_update_device(dev); |
431 | return show_in_0(data, buf, data->in_min[0]); | 431 | return show_in_0(data, buf, data->in_min[0]); |
432 | } | 432 | } |
433 | 433 | ||
434 | static ssize_t show_regs_in_max0(struct device *dev, char *buf) | 434 | static ssize_t show_regs_in_max0(struct device *dev, struct device_attribute *attr, char *buf) |
435 | { | 435 | { |
436 | struct w83627hf_data *data = w83627hf_update_device(dev); | 436 | struct w83627hf_data *data = w83627hf_update_device(dev); |
437 | return show_in_0(data, buf, data->in_max[0]); | 437 | return show_in_0(data, buf, data->in_max[0]); |
438 | } | 438 | } |
439 | 439 | ||
440 | static ssize_t store_regs_in_min0(struct device *dev, | 440 | static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *attr, |
441 | const char *buf, size_t count) | 441 | const char *buf, size_t count) |
442 | { | 442 | { |
443 | struct i2c_client *client = to_i2c_client(dev); | 443 | struct i2c_client *client = to_i2c_client(dev); |
@@ -462,7 +462,7 @@ static ssize_t store_regs_in_min0(struct device *dev, | |||
462 | return count; | 462 | return count; |
463 | } | 463 | } |
464 | 464 | ||
465 | static ssize_t store_regs_in_max0(struct device *dev, | 465 | static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *attr, |
466 | const char *buf, size_t count) | 466 | const char *buf, size_t count) |
467 | { | 467 | { |
468 | struct i2c_client *client = to_i2c_client(dev); | 468 | struct i2c_client *client = to_i2c_client(dev); |
@@ -531,19 +531,19 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
531 | } | 531 | } |
532 | 532 | ||
533 | #define sysfs_fan_offset(offset) \ | 533 | #define sysfs_fan_offset(offset) \ |
534 | static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \ | 534 | static ssize_t show_regs_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
535 | { \ | 535 | { \ |
536 | return show_fan(dev, buf, offset); \ | 536 | return show_fan(dev, buf, offset); \ |
537 | } \ | 537 | } \ |
538 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL); | 538 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL); |
539 | 539 | ||
540 | #define sysfs_fan_min_offset(offset) \ | 540 | #define sysfs_fan_min_offset(offset) \ |
541 | static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \ | 541 | static ssize_t show_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
542 | { \ | 542 | { \ |
543 | return show_fan_min(dev, buf, offset); \ | 543 | return show_fan_min(dev, buf, offset); \ |
544 | } \ | 544 | } \ |
545 | static ssize_t \ | 545 | static ssize_t \ |
546 | store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \ | 546 | store_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
547 | { \ | 547 | { \ |
548 | return store_fan_min(dev, buf, count, offset); \ | 548 | return store_fan_min(dev, buf, count, offset); \ |
549 | } \ | 549 | } \ |
@@ -608,19 +608,19 @@ store_temp_reg(HYST, max_hyst); | |||
608 | 608 | ||
609 | #define sysfs_temp_offset(offset) \ | 609 | #define sysfs_temp_offset(offset) \ |
610 | static ssize_t \ | 610 | static ssize_t \ |
611 | show_regs_temp_##offset (struct device *dev, char *buf) \ | 611 | show_regs_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
612 | { \ | 612 | { \ |
613 | return show_temp(dev, buf, offset); \ | 613 | return show_temp(dev, buf, offset); \ |
614 | } \ | 614 | } \ |
615 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL); | 615 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL); |
616 | 616 | ||
617 | #define sysfs_temp_reg_offset(reg, offset) \ | 617 | #define sysfs_temp_reg_offset(reg, offset) \ |
618 | static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \ | 618 | static ssize_t show_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
619 | { \ | 619 | { \ |
620 | return show_temp_##reg (dev, buf, offset); \ | 620 | return show_temp_##reg (dev, buf, offset); \ |
621 | } \ | 621 | } \ |
622 | static ssize_t \ | 622 | static ssize_t \ |
623 | store_regs_temp_##reg##offset (struct device *dev, \ | 623 | store_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, \ |
624 | const char *buf, size_t count) \ | 624 | const char *buf, size_t count) \ |
625 | { \ | 625 | { \ |
626 | return store_temp_##reg (dev, buf, count, offset); \ | 626 | return store_temp_##reg (dev, buf, count, offset); \ |
@@ -645,7 +645,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \ | |||
645 | } while (0) | 645 | } while (0) |
646 | 646 | ||
647 | static ssize_t | 647 | static ssize_t |
648 | show_vid_reg(struct device *dev, char *buf) | 648 | show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
649 | { | 649 | { |
650 | struct w83627hf_data *data = w83627hf_update_device(dev); | 650 | struct w83627hf_data *data = w83627hf_update_device(dev); |
651 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); | 651 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); |
@@ -655,13 +655,13 @@ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | |||
655 | device_create_file(&client->dev, &dev_attr_cpu0_vid) | 655 | device_create_file(&client->dev, &dev_attr_cpu0_vid) |
656 | 656 | ||
657 | static ssize_t | 657 | static ssize_t |
658 | show_vrm_reg(struct device *dev, char *buf) | 658 | show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
659 | { | 659 | { |
660 | struct w83627hf_data *data = w83627hf_update_device(dev); | 660 | struct w83627hf_data *data = w83627hf_update_device(dev); |
661 | return sprintf(buf, "%ld\n", (long) data->vrm); | 661 | return sprintf(buf, "%ld\n", (long) data->vrm); |
662 | } | 662 | } |
663 | static ssize_t | 663 | static ssize_t |
664 | store_vrm_reg(struct device *dev, const char *buf, size_t count) | 664 | store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
665 | { | 665 | { |
666 | struct i2c_client *client = to_i2c_client(dev); | 666 | struct i2c_client *client = to_i2c_client(dev); |
667 | struct w83627hf_data *data = i2c_get_clientdata(client); | 667 | struct w83627hf_data *data = i2c_get_clientdata(client); |
@@ -677,7 +677,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | |||
677 | device_create_file(&client->dev, &dev_attr_vrm) | 677 | device_create_file(&client->dev, &dev_attr_vrm) |
678 | 678 | ||
679 | static ssize_t | 679 | static ssize_t |
680 | show_alarms_reg(struct device *dev, char *buf) | 680 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
681 | { | 681 | { |
682 | struct w83627hf_data *data = w83627hf_update_device(dev); | 682 | struct w83627hf_data *data = w83627hf_update_device(dev); |
683 | return sprintf(buf, "%ld\n", (long) data->alarms); | 683 | return sprintf(buf, "%ld\n", (long) data->alarms); |
@@ -687,7 +687,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | |||
687 | device_create_file(&client->dev, &dev_attr_alarms) | 687 | device_create_file(&client->dev, &dev_attr_alarms) |
688 | 688 | ||
689 | #define show_beep_reg(REG, reg) \ | 689 | #define show_beep_reg(REG, reg) \ |
690 | static ssize_t show_beep_##reg (struct device *dev, char *buf) \ | 690 | static ssize_t show_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \ |
691 | { \ | 691 | { \ |
692 | struct w83627hf_data *data = w83627hf_update_device(dev); \ | 692 | struct w83627hf_data *data = w83627hf_update_device(dev); \ |
693 | return sprintf(buf,"%ld\n", \ | 693 | return sprintf(buf,"%ld\n", \ |
@@ -732,12 +732,12 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
732 | } | 732 | } |
733 | 733 | ||
734 | #define sysfs_beep(REG, reg) \ | 734 | #define sysfs_beep(REG, reg) \ |
735 | static ssize_t show_regs_beep_##reg (struct device *dev, char *buf) \ | 735 | static ssize_t show_regs_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \ |
736 | { \ | 736 | { \ |
737 | return show_beep_##reg(dev, buf); \ | 737 | return show_beep_##reg(dev, attr, buf); \ |
738 | } \ | 738 | } \ |
739 | static ssize_t \ | 739 | static ssize_t \ |
740 | store_regs_beep_##reg (struct device *dev, const char *buf, size_t count) \ | 740 | store_regs_beep_##reg (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
741 | { \ | 741 | { \ |
742 | return store_beep_reg(dev, buf, count, BEEP_##REG); \ | 742 | return store_beep_reg(dev, buf, count, BEEP_##REG); \ |
743 | } \ | 743 | } \ |
@@ -801,12 +801,12 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
801 | } | 801 | } |
802 | 802 | ||
803 | #define sysfs_fan_div(offset) \ | 803 | #define sysfs_fan_div(offset) \ |
804 | static ssize_t show_regs_fan_div_##offset (struct device *dev, char *buf) \ | 804 | static ssize_t show_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
805 | { \ | 805 | { \ |
806 | return show_fan_div_reg(dev, buf, offset); \ | 806 | return show_fan_div_reg(dev, buf, offset); \ |
807 | } \ | 807 | } \ |
808 | static ssize_t \ | 808 | static ssize_t \ |
809 | store_regs_fan_div_##offset (struct device *dev, \ | 809 | store_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, \ |
810 | const char *buf, size_t count) \ | 810 | const char *buf, size_t count) \ |
811 | { \ | 811 | { \ |
812 | return store_fan_div_reg(dev, buf, count, offset - 1); \ | 812 | return store_fan_div_reg(dev, buf, count, offset - 1); \ |
@@ -861,12 +861,12 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
861 | } | 861 | } |
862 | 862 | ||
863 | #define sysfs_pwm(offset) \ | 863 | #define sysfs_pwm(offset) \ |
864 | static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \ | 864 | static ssize_t show_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
865 | { \ | 865 | { \ |
866 | return show_pwm_reg(dev, buf, offset); \ | 866 | return show_pwm_reg(dev, buf, offset); \ |
867 | } \ | 867 | } \ |
868 | static ssize_t \ | 868 | static ssize_t \ |
869 | store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \ | 869 | store_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
870 | { \ | 870 | { \ |
871 | return store_pwm_reg(dev, buf, count, offset); \ | 871 | return store_pwm_reg(dev, buf, count, offset); \ |
872 | } \ | 872 | } \ |
@@ -937,12 +937,12 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
937 | } | 937 | } |
938 | 938 | ||
939 | #define sysfs_sensor(offset) \ | 939 | #define sysfs_sensor(offset) \ |
940 | static ssize_t show_regs_sensor_##offset (struct device *dev, char *buf) \ | 940 | static ssize_t show_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
941 | { \ | 941 | { \ |
942 | return show_sensor_reg(dev, buf, offset); \ | 942 | return show_sensor_reg(dev, buf, offset); \ |
943 | } \ | 943 | } \ |
944 | static ssize_t \ | 944 | static ssize_t \ |
945 | store_regs_sensor_##offset (struct device *dev, const char *buf, size_t count) \ | 945 | store_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
946 | { \ | 946 | { \ |
947 | return store_sensor_reg(dev, buf, count, offset); \ | 947 | return store_sensor_reg(dev, buf, count, offset); \ |
948 | } \ | 948 | } \ |
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c index 4954e465c419..0bb131ce09eb 100644 --- a/drivers/i2c/chips/w83781d.c +++ b/drivers/i2c/chips/w83781d.c | |||
@@ -28,14 +28,11 @@ | |||
28 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no | 28 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no |
29 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes | 29 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes |
30 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) | 30 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) |
31 | w83627thf 9 3 2 3 0x90 0x5ca3 no yes(LPC) | ||
32 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes | 31 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes |
33 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no | 32 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no |
34 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | ||
35 | 33 | ||
36 | */ | 34 | */ |
37 | 35 | ||
38 | #include <linux/config.h> | ||
39 | #include <linux/module.h> | 36 | #include <linux/module.h> |
40 | #include <linux/init.h> | 37 | #include <linux/init.h> |
41 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
@@ -53,7 +50,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, | |||
53 | static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; | 50 | static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; |
54 | 51 | ||
55 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
56 | SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf); | 53 | SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); |
57 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 54 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
58 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 55 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
59 | 56 | ||
@@ -173,7 +170,6 @@ FAN_TO_REG(long rpm, int div) | |||
173 | : (val)) / 1000, 0, 0xff)) | 170 | : (val)) / 1000, 0, 0xff)) |
174 | #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) | 171 | #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) |
175 | 172 | ||
176 | #define ALARMS_FROM_REG(val) (val) | ||
177 | #define PWM_FROM_REG(val) (val) | 173 | #define PWM_FROM_REG(val) (val) |
178 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) | 174 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) |
179 | #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ | 175 | #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ |
@@ -193,7 +189,7 @@ DIV_TO_REG(long val, enum chips type) | |||
193 | val = SENSORS_LIMIT(val, 1, | 189 | val = SENSORS_LIMIT(val, 1, |
194 | ((type == w83781d | 190 | ((type == w83781d |
195 | || type == as99127f) ? 8 : 128)) >> 1; | 191 | || type == as99127f) ? 8 : 128)) >> 1; |
196 | for (i = 0; i < 6; i++) { | 192 | for (i = 0; i < 7; i++) { |
197 | if (val == 0) | 193 | if (val == 0) |
198 | break; | 194 | break; |
199 | val >>= 1; | 195 | val >>= 1; |
@@ -309,18 +305,18 @@ store_in_reg(MAX, max); | |||
309 | 305 | ||
310 | #define sysfs_in_offset(offset) \ | 306 | #define sysfs_in_offset(offset) \ |
311 | static ssize_t \ | 307 | static ssize_t \ |
312 | show_regs_in_##offset (struct device *dev, char *buf) \ | 308 | show_regs_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
313 | { \ | 309 | { \ |
314 | return show_in(dev, buf, offset); \ | 310 | return show_in(dev, buf, offset); \ |
315 | } \ | 311 | } \ |
316 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL); | 312 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL); |
317 | 313 | ||
318 | #define sysfs_in_reg_offset(reg, offset) \ | 314 | #define sysfs_in_reg_offset(reg, offset) \ |
319 | static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \ | 315 | static ssize_t show_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
320 | { \ | 316 | { \ |
321 | return show_in_##reg (dev, buf, offset); \ | 317 | return show_in_##reg (dev, buf, offset); \ |
322 | } \ | 318 | } \ |
323 | static ssize_t store_regs_in_##reg##offset (struct device *dev, const char *buf, size_t count) \ | 319 | static ssize_t store_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
324 | { \ | 320 | { \ |
325 | return store_in_##reg (dev, buf, count, offset); \ | 321 | return store_in_##reg (dev, buf, count, offset); \ |
326 | } \ | 322 | } \ |
@@ -378,18 +374,18 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | |||
378 | } | 374 | } |
379 | 375 | ||
380 | #define sysfs_fan_offset(offset) \ | 376 | #define sysfs_fan_offset(offset) \ |
381 | static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \ | 377 | static ssize_t show_regs_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
382 | { \ | 378 | { \ |
383 | return show_fan(dev, buf, offset); \ | 379 | return show_fan(dev, buf, offset); \ |
384 | } \ | 380 | } \ |
385 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL); | 381 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL); |
386 | 382 | ||
387 | #define sysfs_fan_min_offset(offset) \ | 383 | #define sysfs_fan_min_offset(offset) \ |
388 | static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \ | 384 | static ssize_t show_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
389 | { \ | 385 | { \ |
390 | return show_fan_min(dev, buf, offset); \ | 386 | return show_fan_min(dev, buf, offset); \ |
391 | } \ | 387 | } \ |
392 | static ssize_t store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \ | 388 | static ssize_t store_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
393 | { \ | 389 | { \ |
394 | return store_fan_min(dev, buf, count, offset); \ | 390 | return store_fan_min(dev, buf, count, offset); \ |
395 | } \ | 391 | } \ |
@@ -452,18 +448,18 @@ store_temp_reg(HYST, max_hyst); | |||
452 | 448 | ||
453 | #define sysfs_temp_offset(offset) \ | 449 | #define sysfs_temp_offset(offset) \ |
454 | static ssize_t \ | 450 | static ssize_t \ |
455 | show_regs_temp_##offset (struct device *dev, char *buf) \ | 451 | show_regs_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
456 | { \ | 452 | { \ |
457 | return show_temp(dev, buf, offset); \ | 453 | return show_temp(dev, buf, offset); \ |
458 | } \ | 454 | } \ |
459 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL); | 455 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL); |
460 | 456 | ||
461 | #define sysfs_temp_reg_offset(reg, offset) \ | 457 | #define sysfs_temp_reg_offset(reg, offset) \ |
462 | static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \ | 458 | static ssize_t show_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
463 | { \ | 459 | { \ |
464 | return show_temp_##reg (dev, buf, offset); \ | 460 | return show_temp_##reg (dev, buf, offset); \ |
465 | } \ | 461 | } \ |
466 | static ssize_t store_regs_temp_##reg##offset (struct device *dev, const char *buf, size_t count) \ | 462 | static ssize_t store_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
467 | { \ | 463 | { \ |
468 | return store_temp_##reg (dev, buf, count, offset); \ | 464 | return store_temp_##reg (dev, buf, count, offset); \ |
469 | } \ | 465 | } \ |
@@ -486,7 +482,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \ | |||
486 | } while (0) | 482 | } while (0) |
487 | 483 | ||
488 | static ssize_t | 484 | static ssize_t |
489 | show_vid_reg(struct device *dev, char *buf) | 485 | show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
490 | { | 486 | { |
491 | struct w83781d_data *data = w83781d_update_device(dev); | 487 | struct w83781d_data *data = w83781d_update_device(dev); |
492 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); | 488 | return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); |
@@ -497,14 +493,14 @@ DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | |||
497 | #define device_create_file_vid(client) \ | 493 | #define device_create_file_vid(client) \ |
498 | device_create_file(&client->dev, &dev_attr_cpu0_vid); | 494 | device_create_file(&client->dev, &dev_attr_cpu0_vid); |
499 | static ssize_t | 495 | static ssize_t |
500 | show_vrm_reg(struct device *dev, char *buf) | 496 | show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
501 | { | 497 | { |
502 | struct w83781d_data *data = w83781d_update_device(dev); | 498 | struct w83781d_data *data = w83781d_update_device(dev); |
503 | return sprintf(buf, "%ld\n", (long) data->vrm); | 499 | return sprintf(buf, "%ld\n", (long) data->vrm); |
504 | } | 500 | } |
505 | 501 | ||
506 | static ssize_t | 502 | static ssize_t |
507 | store_vrm_reg(struct device *dev, const char *buf, size_t count) | 503 | store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
508 | { | 504 | { |
509 | struct i2c_client *client = to_i2c_client(dev); | 505 | struct i2c_client *client = to_i2c_client(dev); |
510 | struct w83781d_data *data = i2c_get_clientdata(client); | 506 | struct w83781d_data *data = i2c_get_clientdata(client); |
@@ -521,23 +517,23 @@ DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | |||
521 | #define device_create_file_vrm(client) \ | 517 | #define device_create_file_vrm(client) \ |
522 | device_create_file(&client->dev, &dev_attr_vrm); | 518 | device_create_file(&client->dev, &dev_attr_vrm); |
523 | static ssize_t | 519 | static ssize_t |
524 | show_alarms_reg(struct device *dev, char *buf) | 520 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
525 | { | 521 | { |
526 | struct w83781d_data *data = w83781d_update_device(dev); | 522 | struct w83781d_data *data = w83781d_update_device(dev); |
527 | return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); | 523 | return sprintf(buf, "%u\n", data->alarms); |
528 | } | 524 | } |
529 | 525 | ||
530 | static | 526 | static |
531 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 527 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
532 | #define device_create_file_alarms(client) \ | 528 | #define device_create_file_alarms(client) \ |
533 | device_create_file(&client->dev, &dev_attr_alarms); | 529 | device_create_file(&client->dev, &dev_attr_alarms); |
534 | static ssize_t show_beep_mask (struct device *dev, char *buf) | 530 | static ssize_t show_beep_mask (struct device *dev, struct device_attribute *attr, char *buf) |
535 | { | 531 | { |
536 | struct w83781d_data *data = w83781d_update_device(dev); | 532 | struct w83781d_data *data = w83781d_update_device(dev); |
537 | return sprintf(buf, "%ld\n", | 533 | return sprintf(buf, "%ld\n", |
538 | (long)BEEP_MASK_FROM_REG(data->beep_mask, data->type)); | 534 | (long)BEEP_MASK_FROM_REG(data->beep_mask, data->type)); |
539 | } | 535 | } |
540 | static ssize_t show_beep_enable (struct device *dev, char *buf) | 536 | static ssize_t show_beep_enable (struct device *dev, struct device_attribute *attr, char *buf) |
541 | { | 537 | { |
542 | struct w83781d_data *data = w83781d_update_device(dev); | 538 | struct w83781d_data *data = w83781d_update_device(dev); |
543 | return sprintf(buf, "%ld\n", | 539 | return sprintf(buf, "%ld\n", |
@@ -583,11 +579,11 @@ store_beep_reg(struct device *dev, const char *buf, size_t count, | |||
583 | } | 579 | } |
584 | 580 | ||
585 | #define sysfs_beep(REG, reg) \ | 581 | #define sysfs_beep(REG, reg) \ |
586 | static ssize_t show_regs_beep_##reg (struct device *dev, char *buf) \ | 582 | static ssize_t show_regs_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \ |
587 | { \ | 583 | { \ |
588 | return show_beep_##reg(dev, buf); \ | 584 | return show_beep_##reg(dev, attr, buf); \ |
589 | } \ | 585 | } \ |
590 | static ssize_t store_regs_beep_##reg (struct device *dev, const char *buf, size_t count) \ | 586 | static ssize_t store_regs_beep_##reg (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
591 | { \ | 587 | { \ |
592 | return store_beep_reg(dev, buf, count, BEEP_##REG); \ | 588 | return store_beep_reg(dev, buf, count, BEEP_##REG); \ |
593 | } \ | 589 | } \ |
@@ -653,11 +649,11 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
653 | } | 649 | } |
654 | 650 | ||
655 | #define sysfs_fan_div(offset) \ | 651 | #define sysfs_fan_div(offset) \ |
656 | static ssize_t show_regs_fan_div_##offset (struct device *dev, char *buf) \ | 652 | static ssize_t show_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
657 | { \ | 653 | { \ |
658 | return show_fan_div_reg(dev, buf, offset); \ | 654 | return show_fan_div_reg(dev, buf, offset); \ |
659 | } \ | 655 | } \ |
660 | static ssize_t store_regs_fan_div_##offset (struct device *dev, const char *buf, size_t count) \ | 656 | static ssize_t store_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
661 | { \ | 657 | { \ |
662 | return store_fan_div_reg(dev, buf, count, offset - 1); \ | 658 | return store_fan_div_reg(dev, buf, count, offset - 1); \ |
663 | } \ | 659 | } \ |
@@ -737,11 +733,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
737 | } | 733 | } |
738 | 734 | ||
739 | #define sysfs_pwm(offset) \ | 735 | #define sysfs_pwm(offset) \ |
740 | static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \ | 736 | static ssize_t show_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
741 | { \ | 737 | { \ |
742 | return show_pwm_reg(dev, buf, offset); \ | 738 | return show_pwm_reg(dev, buf, offset); \ |
743 | } \ | 739 | } \ |
744 | static ssize_t store_regs_pwm_##offset (struct device *dev, \ | 740 | static ssize_t store_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, \ |
745 | const char *buf, size_t count) \ | 741 | const char *buf, size_t count) \ |
746 | { \ | 742 | { \ |
747 | return store_pwm_reg(dev, buf, count, offset); \ | 743 | return store_pwm_reg(dev, buf, count, offset); \ |
@@ -750,11 +746,11 @@ static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | |||
750 | show_regs_pwm_##offset, store_regs_pwm_##offset); | 746 | show_regs_pwm_##offset, store_regs_pwm_##offset); |
751 | 747 | ||
752 | #define sysfs_pwmenable(offset) \ | 748 | #define sysfs_pwmenable(offset) \ |
753 | static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \ | 749 | static ssize_t show_regs_pwmenable_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
754 | { \ | 750 | { \ |
755 | return show_pwmenable_reg(dev, buf, offset); \ | 751 | return show_pwmenable_reg(dev, buf, offset); \ |
756 | } \ | 752 | } \ |
757 | static ssize_t store_regs_pwmenable_##offset (struct device *dev, \ | 753 | static ssize_t store_regs_pwmenable_##offset (struct device *dev, struct device_attribute *attr, \ |
758 | const char *buf, size_t count) \ | 754 | const char *buf, size_t count) \ |
759 | { \ | 755 | { \ |
760 | return store_pwmenable_reg(dev, buf, count, offset); \ | 756 | return store_pwmenable_reg(dev, buf, count, offset); \ |
@@ -832,11 +828,11 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr) | |||
832 | } | 828 | } |
833 | 829 | ||
834 | #define sysfs_sensor(offset) \ | 830 | #define sysfs_sensor(offset) \ |
835 | static ssize_t show_regs_sensor_##offset (struct device *dev, char *buf) \ | 831 | static ssize_t show_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
836 | { \ | 832 | { \ |
837 | return show_sensor_reg(dev, buf, offset); \ | 833 | return show_sensor_reg(dev, buf, offset); \ |
838 | } \ | 834 | } \ |
839 | static ssize_t store_regs_sensor_##offset (struct device *dev, const char *buf, size_t count) \ | 835 | static ssize_t store_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
840 | { \ | 836 | { \ |
841 | return store_sensor_reg(dev, buf, count, offset); \ | 837 | return store_sensor_reg(dev, buf, count, offset); \ |
842 | } \ | 838 | } \ |
@@ -1000,13 +996,6 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1000 | err = -EINVAL; | 996 | err = -EINVAL; |
1001 | goto ERROR0; | 997 | goto ERROR0; |
1002 | } | 998 | } |
1003 | if (!is_isa && kind == w83697hf) { | ||
1004 | dev_err(&adapter->dev, | ||
1005 | "Cannot force ISA-only chip for I2C address 0x%02x.\n", | ||
1006 | address); | ||
1007 | err = -EINVAL; | ||
1008 | goto ERROR0; | ||
1009 | } | ||
1010 | 999 | ||
1011 | if (is_isa) | 1000 | if (is_isa) |
1012 | if (!request_region(address, W83781D_EXTENT, | 1001 | if (!request_region(address, W83781D_EXTENT, |
@@ -1139,12 +1128,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1139 | else if (val1 == 0x40 && vendid == winbond && !is_isa | 1128 | else if (val1 == 0x40 && vendid == winbond && !is_isa |
1140 | && address == 0x2d) | 1129 | && address == 0x2d) |
1141 | kind = w83783s; | 1130 | kind = w83783s; |
1142 | else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond) | 1131 | else if (val1 == 0x21 && vendid == winbond) |
1143 | kind = w83627hf; | 1132 | kind = w83627hf; |
1144 | else if (val1 == 0x31 && !is_isa && address >= 0x28) | 1133 | else if (val1 == 0x31 && !is_isa && address >= 0x28) |
1145 | kind = as99127f; | 1134 | kind = as99127f; |
1146 | else if (val1 == 0x60 && vendid == winbond && is_isa) | ||
1147 | kind = w83697hf; | ||
1148 | else { | 1135 | else { |
1149 | if (kind == 0) | 1136 | if (kind == 0) |
1150 | dev_warn(&new_client->dev, "Ignoring 'force' " | 1137 | dev_warn(&new_client->dev, "Ignoring 'force' " |
@@ -1163,14 +1150,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1163 | } else if (kind == w83783s) { | 1150 | } else if (kind == w83783s) { |
1164 | client_name = "w83783s"; | 1151 | client_name = "w83783s"; |
1165 | } else if (kind == w83627hf) { | 1152 | } else if (kind == w83627hf) { |
1166 | if (val1 == 0x90) | 1153 | client_name = "w83627hf"; |
1167 | client_name = "w83627thf"; | ||
1168 | else | ||
1169 | client_name = "w83627hf"; | ||
1170 | } else if (kind == as99127f) { | 1154 | } else if (kind == as99127f) { |
1171 | client_name = "as99127f"; | 1155 | client_name = "as99127f"; |
1172 | } else if (kind == w83697hf) { | ||
1173 | client_name = "w83697hf"; | ||
1174 | } | 1156 | } |
1175 | 1157 | ||
1176 | /* Fill in the remaining client fields and put into the global list */ | 1158 | /* Fill in the remaining client fields and put into the global list */ |
@@ -1208,7 +1190,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1208 | 1190 | ||
1209 | /* Register sysfs hooks */ | 1191 | /* Register sysfs hooks */ |
1210 | device_create_file_in(new_client, 0); | 1192 | device_create_file_in(new_client, 0); |
1211 | if (kind != w83783s && kind != w83697hf) | 1193 | if (kind != w83783s) |
1212 | device_create_file_in(new_client, 1); | 1194 | device_create_file_in(new_client, 1); |
1213 | device_create_file_in(new_client, 2); | 1195 | device_create_file_in(new_client, 2); |
1214 | device_create_file_in(new_client, 3); | 1196 | device_create_file_in(new_client, 3); |
@@ -1222,24 +1204,19 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1222 | 1204 | ||
1223 | device_create_file_fan(new_client, 1); | 1205 | device_create_file_fan(new_client, 1); |
1224 | device_create_file_fan(new_client, 2); | 1206 | device_create_file_fan(new_client, 2); |
1225 | if (kind != w83697hf) | 1207 | device_create_file_fan(new_client, 3); |
1226 | device_create_file_fan(new_client, 3); | ||
1227 | 1208 | ||
1228 | device_create_file_temp(new_client, 1); | 1209 | device_create_file_temp(new_client, 1); |
1229 | device_create_file_temp(new_client, 2); | 1210 | device_create_file_temp(new_client, 2); |
1230 | if (kind != w83783s && kind != w83697hf) | 1211 | if (kind != w83783s) |
1231 | device_create_file_temp(new_client, 3); | 1212 | device_create_file_temp(new_client, 3); |
1232 | 1213 | ||
1233 | if (kind != w83697hf) | 1214 | device_create_file_vid(new_client); |
1234 | device_create_file_vid(new_client); | 1215 | device_create_file_vrm(new_client); |
1235 | |||
1236 | if (kind != w83697hf) | ||
1237 | device_create_file_vrm(new_client); | ||
1238 | 1216 | ||
1239 | device_create_file_fan_div(new_client, 1); | 1217 | device_create_file_fan_div(new_client, 1); |
1240 | device_create_file_fan_div(new_client, 2); | 1218 | device_create_file_fan_div(new_client, 2); |
1241 | if (kind != w83697hf) | 1219 | device_create_file_fan_div(new_client, 3); |
1242 | device_create_file_fan_div(new_client, 3); | ||
1243 | 1220 | ||
1244 | device_create_file_alarms(new_client); | 1221 | device_create_file_alarms(new_client); |
1245 | 1222 | ||
@@ -1258,7 +1235,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1258 | if (kind != as99127f && kind != w83781d) { | 1235 | if (kind != as99127f && kind != w83781d) { |
1259 | device_create_file_sensor(new_client, 1); | 1236 | device_create_file_sensor(new_client, 1); |
1260 | device_create_file_sensor(new_client, 2); | 1237 | device_create_file_sensor(new_client, 2); |
1261 | if (kind != w83783s && kind != w83697hf) | 1238 | if (kind != w83783s) |
1262 | device_create_file_sensor(new_client, 3); | 1239 | device_create_file_sensor(new_client, 3); |
1263 | } | 1240 | } |
1264 | 1241 | ||
@@ -1481,7 +1458,7 @@ w83781d_init_client(struct i2c_client *client) | |||
1481 | else | 1458 | else |
1482 | data->sens[i - 1] = 2; | 1459 | data->sens[i - 1] = 2; |
1483 | } | 1460 | } |
1484 | if ((type == w83783s || type == w83697hf) && (i == 2)) | 1461 | if (type == w83783s && i == 2) |
1485 | break; | 1462 | break; |
1486 | } | 1463 | } |
1487 | } | 1464 | } |
@@ -1497,7 +1474,7 @@ w83781d_init_client(struct i2c_client *client) | |||
1497 | } | 1474 | } |
1498 | 1475 | ||
1499 | /* Enable temp3 */ | 1476 | /* Enable temp3 */ |
1500 | if (type != w83783s && type != w83697hf) { | 1477 | if (type != w83783s) { |
1501 | tmp = w83781d_read_value(client, | 1478 | tmp = w83781d_read_value(client, |
1502 | W83781D_REG_TEMP3_CONFIG); | 1479 | W83781D_REG_TEMP3_CONFIG); |
1503 | if (tmp & 0x01) { | 1480 | if (tmp & 0x01) { |
@@ -1538,8 +1515,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1538 | dev_dbg(dev, "Starting device update\n"); | 1515 | dev_dbg(dev, "Starting device update\n"); |
1539 | 1516 | ||
1540 | for (i = 0; i <= 8; i++) { | 1517 | for (i = 0; i <= 8; i++) { |
1541 | if ((data->type == w83783s || data->type == w83697hf) | 1518 | if (data->type == w83783s && i == 1) |
1542 | && (i == 1)) | ||
1543 | continue; /* 783S has no in1 */ | 1519 | continue; /* 783S has no in1 */ |
1544 | data->in[i] = | 1520 | data->in[i] = |
1545 | w83781d_read_value(client, W83781D_REG_IN(i)); | 1521 | w83781d_read_value(client, W83781D_REG_IN(i)); |
@@ -1547,7 +1523,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1547 | w83781d_read_value(client, W83781D_REG_IN_MIN(i)); | 1523 | w83781d_read_value(client, W83781D_REG_IN_MIN(i)); |
1548 | data->in_max[i] = | 1524 | data->in_max[i] = |
1549 | w83781d_read_value(client, W83781D_REG_IN_MAX(i)); | 1525 | w83781d_read_value(client, W83781D_REG_IN_MAX(i)); |
1550 | if ((data->type != w83782d) && (data->type != w83697hf) | 1526 | if ((data->type != w83782d) |
1551 | && (data->type != w83627hf) && (i == 6)) | 1527 | && (data->type != w83627hf) && (i == 6)) |
1552 | break; | 1528 | break; |
1553 | } | 1529 | } |
@@ -1583,7 +1559,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1583 | w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); | 1559 | w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); |
1584 | data->temp_max_hyst_add[0] = | 1560 | data->temp_max_hyst_add[0] = |
1585 | w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); | 1561 | w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); |
1586 | if (data->type != w83783s && data->type != w83697hf) { | 1562 | if (data->type != w83783s) { |
1587 | data->temp_add[1] = | 1563 | data->temp_add[1] = |
1588 | w83781d_read_value(client, W83781D_REG_TEMP(3)); | 1564 | w83781d_read_value(client, W83781D_REG_TEMP(3)); |
1589 | data->temp_max_add[1] = | 1565 | data->temp_max_add[1] = |
@@ -1594,26 +1570,18 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1594 | W83781D_REG_TEMP_HYST(3)); | 1570 | W83781D_REG_TEMP_HYST(3)); |
1595 | } | 1571 | } |
1596 | i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); | 1572 | i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); |
1597 | if (data->type != w83697hf) { | 1573 | data->vid = i & 0x0f; |
1598 | data->vid = i & 0x0f; | 1574 | data->vid |= (w83781d_read_value(client, |
1599 | data->vid |= | 1575 | W83781D_REG_CHIPID) & 0x01) << 4; |
1600 | (w83781d_read_value(client, W83781D_REG_CHIPID) & | ||
1601 | 0x01) | ||
1602 | << 4; | ||
1603 | } | ||
1604 | data->fan_div[0] = (i >> 4) & 0x03; | 1576 | data->fan_div[0] = (i >> 4) & 0x03; |
1605 | data->fan_div[1] = (i >> 6) & 0x03; | 1577 | data->fan_div[1] = (i >> 6) & 0x03; |
1606 | if (data->type != w83697hf) { | 1578 | data->fan_div[2] = (w83781d_read_value(client, |
1607 | data->fan_div[2] = (w83781d_read_value(client, | 1579 | W83781D_REG_PIN) >> 6) & 0x03; |
1608 | W83781D_REG_PIN) | ||
1609 | >> 6) & 0x03; | ||
1610 | } | ||
1611 | if ((data->type != w83781d) && (data->type != as99127f)) { | 1580 | if ((data->type != w83781d) && (data->type != as99127f)) { |
1612 | i = w83781d_read_value(client, W83781D_REG_VBAT); | 1581 | i = w83781d_read_value(client, W83781D_REG_VBAT); |
1613 | data->fan_div[0] |= (i >> 3) & 0x04; | 1582 | data->fan_div[0] |= (i >> 3) & 0x04; |
1614 | data->fan_div[1] |= (i >> 4) & 0x04; | 1583 | data->fan_div[1] |= (i >> 4) & 0x04; |
1615 | if (data->type != w83697hf) | 1584 | data->fan_div[2] |= (i >> 5) & 0x04; |
1616 | data->fan_div[2] |= (i >> 5) & 0x04; | ||
1617 | } | 1585 | } |
1618 | data->alarms = | 1586 | data->alarms = |
1619 | w83781d_read_value(client, | 1587 | w83781d_read_value(client, |
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c index 59bbc5881fa6..4469d52aba4c 100644 --- a/drivers/i2c/chips/w83l785ts.c +++ b/drivers/i2c/chips/w83l785ts.c | |||
@@ -30,7 +30,6 @@ | |||
30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/config.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
@@ -118,13 +117,13 @@ struct w83l785ts_data { | |||
118 | * Sysfs stuff | 117 | * Sysfs stuff |
119 | */ | 118 | */ |
120 | 119 | ||
121 | static ssize_t show_temp(struct device *dev, char *buf) | 120 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) |
122 | { | 121 | { |
123 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | 122 | struct w83l785ts_data *data = w83l785ts_update_device(dev); |
124 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); | 123 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); |
125 | } | 124 | } |
126 | 125 | ||
127 | static ssize_t show_temp_over(struct device *dev, char *buf) | 126 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) |
128 | { | 127 | { |
129 | struct w83l785ts_data *data = w83l785ts_update_device(dev); | 128 | struct w83l785ts_data *data = w83l785ts_update_device(dev); |
130 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); | 129 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 9011627d7eb0..51ce268998cd 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -21,7 +21,6 @@ | |||
21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> | 21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> |
22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ | 22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
27 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
@@ -103,7 +102,7 @@ static struct class i2c_adapter_class = { | |||
103 | .release = &i2c_adapter_class_dev_release, | 102 | .release = &i2c_adapter_class_dev_release, |
104 | }; | 103 | }; |
105 | 104 | ||
106 | static ssize_t show_adapter_name(struct device *dev, char *buf) | 105 | static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) |
107 | { | 106 | { |
108 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); | 107 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); |
109 | return sprintf(buf, "%s\n", adap->name); | 108 | return sprintf(buf, "%s\n", adap->name); |
@@ -117,7 +116,7 @@ static void i2c_client_release(struct device *dev) | |||
117 | complete(&client->released); | 116 | complete(&client->released); |
118 | } | 117 | } |
119 | 118 | ||
120 | static ssize_t show_client_name(struct device *dev, char *buf) | 119 | static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf) |
121 | { | 120 | { |
122 | struct i2c_client *client = to_i2c_client(dev); | 121 | struct i2c_client *client = to_i2c_client(dev); |
123 | return sprintf(buf, "%s\n", client->name); | 122 | return sprintf(buf, "%s\n", client->name); |
@@ -239,7 +238,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
239 | } | 238 | } |
240 | 239 | ||
241 | /* detach any active clients. This must be done first, because | 240 | /* detach any active clients. This must be done first, because |
242 | * it can fail; in which case we give upp. */ | 241 | * it can fail; in which case we give up. */ |
243 | list_for_each_safe(item, _n, &adap->clients) { | 242 | list_for_each_safe(item, _n, &adap->clients) { |
244 | client = list_entry(item, struct i2c_client, list); | 243 | client = list_entry(item, struct i2c_client, list); |
245 | 244 | ||
@@ -612,27 +611,16 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count) | |||
612 | struct i2c_adapter *adap=client->adapter; | 611 | struct i2c_adapter *adap=client->adapter; |
613 | struct i2c_msg msg; | 612 | struct i2c_msg msg; |
614 | 613 | ||
615 | if (client->adapter->algo->master_xfer) { | 614 | msg.addr = client->addr; |
616 | msg.addr = client->addr; | 615 | msg.flags = client->flags & I2C_M_TEN; |
617 | msg.flags = client->flags & I2C_M_TEN; | 616 | msg.len = count; |
618 | msg.len = count; | 617 | msg.buf = (char *)buf; |
619 | msg.buf = (char *)buf; | ||
620 | 618 | ||
621 | dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n", | 619 | ret = i2c_transfer(adap, &msg, 1); |
622 | count); | ||
623 | |||
624 | down(&adap->bus_lock); | ||
625 | ret = adap->algo->master_xfer(adap,&msg,1); | ||
626 | up(&adap->bus_lock); | ||
627 | 620 | ||
628 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes | 621 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes |
629 | * transmitted, else error code. | 622 | transmitted, else error code. */ |
630 | */ | 623 | return (ret == 1) ? count : ret; |
631 | return (ret == 1 )? count : ret; | ||
632 | } else { | ||
633 | dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); | ||
634 | return -ENOSYS; | ||
635 | } | ||
636 | } | 624 | } |
637 | 625 | ||
638 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | 626 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) |
@@ -640,31 +628,18 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | |||
640 | struct i2c_adapter *adap=client->adapter; | 628 | struct i2c_adapter *adap=client->adapter; |
641 | struct i2c_msg msg; | 629 | struct i2c_msg msg; |
642 | int ret; | 630 | int ret; |
643 | if (client->adapter->algo->master_xfer) { | 631 | |
644 | msg.addr = client->addr; | 632 | msg.addr = client->addr; |
645 | msg.flags = client->flags & I2C_M_TEN; | 633 | msg.flags = client->flags & I2C_M_TEN; |
646 | msg.flags |= I2C_M_RD; | 634 | msg.flags |= I2C_M_RD; |
647 | msg.len = count; | 635 | msg.len = count; |
648 | msg.buf = buf; | 636 | msg.buf = buf; |
649 | 637 | ||
650 | dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n", | 638 | ret = i2c_transfer(adap, &msg, 1); |
651 | count); | 639 | |
652 | 640 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes | |
653 | down(&adap->bus_lock); | 641 | transmitted, else error code. */ |
654 | ret = adap->algo->master_xfer(adap,&msg,1); | 642 | return (ret == 1) ? count : ret; |
655 | up(&adap->bus_lock); | ||
656 | |||
657 | dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n", | ||
658 | ret, count, client->addr); | ||
659 | |||
660 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes | ||
661 | * transmitted, else error code. | ||
662 | */ | ||
663 | return (ret == 1 )? count : ret; | ||
664 | } else { | ||
665 | dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); | ||
666 | return -ENOSYS; | ||
667 | } | ||
668 | } | 643 | } |
669 | 644 | ||
670 | 645 | ||
@@ -742,18 +717,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
742 | found = 1; | 717 | found = 1; |
743 | } | 718 | } |
744 | } | 719 | } |
745 | for (i = 0; | ||
746 | !found && (address_data->ignore_range[i] != I2C_CLIENT_END); | ||
747 | i += 3) { | ||
748 | if (((adap_id == address_data->ignore_range[i]) || | ||
749 | ((address_data->ignore_range[i]==ANY_I2C_BUS))) && | ||
750 | (addr >= address_data->ignore_range[i+1]) && | ||
751 | (addr <= address_data->ignore_range[i+2])) { | ||
752 | dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, " | ||
753 | "addr %04x\n", adap_id,addr); | ||
754 | found = 1; | ||
755 | } | ||
756 | } | ||
757 | if (found) | 720 | if (found) |
758 | continue; | 721 | continue; |
759 | 722 | ||
@@ -770,17 +733,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
770 | } | 733 | } |
771 | 734 | ||
772 | for (i = 0; | 735 | for (i = 0; |
773 | !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); | ||
774 | i += 2) { | ||
775 | if ((addr >= address_data->normal_i2c_range[i]) && | ||
776 | (addr <= address_data->normal_i2c_range[i+1])) { | ||
777 | found = 1; | ||
778 | dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, " | ||
779 | "addr %04x\n", adap_id,addr); | ||
780 | } | ||
781 | } | ||
782 | |||
783 | for (i = 0; | ||
784 | !found && (address_data->probe[i] != I2C_CLIENT_END); | 736 | !found && (address_data->probe[i] != I2C_CLIENT_END); |
785 | i += 2) { | 737 | i += 2) { |
786 | if (((adap_id == address_data->probe[i]) || | 738 | if (((adap_id == address_data->probe[i]) || |
@@ -791,18 +743,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
791 | "addr %04x\n", adap_id,addr); | 743 | "addr %04x\n", adap_id,addr); |
792 | } | 744 | } |
793 | } | 745 | } |
794 | for (i = 0; | ||
795 | !found && (address_data->probe_range[i] != I2C_CLIENT_END); | ||
796 | i += 3) { | ||
797 | if (((adap_id == address_data->probe_range[i]) || | ||
798 | (address_data->probe_range[i] == ANY_I2C_BUS)) && | ||
799 | (addr >= address_data->probe_range[i+1]) && | ||
800 | (addr <= address_data->probe_range[i+2])) { | ||
801 | found = 1; | ||
802 | dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, " | ||
803 | "addr %04x\n", adap_id,addr); | ||
804 | } | ||
805 | } | ||
806 | if (!found) | 746 | if (!found) |
807 | continue; | 747 | continue; |
808 | 748 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 86c4d0149e82..bc5d557e5dd9 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -29,7 +29,6 @@ | |||
29 | /* The devfs code is contributed by Philipp Matthias Hahn | 29 | /* The devfs code is contributed by Philipp Matthias Hahn |
30 | <pmhahn@titan.lahn.de> */ | 30 | <pmhahn@titan.lahn.de> */ |
31 | 31 | ||
32 | #include <linux/config.h> | ||
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
@@ -214,7 +213,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
214 | sizeof(rdwr_arg))) | 213 | sizeof(rdwr_arg))) |
215 | return -EFAULT; | 214 | return -EFAULT; |
216 | 215 | ||
217 | /* Put an arbritrary limit on the number of messages that can | 216 | /* Put an arbitrary limit on the number of messages that can |
218 | * be sent at once */ | 217 | * be sent at once */ |
219 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) | 218 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
220 | return -EINVAL; | 219 | return -EINVAL; |