]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Input: serio - add fast reconnect option
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 3 Mar 2017 19:47:40 +0000 (11:47 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 25 Mar 2017 17:37:26 +0000 (10:37 -0700)
Devices connected to serio bus are quite slow, and to improve apparent
speed of resume process, serio core resumes (reconnects) its devices
asynchronously, by posting port reconnect requests to a workqueue.
Unfortunately this means that if there is a dependent device of a given
serio port (for example SMBus part of touchpad connected via both PS/2 and
SMBus), we do not have a good way of ensuring resume order.

This change allows drivers to define "fast reconnect" handlers that would
be called in-line during system resume. Drivers need to ensure that these
handlers are truly "fast".

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/serio/serio.c
include/linux/serio.h

index 048ae748c4d1f22c19a392dec949f715dc3b525a..30d6230d48f7c45d216f7fcdcb04056cc7448df1 100644 (file)
@@ -953,12 +953,24 @@ static int serio_suspend(struct device *dev)
 static int serio_resume(struct device *dev)
 {
        struct serio *serio = to_serio_port(dev);
+       int error = -ENOENT;
 
-       /*
-        * Driver reconnect can take a while, so better let kseriod
-        * deal with it.
-        */
-       serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
+       mutex_lock(&serio->drv_mutex);
+       if (serio->drv && serio->drv->fast_reconnect) {
+               error = serio->drv->fast_reconnect(serio);
+               if (error && error != -ENOENT)
+                       dev_warn(dev, "fast reconnect failed with error %d\n",
+                                error);
+       }
+       mutex_unlock(&serio->drv_mutex);
+
+       if (error) {
+               /*
+                * Driver reconnect can take a while, so better let
+                * kseriod deal with it.
+                */
+               serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
+       }
 
        return 0;
 }
index c733cff44e18a74f3949032d1413356df0a9e226..138a5efe863a3cb569de62fe00f93bbe38051279 100644 (file)
@@ -77,6 +77,7 @@ struct serio_driver {
        irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
        int  (*connect)(struct serio *, struct serio_driver *drv);
        int  (*reconnect)(struct serio *);
+       int  (*fast_reconnect)(struct serio *);
        void (*disconnect)(struct serio *);
        void (*cleanup)(struct serio *);