Skip to content

Commit 1066625

Browse files
mwilczyrafaeljw
authored andcommitted
ACPI: battery: Install Notify() handler directly
Modify the ACPI battery driver to install its own Notify() handler directly instead of providing an ACPI driver .notify() callback. This will allow the ACPI driver .notify() callback to be eliminated and it will allow the battery driver to be switched over to a platform one in the future. While at it, fix up whitespaces in acpi_battery_remove(). Suggested-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Michal Wilczynski <[email protected]> [ rjw: Subject and changelog edits, whitespace adjustments ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 6f70168 commit 1066625

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

drivers/acpi/battery.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
10341034
}
10351035

10361036
/* Driver Interface */
1037-
static void acpi_battery_notify(struct acpi_device *device, u32 event)
1037+
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
10381038
{
1039+
struct acpi_device *device = data;
10391040
struct acpi_battery *battery = acpi_driver_data(device);
10401041
struct power_supply *old;
10411042

@@ -1212,13 +1213,22 @@ static int acpi_battery_add(struct acpi_device *device)
12121213

12131214
device_init_wakeup(&device->dev, 1);
12141215

1215-
return result;
1216+
result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
1217+
acpi_battery_notify);
1218+
if (result)
1219+
goto fail_pm;
1220+
1221+
return 0;
12161222

1223+
fail_pm:
1224+
device_init_wakeup(&device->dev, 0);
1225+
unregister_pm_notifier(&battery->pm_nb);
12171226
fail:
12181227
sysfs_remove_battery(battery);
12191228
mutex_destroy(&battery->lock);
12201229
mutex_destroy(&battery->sysfs_lock);
12211230
kfree(battery);
1231+
12221232
return result;
12231233
}
12241234

@@ -1228,10 +1238,16 @@ static void acpi_battery_remove(struct acpi_device *device)
12281238

12291239
if (!device || !acpi_driver_data(device))
12301240
return;
1231-
device_init_wakeup(&device->dev, 0);
1241+
12321242
battery = acpi_driver_data(device);
1243+
1244+
acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
1245+
acpi_battery_notify);
1246+
1247+
device_init_wakeup(&device->dev, 0);
12331248
unregister_pm_notifier(&battery->pm_nb);
12341249
sysfs_remove_battery(battery);
1250+
12351251
mutex_destroy(&battery->lock);
12361252
mutex_destroy(&battery->sysfs_lock);
12371253
kfree(battery);
@@ -1264,11 +1280,9 @@ static struct acpi_driver acpi_battery_driver = {
12641280
.name = "battery",
12651281
.class = ACPI_BATTERY_CLASS,
12661282
.ids = battery_device_ids,
1267-
.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
12681283
.ops = {
12691284
.add = acpi_battery_add,
12701285
.remove = acpi_battery_remove,
1271-
.notify = acpi_battery_notify,
12721286
},
12731287
.drv.pm = &acpi_battery_pm,
12741288
};

0 commit comments

Comments
 (0)