aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio/serio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/serio/serio.c')
-rw-r--r--drivers/input/serio/serio.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 17c8c63cbe1a..a15e531ec755 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -778,6 +778,19 @@ static int serio_driver_remove(struct device *dev)
778 return 0; 778 return 0;
779} 779}
780 780
781static void serio_cleanup(struct serio *serio)
782{
783 if (serio->drv && serio->drv->cleanup)
784 serio->drv->cleanup(serio);
785}
786
787static void serio_shutdown(struct device *dev)
788{
789 struct serio *serio = to_serio_port(dev);
790
791 serio_cleanup(serio);
792}
793
781static void serio_attach_driver(struct serio_driver *drv) 794static void serio_attach_driver(struct serio_driver *drv)
782{ 795{
783 int error; 796 int error;
@@ -910,11 +923,25 @@ static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buf
910 923
911#endif /* CONFIG_HOTPLUG */ 924#endif /* CONFIG_HOTPLUG */
912 925
926#ifdef CONFIG_PM
927static int serio_suspend(struct device *dev, pm_message_t state)
928{
929 if (dev->power.power_state.event != state.event) {
930 if (state.event == PM_EVENT_SUSPEND)
931 serio_cleanup(to_serio_port(dev));
932
933 dev->power.power_state = state;
934 }
935
936 return 0;
937}
938
913static int serio_resume(struct device *dev) 939static int serio_resume(struct device *dev)
914{ 940{
915 struct serio *serio = to_serio_port(dev); 941 struct serio *serio = to_serio_port(dev);
916 942
917 if (serio_reconnect_driver(serio)) { 943 if (dev->power.power_state.event != PM_EVENT_ON &&
944 serio_reconnect_driver(serio)) {
918 /* 945 /*
919 * Driver re-probing can take a while, so better let kseriod 946 * Driver re-probing can take a while, so better let kseriod
920 * deal with it. 947 * deal with it.
@@ -922,8 +949,11 @@ static int serio_resume(struct device *dev)
922 serio_rescan(serio); 949 serio_rescan(serio);
923 } 950 }
924 951
952 dev->power.power_state = PMSG_ON;
953
925 return 0; 954 return 0;
926} 955}
956#endif /* CONFIG_PM */
927 957
928/* called from serio_driver->connect/disconnect methods under serio_mutex */ 958/* called from serio_driver->connect/disconnect methods under serio_mutex */
929int serio_open(struct serio *serio, struct serio_driver *drv) 959int serio_open(struct serio *serio, struct serio_driver *drv)
@@ -974,7 +1004,11 @@ static struct bus_type serio_bus = {
974 .uevent = serio_uevent, 1004 .uevent = serio_uevent,
975 .probe = serio_driver_probe, 1005 .probe = serio_driver_probe,
976 .remove = serio_driver_remove, 1006 .remove = serio_driver_remove,
1007 .shutdown = serio_shutdown,
1008#ifdef CONFIG_PM
1009 .suspend = serio_suspend,
977 .resume = serio_resume, 1010 .resume = serio_resume,
1011#endif
978}; 1012};
979 1013
980static int __init serio_init(void) 1014static int __init serio_init(void)