aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/serio/i8042.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 582245c497eb..9f5c0506242f 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -923,41 +923,27 @@ static void i8042_dritek_enable(void)
923 923
924#ifdef CONFIG_PM 924#ifdef CONFIG_PM
925 925
926static bool i8042_suspended;
927
928/* 926/*
929 * Here we try to restore the original BIOS settings. We only want to 927 * Here we try to restore the original BIOS settings to avoid
930 * do that once, when we really suspend, not when we taking memory 928 * upsetting it.
931 * snapshot for swsusp (in this case we'll perform required cleanup
932 * as part of shutdown process).
933 */ 929 */
934 930
935static int i8042_suspend(struct platform_device *dev, pm_message_t state) 931static int i8042_pm_reset(struct device *dev)
936{ 932{
937 if (!i8042_suspended && state.event == PM_EVENT_SUSPEND) 933 i8042_controller_reset();
938 i8042_controller_reset();
939
940 i8042_suspended = state.event == PM_EVENT_SUSPEND ||
941 state.event == PM_EVENT_FREEZE;
942 934
943 return 0; 935 return 0;
944} 936}
945 937
946
947/* 938/*
948 * Here we try to reset everything back to a state in which suspended 939 * Here we try to reset everything back to a state we had
940 * before suspending.
949 */ 941 */
950 942
951static int i8042_resume(struct platform_device *dev) 943static int i8042_pm_restore(struct device *dev)
952{ 944{
953 int error; 945 int error;
954 946
955/*
956 * Do not bother with restoring state if we haven't suspened yet
957 */
958 if (!i8042_suspended)
959 return 0;
960
961 error = i8042_controller_check(); 947 error = i8042_controller_check();
962 if (error) 948 if (error)
963 return error; 949 return error;
@@ -1001,11 +987,18 @@ static int i8042_resume(struct platform_device *dev)
1001 if (i8042_ports[I8042_KBD_PORT_NO].serio) 987 if (i8042_ports[I8042_KBD_PORT_NO].serio)
1002 i8042_enable_kbd_port(); 988 i8042_enable_kbd_port();
1003 989
1004 i8042_suspended = false;
1005 i8042_interrupt(0, NULL); 990 i8042_interrupt(0, NULL);
1006 991
1007 return 0; 992 return 0;
1008} 993}
994
995static const struct dev_pm_ops i8042_pm_ops = {
996 .suspend = i8042_pm_reset,
997 .resume = i8042_pm_restore,
998 .poweroff = i8042_pm_reset,
999 .restore = i8042_pm_restore,
1000};
1001
1009#endif /* CONFIG_PM */ 1002#endif /* CONFIG_PM */
1010 1003
1011/* 1004/*
@@ -1251,14 +1244,13 @@ static struct platform_driver i8042_driver = {
1251 .driver = { 1244 .driver = {
1252 .name = "i8042", 1245 .name = "i8042",
1253 .owner = THIS_MODULE, 1246 .owner = THIS_MODULE,
1247#ifdef CONFIG_PM
1248 .pm = &i8042_pm_ops,
1249#endif
1254 }, 1250 },
1255 .probe = i8042_probe, 1251 .probe = i8042_probe,
1256 .remove = __devexit_p(i8042_remove), 1252 .remove = __devexit_p(i8042_remove),
1257 .shutdown = i8042_shutdown, 1253 .shutdown = i8042_shutdown,
1258#ifdef CONFIG_PM
1259 .suspend = i8042_suspend,
1260 .resume = i8042_resume,
1261#endif
1262}; 1254};
1263 1255
1264static int __init i8042_init(void) 1256static int __init i8042_init(void)