hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/input/mouse/gpio_mouse.c
....@@ -1,17 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for simulating a mouse on GPIO lines.
34 *
45 * Copyright (C) 2007 Atmel Corporation
56 * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/module.h>
1310 #include <linux/platform_device.h>
14
-#include <linux/input-polldev.h>
11
+#include <linux/input.h>
1512 #include <linux/gpio/consumer.h>
1613 #include <linux/property.h>
1714 #include <linux/of.h>
....@@ -46,10 +43,9 @@
4643 * Timer function which is run every scan_ms ms when the device is opened.
4744 * The dev input variable is set to the the input_dev pointer.
4845 */
49
-static void gpio_mouse_scan(struct input_polled_dev *dev)
46
+static void gpio_mouse_scan(struct input_dev *input)
5047 {
51
- struct gpio_mouse *gpio = dev->private;
52
- struct input_dev *input = dev->input;
48
+ struct gpio_mouse *gpio = input_get_drvdata(input);
5349 int x, y;
5450
5551 if (gpio->bleft)
....@@ -74,18 +70,17 @@
7470 {
7571 struct device *dev = &pdev->dev;
7672 struct gpio_mouse *gmouse;
77
- struct input_polled_dev *input_poll;
7873 struct input_dev *input;
79
- int ret;
74
+ int error;
8075
8176 gmouse = devm_kzalloc(dev, sizeof(*gmouse), GFP_KERNEL);
8277 if (!gmouse)
8378 return -ENOMEM;
8479
8580 /* Assign some default scanning time */
86
- ret = device_property_read_u32(dev, "scan-interval-ms",
87
- &gmouse->scan_ms);
88
- if (ret || gmouse->scan_ms == 0) {
81
+ error = device_property_read_u32(dev, "scan-interval-ms",
82
+ &gmouse->scan_ms);
83
+ if (error || gmouse->scan_ms == 0) {
8984 dev_warn(dev, "invalid scan time, set to 50 ms\n");
9085 gmouse->scan_ms = 50;
9186 }
....@@ -115,23 +110,14 @@
115110 if (IS_ERR(gmouse->bright))
116111 return PTR_ERR(gmouse->bright);
117112
118
- input_poll = devm_input_allocate_polled_device(dev);
119
- if (!input_poll) {
120
- dev_err(dev, "not enough memory for input device\n");
113
+ input = devm_input_allocate_device(dev);
114
+ if (!input)
121115 return -ENOMEM;
122
- }
123116
124
- platform_set_drvdata(pdev, input_poll);
125
-
126
- /* set input-polldev handlers */
127
- input_poll->private = gmouse;
128
- input_poll->poll = gpio_mouse_scan;
129
- input_poll->poll_interval = gmouse->scan_ms;
130
-
131
- input = input_poll->input;
132117 input->name = pdev->name;
133118 input->id.bustype = BUS_HOST;
134
- input->dev.parent = &pdev->dev;
119
+
120
+ input_set_drvdata(input, gmouse);
135121
136122 input_set_capability(input, EV_REL, REL_X);
137123 input_set_capability(input, EV_REL, REL_Y);
....@@ -142,10 +128,16 @@
142128 if (gmouse->bright)
143129 input_set_capability(input, EV_KEY, BTN_RIGHT);
144130
145
- ret = input_register_polled_device(input_poll);
146
- if (ret) {
131
+ error = input_setup_polling(input, gpio_mouse_scan);
132
+ if (error)
133
+ return error;
134
+
135
+ input_set_poll_interval(input, gmouse->scan_ms);
136
+
137
+ error = input_register_device(input);
138
+ if (error) {
147139 dev_err(dev, "could not register input device\n");
148
- return ret;
140
+ return error;
149141 }
150142
151143 dev_dbg(dev, "%d ms scan time, buttons: %s%s%s\n",