]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
HID: i2c-hid: call the hid driver's suspend and resume callbacks
authorAndrew Duggan <aduggan@synaptics.com>
Fri, 11 Jul 2014 23:34:18 +0000 (16:34 -0700)
committerJiri Kosina <jkosina@suse.cz>
Tue, 29 Jul 2014 09:11:31 +0000 (11:11 +0200)
Currently, the i2c-hid driver does not call the suspend, resume, and
reset_resume callbacks in the hid_driver struct when those events occur.
This means that HID drivers for i2c-hid devices will not be able to execute
commands which may be needed during suspend or resume. One example is when a
touchpad using the hid-multitouch driver gets reset by i2c-hid coming out of
resume. Since the reset_resume callback never gets called the device is never
put back into the correct input mode. This patch calls the suspend and resume
callbacks and tries to duplicate the functionality of the usb-hid driver.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Signed-off-by: Vincent Huang <vincent.huang@tw.synaptics.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/i2c-hid/i2c-hid.c

index 21aafc8f48c87d483110da79b6e85481d35d904c..747d54421e733a407949f50762bb62c5e596fb34 100644 (file)
@@ -1054,21 +1054,29 @@ static int i2c_hid_remove(struct i2c_client *client)
 static int i2c_hid_suspend(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
+       struct i2c_hid *ihid = i2c_get_clientdata(client);
+       struct hid_device *hid = ihid->hid;
+       int ret = 0;
 
        disable_irq(client->irq);
        if (device_may_wakeup(&client->dev))
                enable_irq_wake(client->irq);
 
+       if (hid->driver && hid->driver->suspend)
+               ret = hid->driver->suspend(hid, PMSG_SUSPEND);
+
        /* Save some power */
        i2c_hid_set_power(client, I2C_HID_PWR_SLEEP);
 
-       return 0;
+       return ret;
 }
 
 static int i2c_hid_resume(struct device *dev)
 {
        int ret;
        struct i2c_client *client = to_i2c_client(dev);
+       struct i2c_hid *ihid = i2c_get_clientdata(client);
+       struct hid_device *hid = ihid->hid;
 
        enable_irq(client->irq);
        ret = i2c_hid_hwreset(client);
@@ -1078,6 +1086,11 @@ static int i2c_hid_resume(struct device *dev)
        if (device_may_wakeup(&client->dev))
                disable_irq_wake(client->irq);
 
+       if (hid->driver && hid->driver->reset_resume) {
+               ret = hid->driver->reset_resume(hid);
+               return ret;
+       }
+
        return 0;
 }
 #endif