Skip to content

Commit 4a767ec

Browse files
committed
Input: wistron_btns - switch to using polled mode of input devices
We have added polled mode to the normal input devices with the intent of retiring input_polled_dev. This converts wistron_btns driver to use the polling mode of standard input devices and removes dependency on INPUT_POLLDEV. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 071ec84 commit 4a767ec

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

drivers/input/misc/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ config INPUT_CPCAP_PWRBUTTON
346346
config INPUT_WISTRON_BTNS
347347
tristate "x86 Wistron laptop button interface"
348348
depends on X86_32
349-
select INPUT_POLLDEV
350349
select INPUT_SPARSEKMAP
351350
select NEW_LEDS
352351
select LEDS_CLASS

drivers/input/misc/wistron_btns.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/io.h>
99
#include <linux/dmi.h>
1010
#include <linux/init.h>
11-
#include <linux/input-polldev.h>
11+
#include <linux/input.h>
1212
#include <linux/input/sparse-keymap.h>
1313
#include <linux/interrupt.h>
1414
#include <linux/jiffies.h>
@@ -1030,7 +1030,7 @@ static int __init select_keymap(void)
10301030

10311031
/* Input layer interface */
10321032

1033-
static struct input_polled_dev *wistron_idev;
1033+
static struct input_dev *wistron_idev;
10341034
static unsigned long jiffies_last_press;
10351035
static bool wifi_enabled;
10361036
static bool bluetooth_enabled;
@@ -1114,7 +1114,7 @@ static inline void wistron_led_resume(void)
11141114
static void handle_key(u8 code)
11151115
{
11161116
const struct key_entry *key =
1117-
sparse_keymap_entry_from_scancode(wistron_idev->input, code);
1117+
sparse_keymap_entry_from_scancode(wistron_idev, code);
11181118

11191119
if (key) {
11201120
switch (key->type) {
@@ -1133,14 +1133,14 @@ static void handle_key(u8 code)
11331133
break;
11341134

11351135
default:
1136-
sparse_keymap_report_entry(wistron_idev->input,
1137-
key, 1, true);
1136+
sparse_keymap_report_entry(wistron_idev, key, 1, true);
11381137
break;
11391138
}
11401139
jiffies_last_press = jiffies;
1141-
} else
1140+
} else {
11421141
printk(KERN_NOTICE
11431142
"wistron_btns: Unknown key code %02X\n", code);
1143+
}
11441144
}
11451145

11461146
static void poll_bios(bool discard)
@@ -1158,21 +1158,23 @@ static void poll_bios(bool discard)
11581158
}
11591159
}
11601160

1161-
static void wistron_flush(struct input_polled_dev *dev)
1161+
static int wistron_flush(struct input_dev *dev)
11621162
{
11631163
/* Flush stale event queue */
11641164
poll_bios(true);
1165+
1166+
return 0;
11651167
}
11661168

1167-
static void wistron_poll(struct input_polled_dev *dev)
1169+
static void wistron_poll(struct input_dev *dev)
11681170
{
11691171
poll_bios(false);
11701172

11711173
/* Increase poll frequency if user is currently pressing keys (< 2s ago) */
11721174
if (time_before(jiffies, jiffies_last_press + 2 * HZ))
1173-
dev->poll_interval = POLL_INTERVAL_BURST;
1175+
input_set_poll_interval(dev, POLL_INTERVAL_BURST);
11741176
else
1175-
dev->poll_interval = POLL_INTERVAL_DEFAULT;
1177+
input_set_poll_interval(dev, POLL_INTERVAL_DEFAULT);
11761178
}
11771179

11781180
static int wistron_setup_keymap(struct input_dev *dev,
@@ -1208,35 +1210,37 @@ static int wistron_setup_keymap(struct input_dev *dev,
12081210

12091211
static int setup_input_dev(void)
12101212
{
1211-
struct input_dev *input_dev;
12121213
int error;
12131214

1214-
wistron_idev = input_allocate_polled_device();
1215+
wistron_idev = input_allocate_device();
12151216
if (!wistron_idev)
12161217
return -ENOMEM;
12171218

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+
12181224
wistron_idev->open = wistron_flush;
1219-
wistron_idev->poll = wistron_poll;
1220-
wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT;
12211225

1222-
input_dev = wistron_idev->input;
1223-
input_dev->name = "Wistron laptop buttons";
1224-
input_dev->phys = "wistron/input0";
1225-
input_dev->id.bustype = BUS_HOST;
1226-
input_dev->dev.parent = &wistron_device->dev;
1226+
error = sparse_keymap_setup(wistron_idev, keymap, wistron_setup_keymap);
1227+
if (error)
1228+
goto err_free_dev;
12271229

1228-
error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap);
1230+
error = input_setup_polling(wistron_idev, wistron_poll);
12291231
if (error)
12301232
goto err_free_dev;
12311233

1232-
error = input_register_polled_device(wistron_idev);
1234+
input_set_poll_interval(wistron_idev, POLL_INTERVAL_DEFAULT);
1235+
1236+
error = input_register_device(wistron_idev);
12331237
if (error)
12341238
goto err_free_dev;
12351239

12361240
return 0;
12371241

12381242
err_free_dev:
1239-
input_free_polled_device(wistron_idev);
1243+
input_free_device(wistron_idev);
12401244
return error;
12411245
}
12421246

@@ -1285,8 +1289,7 @@ static int wistron_probe(struct platform_device *dev)
12851289
static int wistron_remove(struct platform_device *dev)
12861290
{
12871291
wistron_led_remove();
1288-
input_unregister_polled_device(wistron_idev);
1289-
input_free_polled_device(wistron_idev);
1292+
input_unregister_device(wistron_idev);
12901293
bios_detach();
12911294

12921295
return 0;

0 commit comments

Comments
 (0)