]>
Commit | Line | Data |
---|---|---|
a65d4bac GKH |
1 | From foo@baz Sat Jul 28 10:25:26 CEST 2018 |
2 | From: Dmitry Torokhov <dtor@chromium.org> | |
3 | Date: Wed, 9 May 2018 12:12:15 -0700 | |
4 | Subject: HID: i2c-hid: check if device is there before really probing | |
5 | ||
6 | From: Dmitry Torokhov <dtor@chromium.org> | |
7 | ||
8 | [ Upstream commit b3a81b6c4fc6730ac49e20d789a93c0faabafc98 ] | |
9 | ||
10 | On many Chromebooks touch devices are multi-sourced; the components are | |
11 | electrically compatible and one can be freely swapped for another without | |
12 | changing the OS image or firmware. | |
13 | ||
14 | To avoid bunch of scary messages when device is not actually present in the | |
15 | system let's try testing basic communication with it and if there is no | |
16 | response terminate probe early with -ENXIO. | |
17 | ||
18 | Signed-off-by: Dmitry Torokhov <dtor@chromium.org> | |
19 | Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> | |
20 | Signed-off-by: Jiri Kosina <jkosina@suse.cz> | |
21 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
22 | Signed-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; |