Commit ebd7768d authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: i8042 - switch to using dev_pm_ops

Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent ae78e0e0
...@@ -923,41 +923,27 @@ static void i8042_dritek_enable(void) ...@@ -923,41 +923,27 @@ static void i8042_dritek_enable(void)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static bool i8042_suspended;
/* /*
* Here we try to restore the original BIOS settings. We only want to * Here we try to restore the original BIOS settings to avoid
* do that once, when we really suspend, not when we taking memory * upsetting it.
* snapshot for swsusp (in this case we'll perform required cleanup
* as part of shutdown process).
*/ */
static int i8042_suspend(struct platform_device *dev, pm_message_t state) static int i8042_pm_reset(struct device *dev)
{ {
if (!i8042_suspended && state.event == PM_EVENT_SUSPEND)
i8042_controller_reset(); i8042_controller_reset();
i8042_suspended = state.event == PM_EVENT_SUSPEND ||
state.event == PM_EVENT_FREEZE;
return 0; return 0;
} }
/* /*
* Here we try to reset everything back to a state in which suspended * Here we try to reset everything back to a state we had
* before suspending.
*/ */
static int i8042_resume(struct platform_device *dev) static int i8042_pm_restore(struct device *dev)
{ {
int error; int error;
/*
* Do not bother with restoring state if we haven't suspened yet
*/
if (!i8042_suspended)
return 0;
error = i8042_controller_check(); error = i8042_controller_check();
if (error) if (error)
return error; return error;
...@@ -1001,11 +987,18 @@ static int i8042_resume(struct platform_device *dev) ...@@ -1001,11 +987,18 @@ static int i8042_resume(struct platform_device *dev)
if (i8042_ports[I8042_KBD_PORT_NO].serio) if (i8042_ports[I8042_KBD_PORT_NO].serio)
i8042_enable_kbd_port(); i8042_enable_kbd_port();
i8042_suspended = false;
i8042_interrupt(0, NULL); i8042_interrupt(0, NULL);
return 0; return 0;
} }
static const struct dev_pm_ops i8042_pm_ops = {
.suspend = i8042_pm_reset,
.resume = i8042_pm_restore,
.poweroff = i8042_pm_reset,
.restore = i8042_pm_restore,
};
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
/* /*
...@@ -1251,14 +1244,13 @@ static struct platform_driver i8042_driver = { ...@@ -1251,14 +1244,13 @@ static struct platform_driver i8042_driver = {
.driver = { .driver = {
.name = "i8042", .name = "i8042",
.owner = THIS_MODULE, .owner = THIS_MODULE,
#ifdef CONFIG_PM
.pm = &i8042_pm_ops,
#endif
}, },
.probe = i8042_probe, .probe = i8042_probe,
.remove = __devexit_p(i8042_remove), .remove = __devexit_p(i8042_remove),
.shutdown = i8042_shutdown, .shutdown = i8042_shutdown,
#ifdef CONFIG_PM
.suspend = i8042_suspend,
.resume = i8042_resume,
#endif
}; };
static int __init i8042_init(void) static int __init i8042_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment