@@ -169,6 +169,7 @@ static struct acpi_driver acpi_button_driver = {
169169};
170170
171171struct acpi_button {
172+ struct acpi_device * adev ;
172173 unsigned int type ;
173174 struct input_dev * input ;
174175 char phys [32 ]; /* for input device */
@@ -202,9 +203,9 @@ static int acpi_lid_evaluate_state(struct acpi_device *device)
202203 return lid_state ? 1 : 0 ;
203204}
204205
205- static int acpi_lid_notify_state (struct acpi_device * device , int state )
206+ static int acpi_lid_notify_state (struct acpi_button * button , int state )
206207{
207- struct acpi_button * button = acpi_driver_data ( device ) ;
208+ struct acpi_device * device = button -> adev ;
208209 ktime_t next_report ;
209210 bool do_update ;
210211
@@ -287,18 +288,18 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
287288static int __maybe_unused acpi_button_state_seq_show (struct seq_file * seq ,
288289 void * offset )
289290{
290- struct acpi_device * device = seq -> private ;
291+ struct acpi_button * button = seq -> private ;
291292 int state ;
292293
293- state = acpi_lid_evaluate_state (device );
294+ state = acpi_lid_evaluate_state (button -> adev );
294295 seq_printf (seq , "state: %s\n" ,
295296 state < 0 ? "unsupported" : (state ? "open" : "closed" ));
296297 return 0 ;
297298}
298299
299- static int acpi_button_add_fs (struct acpi_device * device )
300+ static int acpi_button_add_fs (struct acpi_button * button )
300301{
301- struct acpi_button * button = acpi_driver_data ( device ) ;
302+ struct acpi_device * device = button -> adev ;
302303 struct proc_dir_entry * entry = NULL ;
303304 int ret = 0 ;
304305
@@ -333,7 +334,7 @@ static int acpi_button_add_fs(struct acpi_device *device)
333334 /* create /proc/acpi/button/lid/LID/state */
334335 entry = proc_create_single_data (ACPI_BUTTON_FILE_STATE , S_IRUGO ,
335336 acpi_device_dir (device ), acpi_button_state_seq_show ,
336- device );
337+ button );
337338 if (!entry ) {
338339 ret = - ENODEV ;
339340 goto remove_dev_dir ;
@@ -355,9 +356,9 @@ static int acpi_button_add_fs(struct acpi_device *device)
355356 goto done ;
356357}
357358
358- static int acpi_button_remove_fs (struct acpi_device * device )
359+ static int acpi_button_remove_fs (struct acpi_button * button )
359360{
360- struct acpi_button * button = acpi_driver_data ( device ) ;
361+ struct acpi_device * device = button -> adev ;
361362
362363 if (button -> type != ACPI_BUTTON_TYPE_LID )
363364 return 0 ;
@@ -385,9 +386,10 @@ int acpi_lid_open(void)
385386}
386387EXPORT_SYMBOL (acpi_lid_open );
387388
388- static int acpi_lid_update_state (struct acpi_device * device ,
389+ static int acpi_lid_update_state (struct acpi_button * button ,
389390 bool signal_wakeup )
390391{
392+ struct acpi_device * device = button -> adev ;
391393 int state ;
392394
393395 state = acpi_lid_evaluate_state (device );
@@ -397,19 +399,17 @@ static int acpi_lid_update_state(struct acpi_device *device,
397399 if (state && signal_wakeup )
398400 acpi_pm_wakeup_event (& device -> dev );
399401
400- return acpi_lid_notify_state (device , state );
402+ return acpi_lid_notify_state (button , state );
401403}
402404
403- static void acpi_lid_initialize_state (struct acpi_device * device )
405+ static void acpi_lid_initialize_state (struct acpi_button * button )
404406{
405- struct acpi_button * button = acpi_driver_data (device );
406-
407407 switch (lid_init_state ) {
408408 case ACPI_BUTTON_LID_INIT_OPEN :
409- (void )acpi_lid_notify_state (device , 1 );
409+ (void )acpi_lid_notify_state (button , 1 );
410410 break ;
411411 case ACPI_BUTTON_LID_INIT_METHOD :
412- (void )acpi_lid_update_state (device , false);
412+ (void )acpi_lid_update_state (button , false);
413413 break ;
414414 case ACPI_BUTTON_LID_INIT_IGNORE :
415415 default :
@@ -421,26 +421,25 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
421421
422422static void acpi_lid_notify (acpi_handle handle , u32 event , void * data )
423423{
424- struct acpi_device * device = data ;
425- struct acpi_button * button ;
424+ struct acpi_button * button = data ;
425+ struct acpi_device * device = button -> adev ;
426426
427427 if (event != ACPI_BUTTON_NOTIFY_STATUS ) {
428428 acpi_handle_debug (device -> handle , "Unsupported event [0x%x]\n" ,
429429 event );
430430 return ;
431431 }
432432
433- button = acpi_driver_data (device );
434433 if (!button -> lid_state_initialized )
435434 return ;
436435
437- acpi_lid_update_state (device , true);
436+ acpi_lid_update_state (button , true);
438437}
439438
440439static void acpi_button_notify (acpi_handle handle , u32 event , void * data )
441440{
442- struct acpi_device * device = data ;
443- struct acpi_button * button ;
441+ struct acpi_button * button = data ;
442+ struct acpi_device * device = button -> adev ;
444443 struct input_dev * input ;
445444 int keycode ;
446445
@@ -457,7 +456,6 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
457456
458457 acpi_pm_wakeup_event (& device -> dev );
459458
460- button = acpi_driver_data (device );
461459 if (button -> suspended || event == ACPI_BUTTON_NOTIFY_WAKE )
462460 return ;
463461
@@ -505,7 +503,7 @@ static int acpi_button_resume(struct device *dev)
505503 if (button -> type == ACPI_BUTTON_TYPE_LID ) {
506504 button -> last_state = !!acpi_lid_evaluate_state (device );
507505 button -> last_time = ktime_get ();
508- acpi_lid_initialize_state (device );
506+ acpi_lid_initialize_state (button );
509507 }
510508
511509 if (button -> type == ACPI_BUTTON_TYPE_POWER ) {
@@ -521,12 +519,12 @@ static int acpi_button_resume(struct device *dev)
521519
522520static int acpi_lid_input_open (struct input_dev * input )
523521{
524- struct acpi_device * device = input_get_drvdata (input );
525- struct acpi_button * button = acpi_driver_data ( device ) ;
522+ struct acpi_button * button = input_get_drvdata (input );
523+ struct acpi_device * device = button -> adev ;
526524
527525 button -> last_state = !!acpi_lid_evaluate_state (device );
528526 button -> last_time = ktime_get ();
529- acpi_lid_initialize_state (device );
527+ acpi_lid_initialize_state (button );
530528
531529 return 0 ;
532530}
@@ -551,6 +549,7 @@ static int acpi_button_add(struct acpi_device *device)
551549
552550 device -> driver_data = button ;
553551
552+ button -> adev = device ;
554553 button -> input = input = input_allocate_device ();
555554 if (!input ) {
556555 error = - ENOMEM ;
@@ -587,7 +586,7 @@ static int acpi_button_add(struct acpi_device *device)
587586 }
588587
589588 if (!error )
590- error = acpi_button_add_fs (device );
589+ error = acpi_button_add_fs (button );
591590
592591 if (error ) {
593592 input_free_device (input );
@@ -617,7 +616,7 @@ static int acpi_button_add(struct acpi_device *device)
617616 break ;
618617 }
619618
620- input_set_drvdata (input , device );
619+ input_set_drvdata (input , button );
621620 error = input_register_device (input );
622621 if (error ) {
623622 input_free_device (input );
@@ -628,17 +627,17 @@ static int acpi_button_add(struct acpi_device *device)
628627 case ACPI_BUS_TYPE_POWER_BUTTON :
629628 status = acpi_install_fixed_event_handler (ACPI_EVENT_POWER_BUTTON ,
630629 acpi_button_event ,
631- device );
630+ button );
632631 break ;
633632 case ACPI_BUS_TYPE_SLEEP_BUTTON :
634633 status = acpi_install_fixed_event_handler (ACPI_EVENT_SLEEP_BUTTON ,
635634 acpi_button_event ,
636- device );
635+ button );
637636 break ;
638637 default :
639638 status = acpi_install_notify_handler (device -> handle ,
640639 ACPI_ALL_NOTIFY , handler ,
641- device );
640+ button );
642641 break ;
643642 }
644643 if (ACPI_FAILURE (status )) {
@@ -661,7 +660,7 @@ static int acpi_button_add(struct acpi_device *device)
661660err_input_unregister :
662661 input_unregister_device (input );
663662err_remove_fs :
664- acpi_button_remove_fs (device );
663+ acpi_button_remove_fs (button );
665664err_free_button :
666665 kfree (button );
667666 return error ;
@@ -689,7 +688,7 @@ static void acpi_button_remove(struct acpi_device *device)
689688 }
690689 acpi_os_wait_events_complete ();
691690
692- acpi_button_remove_fs (device );
691+ acpi_button_remove_fs (button );
693692 input_unregister_device (button -> input );
694693 kfree (button );
695694}
0 commit comments