diff mbox

Input: of_touchscreen - remove interdependence of max/fuzz values

Message ID 1432952674-15228-1-git-send-email-sre@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Reichel May 30, 2015, 2:24 a.m. UTC
Commit 3eea8b5d68c8 introduced a dependency between touchscreen-max-*
and touchscreen-fuzz-*, so that either both must be specified or none
of them. If only one of them is specified the other value will be
reset to 0. This commit restores the previous behaviour, that the
drivers default value will be used for the unspecified value.

Reported-By: Pavel Machek <pavel@ucw.cz>
Fixes: 3eea8b5d68c8 (Input: of_touchscreen - rework the DT parsing function)
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/input/touchscreen/of_touchscreen.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Comments

Pavel Machek May 30, 2015, 6:26 a.m. UTC | #1
On Sat 2015-05-30 04:24:34, Sebastian Reichel wrote:
> Commit 3eea8b5d68c8 introduced a dependency between touchscreen-max-*
> and touchscreen-fuzz-*, so that either both must be specified or none
> of them. If only one of them is specified the other value will be
> reset to 0. This commit restores the previous behaviour, that the
> drivers default value will be used for the unspecified value.
> 
> Reported-By: Pavel Machek <pavel@ucw.cz>
> Fixes: 3eea8b5d68c8 (Input: of_touchscreen - rework the DT parsing function)
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  drivers/input/touchscreen/of_touchscreen.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
> index b82b520..7d2cf59 100644
> --- a/drivers/input/touchscreen/of_touchscreen.c
> +++ b/drivers/input/touchscreen/of_touchscreen.c
> @@ -42,8 +42,11 @@ static void touchscreen_set_params(struct input_dev *dev,
>  	}
>  
>  	absinfo = &dev->absinfo[axis];
> -	absinfo->maximum = max;
> -	absinfo->fuzz = fuzz;
> +
> +	if (max)
> +		absinfo->maximum = max;
> +	if (fuzz)
> +		absinfo->fuzz = fuzz;

If driver sets absinfo->fuzz to 5, and then device tree specifies fuzz
of 0, this means it will not be overwritten.

> @@ -65,23 +68,17 @@ void touchscreen_parse_of_params(struct input_dev *dev)
>  
>  	maximum = of_get_optional_u32(np, "touchscreen-size-x");
>  	fuzz = of_get_optional_u32(np, "touchscreen-fuzz-x");
> -	if (maximum || fuzz) {
> -		touchscreen_set_params(dev, ABS_X, maximum, fuzz);
> -		touchscreen_set_params(dev, ABS_MT_POSITION_X, maximum, fuzz);
> -	}
> +	touchscreen_set_params(dev, ABS_X, maximum, fuzz);
> +	touchscreen_set_params(dev, ABS_MT_POSITION_X, maximum, fuzz);

This will introduce warn_on() on axis that are not mentioned in the
device tree. Same problem Dmitry did not like on my patch.
								Pavel
diff mbox

Patch

diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
index b82b520..7d2cf59 100644
--- a/drivers/input/touchscreen/of_touchscreen.c
+++ b/drivers/input/touchscreen/of_touchscreen.c
@@ -42,8 +42,11 @@  static void touchscreen_set_params(struct input_dev *dev,
 	}
 
 	absinfo = &dev->absinfo[axis];
-	absinfo->maximum = max;
-	absinfo->fuzz = fuzz;
+
+	if (max)
+		absinfo->maximum = max;
+	if (fuzz)
+		absinfo->fuzz = fuzz;
 }
 
 /**
@@ -65,23 +68,17 @@  void touchscreen_parse_of_params(struct input_dev *dev)
 
 	maximum = of_get_optional_u32(np, "touchscreen-size-x");
 	fuzz = of_get_optional_u32(np, "touchscreen-fuzz-x");
-	if (maximum || fuzz) {
-		touchscreen_set_params(dev, ABS_X, maximum, fuzz);
-		touchscreen_set_params(dev, ABS_MT_POSITION_X, maximum, fuzz);
-	}
+	touchscreen_set_params(dev, ABS_X, maximum, fuzz);
+	touchscreen_set_params(dev, ABS_MT_POSITION_X, maximum, fuzz);
 
 	maximum = of_get_optional_u32(np, "touchscreen-size-y");
 	fuzz = of_get_optional_u32(np, "touchscreen-fuzz-y");
-	if (maximum || fuzz) {
-		touchscreen_set_params(dev, ABS_Y, maximum, fuzz);
-		touchscreen_set_params(dev, ABS_MT_POSITION_Y, maximum, fuzz);
-	}
+	touchscreen_set_params(dev, ABS_Y, maximum, fuzz);
+	touchscreen_set_params(dev, ABS_MT_POSITION_Y, maximum, fuzz);
 
 	maximum = of_get_optional_u32(np, "touchscreen-max-pressure");
 	fuzz = of_get_optional_u32(np, "touchscreen-fuzz-pressure");
-	if (maximum || fuzz) {
-		touchscreen_set_params(dev, ABS_PRESSURE, maximum, fuzz);
-		touchscreen_set_params(dev, ABS_MT_PRESSURE, maximum, fuzz);
-	}
+	touchscreen_set_params(dev, ABS_PRESSURE, maximum, fuzz);
+	touchscreen_set_params(dev, ABS_MT_PRESSURE, maximum, fuzz);
 }
 EXPORT_SYMBOL(touchscreen_parse_of_params);