]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.60/hid-i2c-hid-check-if-device-is-there-before-really-probing.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / hid-i2c-hid-check-if-device-is-there-before-really-probing.patch
CommitLineData
a65d4bac
GKH
1From foo@baz Sat Jul 28 10:25:26 CEST 2018
2From: Dmitry Torokhov <dtor@chromium.org>
3Date: Wed, 9 May 2018 12:12:15 -0700
4Subject: HID: i2c-hid: check if device is there before really probing
5
6From: Dmitry Torokhov <dtor@chromium.org>
7
8[ Upstream commit b3a81b6c4fc6730ac49e20d789a93c0faabafc98 ]
9
10On many Chromebooks touch devices are multi-sourced; the components are
11electrically compatible and one can be freely swapped for another without
12changing the OS image or firmware.
13
14To avoid bunch of scary messages when device is not actually present in the
15system let's try testing basic communication with it and if there is no
16response terminate probe early with -ENXIO.
17
18Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
19Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
20Signed-off-by: Jiri Kosina <jkosina@suse.cz>
21Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23---
24 drivers/hid/i2c-hid/i2c-hid.c | 8 ++++++++
25 1 file changed, 8 insertions(+)
26
27--- a/drivers/hid/i2c-hid/i2c-hid.c
28+++ b/drivers/hid/i2c-hid/i2c-hid.c
29@@ -1036,6 +1036,14 @@ static int i2c_hid_probe(struct i2c_clie
30 pm_runtime_enable(&client->dev);
31 device_enable_async_suspend(&client->dev);
32
33+ /* Make sure there is something at this address */
34+ ret = i2c_smbus_read_byte(client);
35+ if (ret < 0) {
36+ dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
37+ ret = -ENXIO;
38+ goto err_pm;
39+ }
40+
41 ret = i2c_hid_fetch_hid_descriptor(ihid);
42 if (ret < 0)
43 goto err_pm;