Input: elan_i2c - check if device is there before really probing
Subsystems (2)
Dmitry Torokhov
maintainerPATCH v2 1/1 Input: elan_i2c - check if device is there before really probing
Before trying to properly initialize the touchpad and generate bunch of errors, let's first see it there is anything at the given address. If we get error, fail silently with -ENXIO.
---
v2: switched over to i2c_smbus_read_byte() as Guenter suggested
drivers/input/mouse/elan_i2c_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/mouse/elan_i2c_core.c +7 -0
@@ -1091,6 +1091,13 @@ static int elan_probe(struct i2c_client *client,return error; } +/* Make sure there is something at this address */ + error =i2c_smbus_read_byte (client); +if (error <0 ) { +dev_dbg (&client->dev,"nothing at this address: %d\n" , error); +return -ENXIO ; + } +/* Initialize the touchpad. */ error =elan_initialize (data);if (error)
Signature · 5 lines
2.13.0.rc2.291.g57267f2277-goog -- Dmitry
drivers/input/mouse/elan_i2c_core.c static int elan_probe(struct i2c_client *client, · line 1098
Quoted 5 lines · Dmitry Torokhov
drivers/input/mouse/elan_i2c_core.c +5
-0+/* Make sure there is something at this address */ + error =i2c_smbus_read_byte (client); +if (error <0 ) { +dev_dbg (&client->dev,"nothing at this address: %d\n" , error); +return -ENXIO ;
You could return the real error code here: 'return error'
Dmitry Torokhov
maintainerQuoted 10 lines · Fabio Estevam
drivers/input/mouse/elan_i2c_core.c static int elan_probe(struct i2c_client *client, · line 1098
Quoted 5 lines · Dmitry Torokhov
drivers/input/mouse/elan_i2c_core.c +5
-0+/* Make sure there is something at this address */ + error =i2c_smbus_read_byte (client); +if (error <0 ) { +dev_dbg (&client->dev,"nothing at this address: %d\n" , error); +return -ENXIO ;You could return the real error code here: 'return error'
That is the point of the patch - we want to fail silently if the device is not actually there and fails even the simplest communication. Driver core treats ENXIO and ENODEV as special and does not log errors.
Thanks.
Signature · 1 line
Dmitry
Quoted 3 lines · Dmitry Torokhov
That is the point of the patch - we want to fail silently if the device is not actually there and fails even the simplest communication. Driver core treats ENXIO and ENODEV as special and does not log errors.
Got it, thanks for the explanation!
Quoted 5 lines · Dmitry Torokhov
Before trying to properly initialize the touchpad and generate bunch of errors, let's first see it there is anything at the given address. If we get error, fail silently with
-ENXIO.Signed-off-by Dmitry Torokhov <[email protected]>
Quoted 25 lines
---
v2: switched over to
i2c_smbus_read_byte()as Guenter suggesteddrivers/input/mouse/elan_i2c_core.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/input/mouse/elan_i2c_core.c +7
-0@@ -1091,6 +1091,13 @@ static int elan_probe(struct i2c_client *client,return error; } +/* Make sure there is something at this address */ + error =i2c_smbus_read_byte (client); +if (error <0 ) { +dev_dbg (&client->dev,"nothing at this address: %d\n" , error); +return -ENXIO ; + } +/* Initialize the touchpad. */ error =elan_initialize (data);if (error)