diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2007-09-26 11:44:00 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-09-27 15:50:23 -0400 |
commit | 8bd955320661cfd03ab8d5574d96aa684acd38f6 (patch) | |
tree | 9a940cee66ac99f5f2564e33ddcf6307f992a7f2 /drivers/acpi/sbs.c | |
parent | 66e4b72bfa7347fd1017b9b82dce77a410f2e4a1 (diff) |
ACPI: SBS: Add sysfs alarm
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sbs.c')
-rw-r--r-- | drivers/acpi/sbs.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index aae65e8f70f3..90fd09c65f95 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -386,8 +386,6 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
386 | return result; | 386 | return result; |
387 | } | 387 | } |
388 | 388 | ||
389 | #ifdef CONFIG_ACPI_PROCFS | ||
390 | |||
391 | static int acpi_battery_get_alarm(struct acpi_battery *battery) | 389 | static int acpi_battery_get_alarm(struct acpi_battery *battery) |
392 | { | 390 | { |
393 | return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, | 391 | return acpi_smbus_read(battery->sbs->hc, SMBUS_READ_WORD, |
@@ -424,8 +422,6 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) | |||
424 | return ret; | 422 | return ret; |
425 | } | 423 | } |
426 | 424 | ||
427 | #endif | ||
428 | |||
429 | static int acpi_ac_get_present(struct acpi_sbs *sbs) | 425 | static int acpi_ac_get_present(struct acpi_sbs *sbs) |
430 | { | 426 | { |
431 | int result; | 427 | int result; |
@@ -438,6 +434,36 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs) | |||
438 | return result; | 434 | return result; |
439 | } | 435 | } |
440 | 436 | ||
437 | static ssize_t acpi_battery_alarm_show(struct device *dev, | ||
438 | struct device_attribute *attr, | ||
439 | char *buf) | ||
440 | { | ||
441 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
442 | acpi_battery_get_alarm(battery); | ||
443 | return sprintf(buf, "%d\n", battery->alarm_capacity * | ||
444 | acpi_battery_scale(battery) * 1000); | ||
445 | } | ||
446 | |||
447 | static ssize_t acpi_battery_alarm_store(struct device *dev, | ||
448 | struct device_attribute *attr, | ||
449 | const char *buf, size_t count) | ||
450 | { | ||
451 | unsigned long x; | ||
452 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
453 | if (sscanf(buf, "%ld\n", &x) == 1) | ||
454 | battery->alarm_capacity = x / | ||
455 | (1000 * acpi_battery_scale(battery)); | ||
456 | if (battery->present) | ||
457 | acpi_battery_set_alarm(battery); | ||
458 | return count; | ||
459 | } | ||
460 | |||
461 | static struct device_attribute alarm_attr = { | ||
462 | .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, | ||
463 | .show = acpi_battery_alarm_show, | ||
464 | .store = acpi_battery_alarm_store, | ||
465 | }; | ||
466 | |||
441 | /* -------------------------------------------------------------------------- | 467 | /* -------------------------------------------------------------------------- |
442 | FS Interface (/proc/acpi) | 468 | FS Interface (/proc/acpi) |
443 | -------------------------------------------------------------------------- */ | 469 | -------------------------------------------------------------------------- */ |
@@ -782,6 +808,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
782 | } | 808 | } |
783 | battery->bat.get_property = acpi_sbs_battery_get_property; | 809 | battery->bat.get_property = acpi_sbs_battery_get_property; |
784 | result = power_supply_register(&sbs->device->dev, &battery->bat); | 810 | result = power_supply_register(&sbs->device->dev, &battery->bat); |
811 | device_create_file(battery->bat.dev, &alarm_attr); | ||
785 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", | 812 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", |
786 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 813 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
787 | battery->name, sbs->battery->present ? "present" : "absent"); | 814 | battery->name, sbs->battery->present ? "present" : "absent"); |
@@ -791,6 +818,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
791 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) | 818 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) |
792 | { | 819 | { |
793 | if (sbs->battery[id].bat.dev) | 820 | if (sbs->battery[id].bat.dev) |
821 | device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); | ||
794 | power_supply_unregister(&sbs->battery[id].bat); | 822 | power_supply_unregister(&sbs->battery[id].bat); |
795 | #ifdef CONFIG_ACPI_PROCFS | 823 | #ifdef CONFIG_ACPI_PROCFS |
796 | if (sbs->battery[id].proc_entry) { | 824 | if (sbs->battery[id].proc_entry) { |