diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/battery.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 057a5eb67ccc..681e26b56b11 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -687,6 +687,34 @@ static void acpi_battery_remove_fs(struct acpi_device *device) | |||
687 | } | 687 | } |
688 | 688 | ||
689 | #endif | 689 | #endif |
690 | |||
691 | static ssize_t acpi_battery_alarm_show(struct device *dev, | ||
692 | struct device_attribute *attr, | ||
693 | char *buf) | ||
694 | { | ||
695 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
696 | return sprintf(buf, "%d\n", battery->alarm * 1000); | ||
697 | } | ||
698 | |||
699 | static ssize_t acpi_battery_alarm_store(struct device *dev, | ||
700 | struct device_attribute *attr, | ||
701 | const char *buf, size_t count) | ||
702 | { | ||
703 | unsigned long x; | ||
704 | struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); | ||
705 | if (sscanf(buf, "%ld\n", &x) == 1) | ||
706 | battery->alarm = x/1000; | ||
707 | if (acpi_battery_present(battery)) | ||
708 | acpi_battery_set_alarm(battery); | ||
709 | return count; | ||
710 | } | ||
711 | |||
712 | static struct device_attribute alarm_attr = { | ||
713 | .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, | ||
714 | .show = acpi_battery_alarm_show, | ||
715 | .store = acpi_battery_alarm_store, | ||
716 | }; | ||
717 | |||
690 | /* -------------------------------------------------------------------------- | 718 | /* -------------------------------------------------------------------------- |
691 | Driver Interface | 719 | Driver Interface |
692 | -------------------------------------------------------------------------- */ | 720 | -------------------------------------------------------------------------- */ |
@@ -732,6 +760,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
732 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; | 760 | battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; |
733 | battery->bat.get_property = acpi_battery_get_property; | 761 | battery->bat.get_property = acpi_battery_get_property; |
734 | result = power_supply_register(&battery->device->dev, &battery->bat); | 762 | result = power_supply_register(&battery->device->dev, &battery->bat); |
763 | result = device_create_file(battery->bat.dev, &alarm_attr); | ||
735 | status = acpi_install_notify_handler(device->handle, | 764 | status = acpi_install_notify_handler(device->handle, |
736 | ACPI_ALL_NOTIFY, | 765 | ACPI_ALL_NOTIFY, |
737 | acpi_battery_notify, battery); | 766 | acpi_battery_notify, battery); |
@@ -767,8 +796,10 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
767 | #ifdef CONFIG_ACPI_PROCFS | 796 | #ifdef CONFIG_ACPI_PROCFS |
768 | acpi_battery_remove_fs(device); | 797 | acpi_battery_remove_fs(device); |
769 | #endif | 798 | #endif |
770 | if (battery->bat.dev) | 799 | if (battery->bat.dev) { |
800 | device_remove_file(battery->bat.dev, &alarm_attr); | ||
771 | power_supply_unregister(&battery->bat); | 801 | power_supply_unregister(&battery->bat); |
802 | } | ||
772 | mutex_destroy(&battery->lock); | 803 | mutex_destroy(&battery->lock); |
773 | kfree(battery); | 804 | kfree(battery); |
774 | return 0; | 805 | return 0; |