linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Ping Cheng <pinglinux@gmail.com>
Cc: linux-input@vger.kernel.org, Ping Cheng <pingc@wacom.com>
Subject: Re: [PATCH] Input: wacom - add support for DTU-1031
Date: Thu, 16 Jan 2014 16:34:19 -0800	[thread overview]
Message-ID: <20140117003419.GD837@core.coreip.homeip.net> (raw)
In-Reply-To: <1389907779-12125-1-git-send-email-pingc@wacom.com>

Hi Ping,

On Thu, Jan 16, 2014 at 01:29:39PM -0800, Ping Cheng wrote:
> Signed-off-by: Ping Cheng <pingc@wacom.com>
> ---
>  drivers/input/tablet/wacom_wac.c | 80 +++++++++++++++++++++++++++++++++++++++-
>  drivers/input/tablet/wacom_wac.h |  6 ++-
>  2 files changed, 84 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
> index 0bcc7a6..fed2f04 100644
> --- a/drivers/input/tablet/wacom_wac.c
> +++ b/drivers/input/tablet/wacom_wac.c
> @@ -210,6 +210,70 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
>  	return 1;
>  }
>  
> +static int wacom_dtus_irq(struct wacom_wac *wacom)
> +{
> +	char *data = wacom->data;
> +	struct input_dev *input = wacom->input;
> +	unsigned short prox, pressure = 0;
> +	int retval = 0;
> +
> +	if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
> +		dev_dbg(input->dev.parent,
> +		"%s: received unknown report #%d", __func__, data[0]);
> +		goto exit;
> +	}
> +
> +	if (data[0] == WACOM_REPORT_DTUSPAD) {
> +		input_report_key(input, BTN_0, (data[1] & 0x01));
> +		input_report_key(input, BTN_1, (data[1] & 0x02));
> +		input_report_key(input, BTN_2, (data[1] & 0x04));
> +		input_report_key(input, BTN_3, (data[1] & 0x08));
> +		if (data[1] & 0x0f) {
> +			input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
> +		} else {
> +			input_report_abs(input, ABS_MISC, 0);
> +		}
> +		/* serial number is required when expresskeys are
> +		 * reported through pen interface.
> +		 */
> +		input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
> +		retval = 1;
> +		goto exit;

Let's not abuse gotos. This seems like perfect candidate for
"if/else if/else" construct.

> +	}
> +
> +	prox = data[1] & 0x80;
> +	if (prox) {
> +		switch ((data[1] >> 3) & 3) {
> +		case 1: /* Rubber */
> +			wacom->tool[0] = BTN_TOOL_RUBBER;
> +			wacom->id[0] = ERASER_DEVICE_ID;
> +			break;
> +
> +		case 2: /* Pen */
> +			wacom->tool[0] = BTN_TOOL_PEN;
> +			wacom->id[0] = STYLUS_DEVICE_ID;
> +			break;
> +		}
> +	}
> +
> +	input_report_key(input, BTN_STYLUS, data[1] & 0x20);
> +	input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
> +	input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[3]));
> +	input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[5]));

I am pretty sure this is not aligned on word boundary so you need to use
get_unaligned_be16() here.

Thanks.

-- 
Dmitry

      reply	other threads:[~2014-01-17  0:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16 21:29 [PATCH] Input: wacom - add support for DTU-1031 Ping Cheng
2014-01-17  0:34 ` Dmitry Torokhov [this message]

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=20140117003419.GD837@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=pingc@wacom.com \
    --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).