diff options
author | Dmitry Torokhov <dtor@chromium.org> | 2018-05-09 12:12:15 -0700 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2018-05-15 11:15:05 +0200 |
commit | b3a81b6c4fc6730ac49e20d789a93c0faabafc98 (patch) | |
tree | 2aa89b56e850590c14576648ef3affbed89112aa /drivers/hid | |
parent | 2dcc8197fefc7eb1d255f1856fc0f642c38cf78d (diff) | |
download | linux-b3a81b6c4fc6730ac49e20d789a93c0faabafc98.tar.bz2 |
HID: i2c-hid: check if device is there before really probing
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>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/i2c-hid/i2c-hid.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index cf71c33ac2b2..c5ad918e36e3 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -1060,6 +1060,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; |