hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/input/touchscreen/ts4800-ts.c
....@@ -10,7 +10,6 @@
1010
1111 #include <linux/bitops.h>
1212 #include <linux/input.h>
13
-#include <linux/input-polldev.h>
1413 #include <linux/io.h>
1514 #include <linux/kernel.h>
1615 #include <linux/mfd/syscon.h>
....@@ -33,7 +32,7 @@
3332 #define Y_OFFSET 0x2
3433
3534 struct ts4800_ts {
36
- struct input_polled_dev *poll_dev;
35
+ struct input_dev *input;
3736 struct device *dev;
3837 char phys[32];
3938
....@@ -46,22 +45,26 @@
4645 int debounce;
4746 };
4847
49
-static void ts4800_ts_open(struct input_polled_dev *dev)
48
+static int ts4800_ts_open(struct input_dev *input_dev)
5049 {
51
- struct ts4800_ts *ts = dev->private;
52
- int ret;
50
+ struct ts4800_ts *ts = input_get_drvdata(input_dev);
51
+ int error;
5352
5453 ts->pendown = false;
5554 ts->debounce = DEBOUNCE_COUNT;
5655
57
- ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit);
58
- if (ret)
59
- dev_warn(ts->dev, "Failed to enable touchscreen\n");
56
+ error = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit);
57
+ if (error) {
58
+ dev_warn(ts->dev, "Failed to enable touchscreen: %d\n", error);
59
+ return error;
60
+ }
61
+
62
+ return 0;
6063 }
6164
62
-static void ts4800_ts_close(struct input_polled_dev *dev)
65
+static void ts4800_ts_close(struct input_dev *input_dev)
6366 {
64
- struct ts4800_ts *ts = dev->private;
67
+ struct ts4800_ts *ts = input_get_drvdata(input_dev);
6568 int ret;
6669
6770 ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, 0);
....@@ -70,10 +73,9 @@
7073
7174 }
7275
73
-static void ts4800_ts_poll(struct input_polled_dev *dev)
76
+static void ts4800_ts_poll(struct input_dev *input_dev)
7477 {
75
- struct input_dev *input_dev = dev->input;
76
- struct ts4800_ts *ts = dev->private;
78
+ struct ts4800_ts *ts = input_get_drvdata(input_dev);
7779 u16 last_x = readw(ts->base + X_OFFSET);
7880 u16 last_y = readw(ts->base + Y_OFFSET);
7981 bool pendown = last_x & PENDOWN_MASK;
....@@ -146,9 +148,8 @@
146148
147149 static int ts4800_ts_probe(struct platform_device *pdev)
148150 {
149
- struct input_polled_dev *poll_dev;
151
+ struct input_dev *input_dev;
150152 struct ts4800_ts *ts;
151
- struct resource *res;
152153 int error;
153154
154155 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
....@@ -159,37 +160,42 @@
159160 if (error)
160161 return error;
161162
162
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
163
- ts->base = devm_ioremap_resource(&pdev->dev, res);
163
+ ts->base = devm_platform_ioremap_resource(pdev, 0);
164164 if (IS_ERR(ts->base))
165165 return PTR_ERR(ts->base);
166166
167
- poll_dev = devm_input_allocate_polled_device(&pdev->dev);
168
- if (!poll_dev)
167
+ input_dev = devm_input_allocate_device(&pdev->dev);
168
+ if (!input_dev)
169169 return -ENOMEM;
170170
171171 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&pdev->dev));
172
- ts->poll_dev = poll_dev;
172
+ ts->input = input_dev;
173173 ts->dev = &pdev->dev;
174174
175
- poll_dev->private = ts;
176
- poll_dev->poll_interval = POLL_INTERVAL;
177
- poll_dev->open = ts4800_ts_open;
178
- poll_dev->close = ts4800_ts_close;
179
- poll_dev->poll = ts4800_ts_poll;
175
+ input_set_drvdata(input_dev, ts);
180176
181
- poll_dev->input->name = "TS-4800 Touchscreen";
182
- poll_dev->input->phys = ts->phys;
177
+ input_dev->name = "TS-4800 Touchscreen";
178
+ input_dev->phys = ts->phys;
183179
184
- input_set_capability(poll_dev->input, EV_KEY, BTN_TOUCH);
185
- input_set_abs_params(poll_dev->input, ABS_X, 0, MAX_12BIT, 0, 0);
186
- input_set_abs_params(poll_dev->input, ABS_Y, 0, MAX_12BIT, 0, 0);
180
+ input_dev->open = ts4800_ts_open;
181
+ input_dev->close = ts4800_ts_close;
187182
188
- error = input_register_polled_device(poll_dev);
183
+ input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
184
+ input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
185
+ input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
186
+
187
+ error = input_setup_polling(input_dev, ts4800_ts_poll);
188
+ if (error) {
189
+ dev_err(&pdev->dev, "Unable to set up polling: %d\n", error);
190
+ return error;
191
+ }
192
+
193
+ input_set_poll_interval(input_dev, POLL_INTERVAL);
194
+
195
+ error = input_register_device(input_dev);
189196 if (error) {
190197 dev_err(&pdev->dev,
191
- "Unabled to register polled input device (%d)\n",
192
- error);
198
+ "Unable to register input device: %d\n", error);
193199 return error;
194200 }
195201