Commit 9b587815 authored by Dmitry Torokhov's avatar Dmitry Torokhov

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.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 08b93601
......@@ -1037,7 +1037,6 @@ config TOUCHSCREEN_TS4800
depends on HAS_IOMEM && OF
depends on SOC_IMX51 || COMPILE_TEST
select MFD_SYSCON
select INPUT_POLLDEV
help
Say Y here if you have a touchscreen on a TS-4800 board.
......
......@@ -10,7 +10,6 @@
#include <linux/bitops.h>
#include <linux/input.h>
#include <linux/input-polldev.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
......@@ -33,7 +32,7 @@
#define Y_OFFSET 0x2
struct ts4800_ts {
struct input_polled_dev *poll_dev;
struct input_dev *input;
struct device *dev;
char phys[32];
......@@ -46,22 +45,26 @@ struct ts4800_ts {
int debounce;
};
static void ts4800_ts_open(struct input_polled_dev *dev)
static int ts4800_ts_open(struct input_dev *input_dev)
{
struct ts4800_ts *ts = dev->private;
int ret;
struct ts4800_ts *ts = input_get_drvdata(input_dev);
int error;
ts->pendown = false;
ts->debounce = DEBOUNCE_COUNT;
ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit);
if (ret)
dev_warn(ts->dev, "Failed to enable touchscreen\n");
error = regmap_update_bits(ts->regmap, ts->reg, ts->bit, ts->bit);
if (error) {
dev_warn(ts->dev, "Failed to enable touchscreen: %d\n", error);
return error;
}
return 0;
}
static void ts4800_ts_close(struct input_polled_dev *dev)
static void ts4800_ts_close(struct input_dev *input_dev)
{
struct ts4800_ts *ts = dev->private;
struct ts4800_ts *ts = input_get_drvdata(input_dev);
int ret;
ret = regmap_update_bits(ts->regmap, ts->reg, ts->bit, 0);
......@@ -70,10 +73,9 @@ static void ts4800_ts_close(struct input_polled_dev *dev)
}
static void ts4800_ts_poll(struct input_polled_dev *dev)
static void ts4800_ts_poll(struct input_dev *input_dev)
{
struct input_dev *input_dev = dev->input;
struct ts4800_ts *ts = dev->private;
struct ts4800_ts *ts = input_get_drvdata(input_dev);
u16 last_x = readw(ts->base + X_OFFSET);
u16 last_y = readw(ts->base + Y_OFFSET);
bool pendown = last_x & PENDOWN_MASK;
......@@ -146,7 +148,7 @@ static int ts4800_parse_dt(struct platform_device *pdev,
static int ts4800_ts_probe(struct platform_device *pdev)
{
struct input_polled_dev *poll_dev;
struct input_dev *input_dev;
struct ts4800_ts *ts;
int error;
......@@ -162,32 +164,38 @@ static int ts4800_ts_probe(struct platform_device *pdev)
if (IS_ERR(ts->base))
return PTR_ERR(ts->base);
poll_dev = devm_input_allocate_polled_device(&pdev->dev);
if (!poll_dev)
input_dev = devm_input_allocate_device(&pdev->dev);
if (!input_dev)
return -ENOMEM;
snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&pdev->dev));
ts->poll_dev = poll_dev;
ts->input = input_dev;
ts->dev = &pdev->dev;
poll_dev->private = ts;
poll_dev->poll_interval = POLL_INTERVAL;
poll_dev->open = ts4800_ts_open;
poll_dev->close = ts4800_ts_close;
poll_dev->poll = ts4800_ts_poll;
input_set_drvdata(input_dev, ts);
input_dev->name = "TS-4800 Touchscreen";
input_dev->phys = ts->phys;
input_dev->open = ts4800_ts_open;
input_dev->close = ts4800_ts_close;
input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
poll_dev->input->name = "TS-4800 Touchscreen";
poll_dev->input->phys = ts->phys;
error = input_setup_polling(input_dev, ts4800_ts_poll);
if (error) {
dev_err(&pdev->dev, "Unable to set up polling: %d\n", error);
return error;
}
input_set_capability(poll_dev->input, EV_KEY, BTN_TOUCH);
input_set_abs_params(poll_dev->input, ABS_X, 0, MAX_12BIT, 0, 0);
input_set_abs_params(poll_dev->input, ABS_Y, 0, MAX_12BIT, 0, 0);
input_set_poll_interval(input_dev, POLL_INTERVAL);
error = input_register_polled_device(poll_dev);
error = input_register_device(input_dev);
if (error) {
dev_err(&pdev->dev,
"Unabled to register polled input device (%d)\n",
error);
"Unable to register input device: %d\n", error);
return error;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment