Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+28 -26
-1
drivers/input/misc/Kconfig
··· 346 346 config INPUT_WISTRON_BTNS 347 347 tristate "x86 Wistron laptop button interface" 348 348 depends on X86_32 349 - select INPUT_POLLDEV 350 349 select INPUT_SPARSEKMAP 351 350 select NEW_LEDS 352 351 select LEDS_CLASS
+28 -25
drivers/input/misc/wistron_btns.c
··· 8 8 #include <linux/io.h> 9 9 #include <linux/dmi.h> 10 10 #include <linux/init.h> 11 - #include <linux/input-polldev.h> 11 + #include <linux/input.h> 12 12 #include <linux/input/sparse-keymap.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/jiffies.h> ··· 1030 1030 1031 1031 /* Input layer interface */ 1032 1032 1033 - static struct input_polled_dev *wistron_idev; 1033 + static struct input_dev *wistron_idev; 1034 1034 static unsigned long jiffies_last_press; 1035 1035 static bool wifi_enabled; 1036 1036 static bool bluetooth_enabled; ··· 1114 1114 static void handle_key(u8 code) 1115 1115 { 1116 1116 const struct key_entry *key = 1117 - sparse_keymap_entry_from_scancode(wistron_idev->input, code); 1117 + sparse_keymap_entry_from_scancode(wistron_idev, code); 1118 1118 1119 1119 if (key) { 1120 1120 switch (key->type) { ··· 1133 1133 break; 1134 1134 1135 1135 default: 1136 - sparse_keymap_report_entry(wistron_idev->input, 1137 - key, 1, true); 1136 + sparse_keymap_report_entry(wistron_idev, key, 1, true); 1138 1137 break; 1139 1138 } 1140 1139 jiffies_last_press = jiffies; 1141 - } else 1140 + } else { 1142 1141 printk(KERN_NOTICE 1143 1142 "wistron_btns: Unknown key code %02X\n", code); 1143 + } 1144 1144 } 1145 1145 1146 1146 static void poll_bios(bool discard) ··· 1158 1158 } 1159 1159 } 1160 1160 1161 - static void wistron_flush(struct input_polled_dev *dev) 1161 + static int wistron_flush(struct input_dev *dev) 1162 1162 { 1163 1163 /* Flush stale event queue */ 1164 1164 poll_bios(true); 1165 + 1166 + return 0; 1165 1167 } 1166 1168 1167 - static void wistron_poll(struct input_polled_dev *dev) 1169 + static void wistron_poll(struct input_dev *dev) 1168 1170 { 1169 1171 poll_bios(false); 1170 1172 1171 1173 /* Increase poll frequency if user is currently pressing keys (< 2s ago) */ 1172 1174 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); 1174 1176 else 1175 - dev->poll_interval = POLL_INTERVAL_DEFAULT; 1177 + input_set_poll_interval(dev, POLL_INTERVAL_DEFAULT); 1176 1178 } 1177 1179 1178 1180 static int wistron_setup_keymap(struct input_dev *dev, ··· 1210 1208 1211 1209 static int setup_input_dev(void) 1212 1210 { 1213 - struct input_dev *input_dev; 1214 1211 int error; 1215 1212 1216 - wistron_idev = input_allocate_polled_device(); 1213 + wistron_idev = input_allocate_device(); 1217 1214 if (!wistron_idev) 1218 1215 return -ENOMEM; 1219 1216 1217 + wistron_idev->name = "Wistron laptop buttons"; 1218 + wistron_idev->phys = "wistron/input0"; 1219 + wistron_idev->id.bustype = BUS_HOST; 1220 + wistron_idev->dev.parent = &wistron_device->dev; 1221 + 1220 1222 wistron_idev->open = wistron_flush; 1221 - wistron_idev->poll = wistron_poll; 1222 - wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT; 1223 1223 1224 - input_dev = wistron_idev->input; 1225 - input_dev->name = "Wistron laptop buttons"; 1226 - input_dev->phys = "wistron/input0"; 1227 - input_dev->id.bustype = BUS_HOST; 1228 - input_dev->dev.parent = &wistron_device->dev; 1229 - 1230 - error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap); 1224 + error = sparse_keymap_setup(wistron_idev, keymap, wistron_setup_keymap); 1231 1225 if (error) 1232 1226 goto err_free_dev; 1233 1227 1234 - error = input_register_polled_device(wistron_idev); 1228 + error = input_setup_polling(wistron_idev, wistron_poll); 1229 + if (error) 1230 + goto err_free_dev; 1231 + 1232 + input_set_poll_interval(wistron_idev, POLL_INTERVAL_DEFAULT); 1233 + 1234 + error = input_register_device(wistron_idev); 1235 1235 if (error) 1236 1236 goto err_free_dev; 1237 1237 1238 1238 return 0; 1239 1239 1240 1240 err_free_dev: 1241 - input_free_polled_device(wistron_idev); 1241 + input_free_device(wistron_idev); 1242 1242 return error; 1243 1243 } 1244 1244 ··· 1289 1285 static int wistron_remove(struct platform_device *dev) 1290 1286 { 1291 1287 wistron_led_remove(); 1292 - input_unregister_polled_device(wistron_idev); 1293 - input_free_polled_device(wistron_idev); 1288 + input_unregister_device(wistron_idev); 1294 1289 bios_detach(); 1295 1290 1296 1291 return 0;