diff options
author | Guenter Roeck <linux@roeck-us.net> | 2015-07-27 13:21:46 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-07-29 23:06:46 -0400 |
commit | 0d6aaffc3a6db642e0a165ba4d17d6d7bbaf5201 (patch) | |
tree | 9e2e6ca11e0201f4c8cf8fc19dd61e60cb0e608e | |
parent | cbfe8fa6cd672011c755c3cd85c9ffd4e2d10a6f (diff) |
hwmon: (nct7904) Rename pwm attributes to match hwmon ABI
pwm attributes have well defined names, which should be used.
Cc: Vadim V. Vlasov <vvlasov@dev.rtsoft.ru>
Cc: stable@vger.kernel.org #v4.1+
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | Documentation/hwmon/nct7904 | 4 | ||||
-rw-r--r-- | drivers/hwmon/nct7904.c | 57 |
2 files changed, 31 insertions, 30 deletions
diff --git a/Documentation/hwmon/nct7904 b/Documentation/hwmon/nct7904 index 014f112e2a14..57fffe33ebfc 100644 --- a/Documentation/hwmon/nct7904 +++ b/Documentation/hwmon/nct7904 | |||
@@ -35,11 +35,11 @@ temp1_input Local temperature (1/1000 degree, | |||
35 | temp[2-9]_input CPU temperatures (1/1000 degree, | 35 | temp[2-9]_input CPU temperatures (1/1000 degree, |
36 | 0.125 degree resolution) | 36 | 0.125 degree resolution) |
37 | 37 | ||
38 | fan[1-4]_mode R/W, 0/1 for manual or SmartFan mode | 38 | pwm[1-4]_enable R/W, 1/2 for manual or SmartFan mode |
39 | Setting SmartFan mode is supported only if it has been | 39 | Setting SmartFan mode is supported only if it has been |
40 | previously configured by BIOS (or configuration EEPROM) | 40 | previously configured by BIOS (or configuration EEPROM) |
41 | 41 | ||
42 | fan[1-4]_pwm R/O in SmartFan mode, R/W in manual control mode | 42 | pwm[1-4] R/O in SmartFan mode, R/W in manual control mode |
43 | 43 | ||
44 | The driver checks sensor control registers and does not export the sensors | 44 | The driver checks sensor control registers and does not export the sensors |
45 | that are not enabled. Anyway, a sensor that is enabled may actually be not | 45 | that are not enabled. Anyway, a sensor that is enabled may actually be not |
diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c index b77b82f24480..6153df735e82 100644 --- a/drivers/hwmon/nct7904.c +++ b/drivers/hwmon/nct7904.c | |||
@@ -412,8 +412,9 @@ static ssize_t show_pwm(struct device *dev, | |||
412 | return sprintf(buf, "%d\n", val); | 412 | return sprintf(buf, "%d\n", val); |
413 | } | 413 | } |
414 | 414 | ||
415 | static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, | 415 | static ssize_t store_enable(struct device *dev, |
416 | const char *buf, size_t count) | 416 | struct device_attribute *devattr, |
417 | const char *buf, size_t count) | ||
417 | { | 418 | { |
418 | int index = to_sensor_dev_attr(devattr)->index; | 419 | int index = to_sensor_dev_attr(devattr)->index; |
419 | struct nct7904_data *data = dev_get_drvdata(dev); | 420 | struct nct7904_data *data = dev_get_drvdata(dev); |
@@ -422,18 +423,18 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, | |||
422 | 423 | ||
423 | if (kstrtoul(buf, 10, &val) < 0) | 424 | if (kstrtoul(buf, 10, &val) < 0) |
424 | return -EINVAL; | 425 | return -EINVAL; |
425 | if (val > 1 || (val && !data->fan_mode[index])) | 426 | if (val < 1 || val > 2 || (val == 2 && !data->fan_mode[index])) |
426 | return -EINVAL; | 427 | return -EINVAL; |
427 | 428 | ||
428 | ret = nct7904_write_reg(data, BANK_3, FANCTL1_FMR_REG + index, | 429 | ret = nct7904_write_reg(data, BANK_3, FANCTL1_FMR_REG + index, |
429 | val ? data->fan_mode[index] : 0); | 430 | val == 2 ? data->fan_mode[index] : 0); |
430 | 431 | ||
431 | return ret ? ret : count; | 432 | return ret ? ret : count; |
432 | } | 433 | } |
433 | 434 | ||
434 | /* Return 0 for manual mode or 1 for SmartFan mode */ | 435 | /* Return 1 for manual mode or 2 for SmartFan mode */ |
435 | static ssize_t show_mode(struct device *dev, | 436 | static ssize_t show_enable(struct device *dev, |
436 | struct device_attribute *devattr, char *buf) | 437 | struct device_attribute *devattr, char *buf) |
437 | { | 438 | { |
438 | int index = to_sensor_dev_attr(devattr)->index; | 439 | int index = to_sensor_dev_attr(devattr)->index; |
439 | struct nct7904_data *data = dev_get_drvdata(dev); | 440 | struct nct7904_data *data = dev_get_drvdata(dev); |
@@ -443,36 +444,36 @@ static ssize_t show_mode(struct device *dev, | |||
443 | if (val < 0) | 444 | if (val < 0) |
444 | return val; | 445 | return val; |
445 | 446 | ||
446 | return sprintf(buf, "%d\n", val ? 1 : 0); | 447 | return sprintf(buf, "%d\n", val ? 2 : 1); |
447 | } | 448 | } |
448 | 449 | ||
449 | /* 2 attributes per channel: pwm and mode */ | 450 | /* 2 attributes per channel: pwm and mode */ |
450 | static SENSOR_DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, | 451 | static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, |
451 | show_pwm, store_pwm, 0); | 452 | show_pwm, store_pwm, 0); |
452 | static SENSOR_DEVICE_ATTR(fan1_mode, S_IRUGO | S_IWUSR, | 453 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, |
453 | show_mode, store_mode, 0); | 454 | show_enable, store_enable, 0); |
454 | static SENSOR_DEVICE_ATTR(fan2_pwm, S_IRUGO | S_IWUSR, | 455 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, |
455 | show_pwm, store_pwm, 1); | 456 | show_pwm, store_pwm, 1); |
456 | static SENSOR_DEVICE_ATTR(fan2_mode, S_IRUGO | S_IWUSR, | 457 | static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, |
457 | show_mode, store_mode, 1); | 458 | show_enable, store_enable, 1); |
458 | static SENSOR_DEVICE_ATTR(fan3_pwm, S_IRUGO | S_IWUSR, | 459 | static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, |
459 | show_pwm, store_pwm, 2); | 460 | show_pwm, store_pwm, 2); |
460 | static SENSOR_DEVICE_ATTR(fan3_mode, S_IRUGO | S_IWUSR, | 461 | static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, |
461 | show_mode, store_mode, 2); | 462 | show_enable, store_enable, 2); |
462 | static SENSOR_DEVICE_ATTR(fan4_pwm, S_IRUGO | S_IWUSR, | 463 | static SENSOR_DEVICE_ATTR(pwm4, S_IRUGO | S_IWUSR, |
463 | show_pwm, store_pwm, 3); | 464 | show_pwm, store_pwm, 3); |
464 | static SENSOR_DEVICE_ATTR(fan4_mode, S_IRUGO | S_IWUSR, | 465 | static SENSOR_DEVICE_ATTR(pwm4_enable, S_IRUGO | S_IWUSR, |
465 | show_mode, store_mode, 3); | 466 | show_enable, store_enable, 3); |
466 | 467 | ||
467 | static struct attribute *nct7904_fanctl_attrs[] = { | 468 | static struct attribute *nct7904_fanctl_attrs[] = { |
468 | &sensor_dev_attr_fan1_pwm.dev_attr.attr, | 469 | &sensor_dev_attr_pwm1.dev_attr.attr, |
469 | &sensor_dev_attr_fan1_mode.dev_attr.attr, | 470 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
470 | &sensor_dev_attr_fan2_pwm.dev_attr.attr, | 471 | &sensor_dev_attr_pwm2.dev_attr.attr, |
471 | &sensor_dev_attr_fan2_mode.dev_attr.attr, | 472 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, |
472 | &sensor_dev_attr_fan3_pwm.dev_attr.attr, | 473 | &sensor_dev_attr_pwm3.dev_attr.attr, |
473 | &sensor_dev_attr_fan3_mode.dev_attr.attr, | 474 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
474 | &sensor_dev_attr_fan4_pwm.dev_attr.attr, | 475 | &sensor_dev_attr_pwm4.dev_attr.attr, |
475 | &sensor_dev_attr_fan4_mode.dev_attr.attr, | 476 | &sensor_dev_attr_pwm4_enable.dev_attr.attr, |
476 | NULL | 477 | NULL |
477 | }; | 478 | }; |
478 | 479 | ||