linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Peter Hutterer <peter.hutterer@who-t.net>
Cc: linux-input@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	Ping Cheng <pinglinux@gmail.com>,
	Jason Gerecke <killertofu@gmail.com>
Subject: Re: [PATCH 3/5] Input: wacom_w8001 - handle touch error case correctly
Date: Tue, 1 Dec 2015 14:01:56 -0800	[thread overview]
Message-ID: <20151201220156.GE3740@dtor-ws> (raw)
In-Reply-To: <1448854696-32625-3-git-send-email-peter.hutterer@who-t.net>

On Mon, Nov 30, 2015 at 01:38:14PM +1000, Peter Hutterer wrote:
> 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.

But if device does not fail pen setup (err_pen == 0) we should not
return error, which you will !err_pen || !err_touch will be 1.

Additionally we better return proper error codes to the upper layer
instead of a boolean value.

> 
> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
> Acked-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
> ---
>  drivers/input/touchscreen/wacom_w8001.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
> index 222006e..cdebf8e 100644
> --- a/drivers/input/touchscreen/wacom_w8001.c
> +++ b/drivers/input/touchscreen/wacom_w8001.c
> @@ -385,7 +385,7 @@ static int w8001_setup(struct w8001 *w8001)
>  	struct input_dev *dev = w8001->dev;
>  	struct w8001_coord coord;
>  	struct w8001_touch_query touch;
> -	int error;
> +	int error, err_pen, err_touch;
>  
>  	error = w8001_command(w8001, W8001_CMD_STOP, false);
>  	if (error)
> @@ -400,8 +400,8 @@ static int w8001_setup(struct w8001 *w8001)
>  	__set_bit(INPUT_PROP_DIRECT, dev->propbit);
>  
>  	/* penabled? */
> -	error = w8001_command(w8001, W8001_CMD_QUERY, true);
> -	if (!error) {
> +	err_pen = w8001_command(w8001, W8001_CMD_QUERY, true);
> +	if (!err_pen) {
>  		__set_bit(BTN_TOUCH, dev->keybit);
>  		__set_bit(BTN_TOOL_PEN, dev->keybit);
>  		__set_bit(BTN_TOOL_RUBBER, dev->keybit);
> @@ -426,13 +426,15 @@ static int w8001_setup(struct w8001 *w8001)
>  	}
>  
>  	/* Touch enabled? */
> -	error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
> +	err_touch = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
>  
>  	/*
>  	 * Some non-touch devices may reply to the touch query. But their
>  	 * second byte is empty, which indicates touch is not supported.
>  	 */
> -	if (!error && w8001->response[1]) {
> +	if (!err_touch && w8001->response[1]) {
> +		err_touch = 1;

Huh? Let's do:

	if (!err_touch && !w8001->response[1])
		err_touch = -ENXIO;

	if (!err_touch) {
		...
	}

> +
>  		__set_bit(BTN_TOUCH, dev->keybit);
>  		__set_bit(BTN_TOOL_FINGER, dev->keybit);
>  
> @@ -491,7 +493,7 @@ static int w8001_setup(struct w8001 *w8001)
>  
>  	strlcat(w8001->name, " Touchscreen", sizeof(w8001->name));
>  
> -	return 0;
> +	return !err_pen || !err_touch;

	return !err_pen || !err_touch ? 0 : -ENXIO;

>  }
>  
>  /*
> -- 
> 2.5.0
> 

Thanks.

-- 
Dmitry

  reply	other threads:[~2015-12-01 22:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30  3:38 [PATCH 1/5] Input: wacom_w8001 - use __set_bit for evbits Peter Hutterer
2015-11-30  3:38 ` [PATCH 2/5] Input: wacom_w8001 - set BTN_TOOL_DOUBLETAP if we have 2fg support Peter Hutterer
2015-11-30  3:38 ` [PATCH 3/5] Input: wacom_w8001 - handle touch error case correctly Peter Hutterer
2015-12-01 22:01   ` Dmitry Torokhov [this message]
2015-12-03  4:21     ` [PATCH v2 " Peter Hutterer
2015-12-03  4:22     ` [PATCH v2 4/5] Input: wacom_w8001 - split pen and touch initialization up Peter Hutterer
2015-11-30  3:38 ` [PATCH " Peter Hutterer
2015-12-01 22:04   ` Dmitry Torokhov
2015-11-30  3:38 ` [PATCH 5/5] Input: wacom_w8001 - split the touch and pen devices into two devices Peter Hutterer
2015-12-01 22:06   ` Dmitry Torokhov
2015-12-03  4:22     ` [PATCH v2 " Peter Hutterer
2015-12-03 23:59       ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151201220156.GE3740@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=benjamin.tissoires@gmail.com \
    --cc=killertofu@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=peter.hutterer@who-t.net \
    --cc=pinglinux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).