]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
HID: i2c-hid: check if device is there before really probing
authorDmitry Torokhov <dtor@chromium.org>
Wed, 9 May 2018 19:12:15 +0000 (12:12 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 1 Mar 2019 13:20:44 +0000 (14:20 +0100)
BugLink: http://bugs.launchpad.net/bugs/1815234
[ Upstream commit b3a81b6c4fc6730ac49e20d789a93c0faabafc98 ]

On many Chromebooks touch devices are multi-sourced; the components are
electrically compatible and one can be freely swapped for another without
changing the OS image or firmware.

To avoid bunch of scary messages when device is not actually present in the
system let's try testing basic communication with it and if there is no
response terminate probe early with -ENXIO.

Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/hid/i2c-hid/i2c-hid.c

index 95d6e1c1d97695d9a20b5856eb606873e78c858d..ed1e78796928506c86de6df703c22899412b73fe 100644 (file)
@@ -1059,6 +1059,14 @@ static int i2c_hid_probe(struct i2c_client *client,
        pm_runtime_enable(&client->dev);
        device_enable_async_suspend(&client->dev);
 
+       /* Make sure there is something at this address */
+       ret = i2c_smbus_read_byte(client);
+       if (ret < 0) {
+               dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
+               ret = -ENXIO;
+               goto err_pm;
+       }
+
        ret = i2c_hid_fetch_hid_descriptor(ihid);
        if (ret < 0)
                goto err_pm;