aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r--drivers/acpi/battery.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 00b0728efe82..24bf4dca88cc 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -59,6 +59,9 @@ ACPI_MODULE_NAME("acpi_battery")
59MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME); 59MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME);
60MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
61 61
62extern struct proc_dir_entry *acpi_lock_battery_dir(void);
63extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
64
62static int acpi_battery_add(struct acpi_device *device); 65static int acpi_battery_add(struct acpi_device *device);
63static int acpi_battery_remove(struct acpi_device *device, int type); 66static int acpi_battery_remove(struct acpi_device *device, int type);
64 67
@@ -108,7 +111,7 @@ struct acpi_battery_trips {
108}; 111};
109 112
110struct acpi_battery { 113struct acpi_battery {
111 acpi_handle handle; 114 struct acpi_device * device;
112 struct acpi_battery_flags flags; 115 struct acpi_battery_flags flags;
113 struct acpi_battery_trips trips; 116 struct acpi_battery_trips trips;
114 unsigned long alarm; 117 unsigned long alarm;
@@ -138,7 +141,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
138 141
139 /* Evalute _BIF */ 142 /* Evalute _BIF */
140 143
141 status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); 144 status = acpi_evaluate_object(battery->device->handle, "_BIF", NULL, &buffer);
142 if (ACPI_FAILURE(status)) { 145 if (ACPI_FAILURE(status)) {
143 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); 146 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
144 return -ENODEV; 147 return -ENODEV;
@@ -171,7 +174,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
171 } 174 }
172 175
173 end: 176 end:
174 acpi_os_free(buffer.pointer); 177 kfree(buffer.pointer);
175 178
176 if (!result) 179 if (!result)
177 (*bif) = (struct acpi_battery_info *)data.pointer; 180 (*bif) = (struct acpi_battery_info *)data.pointer;
@@ -198,7 +201,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
198 201
199 /* Evalute _BST */ 202 /* Evalute _BST */
200 203
201 status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); 204 status = acpi_evaluate_object(battery->device->handle, "_BST", NULL, &buffer);
202 if (ACPI_FAILURE(status)) { 205 if (ACPI_FAILURE(status)) {
203 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); 206 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
204 return -ENODEV; 207 return -ENODEV;
@@ -231,7 +234,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
231 } 234 }
232 235
233 end: 236 end:
234 acpi_os_free(buffer.pointer); 237 kfree(buffer.pointer);
235 238
236 if (!result) 239 if (!result)
237 (*bst) = (struct acpi_battery_status *)data.pointer; 240 (*bst) = (struct acpi_battery_status *)data.pointer;
@@ -255,7 +258,7 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
255 258
256 arg0.integer.value = alarm; 259 arg0.integer.value = alarm;
257 260
258 status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); 261 status = acpi_evaluate_object(battery->device->handle, "_BTP", &arg_list, NULL);
259 if (ACPI_FAILURE(status)) 262 if (ACPI_FAILURE(status))
260 return -ENODEV; 263 return -ENODEV;
261 264
@@ -278,9 +281,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
278 if (!battery) 281 if (!battery)
279 return -EINVAL; 282 return -EINVAL;
280 283
281 result = acpi_bus_get_device(battery->handle, &device); 284 device = battery->device;
282 if (result)
283 return result;
284 285
285 result = acpi_bus_get_status(device); 286 result = acpi_bus_get_status(device);
286 if (result) 287 if (result)
@@ -305,7 +306,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
305 306
306 /* See if alarms are supported, and if so, set default */ 307 /* See if alarms are supported, and if so, set default */
307 308
308 status = acpi_get_handle(battery->handle, "_BTP", &handle); 309 status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
309 if (ACPI_SUCCESS(status)) { 310 if (ACPI_SUCCESS(status)) {
310 battery->flags.alarm = 1; 311 battery->flags.alarm = 1;
311 acpi_battery_set_alarm(battery, battery->trips.warning); 312 acpi_battery_set_alarm(battery, battery->trips.warning);
@@ -662,12 +663,13 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
662 if (!battery) 663 if (!battery)
663 return; 664 return;
664 665
665 if (acpi_bus_get_device(handle, &device)) 666 device = battery->device;
666 return;
667 667
668 switch (event) { 668 switch (event) {
669 case ACPI_BATTERY_NOTIFY_STATUS: 669 case ACPI_BATTERY_NOTIFY_STATUS:
670 case ACPI_BATTERY_NOTIFY_INFO: 670 case ACPI_BATTERY_NOTIFY_INFO:
671 case ACPI_NOTIFY_BUS_CHECK:
672 case ACPI_NOTIFY_DEVICE_CHECK:
671 acpi_battery_check(battery); 673 acpi_battery_check(battery);
672 acpi_bus_generate_event(device, event, battery->flags.present); 674 acpi_bus_generate_event(device, event, battery->flags.present);
673 break; 675 break;
@@ -695,7 +697,7 @@ static int acpi_battery_add(struct acpi_device *device)
695 return -ENOMEM; 697 return -ENOMEM;
696 memset(battery, 0, sizeof(struct acpi_battery)); 698 memset(battery, 0, sizeof(struct acpi_battery));
697 699
698 battery->handle = device->handle; 700 battery->device = device;
699 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); 701 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
700 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 702 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
701 acpi_driver_data(device) = battery; 703 acpi_driver_data(device) = battery;
@@ -708,8 +710,8 @@ static int acpi_battery_add(struct acpi_device *device)
708 if (result) 710 if (result)
709 goto end; 711 goto end;
710 712
711 status = acpi_install_notify_handler(battery->handle, 713 status = acpi_install_notify_handler(device->handle,
712 ACPI_DEVICE_NOTIFY, 714 ACPI_ALL_NOTIFY,
713 acpi_battery_notify, battery); 715 acpi_battery_notify, battery);
714 if (ACPI_FAILURE(status)) { 716 if (ACPI_FAILURE(status)) {
715 result = -ENODEV; 717 result = -ENODEV;
@@ -740,8 +742,8 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
740 742
741 battery = (struct acpi_battery *)acpi_driver_data(device); 743 battery = (struct acpi_battery *)acpi_driver_data(device);
742 744
743 status = acpi_remove_notify_handler(battery->handle, 745 status = acpi_remove_notify_handler(device->handle,
744 ACPI_DEVICE_NOTIFY, 746 ACPI_ALL_NOTIFY,
745 acpi_battery_notify); 747 acpi_battery_notify);
746 748
747 acpi_battery_remove_fs(device); 749 acpi_battery_remove_fs(device);
@@ -753,17 +755,15 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
753 755
754static int __init acpi_battery_init(void) 756static int __init acpi_battery_init(void)
755{ 757{
756 int result = 0; 758 int result;
757
758 759
759 acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); 760 acpi_battery_dir = acpi_lock_battery_dir();
760 if (!acpi_battery_dir) 761 if (!acpi_battery_dir)
761 return -ENODEV; 762 return -ENODEV;
762 acpi_battery_dir->owner = THIS_MODULE;
763 763
764 result = acpi_bus_register_driver(&acpi_battery_driver); 764 result = acpi_bus_register_driver(&acpi_battery_driver);
765 if (result < 0) { 765 if (result < 0) {
766 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 766 acpi_unlock_battery_dir(acpi_battery_dir);
767 return -ENODEV; 767 return -ENODEV;
768 } 768 }
769 769
@@ -775,7 +775,7 @@ static void __exit acpi_battery_exit(void)
775 775
776 acpi_bus_unregister_driver(&acpi_battery_driver); 776 acpi_bus_unregister_driver(&acpi_battery_driver);
777 777
778 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 778 acpi_unlock_battery_dir(acpi_battery_dir);
779 779
780 return; 780 return;
781} 781}