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/20191017204217.106453-11-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
@@ -346,7 +346,6 @@ config INPUT_CPCAP_PWRBUTTON
|
|||||||
config INPUT_WISTRON_BTNS
|
config INPUT_WISTRON_BTNS
|
||||||
tristate "x86 Wistron laptop button interface"
|
tristate "x86 Wistron laptop button interface"
|
||||||
depends on X86_32
|
depends on X86_32
|
||||||
select INPUT_POLLDEV
|
|
||||||
select INPUT_SPARSEKMAP
|
select INPUT_SPARSEKMAP
|
||||||
select NEW_LEDS
|
select NEW_LEDS
|
||||||
select LEDS_CLASS
|
select LEDS_CLASS
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/dmi.h>
|
#include <linux/dmi.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/input-polldev.h>
|
#include <linux/input.h>
|
||||||
#include <linux/input/sparse-keymap.h>
|
#include <linux/input/sparse-keymap.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
@@ -1030,7 +1030,7 @@ static int __init select_keymap(void)
|
|||||||
|
|
||||||
/* Input layer interface */
|
/* Input layer interface */
|
||||||
|
|
||||||
static struct input_polled_dev *wistron_idev;
|
static struct input_dev *wistron_idev;
|
||||||
static unsigned long jiffies_last_press;
|
static unsigned long jiffies_last_press;
|
||||||
static bool wifi_enabled;
|
static bool wifi_enabled;
|
||||||
static bool bluetooth_enabled;
|
static bool bluetooth_enabled;
|
||||||
@@ -1114,7 +1114,7 @@ static inline void wistron_led_resume(void)
|
|||||||
static void handle_key(u8 code)
|
static void handle_key(u8 code)
|
||||||
{
|
{
|
||||||
const struct key_entry *key =
|
const struct key_entry *key =
|
||||||
sparse_keymap_entry_from_scancode(wistron_idev->input, code);
|
sparse_keymap_entry_from_scancode(wistron_idev, code);
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
@@ -1133,15 +1133,15 @@ static void handle_key(u8 code)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sparse_keymap_report_entry(wistron_idev->input,
|
sparse_keymap_report_entry(wistron_idev, key, 1, true);
|
||||||
key, 1, true);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
jiffies_last_press = jiffies;
|
jiffies_last_press = jiffies;
|
||||||
} else
|
} else {
|
||||||
printk(KERN_NOTICE
|
printk(KERN_NOTICE
|
||||||
"wistron_btns: Unknown key code %02X\n", code);
|
"wistron_btns: Unknown key code %02X\n", code);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void poll_bios(bool discard)
|
static void poll_bios(bool discard)
|
||||||
{
|
{
|
||||||
@@ -1158,21 +1158,23 @@ static void poll_bios(bool discard)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wistron_flush(struct input_polled_dev *dev)
|
static int wistron_flush(struct input_dev *dev)
|
||||||
{
|
{
|
||||||
/* Flush stale event queue */
|
/* Flush stale event queue */
|
||||||
poll_bios(true);
|
poll_bios(true);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wistron_poll(struct input_polled_dev *dev)
|
static void wistron_poll(struct input_dev *dev)
|
||||||
{
|
{
|
||||||
poll_bios(false);
|
poll_bios(false);
|
||||||
|
|
||||||
/* Increase poll frequency if user is currently pressing keys (< 2s ago) */
|
/* Increase poll frequency if user is currently pressing keys (< 2s ago) */
|
||||||
if (time_before(jiffies, jiffies_last_press + 2 * HZ))
|
if (time_before(jiffies, jiffies_last_press + 2 * HZ))
|
||||||
dev->poll_interval = POLL_INTERVAL_BURST;
|
input_set_poll_interval(dev, POLL_INTERVAL_BURST);
|
||||||
else
|
else
|
||||||
dev->poll_interval = POLL_INTERVAL_DEFAULT;
|
input_set_poll_interval(dev, POLL_INTERVAL_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wistron_setup_keymap(struct input_dev *dev,
|
static int wistron_setup_keymap(struct input_dev *dev,
|
||||||
@@ -1208,35 +1210,37 @@ static int wistron_setup_keymap(struct input_dev *dev,
|
|||||||
|
|
||||||
static int setup_input_dev(void)
|
static int setup_input_dev(void)
|
||||||
{
|
{
|
||||||
struct input_dev *input_dev;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
wistron_idev = input_allocate_polled_device();
|
wistron_idev = input_allocate_device();
|
||||||
if (!wistron_idev)
|
if (!wistron_idev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
wistron_idev->name = "Wistron laptop buttons";
|
||||||
|
wistron_idev->phys = "wistron/input0";
|
||||||
|
wistron_idev->id.bustype = BUS_HOST;
|
||||||
|
wistron_idev->dev.parent = &wistron_device->dev;
|
||||||
|
|
||||||
wistron_idev->open = wistron_flush;
|
wistron_idev->open = wistron_flush;
|
||||||
wistron_idev->poll = wistron_poll;
|
|
||||||
wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT;
|
|
||||||
|
|
||||||
input_dev = wistron_idev->input;
|
error = sparse_keymap_setup(wistron_idev, keymap, wistron_setup_keymap);
|
||||||
input_dev->name = "Wistron laptop buttons";
|
|
||||||
input_dev->phys = "wistron/input0";
|
|
||||||
input_dev->id.bustype = BUS_HOST;
|
|
||||||
input_dev->dev.parent = &wistron_device->dev;
|
|
||||||
|
|
||||||
error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap);
|
|
||||||
if (error)
|
if (error)
|
||||||
goto err_free_dev;
|
goto err_free_dev;
|
||||||
|
|
||||||
error = input_register_polled_device(wistron_idev);
|
error = input_setup_polling(wistron_idev, wistron_poll);
|
||||||
|
if (error)
|
||||||
|
goto err_free_dev;
|
||||||
|
|
||||||
|
input_set_poll_interval(wistron_idev, POLL_INTERVAL_DEFAULT);
|
||||||
|
|
||||||
|
error = input_register_device(wistron_idev);
|
||||||
if (error)
|
if (error)
|
||||||
goto err_free_dev;
|
goto err_free_dev;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_free_dev:
|
err_free_dev:
|
||||||
input_free_polled_device(wistron_idev);
|
input_free_device(wistron_idev);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1285,8 +1289,7 @@ static int wistron_probe(struct platform_device *dev)
|
|||||||
static int wistron_remove(struct platform_device *dev)
|
static int wistron_remove(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
wistron_led_remove();
|
wistron_led_remove();
|
||||||
input_unregister_polled_device(wistron_idev);
|
input_unregister_device(wistron_idev);
|
||||||
input_free_polled_device(wistron_idev);
|
|
||||||
bios_detach();
|
bios_detach();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user