Skip to content

Commit e171735

Browse files
whotdtor
authored andcommitted
Input: wacom_w8001 - handle touch error case correctly
If a device failed at the pen setup and gets a zero reply from the touch device, we need to return an error. Otherwise we have a device with nothing but a name and the EV_KEY and EV_ABS bits. Signed-off-by: Peter Hutterer <[email protected]> Acked-by: Benjamin Tissoires <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent ec9acda commit e171735

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

drivers/input/touchscreen/wacom_w8001.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static int w8001_setup(struct w8001 *w8001)
385385
struct input_dev *dev = w8001->dev;
386386
struct w8001_coord coord;
387387
struct w8001_touch_query touch;
388-
int error;
388+
int error, err_pen, err_touch;
389389

390390
error = w8001_command(w8001, W8001_CMD_STOP, false);
391391
if (error)
@@ -400,8 +400,8 @@ static int w8001_setup(struct w8001 *w8001)
400400
__set_bit(INPUT_PROP_DIRECT, dev->propbit);
401401

402402
/* penabled? */
403-
error = w8001_command(w8001, W8001_CMD_QUERY, true);
404-
if (!error) {
403+
err_pen = w8001_command(w8001, W8001_CMD_QUERY, true);
404+
if (!err_pen) {
405405
__set_bit(BTN_TOUCH, dev->keybit);
406406
__set_bit(BTN_TOOL_PEN, dev->keybit);
407407
__set_bit(BTN_TOOL_RUBBER, dev->keybit);
@@ -426,13 +426,12 @@ static int w8001_setup(struct w8001 *w8001)
426426
}
427427

428428
/* Touch enabled? */
429-
error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
429+
err_touch = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
430430

431-
/*
432-
* Some non-touch devices may reply to the touch query. But their
433-
* second byte is empty, which indicates touch is not supported.
434-
*/
435-
if (!error && w8001->response[1]) {
431+
if (!err_touch && !w8001->response[1])
432+
err_touch = -ENXIO;
433+
434+
if (!err_touch) {
436435
__set_bit(BTN_TOUCH, dev->keybit);
437436
__set_bit(BTN_TOOL_FINGER, dev->keybit);
438437

@@ -491,7 +490,7 @@ static int w8001_setup(struct w8001 *w8001)
491490

492491
strlcat(w8001->name, " Touchscreen", sizeof(w8001->name));
493492

494-
return 0;
493+
return !err_pen || !err_touch ? 0 : -ENXIO;
495494
}
496495

497496
/*

0 commit comments

Comments
 (0)