@@ -33,8 +33,9 @@ MODULE_AUTHOR("Paul Diefenbaugh");
3333MODULE_DESCRIPTION ("ACPI AC Adapter Driver" );
3434MODULE_LICENSE ("GPL" );
3535
36- static int acpi_ac_add (struct acpi_device * device );
37- static void acpi_ac_remove (struct acpi_device * device );
36+ static int acpi_ac_probe (struct platform_device * pdev );
37+ static void acpi_ac_remove (struct platform_device * pdev );
38+
3839static void acpi_ac_notify (acpi_handle handle , u32 event , void * data );
3940
4041static const struct acpi_device_id ac_device_ids [] = {
@@ -51,17 +52,6 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
5152static int ac_sleep_before_get_state_ms ;
5253static int ac_only ;
5354
54- static struct acpi_driver acpi_ac_driver = {
55- .name = "ac" ,
56- .class = ACPI_AC_CLASS ,
57- .ids = ac_device_ids ,
58- .ops = {
59- .add = acpi_ac_add ,
60- .remove = acpi_ac_remove ,
61- },
62- .drv .pm = & acpi_ac_pm ,
63- };
64-
6555struct acpi_ac {
6656 struct power_supply * charger ;
6757 struct power_supply_desc charger_desc ;
@@ -129,8 +119,8 @@ static enum power_supply_property ac_props[] = {
129119/* Driver Model */
130120static void acpi_ac_notify (acpi_handle handle , u32 event , void * data )
131121{
132- struct acpi_device * device = data ;
133- struct acpi_ac * ac = acpi_driver_data ( device ) ;
122+ struct acpi_ac * ac = data ;
123+ struct acpi_device * device = ac -> device ;
134124
135125 switch (event ) {
136126 default :
@@ -211,8 +201,9 @@ static const struct dmi_system_id ac_dmi_table[] __initconst = {
211201 {},
212202};
213203
214- static int acpi_ac_add (struct acpi_device * device )
204+ static int acpi_ac_probe (struct platform_device * pdev )
215205{
206+ struct acpi_device * device = ACPI_COMPANION (& pdev -> dev );
216207 struct power_supply_config psy_cfg = {};
217208 struct acpi_ac * ac ;
218209 int result ;
@@ -224,7 +215,8 @@ static int acpi_ac_add(struct acpi_device *device)
224215 ac -> device = device ;
225216 strcpy (acpi_device_name (device ), ACPI_AC_DEVICE_NAME );
226217 strcpy (acpi_device_class (device ), ACPI_AC_CLASS );
227- device -> driver_data = ac ;
218+
219+ platform_set_drvdata (pdev , ac );
228220
229221 result = acpi_ac_get_state (ac );
230222 if (result )
@@ -237,7 +229,7 @@ static int acpi_ac_add(struct acpi_device *device)
237229 ac -> charger_desc .properties = ac_props ;
238230 ac -> charger_desc .num_properties = ARRAY_SIZE (ac_props );
239231 ac -> charger_desc .get_property = get_ac_property ;
240- ac -> charger = power_supply_register (& ac -> device -> dev ,
232+ ac -> charger = power_supply_register (& pdev -> dev ,
241233 & ac -> charger_desc , & psy_cfg );
242234 if (IS_ERR (ac -> charger )) {
243235 result = PTR_ERR (ac -> charger );
@@ -251,7 +243,7 @@ static int acpi_ac_add(struct acpi_device *device)
251243 register_acpi_notifier (& ac -> battery_nb );
252244
253245 result = acpi_dev_install_notify_handler (device , ACPI_ALL_NOTIFY ,
254- acpi_ac_notify , device );
246+ acpi_ac_notify , ac );
255247 if (result )
256248 goto err_unregister ;
257249
@@ -269,7 +261,7 @@ static int acpi_ac_add(struct acpi_device *device)
269261#ifdef CONFIG_PM_SLEEP
270262static int acpi_ac_resume (struct device * dev )
271263{
272- struct acpi_ac * ac = acpi_driver_data ( to_acpi_device ( dev ) );
264+ struct acpi_ac * ac = dev_get_drvdata ( dev );
273265 unsigned int old_state ;
274266
275267 old_state = ac -> state ;
@@ -284,18 +276,28 @@ static int acpi_ac_resume(struct device *dev)
284276#define acpi_ac_resume NULL
285277#endif
286278
287- static void acpi_ac_remove (struct acpi_device * device )
279+ static void acpi_ac_remove (struct platform_device * pdev )
288280{
289- struct acpi_ac * ac = acpi_driver_data ( device );
281+ struct acpi_ac * ac = platform_get_drvdata ( pdev );
290282
291- acpi_dev_remove_notify_handler (device , ACPI_ALL_NOTIFY ,
283+ acpi_dev_remove_notify_handler (ac -> device , ACPI_ALL_NOTIFY ,
292284 acpi_ac_notify );
293285 power_supply_unregister (ac -> charger );
294286 unregister_acpi_notifier (& ac -> battery_nb );
295287
296288 kfree (ac );
297289}
298290
291+ static struct platform_driver acpi_ac_driver = {
292+ .probe = acpi_ac_probe ,
293+ .remove_new = acpi_ac_remove ,
294+ .driver = {
295+ .name = "ac" ,
296+ .acpi_match_table = ac_device_ids ,
297+ .pm = & acpi_ac_pm ,
298+ },
299+ };
300+
299301static int __init acpi_ac_init (void )
300302{
301303 int result ;
@@ -308,7 +310,7 @@ static int __init acpi_ac_init(void)
308310
309311 dmi_check_system (ac_dmi_table );
310312
311- result = acpi_bus_register_driver (& acpi_ac_driver );
313+ result = platform_driver_register (& acpi_ac_driver );
312314 if (result < 0 )
313315 return - ENODEV ;
314316
@@ -317,7 +319,7 @@ static int __init acpi_ac_init(void)
317319
318320static void __exit acpi_ac_exit (void )
319321{
320- acpi_bus_unregister_driver (& acpi_ac_driver );
322+ platform_driver_unregister (& acpi_ac_driver );
321323}
322324module_init (acpi_ac_init );
323325module_exit (acpi_ac_exit );
0 commit comments