aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 12:59:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 12:59:26 -0400
commitf934fb19ef34730263e6afc01e8ec27a8a71470f (patch)
tree6988fa3734adb98ab989657c56b7e31e94e723f8 /drivers/input/serio
parent3988ba0708e98b4bafc9034aa476775520bee708 (diff)
parent72d18a7b9e1a3a9511bae78fc7f0932ae01d5d73 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: add driver for Atmel integrated touchscreen controller Input: ads7846 - optimize order of calculating Rt in ads7846_rx() Input: ads7846 - fix sparse endian warnings Input: uinput - remove duplicate include Input: serio - offload resume to kseriod Input: serio - mark serio_register_driver() __must_check
Diffstat (limited to 'drivers/input/serio')
-rw-r--r--drivers/input/serio/serio.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 78f2abb5c11b..2f12d60eee3b 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -63,8 +63,9 @@ static LIST_HEAD(serio_list);
63static struct bus_type serio_bus; 63static struct bus_type serio_bus;
64 64
65static void serio_add_port(struct serio *serio); 65static void serio_add_port(struct serio *serio);
66static void serio_reconnect_port(struct serio *serio); 66static int serio_reconnect_port(struct serio *serio);
67static void serio_disconnect_port(struct serio *serio); 67static void serio_disconnect_port(struct serio *serio);
68static void serio_reconnect_chain(struct serio *serio);
68static void serio_attach_driver(struct serio_driver *drv); 69static void serio_attach_driver(struct serio_driver *drv);
69 70
70static int serio_connect_driver(struct serio *serio, struct serio_driver *drv) 71static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
@@ -161,6 +162,7 @@ static void serio_find_driver(struct serio *serio)
161enum serio_event_type { 162enum serio_event_type {
162 SERIO_RESCAN_PORT, 163 SERIO_RESCAN_PORT,
163 SERIO_RECONNECT_PORT, 164 SERIO_RECONNECT_PORT,
165 SERIO_RECONNECT_CHAIN,
164 SERIO_REGISTER_PORT, 166 SERIO_REGISTER_PORT,
165 SERIO_ATTACH_DRIVER, 167 SERIO_ATTACH_DRIVER,
166}; 168};
@@ -315,6 +317,10 @@ static void serio_handle_event(void)
315 serio_find_driver(event->object); 317 serio_find_driver(event->object);
316 break; 318 break;
317 319
320 case SERIO_RECONNECT_CHAIN:
321 serio_reconnect_chain(event->object);
322 break;
323
318 case SERIO_ATTACH_DRIVER: 324 case SERIO_ATTACH_DRIVER:
319 serio_attach_driver(event->object); 325 serio_attach_driver(event->object);
320 break; 326 break;
@@ -470,7 +476,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
470 if (!strncmp(buf, "none", count)) { 476 if (!strncmp(buf, "none", count)) {
471 serio_disconnect_port(serio); 477 serio_disconnect_port(serio);
472 } else if (!strncmp(buf, "reconnect", count)) { 478 } else if (!strncmp(buf, "reconnect", count)) {
473 serio_reconnect_port(serio); 479 serio_reconnect_chain(serio);
474 } else if (!strncmp(buf, "rescan", count)) { 480 } else if (!strncmp(buf, "rescan", count)) {
475 serio_disconnect_port(serio); 481 serio_disconnect_port(serio);
476 serio_find_driver(serio); 482 serio_find_driver(serio);
@@ -620,14 +626,30 @@ static void serio_destroy_port(struct serio *serio)
620} 626}
621 627
622/* 628/*
629 * Reconnect serio port (re-initialize attached device).
630 * If reconnect fails (old device is no longer attached or
631 * there was no device to begin with) we do full rescan in
632 * hope of finding a driver for the port.
633 */
634static int serio_reconnect_port(struct serio *serio)
635{
636 int error = serio_reconnect_driver(serio);
637
638 if (error) {
639 serio_disconnect_port(serio);
640 serio_find_driver(serio);
641 }
642
643 return error;
644}
645
646/*
623 * Reconnect serio port and all its children (re-initialize attached devices) 647 * Reconnect serio port and all its children (re-initialize attached devices)
624 */ 648 */
625static void serio_reconnect_port(struct serio *serio) 649static void serio_reconnect_chain(struct serio *serio)
626{ 650{
627 do { 651 do {
628 if (serio_reconnect_driver(serio)) { 652 if (serio_reconnect_port(serio)) {
629 serio_disconnect_port(serio);
630 serio_find_driver(serio);
631 /* Ok, old children are now gone, we are done */ 653 /* Ok, old children are now gone, we are done */
632 break; 654 break;
633 } 655 }
@@ -673,7 +695,7 @@ void serio_rescan(struct serio *serio)
673 695
674void serio_reconnect(struct serio *serio) 696void serio_reconnect(struct serio *serio)
675{ 697{
676 serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT); 698 serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN);
677} 699}
678 700
679/* 701/*
@@ -927,19 +949,16 @@ static int serio_suspend(struct device *dev, pm_message_t state)
927 949
928static int serio_resume(struct device *dev) 950static int serio_resume(struct device *dev)
929{ 951{
930 struct serio *serio = to_serio_port(dev); 952 /*
931 953 * Driver reconnect can take a while, so better let kseriod
932 if (dev->power.power_state.event != PM_EVENT_ON && 954 * deal with it.
933 serio_reconnect_driver(serio)) { 955 */
934 /* 956 if (dev->power.power_state.event != PM_EVENT_ON) {
935 * Driver re-probing can take a while, so better let kseriod 957 dev->power.power_state = PMSG_ON;
936 * deal with it. 958 serio_queue_event(to_serio_port(dev), NULL,
937 */ 959 SERIO_RECONNECT_PORT);
938 serio_rescan(serio);
939 } 960 }
940 961
941 dev->power.power_state = PMSG_ON;
942
943 return 0; 962 return 0;
944} 963}
945#endif /* CONFIG_PM */ 964#endif /* CONFIG_PM */