hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/input/keyboard/adc-keys.c
....@@ -1,18 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Input driver for resistor ladder connected on ADC
34 *
45 * Copyright (c) 2016 Alexandre Belloni
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
96 */
107
118 #include <linux/err.h>
129 #include <linux/iio/consumer.h>
1310 #include <linux/iio/types.h>
1411 #include <linux/input.h>
15
-#include <linux/input-polldev.h>
1612 #include <linux/kernel.h>
1713 #include <linux/module.h>
1814 #include <linux/of.h>
....@@ -33,9 +29,9 @@
3329 const struct adc_keys_button *map;
3430 };
3531
36
-static void adc_keys_poll(struct input_polled_dev *dev)
32
+static void adc_keys_poll(struct input_dev *input)
3733 {
38
- struct adc_keys_state *st = dev->private;
34
+ struct adc_keys_state *st = input_get_drvdata(input);
3935 int i, value, ret;
4036 u32 diff, closest = 0xffffffff;
4137 int keycode = 0;
....@@ -58,12 +54,12 @@
5854 keycode = 0;
5955
6056 if (st->last_key && st->last_key != keycode)
61
- input_report_key(dev->input, st->last_key, 0);
57
+ input_report_key(input, st->last_key, 0);
6258
6359 if (keycode)
64
- input_report_key(dev->input, keycode, 1);
60
+ input_report_key(input, keycode, 1);
6561
66
- input_sync(dev->input);
62
+ input_sync(input);
6763 st->last_key = keycode;
6864 }
6965
....@@ -111,7 +107,6 @@
111107 {
112108 struct device *dev = &pdev->dev;
113109 struct adc_keys_state *st;
114
- struct input_polled_dev *poll_dev;
115110 struct input_dev *input;
116111 enum iio_chan_type type;
117112 int i, value;
....@@ -148,19 +143,13 @@
148143 if (error)
149144 return error;
150145
151
- poll_dev = devm_input_allocate_polled_device(dev);
152
- if (!poll_dev) {
146
+ input = devm_input_allocate_device(dev);
147
+ if (!input) {
153148 dev_err(dev, "failed to allocate input device\n");
154149 return -ENOMEM;
155150 }
156151
157
- if (!device_property_read_u32(dev, "poll-interval", &value))
158
- poll_dev->poll_interval = value;
159
-
160
- poll_dev->poll = adc_keys_poll;
161
- poll_dev->private = st;
162
-
163
- input = poll_dev->input;
152
+ input_set_drvdata(input, st);
164153
165154 input->name = pdev->name;
166155 input->phys = "adc-keys/input0";
....@@ -177,7 +166,17 @@
177166 if (device_property_read_bool(dev, "autorepeat"))
178167 __set_bit(EV_REP, input->evbit);
179168
180
- error = input_register_polled_device(poll_dev);
169
+
170
+ error = input_setup_polling(input, adc_keys_poll);
171
+ if (error) {
172
+ dev_err(dev, "Unable to set up polling: %d\n", error);
173
+ return error;
174
+ }
175
+
176
+ if (!device_property_read_u32(dev, "poll-interval", &value))
177
+ input_set_poll_interval(input, value);
178
+
179
+ error = input_register_device(input);
181180 if (error) {
182181 dev_err(dev, "Unable to register input device: %d\n", error);
183182 return error;