From: Jonathan Cameron <jic23@kernel.org>
To: Eugen Hristev <eugen.hristev@microchip.com>
Cc: <ludovic.desroches@microchip.com>,
<alexandre.belloni@bootlin.com>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-iio@vger.kernel.org>, <linux-input@vger.kernel.org>,
<nicolas.ferre@microchip.com>, <dmitry.torokhov@gmail.com>,
<robh@kernel.org>
Subject: Re: [PATCH v4 6/9] input: touchscreen: resistive-adc-touch: add generic resistive ADC touchscreen
Date: Sun, 6 May 2018 18:33:41 +0100 [thread overview]
Message-ID: <20180506183341.36919ad2@archlinux> (raw)
In-Reply-To: <1525084335-11276-7-git-send-email-eugen.hristev@microchip.com>
On Mon, 30 Apr 2018 13:32:12 +0300
Eugen Hristev <eugen.hristev@microchip.com> wrote:
> This adds a generic resistive touchscreen (GRTS) driver, which is based
> on an IIO device (an ADC). It must be connected to the channels of an ADC
> to receive touch data. Then it will feed the data into the input subsystem
> where it registers an input device.
> It uses an IIO callback buffer to register to the IIO device
>
> Some parts of this patch are based on initial original work by
> Mohamed Jamsheeth Hajanajubudeen and Bandaru Venkateswara Swamy
>
> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
> ---
> Changes in v4:
> - added a small description in file header
> - changed MAX_POS_MASK to GRTS_MAX_POS_MASK
> - initialized press with 0, as this value means no touch.
> press has to be initialized because compiler/checkpatch complains
> that can be used uninitialized.
> - changed of_property_read_u32 to device_*
> - set_abs_params for pressure will have range according to threshold
> - changed evbit and keybit with set_capability call
> - changed variable names to error instead of ret
> - checked errors for add_action_or_reset
> - cosmetic cleaning
>
> Changes in v3:
> - pressure now reported naturally growing down-up
> - using helpers from touchscreen.h to parse DT properties
> - added devm_add_action_or_reset to handle callback buffer clean on exit
> - changed compatible and threshold property to adapt to changed bindings
>
> Changes in v2:
> - this is now a generic resistive adc touchscreen driver
>
> drivers/input/touchscreen/Kconfig | 13 ++
> drivers/input/touchscreen/Makefile | 1 +
> drivers/input/touchscreen/resistive-adc-touch.c | 199 ++++++++++++++++++++++++
> 3 files changed, 213 insertions(+)
> create mode 100644 drivers/input/touchscreen/resistive-adc-touch.c
>
> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
> index 4f15496..8f85d3a 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -92,6 +92,19 @@ config TOUCHSCREEN_AD7879_SPI
...
> +static int grts_probe(struct platform_device *pdev)
> +{
> + struct grts_state *st;
> + struct input_dev *input;
> + struct device *dev = &pdev->dev;
> + struct iio_channel *chan;
> + int error;
> +
> + st = devm_kzalloc(dev, sizeof(struct grts_state), GFP_KERNEL);
> + if (!st)
> + return -ENOMEM;
> +
> + error = device_property_read_u32(dev, "touchscreen-threshold-pressure",
> + &st->pressure_threshold);
> + if (error) {
> + dev_dbg(dev, "can't get touchscreen pressure threshold property.\n");
> + st->pressure_threshold = GRTS_DEFAULT_PRESSURE_THRESHOLD;
> + }
> +
> + /* get the channels from IIO device */
> + st->iio_chans = devm_iio_channel_get_all(dev);
> + if (IS_ERR(st->iio_chans)) {
> + if (PTR_ERR(st->iio_chans) != -EPROBE_DEFER)
> + dev_err(dev, "can't get iio channels.\n");
> + return PTR_ERR(st->iio_chans);
> + }
> +
> + chan = &st->iio_chans[0];
> + st->pressure = false;
> + while (chan && chan->indio_dev) {
> + if (!strcmp(chan->channel->datasheet_name, "pressure"))
> + st->pressure = true;
> + chan++;
> + }
> +
> + input = devm_input_allocate_device(dev);
> + if (!input) {
> + dev_err(dev, "failed to allocate input device.\n");
> + return -ENOMEM;
> + }
> +
> + input->name = DRIVER_NAME;
> + input->id.bustype = BUS_HOST;
> + input->open = grts_open;
> + input->close = grts_close;
> +
> + input_set_abs_params(input, ABS_X, 0, GRTS_MAX_POS_MASK - 1, 0, 0);
> + input_set_abs_params(input, ABS_Y, 0, GRTS_MAX_POS_MASK - 1, 0, 0);
> + if (st->pressure)
> + input_set_abs_params(input, ABS_PRESSURE,
> + st->pressure_threshold, 0xffff, 0, 0);
> +
> + input_set_capability(input, EV_KEY, BTN_TOUCH);
> +
> + /* parse optional device tree properties */
> + touchscreen_parse_properties(input, false, &st->prop);
> +
> + st->input = input;
> + input_set_drvdata(input, st);
> +
> + error = input_register_device(input);
> + if (error) {
> + dev_err(dev, "failed to register input device.");
> + return error;
> + }
> +
> + st->iio_cb = iio_channel_get_all_cb(dev, grts_cb, st);
> + if (IS_ERR(st->iio_cb)) {
> + dev_err(dev, "failed to allocate callback buffer.\n");
> + error = PTR_ERR(st->iio_cb);
> + return error;
> + }
> +
> + error = devm_add_action_or_reset(dev, grts_disable, st->iio_cb);
> + if (error)
> + dev_err(dev, "failed to add disable action.\n");
Why would you not be returning the error?
> +
> + return 0;
> +}
..
next prev parent reply other threads:[~2018-05-06 17:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-30 10:32 [PATCH v4 0/9] Add support for SAMA5D2 touchscreen Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 1/9] MAINTAINERS: add generic resistive touchscreen adc Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 2/9] iio: Add channel for Position Relative Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 3/9] dt-bindings: input: touchscreen: add pressure threshold touchscreen property Eugen Hristev
2018-05-07 22:38 ` Dmitry Torokhov
2018-04-30 10:32 ` [PATCH v4 4/9] dt-bindings: input: touchscreen: resistive-adc-touch: create bindings Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 5/9] iio: adc: at91-sama5d2_adc: add support for position and pressure channels Eugen Hristev
2018-05-06 17:29 ` Jonathan Cameron
2018-05-06 17:59 ` Alexandre Belloni
2018-05-07 6:18 ` Eugen Hristev
2018-05-07 10:28 ` Alexandre Belloni
2018-05-07 10:40 ` Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 6/9] input: touchscreen: resistive-adc-touch: add generic resistive ADC touchscreen Eugen Hristev
2018-05-06 17:33 ` Jonathan Cameron [this message]
2018-04-30 10:32 ` [PATCH v4 7/9] dt-bindings: iio: adc: at91-sama5d2_adc: add channel specific consumer info Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 8/9] ARM: dts: at91: sama5d2: add channel cells for ADC device Eugen Hristev
2018-04-30 10:32 ` [PATCH v4 9/9] ARM: dts: at91: sama5d2: Add resistive touch device Eugen Hristev
2018-05-06 19:04 ` [PATCH v4 0/9] Add support for SAMA5D2 touchscreen Jonathan Cameron
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=20180506183341.36919ad2@archlinux \
--to=jic23@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=eugen.hristev@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.com \
--cc=robh@kernel.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 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).