History

eeepc-laptop: Fix hwmon interface

Creates a name file in the sysfs directory, that is needed for the libsensors library to work. Also rename fan1_pwm to pwm1 and scale its value as needed. This fixes bug #11520: http://bugzilla.kernel.org/show_bug.cgi?id=11520

Corentin Chary committed 18 years ago

Commit 04dcd841 parent 69849371 file · +13 −3Browse files

Unified · Split

drivers/misc/eeepc-laptop.c+13−3
@@ -450,12 +450,14 @@ static int eeepc_get_fan_pwm(void) · 449 unmodified lines
450 int value = 0;450 int value = 0;
451 451
452 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);452 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);
453 value = value * 255 / 100;
453 return (value);454 return (value);
454}455}
455 456
456static void eeepc_set_fan_pwm(int value)457static void eeepc_set_fan_pwm(int value)
457{458{
458 value = SENSORS_LIMIT(value, 0, 100);459 value = SENSORS_LIMIT(value, 0, 255);
460 value = value * 100 / 255;
459 ec_write(EEEPC_EC_SC02, value);461 ec_write(EEEPC_EC_SC02, value);
460}462}
461 463
@@ -520,15 +522,23 @@ static ssize_t show_sys_hwmon(int (*get)(void), char *buf) · 58 unmodified lines
520 static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0);522 static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0);
521 523
522EEEPC_CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, eeepc_get_fan_rpm, NULL);524EEEPC_CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, eeepc_get_fan_rpm, NULL);
523EEEPC_CREATE_SENSOR_ATTR(fan1_pwm, S_IRUGO | S_IWUSR,525EEEPC_CREATE_SENSOR_ATTR(pwm1, S_IRUGO | S_IWUSR,
524 eeepc_get_fan_pwm, eeepc_set_fan_pwm);526 eeepc_get_fan_pwm, eeepc_set_fan_pwm);
525EEEPC_CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,527EEEPC_CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
526 eeepc_get_fan_ctrl, eeepc_set_fan_ctrl);528 eeepc_get_fan_ctrl, eeepc_set_fan_ctrl);
527 529
530static ssize_t
531show_name(struct device *dev, struct device_attribute *attr, char *buf)
532{
533 return sprintf(buf, "eeepc\n");
534}
535static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
536
528static struct attribute *hwmon_attributes[] = {537static struct attribute *hwmon_attributes[] = {
529 &sensor_dev_attr_fan1_pwm.dev_attr.attr,538 &sensor_dev_attr_pwm1.dev_attr.attr,
530 &sensor_dev_attr_fan1_input.dev_attr.attr,539 &sensor_dev_attr_fan1_input.dev_attr.attr,
531 &sensor_dev_attr_pwm1_enable.dev_attr.attr,540 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
541 &sensor_dev_attr_name.dev_attr.attr,
532 NULL542 NULL
533};543};
534 544

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t