aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/ideapad-laptop.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index edd3656b07b9..70fb5ba7e47a 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -469,9 +469,8 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv)
469 rfkill_set_hw_state(priv->rfk[i], hw_blocked); 469 rfkill_set_hw_state(priv->rfk[i], hw_blocked);
470} 470}
471 471
472static int ideapad_register_rfkill(struct acpi_device *adev, int dev) 472static int ideapad_register_rfkill(struct ideapad_private *priv, int dev)
473{ 473{
474 struct ideapad_private *priv = dev_get_drvdata(&adev->dev);
475 int ret; 474 int ret;
476 unsigned long sw_blocked; 475 unsigned long sw_blocked;
477 476
@@ -483,8 +482,10 @@ static int ideapad_register_rfkill(struct acpi_device *adev, int dev)
483 return 0; 482 return 0;
484 } 483 }
485 484
486 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name, &adev->dev, 485 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name,
487 ideapad_rfk_data[dev].type, &ideapad_rfk_ops, 486 &priv->adev->dev,
487 ideapad_rfk_data[dev].type,
488 &ideapad_rfk_ops,
488 (void *)(long)dev); 489 (void *)(long)dev);
489 if (!priv->rfk[dev]) 490 if (!priv->rfk[dev])
490 return -ENOMEM; 491 return -ENOMEM;
@@ -505,10 +506,8 @@ static int ideapad_register_rfkill(struct acpi_device *adev, int dev)
505 return 0; 506 return 0;
506} 507}
507 508
508static void ideapad_unregister_rfkill(struct acpi_device *adev, int dev) 509static void ideapad_unregister_rfkill(struct ideapad_private *priv, int dev)
509{ 510{
510 struct ideapad_private *priv = dev_get_drvdata(&adev->dev);
511
512 if (!priv->rfk[dev]) 511 if (!priv->rfk[dev])
513 return; 512 return;
514 513
@@ -762,13 +761,12 @@ static const struct acpi_device_id ideapad_device_ids[] = {
762}; 761};
763MODULE_DEVICE_TABLE(acpi, ideapad_device_ids); 762MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
764 763
765static void ideapad_sync_touchpad_state(struct acpi_device *adev) 764static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
766{ 765{
767 struct ideapad_private *priv = dev_get_drvdata(&adev->dev);
768 unsigned long value; 766 unsigned long value;
769 767
770 /* Without reading from EC touchpad LED doesn't switch state */ 768 /* Without reading from EC touchpad LED doesn't switch state */
771 if (!read_ec_data(adev->handle, VPCCMD_R_TOUCHPAD, &value)) { 769 if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
772 /* Some IdeaPads don't really turn off touchpad - they only 770 /* Some IdeaPads don't really turn off touchpad - they only
773 * switch the LED state. We (de)activate KBC AUX port to turn 771 * switch the LED state. We (de)activate KBC AUX port to turn
774 * touchpad off and on. We send KEY_TOUCHPAD_OFF and 772 * touchpad off and on. We send KEY_TOUCHPAD_OFF and
@@ -812,12 +810,12 @@ static int ideapad_acpi_add(struct acpi_device *adev)
812 810
813 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) { 811 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
814 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg)) 812 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg))
815 ideapad_register_rfkill(adev, i); 813 ideapad_register_rfkill(priv, i);
816 else 814 else
817 priv->rfk[i] = NULL; 815 priv->rfk[i] = NULL;
818 } 816 }
819 ideapad_sync_rfk_state(priv); 817 ideapad_sync_rfk_state(priv);
820 ideapad_sync_touchpad_state(adev); 818 ideapad_sync_touchpad_state(priv);
821 819
822 if (!acpi_video_backlight_support()) { 820 if (!acpi_video_backlight_support()) {
823 ret = ideapad_backlight_init(priv); 821 ret = ideapad_backlight_init(priv);
@@ -829,7 +827,7 @@ static int ideapad_acpi_add(struct acpi_device *adev)
829 827
830backlight_failed: 828backlight_failed:
831 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) 829 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
832 ideapad_unregister_rfkill(adev, i); 830 ideapad_unregister_rfkill(priv, i);
833 ideapad_input_exit(priv); 831 ideapad_input_exit(priv);
834input_failed: 832input_failed:
835 ideapad_debugfs_exit(priv); 833 ideapad_debugfs_exit(priv);
@@ -847,7 +845,7 @@ static int ideapad_acpi_remove(struct acpi_device *adev)
847 845
848 ideapad_backlight_exit(priv); 846 ideapad_backlight_exit(priv);
849 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) 847 for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++)
850 ideapad_unregister_rfkill(adev, i); 848 ideapad_unregister_rfkill(priv, i);
851 ideapad_input_exit(priv); 849 ideapad_input_exit(priv);
852 ideapad_debugfs_exit(priv); 850 ideapad_debugfs_exit(priv);
853 ideapad_platform_exit(priv); 851 ideapad_platform_exit(priv);
@@ -882,7 +880,7 @@ static void ideapad_acpi_notify(struct acpi_device *adev, u32 event)
882 ideapad_input_report(priv, vpc_bit); 880 ideapad_input_report(priv, vpc_bit);
883 break; 881 break;
884 case 5: 882 case 5:
885 ideapad_sync_touchpad_state(adev); 883 ideapad_sync_touchpad_state(priv);
886 break; 884 break;
887 case 4: 885 case 4:
888 ideapad_backlight_notify_brightness(priv); 886 ideapad_backlight_notify_brightness(priv);
@@ -906,8 +904,14 @@ static void ideapad_acpi_notify(struct acpi_device *adev, u32 event)
906#ifdef CONFIG_PM_SLEEP 904#ifdef CONFIG_PM_SLEEP
907static int ideapad_acpi_resume(struct device *device) 905static int ideapad_acpi_resume(struct device *device)
908{ 906{
909 ideapad_sync_rfk_state(ideapad_priv); 907 struct ideapad_private *priv;
910 ideapad_sync_touchpad_state(to_acpi_device(device)); 908
909 if (!device)
910 return -EINVAL;
911 priv = dev_get_drvdata(device);
912
913 ideapad_sync_rfk_state(priv);
914 ideapad_sync_touchpad_state(priv);
911 return 0; 915 return 0;
912} 916}
913 917