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: Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Brian Masney <masneyb@onstation.org>, Luca Weiss <luca@z3ntu.xyz>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 17/22] Input: gpio_decoder - switch to using polled mode of input devices
Date: Thu, 17 Oct 2019 13:42:11 -0700	[thread overview]
Message-ID: <20191017204217.106453-18-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 gpio_decoder 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/misc/Kconfig        |  1 -
 drivers/input/misc/gpio_decoder.c | 42 +++++++++++++++++--------------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 102e993bbd6b..b108c992bb7a 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -290,7 +290,6 @@ config INPUT_GPIO_BEEPER
 config INPUT_GPIO_DECODER
 	tristate "Polled GPIO Decoder Input driver"
 	depends on GPIOLIB || COMPILE_TEST
-	select INPUT_POLLDEV
 	help
 	 Say Y here if you want driver to read status of multiple GPIO
 	 lines and report the encoded value as an absolute integer to
diff --git a/drivers/input/misc/gpio_decoder.c b/drivers/input/misc/gpio_decoder.c
index 1dca526e6f1a..145826a1a9a1 100644
--- a/drivers/input/misc/gpio_decoder.c
+++ b/drivers/input/misc/gpio_decoder.c
@@ -17,14 +17,12 @@
 #include <linux/device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/input.h>
-#include <linux/input-polldev.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
 struct gpio_decoder {
-	struct input_polled_dev *poll_dev;
 	struct gpio_descs *input_gpios;
 	struct device *dev;
 	u32 axis;
@@ -53,15 +51,15 @@ static int gpio_decoder_get_gpios_state(struct gpio_decoder *decoder)
 	return ret;
 }
 
-static void gpio_decoder_poll_gpios(struct input_polled_dev *poll_dev)
+static void gpio_decoder_poll_gpios(struct input_dev *input)
 {
-	struct gpio_decoder *decoder = poll_dev->private;
+	struct gpio_decoder *decoder = input_get_drvdata(input);
 	int state;
 
 	state = gpio_decoder_get_gpios_state(decoder);
 	if (state >= 0 && state != decoder->last_stable) {
-		input_report_abs(poll_dev->input, decoder->axis, state);
-		input_sync(poll_dev->input);
+		input_report_abs(input, decoder->axis, state);
+		input_sync(input);
 		decoder->last_stable = state;
 	}
 }
@@ -70,20 +68,23 @@ static int gpio_decoder_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct gpio_decoder *decoder;
-	struct input_polled_dev *poll_dev;
+	struct input_dev *input;
 	u32  max;
 	int err;
 
-	decoder = devm_kzalloc(dev, sizeof(struct gpio_decoder), GFP_KERNEL);
+	decoder = devm_kzalloc(dev, sizeof(*decoder), GFP_KERNEL);
 	if (!decoder)
 		return -ENOMEM;
 
+	decoder->dev = dev;
 	device_property_read_u32(dev, "linux,axis", &decoder->axis);
+
 	decoder->input_gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN);
 	if (IS_ERR(decoder->input_gpios)) {
 		dev_err(dev, "unable to acquire input gpios\n");
 		return PTR_ERR(decoder->input_gpios);
 	}
+
 	if (decoder->input_gpios->ndescs < 2) {
 		dev_err(dev, "not enough gpios found\n");
 		return -EINVAL;
@@ -92,22 +93,25 @@ static int gpio_decoder_probe(struct platform_device *pdev)
 	if (device_property_read_u32(dev, "decoder-max-value", &max))
 		max = (1U << decoder->input_gpios->ndescs) - 1;
 
-	decoder->dev = dev;
-	poll_dev = devm_input_allocate_polled_device(decoder->dev);
-	if (!poll_dev)
+	input = devm_input_allocate_device(dev);
+	if (!input)
 		return -ENOMEM;
 
-	poll_dev->private = decoder;
-	poll_dev->poll = gpio_decoder_poll_gpios;
-	decoder->poll_dev = poll_dev;
+	input_set_drvdata(input, decoder);
 
-	poll_dev->input->name = pdev->name;
-	poll_dev->input->id.bustype = BUS_HOST;
-	input_set_abs_params(poll_dev->input, decoder->axis, 0, max, 0, 0);
+	input->name = pdev->name;
+	input->id.bustype = BUS_HOST;
+	input_set_abs_params(input, decoder->axis, 0, max, 0, 0);
+
+	err = input_setup_polling(input, gpio_decoder_poll_gpios);
+	if (err) {
+		dev_err(dev, "failed to set up polling\n");
+		return err;
+	}
 
-	err = input_register_polled_device(poll_dev);
+	err = input_register_device(input);
 	if (err) {
-		dev_err(dev, "failed to register polled  device\n");
+		dev_err(dev, "failed to register input device\n");
 		return err;
 	}
 
-- 
2.23.0.866.gb869b98d4c-goog


  parent reply	other threads:[~2019-10-17 20:43 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 ` [PATCH 03/22] Input: ts4800-ts " Dmitry Torokhov
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 ` Dmitry Torokhov [this message]
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-18-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=luzmaximilian@gmail.com \
    --cc=masneyb@onstation.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).