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

Input: ts4800-ts - 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 ts4800-ts driver to use the
polling mode of standard input devices and removes dependency on
INPUT_POLLDEV.

Link: https://lore.kernel.org/r/20191017204217.106453-4-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+38 -31
-1
drivers/input/touchscreen/Kconfig
··· 1037 1037 depends on HAS_IOMEM && OF 1038 1038 depends on SOC_IMX51 || COMPILE_TEST 1039 1039 select MFD_SYSCON 1040 - select INPUT_POLLDEV 1041 1040 help 1042 1041 Say Y here if you have a touchscreen on a TS-4800 board. 1043 1042
+38 -30
drivers/input/touchscreen/ts4800-ts.c
··· 10 10 11 11 #include <linux/bitops.h> 12 12 #include <linux/input.h> 13 - #include <linux/input-polldev.h> 14 13 #include <linux/io.h> 15 14 #include <linux/kernel.h> 16 15 #include <linux/mfd/syscon.h> ··· 32 33 #define Y_OFFSET 0x2 33 34 34 35 struct ts4800_ts { 35 - struct input_polled_dev *poll_dev; 36 + struct input_dev *input; 36 37 struct device *dev; 37 38 char phys[32]; 38 39 ··· 45 46 int debounce; 46 47 }; 47 48 48 - static void ts4800_ts_open(struct input_polled_dev *dev) 49 + static int ts4800_ts_open(struct input_dev *input_dev) 49 50 { 50 - struct ts4800_ts *ts = dev->private; 51 - int ret; 51 + struct ts4800_ts *ts = input_get_drvdata(input_dev); 52 + int error; 52 53 53 54 ts->pendown = false; 54 55 ts->debounce = DEBOUNCE_COUNT; 55 56 56 - ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit); 57 - if (ret) 58 - dev_warn(ts->dev, "Failed to enable touchscreen\n"); 57 + error = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit); 58 + if (error) { 59 + dev_warn(ts->dev, "Failed to enable touchscreen: %d\n", error); 60 + return error; 61 + } 62 + 63 + return 0; 59 64 } 60 65 61 - static void ts4800_ts_close(struct input_polled_dev *dev) 66 + static void ts4800_ts_close(struct input_dev *input_dev) 62 67 { 63 - struct ts4800_ts *ts = dev->private; 68 + struct ts4800_ts *ts = input_get_drvdata(input_dev); 64 69 int ret; 65 70 66 71 ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, 0); ··· 73 70 74 71 } 75 72 76 - static void ts4800_ts_poll(struct input_polled_dev *dev) 73 + static void ts4800_ts_poll(struct input_dev *input_dev) 77 74 { 78 - struct input_dev *input_dev = dev->input; 79 - struct ts4800_ts *ts = dev->private; 75 + struct ts4800_ts *ts = input_get_drvdata(input_dev); 80 76 u16 last_x = readw(ts->base + X_OFFSET); 81 77 u16 last_y = readw(ts->base + Y_OFFSET); 82 78 bool pendown = last_x & PENDOWN_MASK; ··· 148 146 149 147 static int ts4800_ts_probe(struct platform_device *pdev) 150 148 { 151 - struct input_polled_dev *poll_dev; 149 + struct input_dev *input_dev; 152 150 struct ts4800_ts *ts; 153 151 int error; 154 152 ··· 164 162 if (IS_ERR(ts->base)) 165 163 return PTR_ERR(ts->base); 166 164 167 - poll_dev = devm_input_allocate_polled_device(&pdev->dev); 168 - if (!poll_dev) 165 + input_dev = devm_input_allocate_device(&pdev->dev); 166 + if (!input_dev) 169 167 return -ENOMEM; 170 168 171 169 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&pdev->dev)); 172 - ts->poll_dev = poll_dev; 170 + ts->input = input_dev; 173 171 ts->dev = &pdev->dev; 174 172 175 - poll_dev->private = ts; 176 - poll_dev->poll_interval = POLL_INTERVAL; 177 - poll_dev->open = ts4800_ts_open; 178 - poll_dev->close = ts4800_ts_close; 179 - poll_dev->poll = ts4800_ts_poll; 173 + input_set_drvdata(input_dev, ts); 180 174 181 - poll_dev->input->name = "TS-4800 Touchscreen"; 182 - poll_dev->input->phys = ts->phys; 175 + input_dev->name = "TS-4800 Touchscreen"; 176 + input_dev->phys = ts->phys; 183 177 184 - input_set_capability(poll_dev->input, EV_KEY, BTN_TOUCH); 185 - input_set_abs_params(poll_dev->input, ABS_X, 0, MAX_12BIT, 0, 0); 186 - input_set_abs_params(poll_dev->input, ABS_Y, 0, MAX_12BIT, 0, 0); 178 + input_dev->open = ts4800_ts_open; 179 + input_dev->close = ts4800_ts_close; 187 180 188 - error = input_register_polled_device(poll_dev); 181 + input_set_capability(input_dev, EV_KEY, BTN_TOUCH); 182 + input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); 183 + input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); 184 + 185 + error = input_setup_polling(input_dev, ts4800_ts_poll); 186 + if (error) { 187 + dev_err(&pdev->dev, "Unable to set up polling: %d\n", error); 188 + return error; 189 + } 190 + 191 + input_set_poll_interval(input_dev, POLL_INTERVAL); 192 + 193 + error = input_register_device(input_dev); 189 194 if (error) { 190 195 dev_err(&pdev->dev, 191 - "Unabled to register polled input device (%d)\n", 192 - error); 196 + "Unable to register input device: %d\n", error); 193 197 return error; 194 198 } 195 199