[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Ztdac2BANNpShK2t@google.com>
Date: Tue, 3 Sep 2024 11:50:27 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Antoniu Miclaus <antoniu.miclaus@...log.com>
Cc: Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Michael Hennerich <michael.hennerich@...log.com>,
linux-input@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/3] input: touchscreen: ad7877: add dt support
Hi Antoniu,
On Mon, Sep 02, 2024 at 11:24:32AM +0300, Antoniu Miclaus wrote:
> Add devicetree support within the driver.
>
> Make the old platform data approach optional.
Nobody is using it, so simply remove it.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@...log.com>
> ---
> new in v2.
> drivers/input/touchscreen/ad7877.c | 68 +++++++++++++++++++++++++++++-
> 1 file changed, 66 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
> index 7886454a19c6..3fa38043b561 100644
> --- a/drivers/input/touchscreen/ad7877.c
> +++ b/drivers/input/touchscreen/ad7877.c
> @@ -27,6 +27,7 @@
> #include <linux/input.h>
> #include <linux/interrupt.h>
> #include <linux/pm.h>
> +#include <linux/property.h>
> #include <linux/slab.h>
> #include <linux/spi/spi.h>
> #include <linux/spi/ad7877.h>
> @@ -667,6 +668,68 @@ static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts)
> }
> }
>
> +static struct ad7877_platform_data *ad7877_parse_props(struct device *dev)
> +{
> + struct ad7877_platform_data *pdata;
> + u32 value, average;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + pdata->model = (uintptr_t)device_get_match_data(dev);
> +
> + device_property_read_u8(dev, "adi,stopacq-polarity",
> + &pdata->stopacq_polarity);
> + device_property_read_u8(dev, "adi,first-conv-delay",
> + &pdata->first_conversion_delay);
> + device_property_read_u8(dev, "adi,pen-down-acc-interval",
> + &pdata->pen_down_acc_interval);
> + device_property_read_u8(dev, "adi,acquisition-time",
> + &pdata->acquisition_time);
> +
> + device_property_read_u16(dev, "adi,vref-delay-usecs",
> + &pdata->vref_delay_usecs);
> +
> + device_property_read_u32(dev, "touchscreen-x-plate-ohms", &value);
> + pdata->x_plate_ohms = (u16)value;
> + device_property_read_u32(dev, "touchscreen-y-plate-ohms", &value);
> + pdata->y_plate_ohms = (u16)value;
> + device_property_read_u32(dev, "touchscreen-min-x", &value);
> + pdata->x_min = (u16)value;
> + device_property_read_u32(dev, "touchscreen-min-y", &value);
> + pdata->y_min = (u16)value;
> + device_property_read_u32(dev, "touchscreen-max-x", &value);
> + pdata->x_max = (u16)value;
> + device_property_read_u32(dev, "touchscreen-max-y", &value);
> + pdata->y_max = (u16)value;
> + device_property_read_u32(dev, "touchscreen-max-pressure", &value);
> + pdata->pressure_max = (u16)value;
> + device_property_read_u32(dev, "touchscreen-min-pressure", &value);
> + pdata->pressure_min = (u16)value;
Please use touchscreen_parse_properties() and also apply transformations
via touchscreen_report_pos() instead of rolling your own logic.
Thanks.
--
Dmitry
Powered by blists - more mailing lists