@@ -33,8 +33,9 @@ MODULE_AUTHOR("Paul Diefenbaugh");
33
33
MODULE_DESCRIPTION ("ACPI AC Adapter Driver" );
34
34
MODULE_LICENSE ("GPL" );
35
35
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
+
38
39
static void acpi_ac_notify (acpi_handle handle , u32 event , void * data );
39
40
40
41
static const struct acpi_device_id ac_device_ids [] = {
@@ -51,17 +52,6 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
51
52
static int ac_sleep_before_get_state_ms ;
52
53
static int ac_only ;
53
54
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
-
65
55
struct acpi_ac {
66
56
struct power_supply * charger ;
67
57
struct power_supply_desc charger_desc ;
@@ -129,8 +119,8 @@ static enum power_supply_property ac_props[] = {
129
119
/* Driver Model */
130
120
static void acpi_ac_notify (acpi_handle handle , u32 event , void * data )
131
121
{
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 ;
134
124
135
125
switch (event ) {
136
126
default :
@@ -211,8 +201,9 @@ static const struct dmi_system_id ac_dmi_table[] __initconst = {
211
201
{},
212
202
};
213
203
214
- static int acpi_ac_add (struct acpi_device * device )
204
+ static int acpi_ac_probe (struct platform_device * pdev )
215
205
{
206
+ struct acpi_device * device = ACPI_COMPANION (& pdev -> dev );
216
207
struct power_supply_config psy_cfg = {};
217
208
struct acpi_ac * ac ;
218
209
int result ;
@@ -224,7 +215,8 @@ static int acpi_ac_add(struct acpi_device *device)
224
215
ac -> device = device ;
225
216
strcpy (acpi_device_name (device ), ACPI_AC_DEVICE_NAME );
226
217
strcpy (acpi_device_class (device ), ACPI_AC_CLASS );
227
- device -> driver_data = ac ;
218
+
219
+ platform_set_drvdata (pdev , ac );
228
220
229
221
result = acpi_ac_get_state (ac );
230
222
if (result )
@@ -237,7 +229,7 @@ static int acpi_ac_add(struct acpi_device *device)
237
229
ac -> charger_desc .properties = ac_props ;
238
230
ac -> charger_desc .num_properties = ARRAY_SIZE (ac_props );
239
231
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 ,
241
233
& ac -> charger_desc , & psy_cfg );
242
234
if (IS_ERR (ac -> charger )) {
243
235
result = PTR_ERR (ac -> charger );
@@ -251,7 +243,7 @@ static int acpi_ac_add(struct acpi_device *device)
251
243
register_acpi_notifier (& ac -> battery_nb );
252
244
253
245
result = acpi_dev_install_notify_handler (device , ACPI_ALL_NOTIFY ,
254
- acpi_ac_notify , device );
246
+ acpi_ac_notify , ac );
255
247
if (result )
256
248
goto err_unregister ;
257
249
@@ -269,7 +261,7 @@ static int acpi_ac_add(struct acpi_device *device)
269
261
#ifdef CONFIG_PM_SLEEP
270
262
static int acpi_ac_resume (struct device * dev )
271
263
{
272
- struct acpi_ac * ac = acpi_driver_data ( to_acpi_device ( dev ) );
264
+ struct acpi_ac * ac = dev_get_drvdata ( dev );
273
265
unsigned int old_state ;
274
266
275
267
old_state = ac -> state ;
@@ -284,18 +276,28 @@ static int acpi_ac_resume(struct device *dev)
284
276
#define acpi_ac_resume NULL
285
277
#endif
286
278
287
- static void acpi_ac_remove (struct acpi_device * device )
279
+ static void acpi_ac_remove (struct platform_device * pdev )
288
280
{
289
- struct acpi_ac * ac = acpi_driver_data ( device );
281
+ struct acpi_ac * ac = platform_get_drvdata ( pdev );
290
282
291
- acpi_dev_remove_notify_handler (device , ACPI_ALL_NOTIFY ,
283
+ acpi_dev_remove_notify_handler (ac -> device , ACPI_ALL_NOTIFY ,
292
284
acpi_ac_notify );
293
285
power_supply_unregister (ac -> charger );
294
286
unregister_acpi_notifier (& ac -> battery_nb );
295
287
296
288
kfree (ac );
297
289
}
298
290
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
+
299
301
static int __init acpi_ac_init (void )
300
302
{
301
303
int result ;
@@ -308,7 +310,7 @@ static int __init acpi_ac_init(void)
308
310
309
311
dmi_check_system (ac_dmi_table );
310
312
311
- result = acpi_bus_register_driver (& acpi_ac_driver );
313
+ result = platform_driver_register (& acpi_ac_driver );
312
314
if (result < 0 )
313
315
return - ENODEV ;
314
316
@@ -317,7 +319,7 @@ static int __init acpi_ac_init(void)
317
319
318
320
static void __exit acpi_ac_exit (void )
319
321
{
320
- acpi_bus_unregister_driver (& acpi_ac_driver );
322
+ platform_driver_unregister (& acpi_ac_driver );
321
323
}
322
324
module_init (acpi_ac_init );
323
325
module_exit (acpi_ac_exit );
0 commit comments