hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/input/misc/wistron_btns.c
....@@ -1,26 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Wistron laptop button driver
34 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
45 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
56 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
6
- *
7
- * You can redistribute and/or modify this program under the terms of the
8
- * GNU General Public License version 2 as published by the Free Software
9
- * Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful, but
12
- * WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14
- * Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License along
17
- * with this program; if not, write to the Free Software Foundation, Inc.,
18
- * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
197 */
208 #include <linux/io.h>
219 #include <linux/dmi.h>
2210 #include <linux/init.h>
23
-#include <linux/input-polldev.h>
11
+#include <linux/input.h>
2412 #include <linux/input/sparse-keymap.h>
2513 #include <linux/interrupt.h>
2614 #include <linux/jiffies.h>
....@@ -1042,7 +1030,7 @@
10421030
10431031 /* Input layer interface */
10441032
1045
-static struct input_polled_dev *wistron_idev;
1033
+static struct input_dev *wistron_idev;
10461034 static unsigned long jiffies_last_press;
10471035 static bool wifi_enabled;
10481036 static bool bluetooth_enabled;
....@@ -1126,7 +1114,7 @@
11261114 static void handle_key(u8 code)
11271115 {
11281116 const struct key_entry *key =
1129
- sparse_keymap_entry_from_scancode(wistron_idev->input, code);
1117
+ sparse_keymap_entry_from_scancode(wistron_idev, code);
11301118
11311119 if (key) {
11321120 switch (key->type) {
....@@ -1145,14 +1133,14 @@
11451133 break;
11461134
11471135 default:
1148
- sparse_keymap_report_entry(wistron_idev->input,
1149
- key, 1, true);
1136
+ sparse_keymap_report_entry(wistron_idev, key, 1, true);
11501137 break;
11511138 }
11521139 jiffies_last_press = jiffies;
1153
- } else
1140
+ } else {
11541141 printk(KERN_NOTICE
11551142 "wistron_btns: Unknown key code %02X\n", code);
1143
+ }
11561144 }
11571145
11581146 static void poll_bios(bool discard)
....@@ -1170,21 +1158,23 @@
11701158 }
11711159 }
11721160
1173
-static void wistron_flush(struct input_polled_dev *dev)
1161
+static int wistron_flush(struct input_dev *dev)
11741162 {
11751163 /* Flush stale event queue */
11761164 poll_bios(true);
1165
+
1166
+ return 0;
11771167 }
11781168
1179
-static void wistron_poll(struct input_polled_dev *dev)
1169
+static void wistron_poll(struct input_dev *dev)
11801170 {
11811171 poll_bios(false);
11821172
11831173 /* Increase poll frequency if user is currently pressing keys (< 2s ago) */
11841174 if (time_before(jiffies, jiffies_last_press + 2 * HZ))
1185
- dev->poll_interval = POLL_INTERVAL_BURST;
1175
+ input_set_poll_interval(dev, POLL_INTERVAL_BURST);
11861176 else
1187
- dev->poll_interval = POLL_INTERVAL_DEFAULT;
1177
+ input_set_poll_interval(dev, POLL_INTERVAL_DEFAULT);
11881178 }
11891179
11901180 static int wistron_setup_keymap(struct input_dev *dev,
....@@ -1220,35 +1210,37 @@
12201210
12211211 static int setup_input_dev(void)
12221212 {
1223
- struct input_dev *input_dev;
12241213 int error;
12251214
1226
- wistron_idev = input_allocate_polled_device();
1215
+ wistron_idev = input_allocate_device();
12271216 if (!wistron_idev)
12281217 return -ENOMEM;
12291218
1219
+ wistron_idev->name = "Wistron laptop buttons";
1220
+ wistron_idev->phys = "wistron/input0";
1221
+ wistron_idev->id.bustype = BUS_HOST;
1222
+ wistron_idev->dev.parent = &wistron_device->dev;
1223
+
12301224 wistron_idev->open = wistron_flush;
1231
- wistron_idev->poll = wistron_poll;
1232
- wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT;
12331225
1234
- input_dev = wistron_idev->input;
1235
- input_dev->name = "Wistron laptop buttons";
1236
- input_dev->phys = "wistron/input0";
1237
- input_dev->id.bustype = BUS_HOST;
1238
- input_dev->dev.parent = &wistron_device->dev;
1239
-
1240
- error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap);
1226
+ error = sparse_keymap_setup(wistron_idev, keymap, wistron_setup_keymap);
12411227 if (error)
12421228 goto err_free_dev;
12431229
1244
- error = input_register_polled_device(wistron_idev);
1230
+ error = input_setup_polling(wistron_idev, wistron_poll);
1231
+ if (error)
1232
+ goto err_free_dev;
1233
+
1234
+ input_set_poll_interval(wistron_idev, POLL_INTERVAL_DEFAULT);
1235
+
1236
+ error = input_register_device(wistron_idev);
12451237 if (error)
12461238 goto err_free_dev;
12471239
12481240 return 0;
12491241
12501242 err_free_dev:
1251
- input_free_polled_device(wistron_idev);
1243
+ input_free_device(wistron_idev);
12521244 return error;
12531245 }
12541246
....@@ -1297,8 +1289,7 @@
12971289 static int wistron_remove(struct platform_device *dev)
12981290 {
12991291 wistron_led_remove();
1300
- input_unregister_polled_device(wistron_idev);
1301
- input_free_polled_device(wistron_idev);
1292
+ input_unregister_device(wistron_idev);
13021293 bios_detach();
13031294
13041295 return 0;