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

i8k: Drop all labels

Labels are known to be wrong for several Dell laptops.
For example, a single fan may be shown as right fan when in reality
it sits on the left side of the chassis. Drop all labels to avoid
such inaccuracies. Users can select labels in the sensors configuration
file instead if desired.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: Andreas Mohr <andi@lisas.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Guenter Roeck and committed by
Greg Kroah-Hartman
b12ce5f2 3915fc87

+13 -34
+13 -34
drivers/char/i8k.c
··· 542 542 return err < 0 ? -EIO : count; 543 543 } 544 544 545 - static ssize_t i8k_hwmon_show_label(struct device *dev, 546 - struct device_attribute *devattr, 547 - char *buf) 548 - { 549 - static const char *labels[3] = { 550 - "CPU", 551 - "Left Fan", 552 - "Right Fan", 553 - }; 554 - int index = to_sensor_dev_attr(devattr)->index; 555 - 556 - return sprintf(buf, "%s\n", labels[index]); 557 - } 558 - 559 545 static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0); 560 546 static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1); 561 547 static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2); ··· 554 568 I8K_FAN_RIGHT); 555 569 static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, 556 570 i8k_hwmon_set_pwm, I8K_FAN_RIGHT); 557 - static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, i8k_hwmon_show_label, NULL, 0); 558 - static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, i8k_hwmon_show_label, NULL, 1); 559 - static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_label, NULL, 2); 560 571 561 572 static struct attribute *i8k_attrs[] = { 562 573 &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */ 563 - &sensor_dev_attr_temp1_label.dev_attr.attr, /* 1 */ 564 - &sensor_dev_attr_temp2_input.dev_attr.attr, /* 2 */ 565 - &sensor_dev_attr_temp3_input.dev_attr.attr, /* 3 */ 566 - &sensor_dev_attr_temp4_input.dev_attr.attr, /* 4 */ 567 - &sensor_dev_attr_fan1_input.dev_attr.attr, /* 5 */ 568 - &sensor_dev_attr_pwm1.dev_attr.attr, /* 6 */ 569 - &sensor_dev_attr_fan1_label.dev_attr.attr, /* 7 */ 570 - &sensor_dev_attr_fan2_input.dev_attr.attr, /* 8 */ 571 - &sensor_dev_attr_pwm2.dev_attr.attr, /* 9 */ 572 - &sensor_dev_attr_fan2_label.dev_attr.attr, /* 10 */ 574 + &sensor_dev_attr_temp2_input.dev_attr.attr, /* 1 */ 575 + &sensor_dev_attr_temp3_input.dev_attr.attr, /* 2 */ 576 + &sensor_dev_attr_temp4_input.dev_attr.attr, /* 3 */ 577 + &sensor_dev_attr_fan1_input.dev_attr.attr, /* 4 */ 578 + &sensor_dev_attr_pwm1.dev_attr.attr, /* 5 */ 579 + &sensor_dev_attr_fan2_input.dev_attr.attr, /* 6 */ 580 + &sensor_dev_attr_pwm2.dev_attr.attr, /* 7 */ 573 581 NULL 574 582 }; 575 583 576 584 static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, 577 585 int index) 578 586 { 579 - if ((index == 0 || index == 1) && 580 - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) 587 + if (index == 0 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) 581 588 return 0; 582 - if (index == 2 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) 589 + if (index == 1 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) 583 590 return 0; 584 - if (index == 3 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) 591 + if (index == 2 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) 585 592 return 0; 586 - if (index == 4 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) 593 + if (index == 3 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) 587 594 return 0; 588 - if (index >= 5 && index <= 7 && 595 + if (index >= 4 && index <= 5 && 589 596 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) 590 597 return 0; 591 - if (index >= 8 && index <= 10 && 598 + if (index >= 6 && index <= 7 && 592 599 !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) 593 600 return 0; 594 601