Input: silead - try firmware reload after unsuccessful resume
authorJulian Sax <jsbc@gmx.de>
Fri, 5 Oct 2018 18:48:31 +0000 (11:48 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 5 Oct 2018 18:52:06 +0000 (11:52 -0700)
A certain silead controller (Chip ID: 0x56810000) loses its firmware
after suspend, causing the resume to fail. This patch tries to load
the firmware, should a resume error occur and retries the resuming.

Signed-off-by: Julian Sax <jsbc@gmx.de>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/silead.c

index ff7043f74a3d32286a6b8cdbed91f1bc3f0be12f..da1fdd16855e1126f7a80b18af48e7f39a4e1990 100644 (file)
@@ -558,20 +558,33 @@ static int __maybe_unused silead_ts_suspend(struct device *dev)
 static int __maybe_unused silead_ts_resume(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
+       bool second_try = false;
        int error, status;
 
        silead_ts_set_power(client, SILEAD_POWER_ON);
 
+ retry:
        error = silead_ts_reset(client);
        if (error)
                return error;
 
+       if (second_try) {
+               error = silead_ts_load_fw(client);
+               if (error)
+                       return error;
+       }
+
        error = silead_ts_startup(client);
        if (error)
                return error;
 
        status = silead_ts_get_status(client);
        if (status != SILEAD_STATUS_OK) {
+               if (!second_try) {
+                       second_try = true;
+                       dev_dbg(dev, "Reloading firmware after unsuccessful resume\n");
+                       goto retry;
+               }
                dev_err(dev, "Resume error, status: 0x%02x\n", status);
                return -ENODEV;
        }