All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-input@vger.kernel.org, Henrik Rydberg <rydberg@bitmath.org>
Subject: Re: [PATCH v1 1/5] Input: of_touchscreen - explicitly choose axis
Date: Fri, 6 Mar 2020 17:12:56 -0800	[thread overview]
Message-ID: <20200307011256.GQ217608@dtor-ws> (raw)
In-Reply-To: <20200303180917.12563-1-andriy.shevchenko@linux.intel.com>

On Tue, Mar 03, 2020 at 08:09:13PM +0200, Andy Shevchenko wrote:
> The 'axis + 1' calculation is implicit and potentially error prone.
> Moreover, few lines before the axis is set explicitly for both X and Y.
> 
> Do the same when retrieving different properties for X and Y.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied, thank you.

> ---
>  drivers/input/touchscreen/of_touchscreen.c | 35 +++++++++++-----------
>  1 file changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
> index e16ec4c7043a..97342e14b4f1 100644
> --- a/drivers/input/touchscreen/of_touchscreen.c
> +++ b/drivers/input/touchscreen/of_touchscreen.c
> @@ -66,7 +66,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
>  {
>  	struct device *dev = input->dev.parent;
>  	struct input_absinfo *absinfo;
> -	unsigned int axis;
> +	unsigned int axis, axis_x, axis_y;
>  	unsigned int minimum, maximum, fuzz;
>  	bool data_present;
>  
> @@ -74,33 +74,34 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
>  	if (!input->absinfo)
>  		return;
>  
> -	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
> +	axis_x = multitouch ? ABS_MT_POSITION_X : ABS_X;
> +	axis_y = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
> +
>  	data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
> -						input_abs_get_min(input, axis),
> +						input_abs_get_min(input, axis_x),
>  						&minimum) |
>  		       touchscreen_get_prop_u32(dev, "touchscreen-size-x",
>  						input_abs_get_max(input,
> -								  axis) + 1,
> +								  axis_x) + 1,
>  						&maximum) |
>  		       touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x",
> -						input_abs_get_fuzz(input, axis),
> +						input_abs_get_fuzz(input, axis_x),
>  						&fuzz);
>  	if (data_present)
> -		touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz);
> +		touchscreen_set_params(input, axis_x, minimum, maximum - 1, fuzz);
>  
> -	axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
>  	data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y",
> -						input_abs_get_min(input, axis),
> +						input_abs_get_min(input, axis_y),
>  						&minimum) |
>  		       touchscreen_get_prop_u32(dev, "touchscreen-size-y",
>  						input_abs_get_max(input,
> -								  axis) + 1,
> +								  axis_y) + 1,
>  						&maximum) |
>  		       touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y",
> -						input_abs_get_fuzz(input, axis),
> +						input_abs_get_fuzz(input, axis_y),
>  						&fuzz);
>  	if (data_present)
> -		touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz);
> +		touchscreen_set_params(input, axis_y, minimum, maximum - 1, fuzz);
>  
>  	axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
>  	data_present = touchscreen_get_prop_u32(dev,
> @@ -117,15 +118,13 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
>  	if (!prop)
>  		return;
>  
> -	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
> -
> -	prop->max_x = input_abs_get_max(input, axis);
> -	prop->max_y = input_abs_get_max(input, axis + 1);
> +	prop->max_x = input_abs_get_max(input, axis_x);
> +	prop->max_y = input_abs_get_max(input, axis_y);
>  
>  	prop->invert_x =
>  		device_property_read_bool(dev, "touchscreen-inverted-x");
>  	if (prop->invert_x) {
> -		absinfo = &input->absinfo[axis];
> +		absinfo = &input->absinfo[axis_x];
>  		absinfo->maximum -= absinfo->minimum;
>  		absinfo->minimum = 0;
>  	}
> @@ -133,7 +132,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
>  	prop->invert_y =
>  		device_property_read_bool(dev, "touchscreen-inverted-y");
>  	if (prop->invert_y) {
> -		absinfo = &input->absinfo[axis + 1];
> +		absinfo = &input->absinfo[axis_y];
>  		absinfo->maximum -= absinfo->minimum;
>  		absinfo->minimum = 0;
>  	}
> @@ -141,7 +140,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
>  	prop->swap_x_y =
>  		device_property_read_bool(dev, "touchscreen-swapped-x-y");
>  	if (prop->swap_x_y)
> -		swap(input->absinfo[axis], input->absinfo[axis + 1]);
> +		swap(input->absinfo[axis_x], input->absinfo[axis_y]);
>  }
>  EXPORT_SYMBOL(touchscreen_parse_properties);
>  
> -- 
> 2.25.1
> 

-- 
Dmitry

      parent reply	other threads:[~2020-03-07  1:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 18:09 [PATCH v1 1/5] Input: of_touchscreen - explicitly choose axis Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 2/5] Input: edt-ft5x06 - refactor condition in edt_ft5x06_debugfs_mode_set() Andy Shevchenko
2020-03-07  1:11   ` Dmitry Torokhov
2020-03-03 18:09 ` [PATCH v1 3/5] Input: edt-ft5x06 - use U16_MAX instead of -1 Andy Shevchenko
2020-05-11 10:09   ` Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 4/5] Input: edt-ft5x06 - do not try to allocate too much memory Andy Shevchenko
2020-03-07  1:08   ` Dmitry Torokhov
2020-05-11 10:08     ` Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 5/5] Input: edt-ft5x06 - allocate buffer once for debugging Andy Shevchenko
2020-03-07  0:57   ` Dmitry Torokhov
2020-03-07  1:12 ` 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=20200307011256.GQ217608@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-input@vger.kernel.org \
    --cc=rydberg@bitmath.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.