Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+31 -30
+2 -2
Documentation/hwmon/nct7904
··· 35 35 temp[2-9]_input CPU temperatures (1/1000 degree, 36 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 39 Setting SmartFan mode is supported only if it has been 40 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 44 The driver checks sensor control registers and does not export the sensors 45 45 that are not enabled. Anyway, a sensor that is enabled may actually be not
+29 -28
drivers/hwmon/nct7904.c
··· 412 412 return sprintf(buf, "%d\n", val); 413 413 } 414 414 415 - static ssize_t store_mode(struct device *dev, struct device_attribute *devattr, 416 - const char *buf, size_t count) 415 + static ssize_t store_enable(struct device *dev, 416 + struct device_attribute *devattr, 417 + const char *buf, size_t count) 417 418 { 418 419 int index = to_sensor_dev_attr(devattr)->index; 419 420 struct nct7904_data *data = dev_get_drvdata(dev); ··· 423 422 424 423 if (kstrtoul(buf, 10, &val) < 0) 425 424 return -EINVAL; 426 - if (val > 1 || (val && !data->fan_mode[index])) 425 + if (val < 1 || val > 2 || (val == 2 && !data->fan_mode[index])) 427 426 return -EINVAL; 428 427 429 428 ret = nct7904_write_reg(data, BANK_3, FANCTL1_FMR_REG + index, 430 - val ? data->fan_mode[index] : 0); 429 + val == 2 ? data->fan_mode[index] : 0); 431 430 432 431 return ret ? ret : count; 433 432 } 434 433 435 - /* Return 0 for manual mode or 1 for SmartFan mode */ 436 - static ssize_t show_mode(struct device *dev, 437 - struct device_attribute *devattr, char *buf) 434 + /* Return 1 for manual mode or 2 for SmartFan mode */ 435 + static ssize_t show_enable(struct device *dev, 436 + struct device_attribute *devattr, char *buf) 438 437 { 439 438 int index = to_sensor_dev_attr(devattr)->index; 440 439 struct nct7904_data *data = dev_get_drvdata(dev); ··· 444 443 if (val < 0) 445 444 return val; 446 445 447 - return sprintf(buf, "%d\n", val ? 1 : 0); 446 + return sprintf(buf, "%d\n", val ? 2 : 1); 448 447 } 449 448 450 449 /* 2 attributes per channel: pwm and mode */ 451 - static SENSOR_DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, 450 + static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, 452 451 show_pwm, store_pwm, 0); 453 - static SENSOR_DEVICE_ATTR(fan1_mode, S_IRUGO | S_IWUSR, 454 - show_mode, store_mode, 0); 455 - static SENSOR_DEVICE_ATTR(fan2_pwm, S_IRUGO | S_IWUSR, 452 + static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, 453 + show_enable, store_enable, 0); 454 + static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, 456 455 show_pwm, store_pwm, 1); 457 - static SENSOR_DEVICE_ATTR(fan2_mode, S_IRUGO | S_IWUSR, 458 - show_mode, store_mode, 1); 459 - static SENSOR_DEVICE_ATTR(fan3_pwm, S_IRUGO | S_IWUSR, 456 + static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, 457 + show_enable, store_enable, 1); 458 + static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, 460 459 show_pwm, store_pwm, 2); 461 - static SENSOR_DEVICE_ATTR(fan3_mode, S_IRUGO | S_IWUSR, 462 - show_mode, store_mode, 2); 463 - static SENSOR_DEVICE_ATTR(fan4_pwm, S_IRUGO | S_IWUSR, 460 + static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, 461 + show_enable, store_enable, 2); 462 + static SENSOR_DEVICE_ATTR(pwm4, S_IRUGO | S_IWUSR, 464 463 show_pwm, store_pwm, 3); 465 - static SENSOR_DEVICE_ATTR(fan4_mode, S_IRUGO | S_IWUSR, 466 - show_mode, store_mode, 3); 464 + static SENSOR_DEVICE_ATTR(pwm4_enable, S_IRUGO | S_IWUSR, 465 + show_enable, store_enable, 3); 467 466 468 467 static struct attribute *nct7904_fanctl_attrs[] = { 469 - &sensor_dev_attr_fan1_pwm.dev_attr.attr, 470 - &sensor_dev_attr_fan1_mode.dev_attr.attr, 471 - &sensor_dev_attr_fan2_pwm.dev_attr.attr, 472 - &sensor_dev_attr_fan2_mode.dev_attr.attr, 473 - &sensor_dev_attr_fan3_pwm.dev_attr.attr, 474 - &sensor_dev_attr_fan3_mode.dev_attr.attr, 475 - &sensor_dev_attr_fan4_pwm.dev_attr.attr, 476 - &sensor_dev_attr_fan4_mode.dev_attr.attr, 468 + &sensor_dev_attr_pwm1.dev_attr.attr, 469 + &sensor_dev_attr_pwm1_enable.dev_attr.attr, 470 + &sensor_dev_attr_pwm2.dev_attr.attr, 471 + &sensor_dev_attr_pwm2_enable.dev_attr.attr, 472 + &sensor_dev_attr_pwm3.dev_attr.attr, 473 + &sensor_dev_attr_pwm3_enable.dev_attr.attr, 474 + &sensor_dev_attr_pwm4.dev_attr.attr, 475 + &sensor_dev_attr_pwm4_enable.dev_attr.attr, 477 476 NULL 478 477 }; 479 478