linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Anders Roxell <anders.roxell@linaro.org>,
	Jeff LaBundy <jeff@labundy.com>,
	Martin Kepplinger <martink@posteo.de>,
	Mukesh Ojha <mojha@codeaurora.org>,
	Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 03/22] Input: ts4800-ts - switch to using polled mode of input devices
Date: Thu, 17 Oct 2019 13:41:57 -0700	[thread overview]
Message-ID: <20191017204217.106453-4-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com>

We have added polled mode to the normal input devices with the intent of
retiring input_polled_dev. This converts ts4800-ts driver to use the
polling mode of standard input devices and removes dependency on
INPUT_POLLDEV.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

 drivers/input/touchscreen/Kconfig     |  1 -
 drivers/input/touchscreen/ts4800-ts.c | 68 +++++++++++++++------------
 2 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index df9cb92166c3..2c00232b2506 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1037,7 +1037,6 @@ config TOUCHSCREEN_TS4800
 	depends on HAS_IOMEM && OF
 	depends on SOC_IMX51 || COMPILE_TEST
 	select MFD_SYSCON
-	select INPUT_POLLDEV
 	help
 	  Say Y here if you have a touchscreen on a TS-4800 board.
 
diff --git a/drivers/input/touchscreen/ts4800-ts.c b/drivers/input/touchscreen/ts4800-ts.c
index 5b4f5362c67b..6cf66aadc10e 100644
--- a/drivers/input/touchscreen/ts4800-ts.c
+++ b/drivers/input/touchscreen/ts4800-ts.c
@@ -10,7 +10,6 @@
 
 #include <linux/bitops.h>
 #include <linux/input.h>
-#include <linux/input-polldev.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/mfd/syscon.h>
@@ -33,7 +32,7 @@
 #define Y_OFFSET		0x2
 
 struct ts4800_ts {
-	struct input_polled_dev *poll_dev;
+	struct input_dev        *input;
 	struct device           *dev;
 	char                    phys[32];
 
@@ -46,22 +45,26 @@ struct ts4800_ts {
 	int                     debounce;
 };
 
-static void ts4800_ts_open(struct input_polled_dev *dev)
+static int ts4800_ts_open(struct input_dev *input_dev)
 {
-	struct ts4800_ts *ts = dev->private;
-	int ret;
+	struct ts4800_ts *ts = input_get_drvdata(input_dev);
+	int error;
 
 	ts->pendown = false;
 	ts->debounce = DEBOUNCE_COUNT;
 
-	ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit);
-	if (ret)
-		dev_warn(ts->dev, "Failed to enable touchscreen\n");
+	error = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit);
+	if (error) {
+		dev_warn(ts->dev, "Failed to enable touchscreen: %d\n", error);
+		return error;
+	}
+
+	return 0;
 }
 
-static void ts4800_ts_close(struct input_polled_dev *dev)
+static void ts4800_ts_close(struct input_dev *input_dev)
 {
-	struct ts4800_ts *ts = dev->private;
+	struct ts4800_ts *ts = input_get_drvdata(input_dev);
 	int ret;
 
 	ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, 0);
@@ -70,10 +73,9 @@ static void ts4800_ts_close(struct input_polled_dev *dev)
 
 }
 
-static void ts4800_ts_poll(struct input_polled_dev *dev)
+static void ts4800_ts_poll(struct input_dev *input_dev)
 {
-	struct input_dev *input_dev = dev->input;
-	struct ts4800_ts *ts = dev->private;
+	struct ts4800_ts *ts = input_get_drvdata(input_dev);
 	u16 last_x = readw(ts->base + X_OFFSET);
 	u16 last_y = readw(ts->base + Y_OFFSET);
 	bool pendown = last_x & PENDOWN_MASK;
@@ -146,7 +148,7 @@ static int ts4800_parse_dt(struct platform_device *pdev,
 
 static int ts4800_ts_probe(struct platform_device *pdev)
 {
-	struct input_polled_dev *poll_dev;
+	struct input_dev *input_dev;
 	struct ts4800_ts *ts;
 	int error;
 
@@ -162,32 +164,38 @@ static int ts4800_ts_probe(struct platform_device *pdev)
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);
 
-	poll_dev = devm_input_allocate_polled_device(&pdev->dev);
-	if (!poll_dev)
+	input_dev = devm_input_allocate_device(&pdev->dev);
+	if (!input_dev)
 		return -ENOMEM;
 
 	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&pdev->dev));
-	ts->poll_dev = poll_dev;
+	ts->input = input_dev;
 	ts->dev = &pdev->dev;
 
-	poll_dev->private = ts;
-	poll_dev->poll_interval = POLL_INTERVAL;
-	poll_dev->open = ts4800_ts_open;
-	poll_dev->close = ts4800_ts_close;
-	poll_dev->poll = ts4800_ts_poll;
+	input_set_drvdata(input_dev, ts);
+
+	input_dev->name = "TS-4800 Touchscreen";
+	input_dev->phys = ts->phys;
+
+	input_dev->open = ts4800_ts_open;
+	input_dev->close = ts4800_ts_close;
+
+	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
+	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
 
-	poll_dev->input->name = "TS-4800 Touchscreen";
-	poll_dev->input->phys = ts->phys;
+	error = input_setup_polling(input_dev, ts4800_ts_poll);
+	if (error) {
+		dev_err(&pdev->dev, "Unable to set up polling: %d\n", error);
+		return error;
+	}
 
-	input_set_capability(poll_dev->input, EV_KEY, BTN_TOUCH);
-	input_set_abs_params(poll_dev->input, ABS_X, 0, MAX_12BIT, 0, 0);
-	input_set_abs_params(poll_dev->input, ABS_Y, 0, MAX_12BIT, 0, 0);
+	input_set_poll_interval(input_dev, POLL_INTERVAL);
 
-	error = input_register_polled_device(poll_dev);
+	error = input_register_device(input_dev);
 	if (error) {
 		dev_err(&pdev->dev,
-			"Unabled to register polled input device (%d)\n",
-			error);
+			"Unable to register input device: %d\n", error);
 		return error;
 	}
 
-- 
2.23.0.866.gb869b98d4c-goog


  parent reply	other threads:[~2019-10-17 20:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 20:41 [PATCH 00/22] Stop using input_polled_dev in polling drivers Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 01/22] Input: raspberrypi-ts - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 02/22] Input: sur40 " Dmitry Torokhov
2019-10-17 20:41 ` Dmitry Torokhov [this message]
2019-10-17 20:41 ` [PATCH 04/22] Input: tsc6507x-ts " Dmitry Torokhov
2019-10-17 20:41 ` [PATCH 05/22] Input: adc-keys " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 06/22] Input: clps711x-keypad " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 07/22] Input: jornada680_kbd " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 08/22] Input: gpio_keys_polled " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 09/22] Input: apanel " Dmitry Torokhov
2019-10-21 20:05   ` Sven Van Asbroeck
2019-10-21 21:27     ` Dmitry Torokhov
2019-10-22 13:21       ` Sven Van Asbroeck
2019-10-17 20:42 ` [PATCH 10/22] Input: wistron_btns " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 11/22] Input: cobalt_btns - convert to use managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 12/22] Input: cobalt_btns - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 13/22] Input: sgi_btns - switch to using managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 14/22] Input: sgi_btns - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 15/22] Input: rb532_button - switch to using managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 16/22] Input: rb532_button - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 17/22] Input: gpio_decoder " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 18/22] Input: mma8450 " Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 19/22] Input: bma150 - use managed resources helpers Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 20/22] Input: bma150 - switch to using polled mode of input devices Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 21/22] Input: kxtj9 - switch to using managed resources Dmitry Torokhov
2019-10-17 20:42 ` [PATCH 22/22] Input: kxtj9 - switch to using polled mode of input devices Dmitry Torokhov
2019-10-18  8:44 ` [PATCH 00/22] Stop using input_polled_dev in polling drivers Andy Shevchenko
2019-10-21  8:03   ` Marco Felsch

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=20191017204217.106453-4-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=anders.roxell@linaro.org \
    --cc=jeff@labundy.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martink@posteo.de \
    --cc=mojha@codeaurora.org \
    --cc=nsaenzjulienne@suse.de \
    /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).