forked from Minki/linux
Input: adc-keys - switch to using polled mode of input devices
We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts adc-keys driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Acked-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.kernel.org/r/20191017204217.106453-6-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
7cca5a342e
commit
d0fe37b923
@ -16,7 +16,6 @@ if INPUT_KEYBOARD
|
||||
config KEYBOARD_ADC
|
||||
tristate "ADC Ladder Buttons"
|
||||
depends on IIO
|
||||
select INPUT_POLLDEV
|
||||
help
|
||||
This driver implements support for buttons connected
|
||||
to an ADC using a resistor ladder.
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <linux/iio/consumer.h>
|
||||
#include <linux/iio/types.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/input-polldev.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@ -30,9 +29,9 @@ struct adc_keys_state {
|
||||
const struct adc_keys_button *map;
|
||||
};
|
||||
|
||||
static void adc_keys_poll(struct input_polled_dev *dev)
|
||||
static void adc_keys_poll(struct input_dev *input)
|
||||
{
|
||||
struct adc_keys_state *st = dev->private;
|
||||
struct adc_keys_state *st = input_get_drvdata(input);
|
||||
int i, value, ret;
|
||||
u32 diff, closest = 0xffffffff;
|
||||
int keycode = 0;
|
||||
@ -55,12 +54,12 @@ static void adc_keys_poll(struct input_polled_dev *dev)
|
||||
keycode = 0;
|
||||
|
||||
if (st->last_key && st->last_key != keycode)
|
||||
input_report_key(dev->input, st->last_key, 0);
|
||||
input_report_key(input, st->last_key, 0);
|
||||
|
||||
if (keycode)
|
||||
input_report_key(dev->input, keycode, 1);
|
||||
input_report_key(input, keycode, 1);
|
||||
|
||||
input_sync(dev->input);
|
||||
input_sync(input);
|
||||
st->last_key = keycode;
|
||||
}
|
||||
|
||||
@ -108,7 +107,6 @@ static int adc_keys_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct adc_keys_state *st;
|
||||
struct input_polled_dev *poll_dev;
|
||||
struct input_dev *input;
|
||||
enum iio_chan_type type;
|
||||
int i, value;
|
||||
@ -145,19 +143,13 @@ static int adc_keys_probe(struct platform_device *pdev)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
poll_dev = devm_input_allocate_polled_device(dev);
|
||||
if (!poll_dev) {
|
||||
input = devm_input_allocate_device(dev);
|
||||
if (!input) {
|
||||
dev_err(dev, "failed to allocate input device\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (!device_property_read_u32(dev, "poll-interval", &value))
|
||||
poll_dev->poll_interval = value;
|
||||
|
||||
poll_dev->poll = adc_keys_poll;
|
||||
poll_dev->private = st;
|
||||
|
||||
input = poll_dev->input;
|
||||
input_set_drvdata(input, st);
|
||||
|
||||
input->name = pdev->name;
|
||||
input->phys = "adc-keys/input0";
|
||||
@ -174,7 +166,17 @@ static int adc_keys_probe(struct platform_device *pdev)
|
||||
if (device_property_read_bool(dev, "autorepeat"))
|
||||
__set_bit(EV_REP, input->evbit);
|
||||
|
||||
error = input_register_polled_device(poll_dev);
|
||||
|
||||
error = input_setup_polling(input, adc_keys_poll);
|
||||
if (error) {
|
||||
dev_err(dev, "Unable to set up polling: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (!device_property_read_u32(dev, "poll-interval", &value))
|
||||
input_set_poll_interval(input, value);
|
||||
|
||||
error = input_register_device(input);
|
||||
if (error) {
|
||||
dev_err(dev, "Unable to register input device: %d\n", error);
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user