@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL");
3434
3535static int acpi_ac_add (struct acpi_device * device );
3636static void acpi_ac_remove (struct acpi_device * device );
37- static void acpi_ac_notify (struct acpi_device * device , u32 event );
37+ static void acpi_ac_notify (acpi_handle handle , u32 event , void * data );
3838
3939static const struct acpi_device_id ac_device_ids [] = {
4040 {"ACPI0003" , 0 },
@@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = {
5454 .name = "ac" ,
5555 .class = ACPI_AC_CLASS ,
5656 .ids = ac_device_ids ,
57- .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS ,
5857 .ops = {
5958 .add = acpi_ac_add ,
6059 .remove = acpi_ac_remove ,
61- .notify = acpi_ac_notify ,
6260 },
6361 .drv .pm = & acpi_ac_pm ,
6462};
@@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = {
128126};
129127
130128/* Driver Model */
131- static void acpi_ac_notify (struct acpi_device * device , u32 event )
129+ static void acpi_ac_notify (acpi_handle handle , u32 event , void * data )
132130{
131+ struct acpi_device * device = data ;
133132 struct acpi_ac * ac = acpi_driver_data (device );
134133
135134 if (!ac )
@@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device)
235234
236235 result = acpi_ac_get_state (ac );
237236 if (result )
238- goto end ;
237+ goto err_release_ac ;
239238
240239 psy_cfg .drv_data = ac ;
241240
@@ -248,17 +247,27 @@ static int acpi_ac_add(struct acpi_device *device)
248247 & ac -> charger_desc , & psy_cfg );
249248 if (IS_ERR (ac -> charger )) {
250249 result = PTR_ERR (ac -> charger );
251- goto end ;
250+ goto err_release_ac ;
252251 }
253252
254253 pr_info ("%s [%s] (%s)\n" , acpi_device_name (device ),
255254 acpi_device_bid (device ), ac -> state ? "on-line" : "off-line" );
256255
257256 ac -> battery_nb .notifier_call = acpi_ac_battery_notify ;
258257 register_acpi_notifier (& ac -> battery_nb );
259- end :
258+
259+ result = acpi_dev_install_notify_handler (device , ACPI_ALL_NOTIFY ,
260+ acpi_ac_notify );
260261 if (result )
261- kfree (ac );
262+ goto err_unregister ;
263+
264+ return 0 ;
265+
266+ err_unregister :
267+ power_supply_unregister (ac -> charger );
268+ unregister_acpi_notifier (& ac -> battery_nb );
269+ err_release_ac :
270+ kfree (ac );
262271
263272 return result ;
264273}
@@ -297,6 +306,8 @@ static void acpi_ac_remove(struct acpi_device *device)
297306
298307 ac = acpi_driver_data (device );
299308
309+ acpi_dev_remove_notify_handler (device , ACPI_ALL_NOTIFY ,
310+ acpi_ac_notify );
300311 power_supply_unregister (ac -> charger );
301312 unregister_acpi_notifier (& ac -> battery_nb );
302313
0 commit comments