aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-04-29 08:03:37 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2008-07-31 23:44:03 -0400
commit1f44809ac3d7a3fc977684dc3a95fa221f33fc15 (patch)
treea2321ce812d601d2a5ecc6d409cb3158cef7fb13 /drivers/hwmon
parent9ebd3d822efeca2e73565516a80373c76ce3fa12 (diff)
hwmon: (lm85) Coding-style cleanups
Fix most style issues reported by checkpatch, including: * Trailing, missing and extra whitespace * Extra parentheses, curly braces and semi-colons * Broken indentation * Lines too long I verified that the generated code is the same before and after these changes. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh at gmail.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm85.c505
1 files changed, 255 insertions, 250 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index ee5eca1c1921..0c0fede8dde9 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1,7 +1,7 @@
1/* 1/*
2 lm85.c - Part of lm_sensors, Linux kernel modules for hardware 2 lm85.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring 3 monitoring
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
5 Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> 5 Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com>
6 Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> 6 Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de>
7 Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> 7 Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com>
@@ -51,8 +51,8 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
51#define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2) 51#define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2)
52 52
53/* Fan speeds are LSB, MSB (2 bytes) */ 53/* Fan speeds are LSB, MSB (2 bytes) */
54#define LM85_REG_FAN(nr) (0x28 + (nr) *2) 54#define LM85_REG_FAN(nr) (0x28 + (nr) * 2)
55#define LM85_REG_FAN_MIN(nr) (0x54 + (nr) *2) 55#define LM85_REG_FAN_MIN(nr) (0x54 + (nr) * 2)
56 56
57#define LM85_REG_PWM(nr) (0x30 + (nr)) 57#define LM85_REG_PWM(nr) (0x30 + (nr))
58 58
@@ -68,7 +68,7 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
68#define LM85_DEVICE_ADX 0x27 68#define LM85_DEVICE_ADX 0x27
69#define LM85_COMPANY_NATIONAL 0x01 69#define LM85_COMPANY_NATIONAL 0x01
70#define LM85_COMPANY_ANALOG_DEV 0x41 70#define LM85_COMPANY_ANALOG_DEV 0x41
71#define LM85_COMPANY_SMSC 0x5c 71#define LM85_COMPANY_SMSC 0x5c
72#define LM85_VERSTEP_VMASK 0xf0 72#define LM85_VERSTEP_VMASK 0xf0
73#define LM85_VERSTEP_GENERIC 0x60 73#define LM85_VERSTEP_GENERIC 0x60
74#define LM85_VERSTEP_LM85C 0x60 74#define LM85_VERSTEP_LM85C 0x60
@@ -115,34 +115,34 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
115 115
116#define EMC6D100_REG_ALARM3 0x7d 116#define EMC6D100_REG_ALARM3 0x7d
117/* IN5, IN6 and IN7 */ 117/* IN5, IN6 and IN7 */
118#define EMC6D100_REG_IN(nr) (0x70 + ((nr)-5)) 118#define EMC6D100_REG_IN(nr) (0x70 + ((nr) - 5))
119#define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr)-5) * 2) 119#define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr) - 5) * 2)
120#define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr)-5) * 2) 120#define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr) - 5) * 2)
121#define EMC6D102_REG_EXTEND_ADC1 0x85 121#define EMC6D102_REG_EXTEND_ADC1 0x85
122#define EMC6D102_REG_EXTEND_ADC2 0x86 122#define EMC6D102_REG_EXTEND_ADC2 0x86
123#define EMC6D102_REG_EXTEND_ADC3 0x87 123#define EMC6D102_REG_EXTEND_ADC3 0x87
124#define EMC6D102_REG_EXTEND_ADC4 0x88 124#define EMC6D102_REG_EXTEND_ADC4 0x88
125 125
126 126
127/* Conversions. Rounding and limit checking is only done on the TO_REG 127/* Conversions. Rounding and limit checking is only done on the TO_REG
128 variants. Note that you should be a bit careful with which arguments 128 variants. Note that you should be a bit careful with which arguments
129 these macros are called: arguments may be evaluated more than once. 129 these macros are called: arguments may be evaluated more than once.
130 */ 130 */
131 131
132/* IN are scaled acording to built-in resistors */ 132/* IN are scaled acording to built-in resistors */
133static int lm85_scaling[] = { /* .001 Volts */ 133static int lm85_scaling[] = { /* .001 Volts */
134 2500, 2250, 3300, 5000, 12000, 134 2500, 2250, 3300, 5000, 12000,
135 3300, 1500, 1800 /*EMC6D100*/ 135 3300, 1500, 1800 /*EMC6D100*/
136 }; 136};
137#define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from)) 137#define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from))
138 138
139#define INS_TO_REG(n,val) \ 139#define INS_TO_REG(n, val) \
140 SENSORS_LIMIT(SCALE(val,lm85_scaling[n],192),0,255) 140 SENSORS_LIMIT(SCALE(val, lm85_scaling[n], 192), 0, 255)
141 141
142#define INSEXT_FROM_REG(n,val,ext) \ 142#define INSEXT_FROM_REG(n, val, ext) \
143 SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n]) 143 SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n])
144 144
145#define INS_FROM_REG(n,val) SCALE((val), 192, lm85_scaling[n]) 145#define INS_FROM_REG(n, val) SCALE((val), 192, lm85_scaling[n])
146 146
147/* FAN speed is measured using 90kHz clock */ 147/* FAN speed is measured using 90kHz clock */
148static inline u16 FAN_TO_REG(unsigned long val) 148static inline u16 FAN_TO_REG(unsigned long val)
@@ -151,16 +151,17 @@ static inline u16 FAN_TO_REG(unsigned long val)
151 return 0xffff; 151 return 0xffff;
152 return SENSORS_LIMIT(5400000 / val, 1, 0xfffe); 152 return SENSORS_LIMIT(5400000 / val, 1, 0xfffe);
153} 153}
154#define FAN_FROM_REG(val) ((val)==0?-1:(val)==0xffff?0:5400000/(val)) 154#define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \
155 5400000 / (val))
155 156
156/* Temperature is reported in .001 degC increments */ 157/* Temperature is reported in .001 degC increments */
157#define TEMP_TO_REG(val) \ 158#define TEMP_TO_REG(val) \
158 SENSORS_LIMIT(SCALE(val,1000,1),-127,127) 159 SENSORS_LIMIT(SCALE(val, 1000, 1), -127, 127)
159#define TEMPEXT_FROM_REG(val,ext) \ 160#define TEMPEXT_FROM_REG(val, ext) \
160 SCALE(((val) << 4) + (ext), 16, 1000) 161 SCALE(((val) << 4) + (ext), 16, 1000)
161#define TEMP_FROM_REG(val) ((val) * 1000) 162#define TEMP_FROM_REG(val) ((val) * 1000)
162 163
163#define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255)) 164#define PWM_TO_REG(val) SENSORS_LIMIT(val, 0, 255)
164#define PWM_FROM_REG(val) (val) 165#define PWM_FROM_REG(val) (val)
165 166
166 167
@@ -183,17 +184,17 @@ static inline u16 FAN_TO_REG(unsigned long val)
183 */ 184 */
184 185
185/* These are the zone temperature range encodings in .001 degree C */ 186/* These are the zone temperature range encodings in .001 degree C */
186static int lm85_range_map[] = { 187static int lm85_range_map[] = {
187 2000, 2500, 3300, 4000, 5000, 6600, 188 2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000,
188 8000, 10000, 13300, 16000, 20000, 26600, 189 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
189 32000, 40000, 53300, 80000 190};
190 }; 191
191static int RANGE_TO_REG( int range ) 192static int RANGE_TO_REG(int range)
192{ 193{
193 int i; 194 int i;
194 195
195 if (range >= lm85_range_map[15]) 196 if (range >= lm85_range_map[15])
196 return 15 ; 197 return 15;
197 198
198 /* Find the closest match */ 199 /* Find the closest match */
199 for (i = 14; i >= 0; --i) { 200 for (i = 14; i >= 0; --i) {
@@ -207,7 +208,7 @@ static int RANGE_TO_REG( int range )
207 208
208 return 0; 209 return 0;
209} 210}
210#define RANGE_FROM_REG(val) (lm85_range_map[(val)&0x0f]) 211#define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f]
211 212
212/* These are the Acoustic Enhancement, or Temperature smoothing encodings 213/* These are the Acoustic Enhancement, or Temperature smoothing encodings
213 * NOTE: The enable/disable bit is INCLUDED in these encodings as the 214 * NOTE: The enable/disable bit is INCLUDED in these encodings as the
@@ -216,19 +217,21 @@ static int RANGE_TO_REG( int range )
216 */ 217 */
217/* These are the PWM frequency encodings */ 218/* These are the PWM frequency encodings */
218static int lm85_freq_map[] = { /* .1 Hz */ 219static int lm85_freq_map[] = { /* .1 Hz */
219 100, 150, 230, 300, 380, 470, 620, 940 220 100, 150, 230, 300, 380, 470, 620, 940
220 }; 221};
221static int FREQ_TO_REG( int freq ) 222
223static int FREQ_TO_REG(int freq)
222{ 224{
223 int i; 225 int i;
224 226
225 if( freq >= lm85_freq_map[7] ) { return 7 ; } 227 if (freq >= lm85_freq_map[7])
226 for( i = 0 ; i < 7 ; ++i ) 228 return 7;
227 if( freq <= lm85_freq_map[i] ) 229 for (i = 0; i < 7; ++i)
228 break ; 230 if (freq <= lm85_freq_map[i])
229 return( i & 0x07 ); 231 break;
232 return i & 0x07;
230} 233}
231#define FREQ_FROM_REG(val) (lm85_freq_map[(val)&0x07]) 234#define FREQ_FROM_REG(val) lm85_freq_map[(val) & 0x07]
232 235
233/* Since we can't use strings, I'm abusing these numbers 236/* Since we can't use strings, I'm abusing these numbers
234 * to stand in for the following meanings: 237 * to stand in for the following meanings:
@@ -243,29 +246,29 @@ static int FREQ_TO_REG( int freq )
243 */ 246 */
244 247
245static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 }; 248static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 };
246#define ZONE_FROM_REG(val) (lm85_zone_map[((val)>>5)&0x07]) 249#define ZONE_FROM_REG(val) lm85_zone_map[((val) >> 5) & 0x07]
247 250
248static int ZONE_TO_REG( int zone ) 251static int ZONE_TO_REG(int zone)
249{ 252{
250 int i; 253 int i;
251 254
252 for( i = 0 ; i <= 7 ; ++i ) 255 for (i = 0; i <= 7; ++i)
253 if( zone == lm85_zone_map[i] ) 256 if (zone == lm85_zone_map[i])
254 break ; 257 break;
255 if( i > 7 ) /* Not found. */ 258 if (i > 7) /* Not found. */
256 i = 3; /* Always 100% */ 259 i = 3; /* Always 100% */
257 return( (i & 0x07)<<5 ); 260 return (i & 0x07) << 5;
258} 261}
259 262
260#define HYST_TO_REG(val) (SENSORS_LIMIT(((val)+500)/1000,0,15)) 263#define HYST_TO_REG(val) SENSORS_LIMIT(((val) + 500) / 1000, 0, 15)
261#define HYST_FROM_REG(val) ((val)*1000) 264#define HYST_FROM_REG(val) ((val) * 1000)
262 265
263#define OFFSET_TO_REG(val) (SENSORS_LIMIT((val)/25,-127,127)) 266#define OFFSET_TO_REG(val) SENSORS_LIMIT((val) / 25, -127, 127)
264#define OFFSET_FROM_REG(val) ((val)*25) 267#define OFFSET_FROM_REG(val) ((val) * 25)
265 268
266#define PPR_MASK(fan) (0x03<<(fan *2)) 269#define PPR_MASK(fan) (0x03 << ((fan) * 2))
267#define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) 270#define PPR_TO_REG(val, fan) (SENSORS_LIMIT((val) - 1, 0, 3) << ((fan) * 2))
268#define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) 271#define PPR_FROM_REG(val, fan) ((((val) >> ((fan) * 2)) & 0x03) + 1)
269 272
270/* Chip sampling rates 273/* Chip sampling rates
271 * 274 *
@@ -292,11 +295,11 @@ struct lm85_zone {
292 u8 hyst; /* Low limit hysteresis. (0-15) */ 295 u8 hyst; /* Low limit hysteresis. (0-15) */
293 u8 range; /* Temp range, encoded */ 296 u8 range; /* Temp range, encoded */
294 s8 critical; /* "All fans ON" temp limit */ 297 s8 critical; /* "All fans ON" temp limit */
295 u8 off_desired; /* Actual "off" temperature specified. Preserved 298 u8 off_desired; /* Actual "off" temperature specified. Preserved
296 * to prevent "drift" as other autofan control 299 * to prevent "drift" as other autofan control
297 * values change. 300 * values change.
298 */ 301 */
299 u8 max_desired; /* Actual "max" temperature specified. Preserved 302 u8 max_desired; /* Actual "max" temperature specified. Preserved
300 * to prevent "drift" as other autofan control 303 * to prevent "drift" as other autofan control
301 * values change. 304 * values change.
302 */ 305 */
@@ -375,7 +378,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
375{ 378{
376 int nr = to_sensor_dev_attr(attr)->index; 379 int nr = to_sensor_dev_attr(attr)->index;
377 struct lm85_data *data = lm85_update_device(dev); 380 struct lm85_data *data = lm85_update_device(dev);
378 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr]) ); 381 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr]));
379} 382}
380 383
381static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, 384static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
@@ -383,7 +386,7 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
383{ 386{
384 int nr = to_sensor_dev_attr(attr)->index; 387 int nr = to_sensor_dev_attr(attr)->index;
385 struct lm85_data *data = lm85_update_device(dev); 388 struct lm85_data *data = lm85_update_device(dev);
386 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr]) ); 389 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr]));
387} 390}
388 391
389static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, 392static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
@@ -414,7 +417,8 @@ show_fan_offset(4);
414 417
415/* vid, vrm, alarms */ 418/* vid, vrm, alarms */
416 419
417static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) 420static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr,
421 char *buf)
418{ 422{
419 struct lm85_data *data = lm85_update_device(dev); 423 struct lm85_data *data = lm85_update_device(dev);
420 int vid; 424 int vid;
@@ -432,13 +436,15 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c
432 436
433static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 437static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
434 438
435static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 439static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr,
440 char *buf)
436{ 441{
437 struct lm85_data *data = dev_get_drvdata(dev); 442 struct lm85_data *data = dev_get_drvdata(dev);
438 return sprintf(buf, "%ld\n", (long) data->vrm); 443 return sprintf(buf, "%ld\n", (long) data->vrm);
439} 444}
440 445
441static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 446static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
447 const char *buf, size_t count)
442{ 448{
443 struct lm85_data *data = dev_get_drvdata(dev); 449 struct lm85_data *data = dev_get_drvdata(dev);
444 data->vrm = simple_strtoul(buf, NULL, 10); 450 data->vrm = simple_strtoul(buf, NULL, 10);
@@ -447,7 +453,8 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
447 453
448static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 454static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
449 455
450static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 456static ssize_t show_alarms_reg(struct device *dev, struct device_attribute
457 *attr, char *buf)
451{ 458{
452 struct lm85_data *data = lm85_update_device(dev); 459 struct lm85_data *data = lm85_update_device(dev);
453 return sprintf(buf, "%u\n", data->alarms); 460 return sprintf(buf, "%u\n", data->alarms);
@@ -488,7 +495,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
488{ 495{
489 int nr = to_sensor_dev_attr(attr)->index; 496 int nr = to_sensor_dev_attr(attr)->index;
490 struct lm85_data *data = lm85_update_device(dev); 497 struct lm85_data *data = lm85_update_device(dev);
491 return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm[nr]) ); 498 return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr]));
492} 499}
493 500
494static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, 501static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
@@ -581,17 +588,16 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,
581{ 588{
582 int nr = to_sensor_dev_attr(attr)->index; 589 int nr = to_sensor_dev_attr(attr)->index;
583 struct lm85_data *data = lm85_update_device(dev); 590 struct lm85_data *data = lm85_update_device(dev);
584 return sprintf( buf, "%d\n", INSEXT_FROM_REG(nr, 591 return sprintf(buf, "%d\n", INSEXT_FROM_REG(nr, data->in[nr],
585 data->in[nr], 592 data->in_ext[nr]));
586 data->in_ext[nr]));
587} 593}
588 594
589static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, 595static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
590 char *buf) 596 char *buf)
591{ 597{
592 int nr = to_sensor_dev_attr(attr)->index; 598 int nr = to_sensor_dev_attr(attr)->index;
593 struct lm85_data *data = lm85_update_device(dev); 599 struct lm85_data *data = lm85_update_device(dev);
594 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr]) ); 600 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr]));
595} 601}
596 602
597static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, 603static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
@@ -614,7 +620,7 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
614{ 620{
615 int nr = to_sensor_dev_attr(attr)->index; 621 int nr = to_sensor_dev_attr(attr)->index;
616 struct lm85_data *data = lm85_update_device(dev); 622 struct lm85_data *data = lm85_update_device(dev);
617 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr]) ); 623 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr]));
618} 624}
619 625
620static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, 626static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
@@ -656,8 +662,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
656{ 662{
657 int nr = to_sensor_dev_attr(attr)->index; 663 int nr = to_sensor_dev_attr(attr)->index;
658 struct lm85_data *data = lm85_update_device(dev); 664 struct lm85_data *data = lm85_update_device(dev);
659 return sprintf(buf,"%d\n", TEMPEXT_FROM_REG(data->temp[nr], 665 return sprintf(buf, "%d\n", TEMPEXT_FROM_REG(data->temp[nr],
660 data->temp_ext[nr])); 666 data->temp_ext[nr]));
661} 667}
662 668
663static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, 669static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
@@ -665,7 +671,7 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
665{ 671{
666 int nr = to_sensor_dev_attr(attr)->index; 672 int nr = to_sensor_dev_attr(attr)->index;
667 struct lm85_data *data = lm85_update_device(dev); 673 struct lm85_data *data = lm85_update_device(dev);
668 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr]) ); 674 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr]));
669} 675}
670 676
671static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, 677static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -688,7 +694,7 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
688{ 694{
689 int nr = to_sensor_dev_attr(attr)->index; 695 int nr = to_sensor_dev_attr(attr)->index;
690 struct lm85_data *data = lm85_update_device(dev); 696 struct lm85_data *data = lm85_update_device(dev);
691 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]) ); 697 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr]));
692} 698}
693 699
694static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, 700static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
@@ -697,7 +703,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
697 int nr = to_sensor_dev_attr(attr)->index; 703 int nr = to_sensor_dev_attr(attr)->index;
698 struct i2c_client *client = to_i2c_client(dev); 704 struct i2c_client *client = to_i2c_client(dev);
699 struct lm85_data *data = i2c_get_clientdata(client); 705 struct lm85_data *data = i2c_get_clientdata(client);
700 long val = simple_strtol(buf, NULL, 10); 706 long val = simple_strtol(buf, NULL, 10);
701 707
702 mutex_lock(&data->update_lock); 708 mutex_lock(&data->update_lock);
703 data->temp_max[nr] = TEMP_TO_REG(val); 709 data->temp_max[nr] = TEMP_TO_REG(val);
@@ -726,7 +732,7 @@ static ssize_t show_pwm_auto_channels(struct device *dev,
726{ 732{
727 int nr = to_sensor_dev_attr(attr)->index; 733 int nr = to_sensor_dev_attr(attr)->index;
728 struct lm85_data *data = lm85_update_device(dev); 734 struct lm85_data *data = lm85_update_device(dev);
729 return sprintf(buf,"%d\n", ZONE_FROM_REG(data->autofan[nr].config)); 735 return sprintf(buf, "%d\n", ZONE_FROM_REG(data->autofan[nr].config));
730} 736}
731 737
732static ssize_t set_pwm_auto_channels(struct device *dev, 738static ssize_t set_pwm_auto_channels(struct device *dev,
@@ -735,11 +741,11 @@ static ssize_t set_pwm_auto_channels(struct device *dev,
735 int nr = to_sensor_dev_attr(attr)->index; 741 int nr = to_sensor_dev_attr(attr)->index;
736 struct i2c_client *client = to_i2c_client(dev); 742 struct i2c_client *client = to_i2c_client(dev);
737 struct lm85_data *data = i2c_get_clientdata(client); 743 struct lm85_data *data = i2c_get_clientdata(client);
738 long val = simple_strtol(buf, NULL, 10); 744 long val = simple_strtol(buf, NULL, 10);
739 745
740 mutex_lock(&data->update_lock); 746 mutex_lock(&data->update_lock);
741 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) 747 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
742 | ZONE_TO_REG(val) ; 748 | ZONE_TO_REG(val);
743 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), 749 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
744 data->autofan[nr].config); 750 data->autofan[nr].config);
745 mutex_unlock(&data->update_lock); 751 mutex_unlock(&data->update_lock);
@@ -751,7 +757,7 @@ static ssize_t show_pwm_auto_pwm_min(struct device *dev,
751{ 757{
752 int nr = to_sensor_dev_attr(attr)->index; 758 int nr = to_sensor_dev_attr(attr)->index;
753 struct lm85_data *data = lm85_update_device(dev); 759 struct lm85_data *data = lm85_update_device(dev);
754 return sprintf(buf,"%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); 760 return sprintf(buf, "%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm));
755} 761}
756 762
757static ssize_t set_pwm_auto_pwm_min(struct device *dev, 763static ssize_t set_pwm_auto_pwm_min(struct device *dev,
@@ -775,7 +781,7 @@ static ssize_t show_pwm_auto_pwm_minctl(struct device *dev,
775{ 781{
776 int nr = to_sensor_dev_attr(attr)->index; 782 int nr = to_sensor_dev_attr(attr)->index;
777 struct lm85_data *data = lm85_update_device(dev); 783 struct lm85_data *data = lm85_update_device(dev);
778 return sprintf(buf,"%d\n", data->autofan[nr].min_off); 784 return sprintf(buf, "%d\n", data->autofan[nr].min_off);
779} 785}
780 786
781static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, 787static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,
@@ -792,8 +798,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,
792 | data->syncpwm3 798 | data->syncpwm3
793 | (data->autofan[0].min_off ? 0x20 : 0) 799 | (data->autofan[0].min_off ? 0x20 : 0)
794 | (data->autofan[1].min_off ? 0x40 : 0) 800 | (data->autofan[1].min_off ? 0x40 : 0)
795 | (data->autofan[2].min_off ? 0x80 : 0) 801 | (data->autofan[2].min_off ? 0x80 : 0));
796 );
797 mutex_unlock(&data->update_lock); 802 mutex_unlock(&data->update_lock);
798 return count; 803 return count;
799} 804}
@@ -803,7 +808,7 @@ static ssize_t show_pwm_auto_pwm_freq(struct device *dev,
803{ 808{
804 int nr = to_sensor_dev_attr(attr)->index; 809 int nr = to_sensor_dev_attr(attr)->index;
805 struct lm85_data *data = lm85_update_device(dev); 810 struct lm85_data *data = lm85_update_device(dev);
806 return sprintf(buf,"%d\n", FREQ_FROM_REG(data->autofan[nr].freq)); 811 return sprintf(buf, "%d\n", FREQ_FROM_REG(data->autofan[nr].freq));
807} 812}
808 813
809static ssize_t set_pwm_auto_pwm_freq(struct device *dev, 814static ssize_t set_pwm_auto_pwm_freq(struct device *dev,
@@ -818,8 +823,7 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev,
818 data->autofan[nr].freq = FREQ_TO_REG(val); 823 data->autofan[nr].freq = FREQ_TO_REG(val);
819 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 824 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
820 (data->zone[nr].range << 4) 825 (data->zone[nr].range << 4)
821 | data->autofan[nr].freq 826 | data->autofan[nr].freq);
822 );
823 mutex_unlock(&data->update_lock); 827 mutex_unlock(&data->update_lock);
824 return count; 828 return count;
825} 829}
@@ -849,7 +853,7 @@ static ssize_t show_temp_auto_temp_off(struct device *dev,
849{ 853{
850 int nr = to_sensor_dev_attr(attr)->index; 854 int nr = to_sensor_dev_attr(attr)->index;
851 struct lm85_data *data = lm85_update_device(dev); 855 struct lm85_data *data = lm85_update_device(dev);
852 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) - 856 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) -
853 HYST_FROM_REG(data->zone[nr].hyst)); 857 HYST_FROM_REG(data->zone[nr].hyst));
854} 858}
855 859
@@ -866,15 +870,13 @@ static ssize_t set_temp_auto_temp_off(struct device *dev,
866 min = TEMP_FROM_REG(data->zone[nr].limit); 870 min = TEMP_FROM_REG(data->zone[nr].limit);
867 data->zone[nr].off_desired = TEMP_TO_REG(val); 871 data->zone[nr].off_desired = TEMP_TO_REG(val);
868 data->zone[nr].hyst = HYST_TO_REG(min - val); 872 data->zone[nr].hyst = HYST_TO_REG(min - val);
869 if ( nr == 0 || nr == 1 ) { 873 if (nr == 0 || nr == 1) {
870 lm85_write_value(client, LM85_REG_AFAN_HYST1, 874 lm85_write_value(client, LM85_REG_AFAN_HYST1,
871 (data->zone[0].hyst << 4) 875 (data->zone[0].hyst << 4)
872 | data->zone[1].hyst 876 | data->zone[1].hyst);
873 );
874 } else { 877 } else {
875 lm85_write_value(client, LM85_REG_AFAN_HYST2, 878 lm85_write_value(client, LM85_REG_AFAN_HYST2,
876 (data->zone[2].hyst << 4) 879 (data->zone[2].hyst << 4));
877 );
878 } 880 }
879 mutex_unlock(&data->update_lock); 881 mutex_unlock(&data->update_lock);
880 return count; 882 return count;
@@ -885,7 +887,7 @@ static ssize_t show_temp_auto_temp_min(struct device *dev,
885{ 887{
886 int nr = to_sensor_dev_attr(attr)->index; 888 int nr = to_sensor_dev_attr(attr)->index;
887 struct lm85_data *data = lm85_update_device(dev); 889 struct lm85_data *data = lm85_update_device(dev);
888 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) ); 890 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit));
889} 891}
890 892
891static ssize_t set_temp_auto_temp_min(struct device *dev, 893static ssize_t set_temp_auto_temp_min(struct device *dev,
@@ -913,15 +915,13 @@ static ssize_t set_temp_auto_temp_min(struct device *dev,
913 data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG( 915 data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG(
914 data->zone[nr].limit) - TEMP_FROM_REG( 916 data->zone[nr].limit) - TEMP_FROM_REG(
915 data->zone[nr].off_desired)); 917 data->zone[nr].off_desired));
916 if ( nr == 0 || nr == 1 ) { 918 if (nr == 0 || nr == 1) {
917 lm85_write_value(client, LM85_REG_AFAN_HYST1, 919 lm85_write_value(client, LM85_REG_AFAN_HYST1,
918 (data->zone[0].hyst << 4) 920 (data->zone[0].hyst << 4)
919 | data->zone[1].hyst 921 | data->zone[1].hyst);
920 );
921 } else { 922 } else {
922 lm85_write_value(client, LM85_REG_AFAN_HYST2, 923 lm85_write_value(client, LM85_REG_AFAN_HYST2,
923 (data->zone[2].hyst << 4) 924 (data->zone[2].hyst << 4));
924 );
925 } 925 }
926 mutex_unlock(&data->update_lock); 926 mutex_unlock(&data->update_lock);
927 return count; 927 return count;
@@ -932,7 +932,7 @@ static ssize_t show_temp_auto_temp_max(struct device *dev,
932{ 932{
933 int nr = to_sensor_dev_attr(attr)->index; 933 int nr = to_sensor_dev_attr(attr)->index;
934 struct lm85_data *data = lm85_update_device(dev); 934 struct lm85_data *data = lm85_update_device(dev);
935 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) + 935 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) +
936 RANGE_FROM_REG(data->zone[nr].range)); 936 RANGE_FROM_REG(data->zone[nr].range));
937} 937}
938 938
@@ -962,11 +962,11 @@ static ssize_t show_temp_auto_temp_crit(struct device *dev,
962{ 962{
963 int nr = to_sensor_dev_attr(attr)->index; 963 int nr = to_sensor_dev_attr(attr)->index;
964 struct lm85_data *data = lm85_update_device(dev); 964 struct lm85_data *data = lm85_update_device(dev);
965 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].critical)); 965 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].critical));
966} 966}
967 967
968static ssize_t set_temp_auto_temp_crit(struct device *dev, 968static ssize_t set_temp_auto_temp_crit(struct device *dev,
969 struct device_attribute *attr,const char *buf, size_t count) 969 struct device_attribute *attr, const char *buf, size_t count)
970{ 970{
971 int nr = to_sensor_dev_attr(attr)->index; 971 int nr = to_sensor_dev_attr(attr)->index;
972 struct i2c_client *client = to_i2c_client(dev); 972 struct i2c_client *client = to_i2c_client(dev);
@@ -1130,7 +1130,7 @@ static const struct attribute_group lm85_group_in567 = {
1130static int lm85_detect(struct i2c_adapter *adapter, int address, 1130static int lm85_detect(struct i2c_adapter *adapter, int address,
1131 int kind) 1131 int kind)
1132{ 1132{
1133 int company, verstep ; 1133 int company, verstep;
1134 struct i2c_client *new_client = NULL; 1134 struct i2c_client *new_client = NULL;
1135 struct lm85_data *data; 1135 struct lm85_data *data;
1136 int err = 0; 1136 int err = 0;
@@ -1139,8 +1139,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1139 if (!i2c_check_functionality(adapter, 1139 if (!i2c_check_functionality(adapter,
1140 I2C_FUNC_SMBUS_BYTE_DATA)) { 1140 I2C_FUNC_SMBUS_BYTE_DATA)) {
1141 /* We need to be able to do byte I/O */ 1141 /* We need to be able to do byte I/O */
1142 goto ERROR0 ; 1142 goto ERROR0;
1143 }; 1143 }
1144 1144
1145 /* OK. For now, we presume we have a valid client. We now create the 1145 /* OK. For now, we presume we have a valid client. We now create the
1146 client structure, even though we cannot fill it completely yet. 1146 client structure, even though we cannot fill it completely yet.
@@ -1171,82 +1171,81 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1171 /* If auto-detecting, Determine the chip type. */ 1171 /* If auto-detecting, Determine the chip type. */
1172 if (kind <= 0) { 1172 if (kind <= 0) {
1173 dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n", 1173 dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n",
1174 i2c_adapter_id(adapter), address ); 1174 i2c_adapter_id(adapter), address);
1175 if( company == LM85_COMPANY_NATIONAL 1175 if (company == LM85_COMPANY_NATIONAL
1176 && verstep == LM85_VERSTEP_LM85C ) { 1176 && verstep == LM85_VERSTEP_LM85C) {
1177 kind = lm85c ; 1177 kind = lm85c;
1178 } else if( company == LM85_COMPANY_NATIONAL 1178 } else if (company == LM85_COMPANY_NATIONAL
1179 && verstep == LM85_VERSTEP_LM85B ) { 1179 && verstep == LM85_VERSTEP_LM85B) {
1180 kind = lm85b ; 1180 kind = lm85b;
1181 } else if( company == LM85_COMPANY_NATIONAL 1181 } else if (company == LM85_COMPANY_NATIONAL
1182 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) { 1182 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1183 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" 1183 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
1184 " Defaulting to LM85.\n", verstep); 1184 " Defaulting to LM85.\n", verstep);
1185 kind = any_chip ; 1185 kind = any_chip;
1186 } else if( company == LM85_COMPANY_ANALOG_DEV 1186 } else if (company == LM85_COMPANY_ANALOG_DEV
1187 && verstep == LM85_VERSTEP_ADM1027 ) { 1187 && verstep == LM85_VERSTEP_ADM1027) {
1188 kind = adm1027 ; 1188 kind = adm1027;
1189 } else if( company == LM85_COMPANY_ANALOG_DEV 1189 } else if (company == LM85_COMPANY_ANALOG_DEV
1190 && (verstep == LM85_VERSTEP_ADT7463 1190 && (verstep == LM85_VERSTEP_ADT7463
1191 || verstep == LM85_VERSTEP_ADT7463C) ) { 1191 || verstep == LM85_VERSTEP_ADT7463C)) {
1192 kind = adt7463 ; 1192 kind = adt7463;
1193 } else if( company == LM85_COMPANY_ANALOG_DEV 1193 } else if (company == LM85_COMPANY_ANALOG_DEV
1194 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) { 1194 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1195 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" 1195 dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
1196 " Defaulting to Generic LM85.\n", verstep ); 1196 " Defaulting to Generic LM85.\n", verstep);
1197 kind = any_chip ; 1197 kind = any_chip;
1198 } else if( company == LM85_COMPANY_SMSC 1198 } else if (company == LM85_COMPANY_SMSC
1199 && (verstep == LM85_VERSTEP_EMC6D100_A0 1199 && (verstep == LM85_VERSTEP_EMC6D100_A0
1200 || verstep == LM85_VERSTEP_EMC6D100_A1) ) { 1200 || verstep == LM85_VERSTEP_EMC6D100_A1)) {
1201 /* Unfortunately, we can't tell a '100 from a '101 1201 /* Unfortunately, we can't tell a '100 from a '101
1202 * from the registers. Since a '101 is a '100 1202 * from the registers. Since a '101 is a '100
1203 * in a package with fewer pins and therefore no 1203 * in a package with fewer pins and therefore no
1204 * 3.3V, 1.5V or 1.8V inputs, perhaps if those 1204 * 3.3V, 1.5V or 1.8V inputs, perhaps if those
1205 * inputs read 0, then it's a '101. 1205 * inputs read 0, then it's a '101.
1206 */ 1206 */
1207 kind = emc6d100 ; 1207 kind = emc6d100;
1208 } else if( company == LM85_COMPANY_SMSC 1208 } else if (company == LM85_COMPANY_SMSC
1209 && verstep == LM85_VERSTEP_EMC6D102) { 1209 && verstep == LM85_VERSTEP_EMC6D102) {
1210 kind = emc6d102 ; 1210 kind = emc6d102;
1211 } else if( company == LM85_COMPANY_SMSC 1211 } else if (company == LM85_COMPANY_SMSC
1212 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { 1212 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1213 dev_err(&adapter->dev, "lm85: Detected SMSC chip\n"); 1213 dev_err(&adapter->dev, "lm85: Detected SMSC chip\n");
1214 dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x" 1214 dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x"
1215 " Defaulting to Generic LM85.\n", verstep ); 1215 " Defaulting to Generic LM85.\n", verstep);
1216 kind = any_chip ; 1216 kind = any_chip;
1217 } else if( kind == any_chip 1217 } else if (kind == any_chip
1218 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { 1218 && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
1219 dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n"); 1219 dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n");
1220 /* Leave kind as "any_chip" */ 1220 /* Leave kind as "any_chip" */
1221 } else { 1221 } else {
1222 dev_dbg(&adapter->dev, "Autodetection failed\n"); 1222 dev_dbg(&adapter->dev, "Autodetection failed\n");
1223 /* Not an LM85 ... */ 1223 /* Not an LM85... */
1224 if( kind == any_chip ) { /* User used force=x,y */ 1224 if (kind == any_chip) { /* User used force=x,y */
1225 dev_err(&adapter->dev, "Generic LM85 Version 6 not" 1225 dev_err(&adapter->dev, "Generic LM85 Version 6 not"
1226 " found at %d,0x%02x. Try force_lm85c.\n", 1226 " found at %d,0x%02x. Try force_lm85c.\n",
1227 i2c_adapter_id(adapter), address ); 1227 i2c_adapter_id(adapter), address);
1228 } 1228 }
1229 err = 0 ; 1229 err = 0;
1230 goto ERROR1; 1230 goto ERROR1;
1231 } 1231 }
1232 } 1232 }
1233 1233
1234 /* Fill in the chip specific driver values */ 1234 /* Fill in the chip specific driver values */
1235 if ( kind == any_chip ) { 1235 if (kind == any_chip)
1236 type_name = "lm85"; 1236 type_name = "lm85";
1237 } else if ( kind == lm85b ) { 1237 else if (kind == lm85b)
1238 type_name = "lm85b"; 1238 type_name = "lm85b";
1239 } else if ( kind == lm85c ) { 1239 else if (kind == lm85c)
1240 type_name = "lm85c"; 1240 type_name = "lm85c";
1241 } else if ( kind == adm1027 ) { 1241 else if (kind == adm1027)
1242 type_name = "adm1027"; 1242 type_name = "adm1027";
1243 } else if ( kind == adt7463 ) { 1243 else if (kind == adt7463)
1244 type_name = "adt7463"; 1244 type_name = "adt7463";
1245 } else if ( kind == emc6d100){ 1245 else if (kind == emc6d100)
1246 type_name = "emc6d100"; 1246 type_name = "emc6d100";
1247 } else if ( kind == emc6d102 ) { 1247 else if (kind == emc6d102)
1248 type_name = "emc6d102"; 1248 type_name = "emc6d102";
1249 }
1250 strlcpy(new_client->name, type_name, I2C_NAME_SIZE); 1249 strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
1251 1250
1252 /* Fill in the remaining client fields */ 1251 /* Fill in the remaining client fields */
@@ -1291,16 +1290,16 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1291 return 0; 1290 return 0;
1292 1291
1293 /* Error out and cleanup code */ 1292 /* Error out and cleanup code */
1294 ERROR3: 1293 ERROR3:
1295 sysfs_remove_group(&new_client->dev.kobj, &lm85_group); 1294 sysfs_remove_group(&new_client->dev.kobj, &lm85_group);
1296 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in4); 1295 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in4);
1297 if (kind == emc6d100) 1296 if (kind == emc6d100)
1298 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in567); 1297 sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in567);
1299 ERROR2: 1298 ERROR2:
1300 i2c_detach_client(new_client); 1299 i2c_detach_client(new_client);
1301 ERROR1: 1300 ERROR1:
1302 kfree(data); 1301 kfree(data);
1303 ERROR0: 1302 ERROR0:
1304 return err; 1303 return err;
1305} 1304}
1306 1305
@@ -1323,58 +1322,60 @@ static int lm85_read_value(struct i2c_client *client, u8 reg)
1323 int res; 1322 int res;
1324 1323
1325 /* What size location is it? */ 1324 /* What size location is it? */
1326 switch( reg ) { 1325 switch (reg) {
1327 case LM85_REG_FAN(0) : /* Read WORD data */ 1326 case LM85_REG_FAN(0): /* Read WORD data */
1328 case LM85_REG_FAN(1) : 1327 case LM85_REG_FAN(1):
1329 case LM85_REG_FAN(2) : 1328 case LM85_REG_FAN(2):
1330 case LM85_REG_FAN(3) : 1329 case LM85_REG_FAN(3):
1331 case LM85_REG_FAN_MIN(0) : 1330 case LM85_REG_FAN_MIN(0):
1332 case LM85_REG_FAN_MIN(1) : 1331 case LM85_REG_FAN_MIN(1):
1333 case LM85_REG_FAN_MIN(2) : 1332 case LM85_REG_FAN_MIN(2):
1334 case LM85_REG_FAN_MIN(3) : 1333 case LM85_REG_FAN_MIN(3):
1335 case LM85_REG_ALARM1 : /* Read both bytes at once */ 1334 case LM85_REG_ALARM1: /* Read both bytes at once */
1336 res = i2c_smbus_read_byte_data(client, reg) & 0xff ; 1335 res = i2c_smbus_read_byte_data(client, reg) & 0xff;
1337 res |= i2c_smbus_read_byte_data(client, reg+1) << 8 ; 1336 res |= i2c_smbus_read_byte_data(client, reg + 1) << 8;
1338 break ; 1337 break;
1339 case ADT7463_REG_TMIN_CTL1 : /* Read WORD MSB, LSB */ 1338 case ADT7463_REG_TMIN_CTL1: /* Read WORD MSB, LSB */
1340 res = i2c_smbus_read_byte_data(client, reg) << 8 ; 1339 res = i2c_smbus_read_byte_data(client, reg) << 8;
1341 res |= i2c_smbus_read_byte_data(client, reg+1) & 0xff ; 1340 res |= i2c_smbus_read_byte_data(client, reg + 1) & 0xff;
1342 break ; 1341 break;
1343 default: /* Read BYTE data */ 1342 default: /* Read BYTE data */
1344 res = i2c_smbus_read_byte_data(client, reg); 1343 res = i2c_smbus_read_byte_data(client, reg);
1345 break ; 1344 break;
1346 } 1345 }
1347 1346
1348 return res ; 1347 return res;
1349} 1348}
1350 1349
1351static int lm85_write_value(struct i2c_client *client, u8 reg, int value) 1350static int lm85_write_value(struct i2c_client *client, u8 reg, int value)
1352{ 1351{
1353 int res ; 1352 int res;
1354 1353
1355 switch( reg ) { 1354 switch (reg) {
1356 case LM85_REG_FAN(0) : /* Write WORD data */ 1355 case LM85_REG_FAN(0): /* Write WORD data */
1357 case LM85_REG_FAN(1) : 1356 case LM85_REG_FAN(1):
1358 case LM85_REG_FAN(2) : 1357 case LM85_REG_FAN(2):
1359 case LM85_REG_FAN(3) : 1358 case LM85_REG_FAN(3):
1360 case LM85_REG_FAN_MIN(0) : 1359 case LM85_REG_FAN_MIN(0):
1361 case LM85_REG_FAN_MIN(1) : 1360 case LM85_REG_FAN_MIN(1):
1362 case LM85_REG_FAN_MIN(2) : 1361 case LM85_REG_FAN_MIN(2):
1363 case LM85_REG_FAN_MIN(3) : 1362 case LM85_REG_FAN_MIN(3):
1364 /* NOTE: ALARM is read only, so not included here */ 1363 /* NOTE: ALARM is read only, so not included here */
1365 res = i2c_smbus_write_byte_data(client, reg, value & 0xff) ; 1364 res = i2c_smbus_write_byte_data(client, reg, value & 0xff);
1366 res |= i2c_smbus_write_byte_data(client, reg+1, (value>>8) & 0xff) ; 1365 res |= i2c_smbus_write_byte_data(client, reg + 1,
1367 break ; 1366 (value >> 8) & 0xff);
1368 case ADT7463_REG_TMIN_CTL1 : /* Write WORD MSB, LSB */ 1367 break;
1369 res = i2c_smbus_write_byte_data(client, reg, (value>>8) & 0xff); 1368 case ADT7463_REG_TMIN_CTL1: /* Write WORD MSB, LSB */
1370 res |= i2c_smbus_write_byte_data(client, reg+1, value & 0xff) ; 1369 res = i2c_smbus_write_byte_data(client, reg,
1371 break ; 1370 (value >> 8) & 0xff);
1371 res |= i2c_smbus_write_byte_data(client, reg + 1, value & 0xff);
1372 break;
1372 default: /* Write BYTE data */ 1373 default: /* Write BYTE data */
1373 res = i2c_smbus_write_byte_data(client, reg, value); 1374 res = i2c_smbus_write_byte_data(client, reg, value);
1374 break ; 1375 break;
1375 } 1376 }
1376 1377
1377 return res ; 1378 return res;
1378} 1379}
1379 1380
1380static void lm85_init_client(struct i2c_client *client) 1381static void lm85_init_client(struct i2c_client *client)
@@ -1387,21 +1388,21 @@ static void lm85_init_client(struct i2c_client *client)
1387 /* Warn if part was not "READY" */ 1388 /* Warn if part was not "READY" */
1388 value = lm85_read_value(client, LM85_REG_CONFIG); 1389 value = lm85_read_value(client, LM85_REG_CONFIG);
1389 dev_dbg(&client->dev, "LM85_REG_CONFIG is: 0x%02x\n", value); 1390 dev_dbg(&client->dev, "LM85_REG_CONFIG is: 0x%02x\n", value);
1390 if( value & 0x02 ) { 1391 if (value & 0x02) {
1391 dev_err(&client->dev, "Client (%d,0x%02x) config is locked.\n", 1392 dev_err(&client->dev, "Client (%d,0x%02x) config is locked.\n",
1392 i2c_adapter_id(client->adapter), client->addr ); 1393 i2c_adapter_id(client->adapter), client->addr);
1393 }; 1394 }
1394 if( ! (value & 0x04) ) { 1395 if (!(value & 0x04)) {
1395 dev_err(&client->dev, "Client (%d,0x%02x) is not ready.\n", 1396 dev_err(&client->dev, "Client (%d,0x%02x) is not ready.\n",
1396 i2c_adapter_id(client->adapter), client->addr ); 1397 i2c_adapter_id(client->adapter), client->addr);
1397 }; 1398 }
1398 if( value & 0x10 1399 if (value & 0x10
1399 && ( data->type == adm1027 1400 && (data->type == adm1027
1400 || data->type == adt7463 ) ) { 1401 || data->type == adt7463)) {
1401 dev_err(&client->dev, "Client (%d,0x%02x) VxI mode is set. " 1402 dev_err(&client->dev, "Client (%d,0x%02x) VxI mode is set. "
1402 "Please report this to the lm85 maintainer.\n", 1403 "Please report this to the lm85 maintainer.\n",
1403 i2c_adapter_id(client->adapter), client->addr ); 1404 i2c_adapter_id(client->adapter), client->addr);
1404 }; 1405 }
1405 1406
1406 /* WE INTENTIONALLY make no changes to the limits, 1407 /* WE INTENTIONALLY make no changes to the limits,
1407 * offsets, pwms, fans and zones. If they were 1408 * offsets, pwms, fans and zones. If they were
@@ -1414,7 +1415,7 @@ static void lm85_init_client(struct i2c_client *client)
1414 /* Start monitoring */ 1415 /* Start monitoring */
1415 value = lm85_read_value(client, LM85_REG_CONFIG); 1416 value = lm85_read_value(client, LM85_REG_CONFIG);
1416 /* Try to clear LOCK, Set START, save everything else */ 1417 /* Try to clear LOCK, Set START, save everything else */
1417 value = (value & ~ 0x02) | 0x01 ; 1418 value = (value & ~0x02) | 0x01;
1418 dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value); 1419 dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value);
1419 lm85_write_value(client, LM85_REG_CONFIG, value); 1420 lm85_write_value(client, LM85_REG_CONFIG, value);
1420} 1421}
@@ -1427,28 +1428,30 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1427 1428
1428 mutex_lock(&data->update_lock); 1429 mutex_lock(&data->update_lock);
1429 1430
1430 if ( !data->valid || 1431 if (!data->valid ||
1431 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { 1432 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL)) {
1432 /* Things that change quickly */ 1433 /* Things that change quickly */
1433 dev_dbg(&client->dev, "Reading sensor values\n"); 1434 dev_dbg(&client->dev, "Reading sensor values\n");
1434 1435
1435 /* Have to read extended bits first to "freeze" the 1436 /* Have to read extended bits first to "freeze" the
1436 * more significant bits that are read later. 1437 * more significant bits that are read later.
1437 * There are 2 additional resolution bits per channel and we 1438 * There are 2 additional resolution bits per channel and we
1438 * have room for 4, so we shift them to the left. 1439 * have room for 4, so we shift them to the left.
1439 */ 1440 */
1440 if ( (data->type == adm1027) || (data->type == adt7463) ) { 1441 if (data->type == adm1027 || data->type == adt7463) {
1441 int ext1 = lm85_read_value(client, 1442 int ext1 = lm85_read_value(client,
1442 ADM1027_REG_EXTEND_ADC1); 1443 ADM1027_REG_EXTEND_ADC1);
1443 int ext2 = lm85_read_value(client, 1444 int ext2 = lm85_read_value(client,
1444 ADM1027_REG_EXTEND_ADC2); 1445 ADM1027_REG_EXTEND_ADC2);
1445 int val = (ext1 << 8) + ext2; 1446 int val = (ext1 << 8) + ext2;
1446 1447
1447 for(i = 0; i <= 4; i++) 1448 for (i = 0; i <= 4; i++)
1448 data->in_ext[i] = ((val>>(i * 2))&0x03) << 2; 1449 data->in_ext[i] =
1450 ((val >> (i * 2)) & 0x03) << 2;
1449 1451
1450 for(i = 0; i <= 2; i++) 1452 for (i = 0; i <= 2; i++)
1451 data->temp_ext[i] = (val>>((i + 4) * 2))&0x0c; 1453 data->temp_ext[i] =
1454 (val >> ((i + 4) * 2)) & 0x0c;
1452 } 1455 }
1453 1456
1454 data->vid = lm85_read_value(client, LM85_REG_VID); 1457 data->vid = lm85_read_value(client, LM85_REG_VID);
@@ -1480,21 +1483,21 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1480 1483
1481 data->alarms = lm85_read_value(client, LM85_REG_ALARM1); 1484 data->alarms = lm85_read_value(client, LM85_REG_ALARM1);
1482 1485
1483 if ( data->type == adt7463 ) { 1486 if (data->type == adt7463) {
1484 if( data->therm_total < ULONG_MAX - 256 ) { 1487 if (data->therm_total < ULONG_MAX - 256) {
1485 data->therm_total += 1488 data->therm_total +=
1486 lm85_read_value(client, ADT7463_REG_THERM ); 1489 lm85_read_value(client, ADT7463_REG_THERM);
1487 } 1490 }
1488 } else if ( data->type == emc6d100 ) { 1491 } else if (data->type == emc6d100) {
1489 /* Three more voltage sensors */ 1492 /* Three more voltage sensors */
1490 for (i = 5; i <= 7; ++i) { 1493 for (i = 5; i <= 7; ++i) {
1491 data->in[i] = 1494 data->in[i] = lm85_read_value(client,
1492 lm85_read_value(client, EMC6D100_REG_IN(i)); 1495 EMC6D100_REG_IN(i));
1493 } 1496 }
1494 /* More alarm bits */ 1497 /* More alarm bits */
1495 data->alarms |= 1498 data->alarms |= lm85_read_value(client,
1496 lm85_read_value(client, EMC6D100_REG_ALARM3) << 16; 1499 EMC6D100_REG_ALARM3) << 16;
1497 } else if (data->type == emc6d102 ) { 1500 } else if (data->type == emc6d102) {
1498 /* Have to read LSB bits after the MSB ones because 1501 /* Have to read LSB bits after the MSB ones because
1499 the reading of the MSB bits has frozen the 1502 the reading of the MSB bits has frozen the
1500 LSBs (backward from the ADM1027). 1503 LSBs (backward from the ADM1027).
@@ -1518,11 +1521,11 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1518 data->temp_ext[2] = (ext1 >> 4) & 0x0f; 1521 data->temp_ext[2] = (ext1 >> 4) & 0x0f;
1519 } 1522 }
1520 1523
1521 data->last_reading = jiffies ; 1524 data->last_reading = jiffies;
1522 }; /* last_reading */ 1525 } /* last_reading */
1523 1526
1524 if ( !data->valid || 1527 if (!data->valid ||
1525 time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL) ) { 1528 time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL)) {
1526 /* Things that don't change often */ 1529 /* Things that don't change often */
1527 dev_dbg(&client->dev, "Reading config values\n"); 1530 dev_dbg(&client->dev, "Reading config values\n");
1528 1531
@@ -1540,12 +1543,12 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1540 LM85_REG_IN_MAX(4)); 1543 LM85_REG_IN_MAX(4));
1541 } 1544 }
1542 1545
1543 if ( data->type == emc6d100 ) { 1546 if (data->type == emc6d100) {
1544 for (i = 5; i <= 7; ++i) { 1547 for (i = 5; i <= 7; ++i) {
1545 data->in_min[i] = 1548 data->in_min[i] = lm85_read_value(client,
1546 lm85_read_value(client, EMC6D100_REG_IN_MIN(i)); 1549 EMC6D100_REG_IN_MIN(i));
1547 data->in_max[i] = 1550 data->in_max[i] = lm85_read_value(client,
1548 lm85_read_value(client, EMC6D100_REG_IN_MAX(i)); 1551 EMC6D100_REG_IN_MAX(i));
1549 } 1552 }
1550 } 1553 }
1551 1554
@@ -1562,12 +1565,12 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1562 } 1565 }
1563 1566
1564 for (i = 0; i <= 2; ++i) { 1567 for (i = 0; i <= 2; ++i) {
1565 int val ; 1568 int val;
1566 data->autofan[i].config = 1569 data->autofan[i].config =
1567 lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); 1570 lm85_read_value(client, LM85_REG_AFAN_CONFIG(i));
1568 val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); 1571 val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i));
1569 data->autofan[i].freq = val & 0x07 ; 1572 data->autofan[i].freq = val & 0x07;
1570 data->zone[i].range = (val >> 4) & 0x0f ; 1573 data->zone[i].range = (val >> 4) & 0x0f;
1571 data->autofan[i].min_pwm = 1574 data->autofan[i].min_pwm =
1572 lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); 1575 lm85_read_value(client, LM85_REG_AFAN_MINPWM(i));
1573 data->zone[i].limit = 1576 data->zone[i].limit =
@@ -1577,50 +1580,50 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1577 } 1580 }
1578 1581
1579 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); 1582 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1);
1580 data->smooth[0] = i & 0x0f ; 1583 data->smooth[0] = i & 0x0f;
1581 data->syncpwm3 = i & 0x10 ; /* Save PWM3 config */ 1584 data->syncpwm3 = i & 0x10; /* Save PWM3 config */
1582 data->autofan[0].min_off = (i & 0x20) != 0 ; 1585 data->autofan[0].min_off = (i & 0x20) != 0;
1583 data->autofan[1].min_off = (i & 0x40) != 0 ; 1586 data->autofan[1].min_off = (i & 0x40) != 0;
1584 data->autofan[2].min_off = (i & 0x80) != 0 ; 1587 data->autofan[2].min_off = (i & 0x80) != 0;
1585 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE2); 1588 i = lm85_read_value(client, LM85_REG_AFAN_SPIKE2);
1586 data->smooth[1] = (i>>4) & 0x0f ; 1589 data->smooth[1] = (i >> 4) & 0x0f;
1587 data->smooth[2] = i & 0x0f ; 1590 data->smooth[2] = i & 0x0f;
1588 1591
1589 i = lm85_read_value(client, LM85_REG_AFAN_HYST1); 1592 i = lm85_read_value(client, LM85_REG_AFAN_HYST1);
1590 data->zone[0].hyst = (i>>4) & 0x0f ; 1593 data->zone[0].hyst = (i >> 4) & 0x0f;
1591 data->zone[1].hyst = i & 0x0f ; 1594 data->zone[1].hyst = i & 0x0f;
1592 1595
1593 i = lm85_read_value(client, LM85_REG_AFAN_HYST2); 1596 i = lm85_read_value(client, LM85_REG_AFAN_HYST2);
1594 data->zone[2].hyst = (i>>4) & 0x0f ; 1597 data->zone[2].hyst = (i >> 4) & 0x0f;
1595 1598
1596 if ( (data->type == lm85b) || (data->type == lm85c) ) { 1599 if (data->type == lm85b || data->type == lm85c) {
1597 data->tach_mode = lm85_read_value(client, 1600 data->tach_mode = lm85_read_value(client,
1598 LM85_REG_TACH_MODE ); 1601 LM85_REG_TACH_MODE);
1599 data->spinup_ctl = lm85_read_value(client, 1602 data->spinup_ctl = lm85_read_value(client,
1600 LM85_REG_SPINUP_CTL ); 1603 LM85_REG_SPINUP_CTL);
1601 } else if ( (data->type == adt7463) || (data->type == adm1027) ) { 1604 } else if (data->type == adt7463 || data->type == adm1027) {
1602 if ( data->type == adt7463 ) { 1605 if (data->type == adt7463) {
1603 for (i = 0; i <= 2; ++i) { 1606 for (i = 0; i <= 2; ++i) {
1604 data->oppoint[i] = lm85_read_value(client, 1607 data->oppoint[i] = lm85_read_value(client,
1605 ADT7463_REG_OPPOINT(i) ); 1608 ADT7463_REG_OPPOINT(i));
1606 } 1609 }
1607 data->tmin_ctl = lm85_read_value(client, 1610 data->tmin_ctl = lm85_read_value(client,
1608 ADT7463_REG_TMIN_CTL1 ); 1611 ADT7463_REG_TMIN_CTL1);
1609 data->therm_limit = lm85_read_value(client, 1612 data->therm_limit = lm85_read_value(client,
1610 ADT7463_REG_THERM_LIMIT ); 1613 ADT7463_REG_THERM_LIMIT);
1611 } 1614 }
1612 for (i = 0; i <= 2; ++i) { 1615 for (i = 0; i <= 2; ++i) {
1613 data->temp_offset[i] = lm85_read_value(client, 1616 data->temp_offset[i] = lm85_read_value(client,
1614 ADM1027_REG_TEMP_OFFSET(i) ); 1617 ADM1027_REG_TEMP_OFFSET(i));
1615 } 1618 }
1616 data->tach_mode = lm85_read_value(client, 1619 data->tach_mode = lm85_read_value(client,
1617 ADM1027_REG_CONFIG3 ); 1620 ADM1027_REG_CONFIG3);
1618 data->fan_ppr = lm85_read_value(client, 1621 data->fan_ppr = lm85_read_value(client,
1619 ADM1027_REG_FAN_PPR ); 1622 ADM1027_REG_FAN_PPR);
1620 } 1623 }
1621 1624
1622 data->last_config = jiffies; 1625 data->last_config = jiffies;
1623 }; /* last_config */ 1626 } /* last_config */
1624 1627
1625 data->valid = 1; 1628 data->valid = 1;
1626 1629
@@ -1635,7 +1638,7 @@ static int __init sm_lm85_init(void)
1635 return i2c_add_driver(&lm85_driver); 1638 return i2c_add_driver(&lm85_driver);
1636} 1639}
1637 1640
1638static void __exit sm_lm85_exit(void) 1641static void __exit sm_lm85_exit(void)
1639{ 1642{
1640 i2c_del_driver(&lm85_driver); 1643 i2c_del_driver(&lm85_driver);
1641} 1644}
@@ -1645,7 +1648,9 @@ static void __exit sm_lm85_exit(void)
1645 * post 2.7.0 CVS changes. 1648 * post 2.7.0 CVS changes.
1646 */ 1649 */
1647MODULE_LICENSE("GPL"); 1650MODULE_LICENSE("GPL");
1648MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>, Justin Thiessen <jthiessen@penguincomputing.com"); 1651MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, "
1652 "Margit Schubert-While <margitsw@t-online.de>, "
1653 "Justin Thiessen <jthiessen@penguincomputing.com");
1649MODULE_DESCRIPTION("LM85-B, LM85-C driver"); 1654MODULE_DESCRIPTION("LM85-B, LM85-C driver");
1650 1655
1651module_init(sm_lm85_init); 1656module_init(sm_lm85_init);