devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ADS7846 add general touchscreen features
@ 2019-03-27 13:39 Marco Felsch
  2019-03-27 13:39 ` [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Marco Felsch
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Marco Felsch @ 2019-03-27 13:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: kernel, linux-input, devicetree

Hi,

The main purpose of this small set is to add support for the general
touchscreen dt-properties. During this work I also changed the memory
allocation methods to the devm_* ones to cleanup the error-paths.

Regards,
Marco

Marco Felsch (4):
  Input: ads7846 - convert to devm_ alloc functions
  dt-bindings: input: ads7846: fix property description
  dt-bindings: input: ads7846: replace vendor-bindings by general ones
  Input: ads7846 - add support for general touchscreen bindings

 .../bindings/input/touchscreen/ads7846.txt    | 29 +++++--
 drivers/input/touchscreen/ads7846.c           | 75 +++++++++++--------
 2 files changed, 66 insertions(+), 38 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions
  2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
@ 2019-03-27 13:39 ` Marco Felsch
  2019-08-09 16:44   ` Dmitry Torokhov
  2019-03-27 13:39 ` [PATCH 2/4] dt-bindings: input: ads7846: fix property description Marco Felsch
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Marco Felsch @ 2019-03-27 13:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: kernel, linux-input, devicetree

Convert to devm function to drop the 'no-mem' error handling path and
strip down the remove funciton a bit.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/input/touchscreen/ads7846.c | 37 ++++++++++++-----------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index a2f45aefce08..5a7a8425d619 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1283,13 +1283,17 @@ static int ads7846_probe(struct spi_device *spi)
 	if (err < 0)
 		return err;
 
-	ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL);
-	packet = kzalloc(sizeof(struct ads7846_packet), GFP_KERNEL);
-	input_dev = input_allocate_device();
-	if (!ts || !packet || !input_dev) {
-		err = -ENOMEM;
-		goto err_free_mem;
-	}
+	ts = devm_kzalloc(&spi->dev, sizeof(*ts), GFP_KERNEL);
+	if (!ts)
+		return -ENOMEM;
+
+	packet = devm_kzalloc(&spi->dev, sizeof(*packet), GFP_KERNEL);
+	if (!packet)
+		return -ENOMEM;
+
+	input_dev = devm_input_allocate_device(&spi->dev);
+	if (!input_dev)
+		return -ENOMEM;
 
 	spi_set_drvdata(spi, ts);
 
@@ -1303,10 +1307,8 @@ static int ads7846_probe(struct spi_device *spi)
 	pdata = dev_get_platdata(&spi->dev);
 	if (!pdata) {
 		pdata = ads7846_probe_dt(&spi->dev);
-		if (IS_ERR(pdata)) {
-			err = PTR_ERR(pdata);
-			goto err_free_mem;
-		}
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
 	}
 
 	ts->model = pdata->model ? : 7846;
@@ -1321,7 +1323,7 @@ static int ads7846_probe(struct spi_device *spi)
 		if (pdata->filter_init != NULL) {
 			err = pdata->filter_init(pdata, &ts->filter_data);
 			if (err < 0)
-				goto err_free_mem;
+				return err;
 		}
 		ts->filter = pdata->filter;
 		ts->filter_cleanup = pdata->filter_cleanup;
@@ -1352,7 +1354,6 @@ static int ads7846_probe(struct spi_device *spi)
 
 	input_dev->name = ts->name;
 	input_dev->phys = ts->phys;
-	input_dev->dev.parent = &spi->dev;
 
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
@@ -1451,10 +1452,7 @@ static int ads7846_probe(struct spi_device *spi)
  err_cleanup_filter:
 	if (ts->filter_cleanup)
 		ts->filter_cleanup(ts->filter_data);
- err_free_mem:
-	input_free_device(input_dev);
-	kfree(packet);
-	kfree(ts);
+
 	return err;
 }
 
@@ -1467,8 +1465,6 @@ static int ads7846_remove(struct spi_device *spi)
 	ads7846_disable(ts);
 	free_irq(ts->spi->irq, ts);
 
-	input_unregister_device(ts->input);
-
 	ads784x_hwmon_unregister(spi, ts);
 
 	regulator_put(ts->reg);
@@ -1484,9 +1480,6 @@ static int ads7846_remove(struct spi_device *spi)
 	if (ts->filter_cleanup)
 		ts->filter_cleanup(ts->filter_data);
 
-	kfree(ts->packet);
-	kfree(ts);
-
 	dev_dbg(&spi->dev, "unregistered touchscreen\n");
 
 	return 0;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] dt-bindings: input: ads7846: fix property description
  2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
  2019-03-27 13:39 ` [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Marco Felsch
@ 2019-03-27 13:39 ` Marco Felsch
       [not found]   ` <5ca06164.1c69fb81.39fb3.79f9@mx.google.com>
  2019-03-27 13:39 ` [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones Marco Felsch
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Marco Felsch @ 2019-03-27 13:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: kernel, linux-input, devicetree

The ti,y-max is used for the maximum value of the Y axis.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 Documentation/devicetree/bindings/input/touchscreen/ads7846.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
index 04413da51391..ce540ddac902 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
@@ -52,7 +52,7 @@ Optional properties:
 	ti,x-min			Minimum value on the X axis (u16).
 	ti,y-min			Minimum value on the Y axis (u16).
 	ti,x-max			Maximum value on the X axis (u16).
-	ti,y-max			Minimum value on the Y axis (u16).
+	ti,y-max			Maximum value on the Y axis (u16).
 	ti,pressure-min			Minimum reported pressure value
 					(threshold) - u16.
 	ti,pressure-max			Maximum reported pressure value (u16).
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones
  2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
  2019-03-27 13:39 ` [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Marco Felsch
  2019-03-27 13:39 ` [PATCH 2/4] dt-bindings: input: ads7846: fix property description Marco Felsch
@ 2019-03-27 13:39 ` Marco Felsch
       [not found]   ` <5ca06167.1c69fb81.6e121.c248@mx.google.com>
  2019-03-27 13:39 ` [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings Marco Felsch
  2019-08-09  9:30 ` [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
  4 siblings, 1 reply; 11+ messages in thread
From: Marco Felsch @ 2019-03-27 13:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: kernel, linux-input, devicetree

Mark the vendor-bindings as deprecated and replace them by the general
ones. All deprecated bindings are used as default and gets overwritten by
the general ones if the user supplies both. This ensures the backward
compatibility with old dt's.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 .../bindings/input/touchscreen/ads7846.txt    | 29 ++++++++++++++-----
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
index ce540ddac902..81f6bda97d3c 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
@@ -32,7 +32,6 @@ Optional properties:
 					(ADS7846).
 	ti,keep-vref-on			set to keep vref on for differential
 					measurements as well
-	ti,swap-xy			swap x and y axis
 	ti,settle-delay-usec		Settling time of the analog signals;
 					a function of Vcc and the capacitance
 					on the X/Y drivers.  If set to non-zero,
@@ -51,13 +50,6 @@ Optional properties:
 					in Ohms (u16).
 	ti,x-min			Minimum value on the X axis (u16).
 	ti,y-min			Minimum value on the Y axis (u16).
-	ti,x-max			Maximum value on the X axis (u16).
-	ti,y-max			Maximum value on the Y axis (u16).
-	ti,pressure-min			Minimum reported pressure value
-					(threshold) - u16.
-	ti,pressure-max			Maximum reported pressure value (u16).
-	ti,debounce-max			Max number of additional readings per
-					sample (u16).
 	ti,debounce-tol			Tolerance used for filtering (u16).
 	ti,debounce-rep			Additional consecutive good readings
 					required after the first two (u16).
@@ -67,7 +59,28 @@ Optional properties:
 					line is connected to.
 	wakeup-source			use any event on touchscreen as wakeup event.
 					(Legacy property support: "linux,wakeup")
+	touchscreen-size-x		General touchscreen binding, see [1].
+	touchscreen-size-y		General touchscreen binding, see [1].
+	touchscreen-max-pressure	General touchscreen binding, see [1].
+	touchscreen-min-pressure	General touchscreen binding, see [1].
+	touchscreen-average-samples	General touchscreen binding, see [1].
+	touchscreen-inverted-x		General touchscreen binding, see [1].
+	touchscreen-inverted-y		General touchscreen binding, see [1].
+	touchscreen-swapped-x-y		General touchscreen binding, see [1].
+
+[1] All general touchscreen properties are described in
+    Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt.
 
+Deprecated properties:
+
+	ti,swap-xy			swap x and y axis
+	ti,x-max			Maximum value on the X axis (u16).
+	ti,y-max			Maximum value on the Y axis (u16).
+	ti,pressure-min			Minimum reported pressure value
+					(threshold) - u16.
+	ti,pressure-max			Maximum reported pressure value (u16).
+	ti,debounce-max			Max number of additional readings per
+					sample (u16).
 
 Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC::
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings
  2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
                   ` (2 preceding siblings ...)
  2019-03-27 13:39 ` [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones Marco Felsch
@ 2019-03-27 13:39 ` Marco Felsch
  2019-08-09 16:42   ` Dmitry Torokhov
  2019-08-09  9:30 ` [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
  4 siblings, 1 reply; 11+ messages in thread
From: Marco Felsch @ 2019-03-27 13:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: kernel, linux-input, devicetree

A few vendor specific bindings are now covered by common bindings.

Let the driver parse the common bindings to make use of common
inverting and swapping mechnism. Aslo make use of
touchscreen_report_pos() to ensure the correct inverting-swapping
order.

The vendor specific properties are used as default (backward
compatibility) and gets overwritten by common bindings.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/input/touchscreen/ads7846.c | 38 +++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 5a7a8425d619..2fe3b91f1db8 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -23,6 +23,7 @@
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/input.h>
+#include <linux/input/touchscreen.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/pm.h>
@@ -132,6 +133,8 @@ struct ads7846 {
 
 	u16			penirq_recheck_delay_usecs;
 
+	struct touchscreen_properties core_prop;
+
 	struct mutex		lock;
 	bool			stopped;	/* P: lock */
 	bool			disabled;	/* P: lock */
@@ -826,17 +829,13 @@ static void ads7846_report_state(struct ads7846 *ts)
 	if (Rt) {
 		struct input_dev *input = ts->input;
 
-		if (ts->swap_xy)
-			swap(x, y);
-
 		if (!ts->pendown) {
 			input_report_key(input, BTN_TOUCH, 1);
 			ts->pendown = true;
 			dev_vdbg(&ts->spi->dev, "DOWN\n");
 		}
 
-		input_report_abs(input, ABS_X, x);
-		input_report_abs(input, ABS_Y, y);
+		touchscreen_report_pos(input, &ts->core_prop, x, y, false);
 		input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt);
 
 		input_sync(input);
@@ -1188,6 +1187,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	struct ads7846_platform_data *pdata;
 	struct device_node *node = dev->of_node;
 	const struct of_device_id *match;
+	u32 value;
 
 	if (!node) {
 		dev_err(dev, "Device does not have associated DT data\n");
@@ -1226,10 +1226,18 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	of_property_read_u16(node, "ti,x-max", &pdata->x_max);
 	of_property_read_u16(node, "ti,y-max", &pdata->y_max);
 
+	/*
+	 * touchscreen-max-pressure gets parsed during
+	 * touchscreen_parse_properties()
+	 */
 	of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min);
+	if (!of_property_read_u32(node, "touchscreen-min-pressure", &value))
+		pdata->pressure_min = (u16) value;
 	of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max);
 
 	of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max);
+	if (!of_property_read_u32(node, "touchscreen-average-samples", &value))
+		pdata->debounce_max = (u16) value;
 	of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol);
 	of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep);
 
@@ -1314,10 +1322,7 @@ static int ads7846_probe(struct spi_device *spi)
 	ts->model = pdata->model ? : 7846;
 	ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
 	ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
-	ts->pressure_max = pdata->pressure_max ? : ~0;
-
 	ts->vref_mv = pdata->vref_mv;
-	ts->swap_xy = pdata->swap_xy;
 
 	if (pdata->filter != NULL) {
 		if (pdata->filter_init != NULL) {
@@ -1368,6 +1373,23 @@ static int ads7846_probe(struct spi_device *spi)
 	input_set_abs_params(input_dev, ABS_PRESSURE,
 			pdata->pressure_min, pdata->pressure_max, 0, 0);
 
+	/*
+	 * Parse common framework properties. Must be done here to ensure the
+	 * correct behaviour in case of using the legacy vendor bindings. The
+	 * general binding value overrides the vendor specific one.
+	 */
+	touchscreen_parse_properties(ts->input, false, &ts->core_prop);
+	ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0;
+
+	/*
+	 * Check if legacy ti,swap-xy binding is used instead of
+	 * touchscreen-swapped-x-y
+	 */
+	if (!ts->core_prop.swap_x_y && pdata->swap_xy) {
+		swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]);
+		ts->core_prop.swap_x_y = true;
+	}
+
 	ads7846_setup_spi_msg(ts, pdata);
 
 	ts->reg = regulator_get(&spi->dev, "vcc");
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] ADS7846 add general touchscreen features
  2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
                   ` (3 preceding siblings ...)
  2019-03-27 13:39 ` [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings Marco Felsch
@ 2019-08-09  9:30 ` Marco Felsch
  4 siblings, 0 replies; 11+ messages in thread
From: Marco Felsch @ 2019-08-09  9:30 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: devicetree, kernel, linux-input

Hi Dmitry,

gentle ping.

Regards,
  Marco

On 19-03-27 14:39, Marco Felsch wrote:
> Hi,
> 
> The main purpose of this small set is to add support for the general
> touchscreen dt-properties. During this work I also changed the memory
> allocation methods to the devm_* ones to cleanup the error-paths.
> 
> Regards,
> Marco
> 
> Marco Felsch (4):
>   Input: ads7846 - convert to devm_ alloc functions
>   dt-bindings: input: ads7846: fix property description
>   dt-bindings: input: ads7846: replace vendor-bindings by general ones
>   Input: ads7846 - add support for general touchscreen bindings
> 
>  .../bindings/input/touchscreen/ads7846.txt    | 29 +++++--
>  drivers/input/touchscreen/ads7846.c           | 75 +++++++++++--------
>  2 files changed, 66 insertions(+), 38 deletions(-)
> 
> -- 
> 2.20.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings
  2019-03-27 13:39 ` [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings Marco Felsch
@ 2019-08-09 16:42   ` Dmitry Torokhov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2019-08-09 16:42 UTC (permalink / raw)
  To: Marco Felsch; +Cc: robh+dt, kernel, linux-input, devicetree

On Wed, Mar 27, 2019 at 02:39:27PM +0100, Marco Felsch wrote:
> A few vendor specific bindings are now covered by common bindings.
> 
> Let the driver parse the common bindings to make use of common
> inverting and swapping mechnism. Aslo make use of
> touchscreen_report_pos() to ensure the correct inverting-swapping
> order.
> 
> The vendor specific properties are used as default (backward
> compatibility) and gets overwritten by common bindings.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Applied, thank you.

> ---
>  drivers/input/touchscreen/ads7846.c | 38 +++++++++++++++++++++++------
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> index 5a7a8425d619..2fe3b91f1db8 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -23,6 +23,7 @@
>  #include <linux/sched.h>
>  #include <linux/delay.h>
>  #include <linux/input.h>
> +#include <linux/input/touchscreen.h>
>  #include <linux/interrupt.h>
>  #include <linux/slab.h>
>  #include <linux/pm.h>
> @@ -132,6 +133,8 @@ struct ads7846 {
>  
>  	u16			penirq_recheck_delay_usecs;
>  
> +	struct touchscreen_properties core_prop;
> +
>  	struct mutex		lock;
>  	bool			stopped;	/* P: lock */
>  	bool			disabled;	/* P: lock */
> @@ -826,17 +829,13 @@ static void ads7846_report_state(struct ads7846 *ts)
>  	if (Rt) {
>  		struct input_dev *input = ts->input;
>  
> -		if (ts->swap_xy)
> -			swap(x, y);
> -
>  		if (!ts->pendown) {
>  			input_report_key(input, BTN_TOUCH, 1);
>  			ts->pendown = true;
>  			dev_vdbg(&ts->spi->dev, "DOWN\n");
>  		}
>  
> -		input_report_abs(input, ABS_X, x);
> -		input_report_abs(input, ABS_Y, y);
> +		touchscreen_report_pos(input, &ts->core_prop, x, y, false);
>  		input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt);
>  
>  		input_sync(input);
> @@ -1188,6 +1187,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
>  	struct ads7846_platform_data *pdata;
>  	struct device_node *node = dev->of_node;
>  	const struct of_device_id *match;
> +	u32 value;
>  
>  	if (!node) {
>  		dev_err(dev, "Device does not have associated DT data\n");
> @@ -1226,10 +1226,18 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
>  	of_property_read_u16(node, "ti,x-max", &pdata->x_max);
>  	of_property_read_u16(node, "ti,y-max", &pdata->y_max);
>  
> +	/*
> +	 * touchscreen-max-pressure gets parsed during
> +	 * touchscreen_parse_properties()
> +	 */
>  	of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min);
> +	if (!of_property_read_u32(node, "touchscreen-min-pressure", &value))
> +		pdata->pressure_min = (u16) value;
>  	of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max);
>  
>  	of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max);
> +	if (!of_property_read_u32(node, "touchscreen-average-samples", &value))
> +		pdata->debounce_max = (u16) value;
>  	of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol);
>  	of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep);
>  
> @@ -1314,10 +1322,7 @@ static int ads7846_probe(struct spi_device *spi)
>  	ts->model = pdata->model ? : 7846;
>  	ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
>  	ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
> -	ts->pressure_max = pdata->pressure_max ? : ~0;
> -
>  	ts->vref_mv = pdata->vref_mv;
> -	ts->swap_xy = pdata->swap_xy;
>  
>  	if (pdata->filter != NULL) {
>  		if (pdata->filter_init != NULL) {
> @@ -1368,6 +1373,23 @@ static int ads7846_probe(struct spi_device *spi)
>  	input_set_abs_params(input_dev, ABS_PRESSURE,
>  			pdata->pressure_min, pdata->pressure_max, 0, 0);
>  
> +	/*
> +	 * Parse common framework properties. Must be done here to ensure the
> +	 * correct behaviour in case of using the legacy vendor bindings. The
> +	 * general binding value overrides the vendor specific one.
> +	 */
> +	touchscreen_parse_properties(ts->input, false, &ts->core_prop);
> +	ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0;
> +
> +	/*
> +	 * Check if legacy ti,swap-xy binding is used instead of
> +	 * touchscreen-swapped-x-y
> +	 */
> +	if (!ts->core_prop.swap_x_y && pdata->swap_xy) {
> +		swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]);
> +		ts->core_prop.swap_x_y = true;
> +	}
> +
>  	ads7846_setup_spi_msg(ts, pdata);
>  
>  	ts->reg = regulator_get(&spi->dev, "vcc");
> -- 
> 2.20.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] dt-bindings: input: ads7846: fix property description
       [not found]   ` <5ca06164.1c69fb81.39fb3.79f9@mx.google.com>
@ 2019-08-09 16:42     ` Dmitry Torokhov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2019-08-09 16:42 UTC (permalink / raw)
  To: Rob Herring; +Cc: Marco Felsch, robh+dt, kernel, linux-input, devicetree

On Sun, Mar 31, 2019 at 01:42:42AM -0500, Rob Herring wrote:
> On Wed, 27 Mar 2019 14:39:25 +0100, Marco Felsch wrote:
> > The ti,y-max is used for the maximum value of the Y axis.
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  Documentation/devicetree/bindings/input/touchscreen/ads7846.txt | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> 


Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions
  2019-03-27 13:39 ` [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Marco Felsch
@ 2019-08-09 16:44   ` Dmitry Torokhov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2019-08-09 16:44 UTC (permalink / raw)
  To: Marco Felsch; +Cc: robh+dt, kernel, linux-input, devicetree

On Wed, Mar 27, 2019 at 02:39:24PM +0100, Marco Felsch wrote:
> Convert to devm function to drop the 'no-mem' error handling path and
> strip down the remove funciton a bit.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

I am not fond of partial devm conversions, as this causes reordering in
of freeing resources in unwind path. In this particular case input
device will be unregistered only after majority of the driver structure
is torn down.

If we want to do devm conversion, we need to do a complete one.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones
       [not found]   ` <5ca06167.1c69fb81.6e121.c248@mx.google.com>
@ 2019-08-21  7:36     ` Marco Felsch
  2019-08-22 17:44       ` Dmitry Torokhov
  0 siblings, 1 reply; 11+ messages in thread
From: Marco Felsch @ 2019-08-21  7:36 UTC (permalink / raw)
  To: Rob Herring; +Cc: dmitry.torokhov, robh+dt, kernel, linux-input, devicetree

Hi Dmitry,

On 19-03-31 01:42, Rob Herring wrote:
> On Wed, 27 Mar 2019 14:39:26 +0100, Marco Felsch wrote:
> > Mark the vendor-bindings as deprecated and replace them by the general
> > ones. All deprecated bindings are used as default and gets overwritten by
> > the general ones if the user supplies both. This ensures the backward
> > compatibility with old dt's.
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  .../bindings/input/touchscreen/ads7846.txt    | 29 ++++++++++++++-----
> >  1 file changed, 21 insertions(+), 8 deletions(-)
> > 
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

How about this patch?

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones
  2019-08-21  7:36     ` Marco Felsch
@ 2019-08-22 17:44       ` Dmitry Torokhov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2019-08-22 17:44 UTC (permalink / raw)
  To: Marco Felsch; +Cc: Rob Herring, robh+dt, kernel, linux-input, devicetree

On Wed, Aug 21, 2019 at 09:36:13AM +0200, Marco Felsch wrote:
> Hi Dmitry,
> 
> On 19-03-31 01:42, Rob Herring wrote:
> > On Wed, 27 Mar 2019 14:39:26 +0100, Marco Felsch wrote:
> > > Mark the vendor-bindings as deprecated and replace them by the general
> > > ones. All deprecated bindings are used as default and gets overwritten by
> > > the general ones if the user supplies both. This ensures the backward
> > > compatibility with old dt's.
> > > 
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > ---
> > >  .../bindings/input/touchscreen/ads7846.txt    | 29 ++++++++++++++-----
> > >  1 file changed, 21 insertions(+), 8 deletions(-)
> > > 
> > 
> > Reviewed-by: Rob Herring <robh@kernel.org>
> 
> How about this patch?

It's been folded into the patch implementing the handling of the
bindings in the driver.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-08-22 17:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
2019-03-27 13:39 ` [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Marco Felsch
2019-08-09 16:44   ` Dmitry Torokhov
2019-03-27 13:39 ` [PATCH 2/4] dt-bindings: input: ads7846: fix property description Marco Felsch
     [not found]   ` <5ca06164.1c69fb81.39fb3.79f9@mx.google.com>
2019-08-09 16:42     ` Dmitry Torokhov
2019-03-27 13:39 ` [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones Marco Felsch
     [not found]   ` <5ca06167.1c69fb81.6e121.c248@mx.google.com>
2019-08-21  7:36     ` Marco Felsch
2019-08-22 17:44       ` Dmitry Torokhov
2019-03-27 13:39 ` [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings Marco Felsch
2019-08-09 16:42   ` Dmitry Torokhov
2019-08-09  9:30 ` [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch

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).