diff options
-rw-r--r-- | drivers/hwmon/w83792d.c | 377 |
1 files changed, 229 insertions, 148 deletions
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index a87c4bd2eccf..ffb5fdfecf0d 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -1,39 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | w83792d.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * w83792d.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | * monitoring |
4 | Copyright (C) 2004, 2005 Winbond Electronics Corp. | 4 | * Copyright (C) 2004, 2005 Winbond Electronics Corp. |
5 | Chunhao Huang <DZShen@Winbond.com.tw>, | 5 | * Chunhao Huang <DZShen@Winbond.com.tw>, |
6 | Rudolf Marek <r.marek@assembler.cz> | 6 | * Rudolf Marek <r.marek@assembler.cz> |
7 | 7 | * | |
8 | This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | * the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | * (at your option) any later version. |
12 | 12 | * | |
13 | This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | 17 | * | |
18 | You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | 21 | * | |
22 | Note: | 22 | * Note: |
23 | 1. This driver is only for 2.6 kernel, 2.4 kernel need a different driver. | 23 | * 1. This driver is only for 2.6 kernel, 2.4 kernel need a different driver. |
24 | 2. This driver is only for Winbond W83792D C version device, there | 24 | * 2. This driver is only for Winbond W83792D C version device, there |
25 | are also some motherboards with B version W83792D device. The | 25 | * are also some motherboards with B version W83792D device. The |
26 | calculation method to in6-in7(measured value, limits) is a little | 26 | * calculation method to in6-in7(measured value, limits) is a little |
27 | different between C and B version. C or B version can be identified | 27 | * different between C and B version. C or B version can be identified |
28 | by CR[0x49h]. | 28 | * by CR[0x49h]. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* | 31 | /* |
32 | Supports following chips: | 32 | * Supports following chips: |
33 | 33 | * | |
34 | Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA | 34 | * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA |
35 | w83792d 9 7 7 3 0x7a 0x5ca3 yes no | 35 | * w83792d 9 7 7 3 0x7a 0x5ca3 yes no |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include <linux/module.h> | 38 | #include <linux/module.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
@@ -218,14 +218,16 @@ static const u8 W83792D_REG_LEVELS[3][4] = { | |||
218 | #define W83792D_REG_VBAT 0x5D | 218 | #define W83792D_REG_VBAT 0x5D |
219 | #define W83792D_REG_I2C_ADDR 0x48 | 219 | #define W83792D_REG_I2C_ADDR 0x48 |
220 | 220 | ||
221 | /* Conversions. Rounding and limit checking is only done on the TO_REG | 221 | /* |
222 | variants. Note that you should be a bit careful with which arguments | 222 | * Conversions. Rounding and limit checking is only done on the TO_REG |
223 | these macros are called: arguments may be evaluated more than once. | 223 | * variants. Note that you should be a bit careful with which arguments |
224 | Fixing this is just not worth it. */ | 224 | * these macros are called: arguments may be evaluated more than once. |
225 | #define IN_FROM_REG(nr,val) (((nr)<=1)?(val*2): \ | 225 | * Fixing this is just not worth it. |
226 | ((((nr)==6)||((nr)==7))?(val*6):(val*4))) | 226 | */ |
227 | #define IN_TO_REG(nr,val) (((nr)<=1)?(val/2): \ | 227 | #define IN_FROM_REG(nr, val) (((nr) <= 1) ? ((val) * 2) : \ |
228 | ((((nr)==6)||((nr)==7))?(val/6):(val/4))) | 228 | ((((nr) == 6) || ((nr) == 7)) ? ((val) * 6) : ((val) * 4))) |
229 | #define IN_TO_REG(nr, val) (((nr) <= 1) ? ((val) / 2) : \ | ||
230 | ((((nr) == 6) || ((nr) == 7)) ? ((val) / 6) : ((val) / 4))) | ||
229 | 231 | ||
230 | static inline u8 | 232 | static inline u8 |
231 | FAN_TO_REG(long rpm, int div) | 233 | FAN_TO_REG(long rpm, int div) |
@@ -236,7 +238,7 @@ FAN_TO_REG(long rpm, int div) | |||
236 | return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254); | 238 | return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254); |
237 | } | 239 | } |
238 | 240 | ||
239 | #define FAN_FROM_REG(val,div) ((val) == 0 ? -1 : \ | 241 | #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : \ |
240 | ((val) == 255 ? 0 : \ | 242 | ((val) == 255 ? 0 : \ |
241 | 1350000 / ((val) * (div)))) | 243 | 1350000 / ((val) * (div)))) |
242 | 244 | ||
@@ -287,8 +289,10 @@ struct w83792d_data { | |||
287 | u8 temp1[3]; /* current, over, thyst */ | 289 | u8 temp1[3]; /* current, over, thyst */ |
288 | u8 temp_add[2][6]; /* Register value */ | 290 | u8 temp_add[2][6]; /* Register value */ |
289 | u8 fan_div[7]; /* Register encoding, shifted right */ | 291 | u8 fan_div[7]; /* Register encoding, shifted right */ |
290 | u8 pwm[7]; /* We only consider the first 3 set of pwm, | 292 | u8 pwm[7]; /* |
291 | although 792 chip has 7 set of pwm. */ | 293 | * We only consider the first 3 set of pwm, |
294 | * although 792 chip has 7 set of pwm. | ||
295 | */ | ||
292 | u8 pwmenable[3]; | 296 | u8 pwmenable[3]; |
293 | u32 alarms; /* realtime status register encoding,combined */ | 297 | u32 alarms; /* realtime status register encoding,combined */ |
294 | u8 chassis; /* Chassis status */ | 298 | u8 chassis; /* Chassis status */ |
@@ -336,9 +340,11 @@ static inline long in_count_from_reg(int nr, struct w83792d_data *data) | |||
336 | return (data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03); | 340 | return (data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03); |
337 | } | 341 | } |
338 | 342 | ||
339 | /* The SMBus locks itself. The Winbond W83792D chip has a bank register, | 343 | /* |
340 | but the driver only accesses registers in bank 0, so we don't have | 344 | * The SMBus locks itself. The Winbond W83792D chip has a bank register, |
341 | to switch banks and lock access between switches. */ | 345 | * but the driver only accesses registers in bank 0, so we don't have |
346 | * to switch banks and lock access between switches. | ||
347 | */ | ||
342 | static inline int w83792d_read_value(struct i2c_client *client, u8 reg) | 348 | static inline int w83792d_read_value(struct i2c_client *client, u8 reg) |
343 | { | 349 | { |
344 | return i2c_smbus_read_byte_data(client, reg); | 350 | return i2c_smbus_read_byte_data(client, reg); |
@@ -357,37 +363,43 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, | |||
357 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 363 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
358 | int nr = sensor_attr->index; | 364 | int nr = sensor_attr->index; |
359 | struct w83792d_data *data = w83792d_update_device(dev); | 365 | struct w83792d_data *data = w83792d_update_device(dev); |
360 | return sprintf(buf,"%ld\n", IN_FROM_REG(nr,(in_count_from_reg(nr, data)))); | 366 | return sprintf(buf, "%ld\n", |
367 | IN_FROM_REG(nr, in_count_from_reg(nr, data))); | ||
361 | } | 368 | } |
362 | 369 | ||
363 | #define show_in_reg(reg) \ | 370 | #define show_in_reg(reg) \ |
364 | static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \ | 371 | static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \ |
365 | char *buf) \ | 372 | char *buf) \ |
366 | { \ | 373 | { \ |
367 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | 374 | struct sensor_device_attribute *sensor_attr \ |
375 | = to_sensor_dev_attr(attr); \ | ||
368 | int nr = sensor_attr->index; \ | 376 | int nr = sensor_attr->index; \ |
369 | struct w83792d_data *data = w83792d_update_device(dev); \ | 377 | struct w83792d_data *data = w83792d_update_device(dev); \ |
370 | return sprintf(buf,"%ld\n", (long)(IN_FROM_REG(nr, (data->reg[nr])*4))); \ | 378 | return sprintf(buf, "%ld\n", \ |
379 | (long)(IN_FROM_REG(nr, data->reg[nr]) * 4)); \ | ||
371 | } | 380 | } |
372 | 381 | ||
373 | show_in_reg(in_min); | 382 | show_in_reg(in_min); |
374 | show_in_reg(in_max); | 383 | show_in_reg(in_max); |
375 | 384 | ||
376 | #define store_in_reg(REG, reg) \ | 385 | #define store_in_reg(REG, reg) \ |
377 | static ssize_t store_in_##reg (struct device *dev, \ | 386 | static ssize_t store_in_##reg(struct device *dev, \ |
378 | struct device_attribute *attr, \ | 387 | struct device_attribute *attr, \ |
379 | const char *buf, size_t count) \ | 388 | const char *buf, size_t count) \ |
380 | { \ | 389 | { \ |
381 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | 390 | struct sensor_device_attribute *sensor_attr \ |
391 | = to_sensor_dev_attr(attr); \ | ||
382 | int nr = sensor_attr->index; \ | 392 | int nr = sensor_attr->index; \ |
383 | struct i2c_client *client = to_i2c_client(dev); \ | 393 | struct i2c_client *client = to_i2c_client(dev); \ |
384 | struct w83792d_data *data = i2c_get_clientdata(client); \ | 394 | struct w83792d_data *data = i2c_get_clientdata(client); \ |
385 | u32 val; \ | 395 | unsigned long val; \ |
386 | \ | 396 | int err = kstrtoul(buf, 10, &val); \ |
387 | val = simple_strtoul(buf, NULL, 10); \ | 397 | if (err) \ |
398 | return err; \ | ||
388 | mutex_lock(&data->update_lock); \ | 399 | mutex_lock(&data->update_lock); \ |
389 | data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val)/4, 0, 255); \ | 400 | data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val) / 4, 0, 255); \ |
390 | w83792d_write_value(client, W83792D_REG_IN_##REG[nr], data->in_##reg[nr]); \ | 401 | w83792d_write_value(client, W83792D_REG_IN_##REG[nr], \ |
402 | data->in_##reg[nr]); \ | ||
391 | mutex_unlock(&data->update_lock); \ | 403 | mutex_unlock(&data->update_lock); \ |
392 | \ | 404 | \ |
393 | return count; \ | 405 | return count; \ |
@@ -396,13 +408,14 @@ store_in_reg(MIN, min); | |||
396 | store_in_reg(MAX, max); | 408 | store_in_reg(MAX, max); |
397 | 409 | ||
398 | #define show_fan_reg(reg) \ | 410 | #define show_fan_reg(reg) \ |
399 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ | 411 | static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \ |
400 | char *buf) \ | 412 | char *buf) \ |
401 | { \ | 413 | { \ |
402 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ | 414 | struct sensor_device_attribute *sensor_attr \ |
415 | = to_sensor_dev_attr(attr); \ | ||
403 | int nr = sensor_attr->index - 1; \ | 416 | int nr = sensor_attr->index - 1; \ |
404 | struct w83792d_data *data = w83792d_update_device(dev); \ | 417 | struct w83792d_data *data = w83792d_update_device(dev); \ |
405 | return sprintf(buf,"%d\n", \ | 418 | return sprintf(buf, "%d\n", \ |
406 | FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \ | 419 | FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \ |
407 | } | 420 | } |
408 | 421 | ||
@@ -417,9 +430,13 @@ store_fan_min(struct device *dev, struct device_attribute *attr, | |||
417 | int nr = sensor_attr->index - 1; | 430 | int nr = sensor_attr->index - 1; |
418 | struct i2c_client *client = to_i2c_client(dev); | 431 | struct i2c_client *client = to_i2c_client(dev); |
419 | struct w83792d_data *data = i2c_get_clientdata(client); | 432 | struct w83792d_data *data = i2c_get_clientdata(client); |
420 | u32 val; | 433 | unsigned long val; |
434 | int err; | ||
435 | |||
436 | err = kstrtoul(buf, 10, &val); | ||
437 | if (err) | ||
438 | return err; | ||
421 | 439 | ||
422 | val = simple_strtoul(buf, NULL, 10); | ||
423 | mutex_lock(&data->update_lock); | 440 | mutex_lock(&data->update_lock); |
424 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 441 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
425 | w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], | 442 | w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], |
@@ -439,10 +456,12 @@ show_fan_div(struct device *dev, struct device_attribute *attr, | |||
439 | return sprintf(buf, "%u\n", DIV_FROM_REG(data->fan_div[nr - 1])); | 456 | return sprintf(buf, "%u\n", DIV_FROM_REG(data->fan_div[nr - 1])); |
440 | } | 457 | } |
441 | 458 | ||
442 | /* Note: we save and restore the fan minimum here, because its value is | 459 | /* |
443 | determined in part by the fan divisor. This follows the principle of | 460 | * Note: we save and restore the fan minimum here, because its value is |
444 | least surprise; the user doesn't expect the fan minimum to change just | 461 | * determined in part by the fan divisor. This follows the principle of |
445 | because the divisor changed. */ | 462 | * least surprise; the user doesn't expect the fan minimum to change just |
463 | * because the divisor changed. | ||
464 | */ | ||
446 | static ssize_t | 465 | static ssize_t |
447 | store_fan_div(struct device *dev, struct device_attribute *attr, | 466 | store_fan_div(struct device *dev, struct device_attribute *attr, |
448 | const char *buf, size_t count) | 467 | const char *buf, size_t count) |
@@ -455,13 +474,19 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
455 | /*u8 reg;*/ | 474 | /*u8 reg;*/ |
456 | u8 fan_div_reg = 0; | 475 | u8 fan_div_reg = 0; |
457 | u8 tmp_fan_div; | 476 | u8 tmp_fan_div; |
477 | unsigned long val; | ||
478 | int err; | ||
479 | |||
480 | err = kstrtoul(buf, 10, &val); | ||
481 | if (err) | ||
482 | return err; | ||
458 | 483 | ||
459 | /* Save fan_min */ | 484 | /* Save fan_min */ |
460 | mutex_lock(&data->update_lock); | 485 | mutex_lock(&data->update_lock); |
461 | min = FAN_FROM_REG(data->fan_min[nr], | 486 | min = FAN_FROM_REG(data->fan_min[nr], |
462 | DIV_FROM_REG(data->fan_div[nr])); | 487 | DIV_FROM_REG(data->fan_div[nr])); |
463 | 488 | ||
464 | data->fan_div[nr] = DIV_TO_REG(simple_strtoul(buf, NULL, 10)); | 489 | data->fan_div[nr] = DIV_TO_REG(val); |
465 | 490 | ||
466 | fan_div_reg = w83792d_read_value(client, W83792D_REG_FAN_DIV[nr >> 1]); | 491 | fan_div_reg = w83792d_read_value(client, W83792D_REG_FAN_DIV[nr >> 1]); |
467 | fan_div_reg &= (nr & 0x01) ? 0x8f : 0xf8; | 492 | fan_div_reg &= (nr & 0x01) ? 0x8f : 0xf8; |
@@ -496,9 +521,13 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, | |||
496 | int nr = sensor_attr->index; | 521 | int nr = sensor_attr->index; |
497 | struct i2c_client *client = to_i2c_client(dev); | 522 | struct i2c_client *client = to_i2c_client(dev); |
498 | struct w83792d_data *data = i2c_get_clientdata(client); | 523 | struct w83792d_data *data = i2c_get_clientdata(client); |
499 | s32 val; | 524 | long val; |
525 | int err; | ||
526 | |||
527 | err = kstrtol(buf, 10, &val); | ||
528 | if (err) | ||
529 | return err; | ||
500 | 530 | ||
501 | val = simple_strtol(buf, NULL, 10); | ||
502 | mutex_lock(&data->update_lock); | 531 | mutex_lock(&data->update_lock); |
503 | data->temp1[nr] = TEMP1_TO_REG(val); | 532 | data->temp1[nr] = TEMP1_TO_REG(val); |
504 | w83792d_write_value(client, W83792D_REG_TEMP1[nr], | 533 | w83792d_write_value(client, W83792D_REG_TEMP1[nr], |
@@ -513,11 +542,12 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, | |||
513 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, | 542 | static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, |
514 | char *buf) | 543 | char *buf) |
515 | { | 544 | { |
516 | struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); | 545 | struct sensor_device_attribute_2 *sensor_attr |
546 | = to_sensor_dev_attr_2(attr); | ||
517 | int nr = sensor_attr->nr; | 547 | int nr = sensor_attr->nr; |
518 | int index = sensor_attr->index; | 548 | int index = sensor_attr->index; |
519 | struct w83792d_data *data = w83792d_update_device(dev); | 549 | struct w83792d_data *data = w83792d_update_device(dev); |
520 | return sprintf(buf,"%ld\n", | 550 | return sprintf(buf, "%ld\n", |
521 | (long)TEMP_ADD_FROM_REG(data->temp_add[nr][index], | 551 | (long)TEMP_ADD_FROM_REG(data->temp_add[nr][index], |
522 | data->temp_add[nr][index+1])); | 552 | data->temp_add[nr][index+1])); |
523 | } | 553 | } |
@@ -525,14 +555,19 @@ static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, | |||
525 | static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, | 555 | static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, |
526 | const char *buf, size_t count) | 556 | const char *buf, size_t count) |
527 | { | 557 | { |
528 | struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); | 558 | struct sensor_device_attribute_2 *sensor_attr |
559 | = to_sensor_dev_attr_2(attr); | ||
529 | int nr = sensor_attr->nr; | 560 | int nr = sensor_attr->nr; |
530 | int index = sensor_attr->index; | 561 | int index = sensor_attr->index; |
531 | struct i2c_client *client = to_i2c_client(dev); | 562 | struct i2c_client *client = to_i2c_client(dev); |
532 | struct w83792d_data *data = i2c_get_clientdata(client); | 563 | struct w83792d_data *data = i2c_get_clientdata(client); |
533 | s32 val; | 564 | long val; |
565 | int err; | ||
566 | |||
567 | err = kstrtol(buf, 10, &val); | ||
568 | if (err) | ||
569 | return err; | ||
534 | 570 | ||
535 | val = simple_strtol(buf, NULL, 10); | ||
536 | mutex_lock(&data->update_lock); | 571 | mutex_lock(&data->update_lock); |
537 | data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val); | 572 | data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val); |
538 | data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val); | 573 | data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val); |
@@ -604,7 +639,13 @@ store_pwm(struct device *dev, struct device_attribute *attr, | |||
604 | int nr = sensor_attr->index; | 639 | int nr = sensor_attr->index; |
605 | struct i2c_client *client = to_i2c_client(dev); | 640 | struct i2c_client *client = to_i2c_client(dev); |
606 | struct w83792d_data *data = i2c_get_clientdata(client); | 641 | struct w83792d_data *data = i2c_get_clientdata(client); |
607 | u8 val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 255) >> 4; | 642 | unsigned long val; |
643 | int err; | ||
644 | |||
645 | err = kstrtoul(buf, 10, &val); | ||
646 | if (err) | ||
647 | return err; | ||
648 | val = SENSORS_LIMIT(val, 0, 255) >> 4; | ||
608 | 649 | ||
609 | mutex_lock(&data->update_lock); | 650 | mutex_lock(&data->update_lock); |
610 | val |= w83792d_read_value(client, W83792D_REG_PWM[nr]) & 0xf0; | 651 | val |= w83792d_read_value(client, W83792D_REG_PWM[nr]) & 0xf0; |
@@ -623,10 +664,14 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
623 | int nr = sensor_attr->index - 1; | 664 | int nr = sensor_attr->index - 1; |
624 | struct i2c_client *client = to_i2c_client(dev); | 665 | struct i2c_client *client = to_i2c_client(dev); |
625 | struct w83792d_data *data = i2c_get_clientdata(client); | 666 | struct w83792d_data *data = i2c_get_clientdata(client); |
626 | u32 val; | ||
627 | u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp; | 667 | u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp; |
668 | unsigned long val; | ||
669 | int err; | ||
670 | |||
671 | err = kstrtoul(buf, 10, &val); | ||
672 | if (err) | ||
673 | return err; | ||
628 | 674 | ||
629 | val = simple_strtoul(buf, NULL, 10); | ||
630 | if (val < 1 || val > 3) | 675 | if (val < 1 || val > 3) |
631 | return -EINVAL; | 676 | return -EINVAL; |
632 | 677 | ||
@@ -645,7 +690,7 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
645 | cfg1_tmp = data->pwmenable[0]; | 690 | cfg1_tmp = data->pwmenable[0]; |
646 | cfg2_tmp = (data->pwmenable[1]) << 2; | 691 | cfg2_tmp = (data->pwmenable[1]) << 2; |
647 | cfg3_tmp = (data->pwmenable[2]) << 4; | 692 | cfg3_tmp = (data->pwmenable[2]) << 4; |
648 | cfg4_tmp = w83792d_read_value(client,W83792D_REG_FAN_CFG) & 0xc0; | 693 | cfg4_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG) & 0xc0; |
649 | fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp; | 694 | fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp; |
650 | w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp); | 695 | w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp); |
651 | mutex_unlock(&data->update_lock); | 696 | mutex_unlock(&data->update_lock); |
@@ -671,10 +716,13 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
671 | int nr = sensor_attr->index; | 716 | int nr = sensor_attr->index; |
672 | struct i2c_client *client = to_i2c_client(dev); | 717 | struct i2c_client *client = to_i2c_client(dev); |
673 | struct w83792d_data *data = i2c_get_clientdata(client); | 718 | struct w83792d_data *data = i2c_get_clientdata(client); |
674 | u32 val; | 719 | unsigned long val; |
720 | int err; | ||
675 | 721 | ||
676 | val = simple_strtoul(buf, NULL, 10); | 722 | err = kstrtoul(buf, 10, &val); |
677 | if (val != 0 && val != 1) | 723 | if (err) |
724 | return err; | ||
725 | if (val > 1) | ||
678 | return -EINVAL; | 726 | return -EINVAL; |
679 | 727 | ||
680 | mutex_lock(&data->update_lock); | 728 | mutex_lock(&data->update_lock); |
@@ -721,16 +769,20 @@ store_chassis_clear_legacy(struct device *dev, struct device_attribute *attr, | |||
721 | { | 769 | { |
722 | struct i2c_client *client = to_i2c_client(dev); | 770 | struct i2c_client *client = to_i2c_client(dev); |
723 | struct w83792d_data *data = i2c_get_clientdata(client); | 771 | struct w83792d_data *data = i2c_get_clientdata(client); |
724 | u32 val; | 772 | unsigned long val; |
773 | int err; | ||
725 | u8 temp1 = 0, temp2 = 0; | 774 | u8 temp1 = 0, temp2 = 0; |
726 | 775 | ||
727 | dev_warn(dev, | 776 | dev_warn(dev, |
728 | "Attribute %s is deprecated, use intrusion0_alarm instead\n", | 777 | "Attribute %s is deprecated, use intrusion0_alarm instead\n", |
729 | "chassis_clear"); | 778 | "chassis_clear"); |
730 | 779 | ||
731 | val = simple_strtoul(buf, NULL, 10); | 780 | err = kstrtoul(buf, 10, &val); |
781 | if (err) | ||
782 | return err; | ||
783 | |||
732 | mutex_lock(&data->update_lock); | 784 | mutex_lock(&data->update_lock); |
733 | data->chassis_clear = SENSORS_LIMIT(val, 0 ,1); | 785 | data->chassis_clear = SENSORS_LIMIT(val, 0, 1); |
734 | temp1 = ((data->chassis_clear) << 7) & 0x80; | 786 | temp1 = ((data->chassis_clear) << 7) & 0x80; |
735 | temp2 = w83792d_read_value(client, | 787 | temp2 = w83792d_read_value(client, |
736 | W83792D_REG_CHASSIS_CLR) & 0x7f; | 788 | W83792D_REG_CHASSIS_CLR) & 0x7f; |
@@ -780,14 +832,19 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr, | |||
780 | int nr = sensor_attr->index - 1; | 832 | int nr = sensor_attr->index - 1; |
781 | struct i2c_client *client = to_i2c_client(dev); | 833 | struct i2c_client *client = to_i2c_client(dev); |
782 | struct w83792d_data *data = i2c_get_clientdata(client); | 834 | struct w83792d_data *data = i2c_get_clientdata(client); |
783 | u32 val; | 835 | u8 target_tmp = 0, target_mask = 0; |
784 | u8 target_tmp=0, target_mask=0; | 836 | unsigned long val; |
837 | int err; | ||
838 | |||
839 | err = kstrtoul(buf, 10, &val); | ||
840 | if (err) | ||
841 | return err; | ||
785 | 842 | ||
786 | val = simple_strtoul(buf, NULL, 10); | ||
787 | target_tmp = val; | 843 | target_tmp = val; |
788 | target_tmp = target_tmp & 0x7f; | 844 | target_tmp = target_tmp & 0x7f; |
789 | mutex_lock(&data->update_lock); | 845 | mutex_lock(&data->update_lock); |
790 | target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80; | 846 | target_mask = w83792d_read_value(client, |
847 | W83792D_REG_THERMAL[nr]) & 0x80; | ||
791 | data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255); | 848 | data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255); |
792 | w83792d_write_value(client, W83792D_REG_THERMAL[nr], | 849 | w83792d_write_value(client, W83792D_REG_THERMAL[nr], |
793 | (data->thermal_cruise[nr]) | target_mask); | 850 | (data->thermal_cruise[nr]) | target_mask); |
@@ -815,19 +872,22 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
815 | int nr = sensor_attr->index - 1; | 872 | int nr = sensor_attr->index - 1; |
816 | struct i2c_client *client = to_i2c_client(dev); | 873 | struct i2c_client *client = to_i2c_client(dev); |
817 | struct w83792d_data *data = i2c_get_clientdata(client); | 874 | struct w83792d_data *data = i2c_get_clientdata(client); |
818 | u32 val; | ||
819 | u8 tol_tmp, tol_mask; | 875 | u8 tol_tmp, tol_mask; |
876 | unsigned long val; | ||
877 | int err; | ||
878 | |||
879 | err = kstrtoul(buf, 10, &val); | ||
880 | if (err) | ||
881 | return err; | ||
820 | 882 | ||
821 | val = simple_strtoul(buf, NULL, 10); | ||
822 | mutex_lock(&data->update_lock); | 883 | mutex_lock(&data->update_lock); |
823 | tol_mask = w83792d_read_value(client, | 884 | tol_mask = w83792d_read_value(client, |
824 | W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0); | 885 | W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0); |
825 | tol_tmp = SENSORS_LIMIT(val, 0, 15); | 886 | tol_tmp = SENSORS_LIMIT(val, 0, 15); |
826 | tol_tmp &= 0x0f; | 887 | tol_tmp &= 0x0f; |
827 | data->tolerance[nr] = tol_tmp; | 888 | data->tolerance[nr] = tol_tmp; |
828 | if (nr == 1) { | 889 | if (nr == 1) |
829 | tol_tmp <<= 4; | 890 | tol_tmp <<= 4; |
830 | } | ||
831 | w83792d_write_value(client, W83792D_REG_TOLERANCE[nr], | 891 | w83792d_write_value(client, W83792D_REG_TOLERANCE[nr], |
832 | tol_mask | tol_tmp); | 892 | tol_mask | tol_tmp); |
833 | mutex_unlock(&data->update_lock); | 893 | mutex_unlock(&data->update_lock); |
@@ -840,7 +900,8 @@ static ssize_t | |||
840 | show_sf2_point(struct device *dev, struct device_attribute *attr, | 900 | show_sf2_point(struct device *dev, struct device_attribute *attr, |
841 | char *buf) | 901 | char *buf) |
842 | { | 902 | { |
843 | struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); | 903 | struct sensor_device_attribute_2 *sensor_attr |
904 | = to_sensor_dev_attr_2(attr); | ||
844 | int nr = sensor_attr->nr; | 905 | int nr = sensor_attr->nr; |
845 | int index = sensor_attr->index; | 906 | int index = sensor_attr->index; |
846 | struct w83792d_data *data = w83792d_update_device(dev); | 907 | struct w83792d_data *data = w83792d_update_device(dev); |
@@ -851,15 +912,20 @@ static ssize_t | |||
851 | store_sf2_point(struct device *dev, struct device_attribute *attr, | 912 | store_sf2_point(struct device *dev, struct device_attribute *attr, |
852 | const char *buf, size_t count) | 913 | const char *buf, size_t count) |
853 | { | 914 | { |
854 | struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); | 915 | struct sensor_device_attribute_2 *sensor_attr |
916 | = to_sensor_dev_attr_2(attr); | ||
855 | int nr = sensor_attr->nr - 1; | 917 | int nr = sensor_attr->nr - 1; |
856 | int index = sensor_attr->index - 1; | 918 | int index = sensor_attr->index - 1; |
857 | struct i2c_client *client = to_i2c_client(dev); | 919 | struct i2c_client *client = to_i2c_client(dev); |
858 | struct w83792d_data *data = i2c_get_clientdata(client); | 920 | struct w83792d_data *data = i2c_get_clientdata(client); |
859 | u32 val; | ||
860 | u8 mask_tmp = 0; | 921 | u8 mask_tmp = 0; |
922 | unsigned long val; | ||
923 | int err; | ||
924 | |||
925 | err = kstrtoul(buf, 10, &val); | ||
926 | if (err) | ||
927 | return err; | ||
861 | 928 | ||
862 | val = simple_strtoul(buf, NULL, 10); | ||
863 | mutex_lock(&data->update_lock); | 929 | mutex_lock(&data->update_lock); |
864 | data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127); | 930 | data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127); |
865 | mask_tmp = w83792d_read_value(client, | 931 | mask_tmp = w83792d_read_value(client, |
@@ -875,7 +941,8 @@ static ssize_t | |||
875 | show_sf2_level(struct device *dev, struct device_attribute *attr, | 941 | show_sf2_level(struct device *dev, struct device_attribute *attr, |
876 | char *buf) | 942 | char *buf) |
877 | { | 943 | { |
878 | struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); | 944 | struct sensor_device_attribute_2 *sensor_attr |
945 | = to_sensor_dev_attr_2(attr); | ||
879 | int nr = sensor_attr->nr; | 946 | int nr = sensor_attr->nr; |
880 | int index = sensor_attr->index; | 947 | int index = sensor_attr->index; |
881 | struct w83792d_data *data = w83792d_update_device(dev); | 948 | struct w83792d_data *data = w83792d_update_device(dev); |
@@ -887,25 +954,30 @@ static ssize_t | |||
887 | store_sf2_level(struct device *dev, struct device_attribute *attr, | 954 | store_sf2_level(struct device *dev, struct device_attribute *attr, |
888 | const char *buf, size_t count) | 955 | const char *buf, size_t count) |
889 | { | 956 | { |
890 | struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); | 957 | struct sensor_device_attribute_2 *sensor_attr |
958 | = to_sensor_dev_attr_2(attr); | ||
891 | int nr = sensor_attr->nr; | 959 | int nr = sensor_attr->nr; |
892 | int index = sensor_attr->index - 1; | 960 | int index = sensor_attr->index - 1; |
893 | struct i2c_client *client = to_i2c_client(dev); | 961 | struct i2c_client *client = to_i2c_client(dev); |
894 | struct w83792d_data *data = i2c_get_clientdata(client); | 962 | struct w83792d_data *data = i2c_get_clientdata(client); |
895 | u32 val; | 963 | u8 mask_tmp = 0, level_tmp = 0; |
896 | u8 mask_tmp=0, level_tmp=0; | 964 | unsigned long val; |
965 | int err; | ||
966 | |||
967 | err = kstrtoul(buf, 10, &val); | ||
968 | if (err) | ||
969 | return err; | ||
897 | 970 | ||
898 | val = simple_strtoul(buf, NULL, 10); | ||
899 | mutex_lock(&data->update_lock); | 971 | mutex_lock(&data->update_lock); |
900 | data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15); | 972 | data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15); |
901 | mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr]) | 973 | mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr]) |
902 | & ((nr==3) ? 0xf0 : 0x0f); | 974 | & ((nr == 3) ? 0xf0 : 0x0f); |
903 | if (nr==3) { | 975 | if (nr == 3) |
904 | level_tmp = data->sf2_levels[index][nr]; | 976 | level_tmp = data->sf2_levels[index][nr]; |
905 | } else { | 977 | else |
906 | level_tmp = data->sf2_levels[index][nr] << 4; | 978 | level_tmp = data->sf2_levels[index][nr] << 4; |
907 | } | 979 | w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], |
908 | w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp); | 980 | level_tmp | mask_tmp); |
909 | mutex_unlock(&data->update_lock); | 981 | mutex_unlock(&data->update_lock); |
910 | 982 | ||
911 | return count; | 983 | return count; |
@@ -939,9 +1011,8 @@ w83792d_detect_subclients(struct i2c_client *new_client) | |||
939 | } | 1011 | } |
940 | 1012 | ||
941 | val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR); | 1013 | val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR); |
942 | if (!(val & 0x08)) { | 1014 | if (!(val & 0x08)) |
943 | data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7)); | 1015 | data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7)); |
944 | } | ||
945 | if (!(val & 0x80)) { | 1016 | if (!(val & 0x80)) { |
946 | if ((data->lm75[0] != NULL) && | 1017 | if ((data->lm75[0] != NULL) && |
947 | ((val & 0x7) == ((val >> 4) & 0x7))) { | 1018 | ((val & 0x7) == ((val >> 4) & 0x7))) { |
@@ -1306,9 +1377,8 @@ w83792d_detect(struct i2c_client *client, struct i2c_board_info *info) | |||
1306 | int val1, val2; | 1377 | int val1, val2; |
1307 | unsigned short address = client->addr; | 1378 | unsigned short address = client->addr; |
1308 | 1379 | ||
1309 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 1380 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
1310 | return -ENODEV; | 1381 | return -ENODEV; |
1311 | } | ||
1312 | 1382 | ||
1313 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) | 1383 | if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) |
1314 | return -ENODEV; | 1384 | return -ENODEV; |
@@ -1318,11 +1388,13 @@ w83792d_detect(struct i2c_client *client, struct i2c_board_info *info) | |||
1318 | /* Check for Winbond ID if in bank 0 */ | 1388 | /* Check for Winbond ID if in bank 0 */ |
1319 | if (!(val1 & 0x07)) { /* is Bank0 */ | 1389 | if (!(val1 & 0x07)) { /* is Bank0 */ |
1320 | if ((!(val1 & 0x80) && val2 != 0xa3) || | 1390 | if ((!(val1 & 0x80) && val2 != 0xa3) || |
1321 | ( (val1 & 0x80) && val2 != 0x5c)) | 1391 | ((val1 & 0x80) && val2 != 0x5c)) |
1322 | return -ENODEV; | 1392 | return -ENODEV; |
1323 | } | 1393 | } |
1324 | /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR | 1394 | /* |
1325 | should match */ | 1395 | * If Winbond chip, address of chip and W83792D_REG_I2C_ADDR |
1396 | * should match | ||
1397 | */ | ||
1326 | if (w83792d_read_value(client, W83792D_REG_I2C_ADDR) != address) | 1398 | if (w83792d_read_value(client, W83792D_REG_I2C_ADDR) != address) |
1327 | return -ENODEV; | 1399 | return -ENODEV; |
1328 | 1400 | ||
@@ -1374,33 +1446,40 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1374 | } | 1446 | } |
1375 | 1447 | ||
1376 | /* Register sysfs hooks */ | 1448 | /* Register sysfs hooks */ |
1377 | if ((err = sysfs_create_group(&dev->kobj, &w83792d_group))) | 1449 | err = sysfs_create_group(&dev->kobj, &w83792d_group); |
1450 | if (err) | ||
1378 | goto ERROR3; | 1451 | goto ERROR3; |
1379 | 1452 | ||
1380 | /* Read GPIO enable register to check if pins for fan 4,5 are used as | 1453 | /* |
1381 | GPIO */ | 1454 | * Read GPIO enable register to check if pins for fan 4,5 are used as |
1455 | * GPIO | ||
1456 | */ | ||
1382 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); | 1457 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); |
1383 | 1458 | ||
1384 | if (!(val1 & 0x40)) | 1459 | if (!(val1 & 0x40)) { |
1385 | if ((err = sysfs_create_group(&dev->kobj, | 1460 | err = sysfs_create_group(&dev->kobj, &w83792d_group_fan[0]); |
1386 | &w83792d_group_fan[0]))) | 1461 | if (err) |
1387 | goto exit_remove_files; | 1462 | goto exit_remove_files; |
1463 | } | ||
1388 | 1464 | ||
1389 | if (!(val1 & 0x20)) | 1465 | if (!(val1 & 0x20)) { |
1390 | if ((err = sysfs_create_group(&dev->kobj, | 1466 | err = sysfs_create_group(&dev->kobj, &w83792d_group_fan[1]); |
1391 | &w83792d_group_fan[1]))) | 1467 | if (err) |
1392 | goto exit_remove_files; | 1468 | goto exit_remove_files; |
1469 | } | ||
1393 | 1470 | ||
1394 | val1 = w83792d_read_value(client, W83792D_REG_PIN); | 1471 | val1 = w83792d_read_value(client, W83792D_REG_PIN); |
1395 | if (val1 & 0x40) | 1472 | if (val1 & 0x40) { |
1396 | if ((err = sysfs_create_group(&dev->kobj, | 1473 | err = sysfs_create_group(&dev->kobj, &w83792d_group_fan[2]); |
1397 | &w83792d_group_fan[2]))) | 1474 | if (err) |
1398 | goto exit_remove_files; | 1475 | goto exit_remove_files; |
1476 | } | ||
1399 | 1477 | ||
1400 | if (val1 & 0x04) | 1478 | if (val1 & 0x04) { |
1401 | if ((err = sysfs_create_group(&dev->kobj, | 1479 | err = sysfs_create_group(&dev->kobj, &w83792d_group_fan[3]); |
1402 | &w83792d_group_fan[3]))) | 1480 | if (err) |
1403 | goto exit_remove_files; | 1481 | goto exit_remove_files; |
1482 | } | ||
1404 | 1483 | ||
1405 | data->hwmon_dev = hwmon_device_register(dev); | 1484 | data->hwmon_dev = hwmon_device_register(dev); |
1406 | if (IS_ERR(data->hwmon_dev)) { | 1485 | if (IS_ERR(data->hwmon_dev)) { |
@@ -1451,14 +1530,16 @@ w83792d_init_client(struct i2c_client *client) | |||
1451 | { | 1530 | { |
1452 | u8 temp2_cfg, temp3_cfg, vid_in_b; | 1531 | u8 temp2_cfg, temp3_cfg, vid_in_b; |
1453 | 1532 | ||
1454 | if (init) { | 1533 | if (init) |
1455 | w83792d_write_value(client, W83792D_REG_CONFIG, 0x80); | 1534 | w83792d_write_value(client, W83792D_REG_CONFIG, 0x80); |
1456 | } | 1535 | |
1457 | /* Clear the bit6 of W83792D_REG_VID_IN_B(set it into 0): | 1536 | /* |
1458 | W83792D_REG_VID_IN_B bit6 = 0: the high/low limit of | 1537 | * Clear the bit6 of W83792D_REG_VID_IN_B(set it into 0): |
1459 | vin0/vin1 can be modified by user; | 1538 | * W83792D_REG_VID_IN_B bit6 = 0: the high/low limit of |
1460 | W83792D_REG_VID_IN_B bit6 = 1: the high/low limit of | 1539 | * vin0/vin1 can be modified by user; |
1461 | vin0/vin1 auto-updated, can NOT be modified by user. */ | 1540 | * W83792D_REG_VID_IN_B bit6 = 1: the high/low limit of |
1541 | * vin0/vin1 auto-updated, can NOT be modified by user. | ||
1542 | */ | ||
1462 | vid_in_b = w83792d_read_value(client, W83792D_REG_VID_IN_B); | 1543 | vid_in_b = w83792d_read_value(client, W83792D_REG_VID_IN_B); |
1463 | w83792d_write_value(client, W83792D_REG_VID_IN_B, | 1544 | w83792d_write_value(client, W83792D_REG_VID_IN_B, |
1464 | vid_in_b & 0xbf); | 1545 | vid_in_b & 0xbf); |
@@ -1527,7 +1608,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1527 | for (i = 0; i < 2; i++) { | 1608 | for (i = 0; i < 2; i++) { |
1528 | for (j = 0; j < 6; j++) { | 1609 | for (j = 0; j < 6; j++) { |
1529 | data->temp_add[i][j] = w83792d_read_value( | 1610 | data->temp_add[i][j] = w83792d_read_value( |
1530 | client,W83792D_REG_TEMP_ADD[i][j]); | 1611 | client, W83792D_REG_TEMP_ADD[i][j]); |
1531 | } | 1612 | } |
1532 | } | 1613 | } |
1533 | 1614 | ||
@@ -1572,8 +1653,9 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1572 | /* Update Smart Fan II temperature points */ | 1653 | /* Update Smart Fan II temperature points */ |
1573 | for (i = 0; i < 3; i++) { | 1654 | for (i = 0; i < 3; i++) { |
1574 | for (j = 0; j < 4; j++) { | 1655 | for (j = 0; j < 4; j++) { |
1575 | data->sf2_points[i][j] = w83792d_read_value( | 1656 | data->sf2_points[i][j] |
1576 | client,W83792D_REG_POINTS[i][j]) & 0x7f; | 1657 | = w83792d_read_value(client, |
1658 | W83792D_REG_POINTS[i][j]) & 0x7f; | ||
1577 | } | 1659 | } |
1578 | } | 1660 | } |
1579 | 1661 | ||
@@ -1605,10 +1687,10 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1605 | #ifdef DEBUG | 1687 | #ifdef DEBUG |
1606 | static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) | 1688 | static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) |
1607 | { | 1689 | { |
1608 | int i=0, j=0; | 1690 | int i = 0, j = 0; |
1609 | dev_dbg(dev, "==========The following is the debug message...========\n"); | 1691 | dev_dbg(dev, "==========The following is the debug message...========\n"); |
1610 | dev_dbg(dev, "9 set of Voltages: =====>\n"); | 1692 | dev_dbg(dev, "9 set of Voltages: =====>\n"); |
1611 | for (i=0; i<9; i++) { | 1693 | for (i = 0; i < 9; i++) { |
1612 | dev_dbg(dev, "vin[%d] is: 0x%x\n", i, data->in[i]); | 1694 | dev_dbg(dev, "vin[%d] is: 0x%x\n", i, data->in[i]); |
1613 | dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); | 1695 | dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); |
1614 | dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); | 1696 | dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); |
@@ -1616,27 +1698,26 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) | |||
1616 | dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits & 0xff); | 1698 | dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits & 0xff); |
1617 | dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits >> 8); | 1699 | dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits >> 8); |
1618 | dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); | 1700 | dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); |
1619 | for (i=0; i<7; i++) { | 1701 | for (i = 0; i < 7; i++) { |
1620 | dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); | 1702 | dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); |
1621 | dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); | 1703 | dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); |
1622 | dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]); | 1704 | dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]); |
1623 | } | 1705 | } |
1624 | dev_dbg(dev, "3 set of Temperatures: =====>\n"); | 1706 | dev_dbg(dev, "3 set of Temperatures: =====>\n"); |
1625 | for (i=0; i<3; i++) { | 1707 | for (i = 0; i < 3; i++) |
1626 | dev_dbg(dev, "temp1[%d] is: 0x%x\n", i, data->temp1[i]); | 1708 | dev_dbg(dev, "temp1[%d] is: 0x%x\n", i, data->temp1[i]); |
1627 | } | ||
1628 | 1709 | ||
1629 | for (i=0; i<2; i++) { | 1710 | for (i = 0; i < 2; i++) { |
1630 | for (j=0; j<6; j++) { | 1711 | for (j = 0; j < 6; j++) { |
1631 | dev_dbg(dev, "temp_add[%d][%d] is: 0x%x\n", i, j, | 1712 | dev_dbg(dev, "temp_add[%d][%d] is: 0x%x\n", i, j, |
1632 | data->temp_add[i][j]); | 1713 | data->temp_add[i][j]); |
1633 | } | 1714 | } |
1634 | } | 1715 | } |
1635 | 1716 | ||
1636 | for (i=0; i<7; i++) { | 1717 | for (i = 0; i < 7; i++) |
1637 | dev_dbg(dev, "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]); | 1718 | dev_dbg(dev, "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]); |
1638 | } | 1719 | |
1639 | dev_dbg(dev, "==========End of the debug message...==================\n"); | 1720 | dev_dbg(dev, "==========End of the debug message...================\n"); |
1640 | dev_dbg(dev, "\n"); | 1721 | dev_dbg(dev, "\n"); |
1641 | } | 1722 | } |
1642 | #endif | 1723 | #endif |