.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Input driver for resistor ladder connected on ADC |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/err.h> |
---|
12 | 9 | #include <linux/iio/consumer.h> |
---|
13 | 10 | #include <linux/iio/types.h> |
---|
14 | 11 | #include <linux/input.h> |
---|
15 | | -#include <linux/input-polldev.h> |
---|
16 | 12 | #include <linux/kernel.h> |
---|
17 | 13 | #include <linux/module.h> |
---|
18 | 14 | #include <linux/of.h> |
---|
.. | .. |
---|
33 | 29 | const struct adc_keys_button *map; |
---|
34 | 30 | }; |
---|
35 | 31 | |
---|
36 | | -static void adc_keys_poll(struct input_polled_dev *dev) |
---|
| 32 | +static void adc_keys_poll(struct input_dev *input) |
---|
37 | 33 | { |
---|
38 | | - struct adc_keys_state *st = dev->private; |
---|
| 34 | + struct adc_keys_state *st = input_get_drvdata(input); |
---|
39 | 35 | int i, value, ret; |
---|
40 | 36 | u32 diff, closest = 0xffffffff; |
---|
41 | 37 | int keycode = 0; |
---|
.. | .. |
---|
58 | 54 | keycode = 0; |
---|
59 | 55 | |
---|
60 | 56 | 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); |
---|
62 | 58 | |
---|
63 | 59 | if (keycode) |
---|
64 | | - input_report_key(dev->input, keycode, 1); |
---|
| 60 | + input_report_key(input, keycode, 1); |
---|
65 | 61 | |
---|
66 | | - input_sync(dev->input); |
---|
| 62 | + input_sync(input); |
---|
67 | 63 | st->last_key = keycode; |
---|
68 | 64 | } |
---|
69 | 65 | |
---|
.. | .. |
---|
111 | 107 | { |
---|
112 | 108 | struct device *dev = &pdev->dev; |
---|
113 | 109 | struct adc_keys_state *st; |
---|
114 | | - struct input_polled_dev *poll_dev; |
---|
115 | 110 | struct input_dev *input; |
---|
116 | 111 | enum iio_chan_type type; |
---|
117 | 112 | int i, value; |
---|
.. | .. |
---|
148 | 143 | if (error) |
---|
149 | 144 | return error; |
---|
150 | 145 | |
---|
151 | | - poll_dev = devm_input_allocate_polled_device(dev); |
---|
152 | | - if (!poll_dev) { |
---|
| 146 | + input = devm_input_allocate_device(dev); |
---|
| 147 | + if (!input) { |
---|
153 | 148 | dev_err(dev, "failed to allocate input device\n"); |
---|
154 | 149 | return -ENOMEM; |
---|
155 | 150 | } |
---|
156 | 151 | |
---|
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); |
---|
164 | 153 | |
---|
165 | 154 | input->name = pdev->name; |
---|
166 | 155 | input->phys = "adc-keys/input0"; |
---|
.. | .. |
---|
177 | 166 | if (device_property_read_bool(dev, "autorepeat")) |
---|
178 | 167 | __set_bit(EV_REP, input->evbit); |
---|
179 | 168 | |
---|
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); |
---|
181 | 180 | if (error) { |
---|
182 | 181 | dev_err(dev, "Unable to register input device: %d\n", error); |
---|
183 | 182 | return error; |
---|