summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-20 00:10:54 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-20 00:10:54 +0300
commitc6cfaf4f86d9d15e5541adb3bb899d0b80f89ec7 (patch)
tree4d6906d1ac94afee030934116d304e9a5bbf311f /drivers
parenta9f8b38a071b468276a243ea3ea5a0636e848cf2 (diff)
parent0898782247ae533d1f4e47a06bc5d4870931b284 (diff)
downloadlinux-c6cfaf4f86d9d15e5541adb3bb899d0b80f89ec7.tar.xz
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov: - input core allows hardware drivers to specify a [more precise] timestamp (normally taken in top half) to better track velocity of contacts - input_dev instances now support "polling" mode so that drivers could use the same object for polled and interrupt-driven operation. The plan is to convert existing drivers and retire input_polled_dev API - a new driver for the FlySky FS-iA6B RC receiver - a refresh of BU21013 touchpad driver - w90x900 keyboard and touchpad drivers are removed as the platform is gone - assorted fixes * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (45 commits) Input: sidewinder - make array seq static const, makes object smaller Input: reset device timestamp on sync Input: bu21013_ts - switch to using standard touchscreen properties Input: bu21013_ts - switch to using MT-B (slotted) protocol Input: bu21013_ts - fix suspend when wake source Input: bu21013_ts - use interrupt from I2C client Input: bu21013_ts - remove support for platform data Input: bu21013_ts - convert to using managed resources Input: bu21013_ts - remove useless comments Input: bu21013_ts - annotate supend/resume methods as __maybe_unused Input: bu21013_ts - rename some variables Input: bu21013_ts - convert to use GPIO descriptors ARM: ux500: improve BU21013 touchpad bindings Input: i8042 - enable wakeup on a stable struct device Input: soc_button_array - use platform_device_register_resndata() Input: psmouse - drop all unneeded functions from mouse headers Input: add support for polling to input devices Input: wacom_w8001 - allocate additional space for 'phys' Input: cros_ec_keyb - add back missing mask for event_type Input: remove dev_err() usage after platform_get_irq() ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/Makefile2
-rw-r--r--drivers/input/evdev.c35
-rw-r--r--drivers/input/input-poller.c213
-rw-r--r--drivers/input/input-poller.h18
-rw-r--r--drivers/input/input.c83
-rw-r--r--drivers/input/joystick/Kconfig10
-rw-r--r--drivers/input/joystick/Makefile5
-rw-r--r--drivers/input/joystick/fsia6b.c231
-rw-r--r--drivers/input/joystick/sidewinder.c2
-rw-r--r--drivers/input/keyboard/Kconfig11
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/applespi.c30
-rw-r--r--drivers/input/keyboard/bcm-keypad.c4
-rw-r--r--drivers/input/keyboard/cros_ec_keyb.c6
-rw-r--r--drivers/input/keyboard/davinci_keyscan.c1
-rw-r--r--drivers/input/keyboard/gpio_keys.c13
-rw-r--r--drivers/input/keyboard/imx_keypad.c4
-rw-r--r--drivers/input/keyboard/lpc32xx-keys.c4
-rw-r--r--drivers/input/keyboard/mpr121_touchkey.c3
-rw-r--r--drivers/input/keyboard/nomadik-ske-keypad.c4
-rw-r--r--drivers/input/keyboard/nspire-keypad.c4
-rw-r--r--drivers/input/keyboard/opencores-kbd.c4
-rw-r--r--drivers/input/keyboard/pmic8xxx-keypad.c8
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c4
-rw-r--r--drivers/input/keyboard/pxa930_rotary.c4
-rw-r--r--drivers/input/keyboard/sh_keysc.c4
-rw-r--r--drivers/input/keyboard/snvs_pwrkey.c4
-rw-r--r--drivers/input/keyboard/spear-keyboard.c4
-rw-r--r--drivers/input/keyboard/st-keyscan.c4
-rw-r--r--drivers/input/keyboard/tegra-kbc.c4
-rw-r--r--drivers/input/keyboard/w90p910_keypad.c264
-rw-r--r--drivers/input/matrix-keymap.c2
-rw-r--r--drivers/input/misc/88pm80x_onkey.c1
-rw-r--r--drivers/input/misc/88pm860x_onkey.c4
-rw-r--r--drivers/input/misc/Kconfig6
-rw-r--r--drivers/input/misc/ab8500-ponkey.c8
-rw-r--r--drivers/input/misc/axp20x-pek.c25
-rw-r--r--drivers/input/misc/da9055_onkey.c5
-rw-r--r--drivers/input/misc/da9063_onkey.c7
-rw-r--r--drivers/input/misc/e3x0-button.c10
-rw-r--r--drivers/input/misc/hisi_powerkey.c8
-rw-r--r--drivers/input/misc/max8925_onkey.c8
-rw-r--r--drivers/input/misc/pm8941-pwrkey.c4
-rw-r--r--drivers/input/misc/rk805-pwrkey.c8
-rw-r--r--drivers/input/misc/soc_button_array.c127
-rw-r--r--drivers/input/misc/stpmic1_onkey.c10
-rw-r--r--drivers/input/misc/tps65218-pwrbutton.c4
-rw-r--r--drivers/input/misc/twl6040-vibra.c4
-rw-r--r--drivers/input/mouse/alps.h11
-rw-r--r--drivers/input/mouse/byd.h11
-rw-r--r--drivers/input/mouse/cyapa.c16
-rw-r--r--drivers/input/mouse/cypress_ps2.h11
-rw-r--r--drivers/input/mouse/elan_i2c_core.c20
-rw-r--r--drivers/input/mouse/elantech.h18
-rw-r--r--drivers/input/mouse/hgpk.h13
-rw-r--r--drivers/input/mouse/lifebook.h13
-rw-r--r--drivers/input/mouse/logips2pp.h7
-rw-r--r--drivers/input/mouse/pxa930_trkball.c4
-rw-r--r--drivers/input/mouse/sentelic.h11
-rw-r--r--drivers/input/mouse/synaptics.c2
-rw-r--r--drivers/input/mouse/touchkit_ps2.h8
-rw-r--r--drivers/input/mouse/trackpoint.h8
-rw-r--r--drivers/input/mouse/vmmouse.h11
-rw-r--r--drivers/input/rmi4/rmi_2d_sensor.c1
-rw-r--r--drivers/input/serio/arc_ps2.c4
-rw-r--r--drivers/input/serio/i8042.c25
-rw-r--r--drivers/input/serio/ps2-gpio.c2
-rw-r--r--drivers/input/touchscreen/88pm860x-ts.c4
-rw-r--r--drivers/input/touchscreen/Kconfig9
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/ads7846.c38
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c3
-rw-r--r--drivers/input/touchscreen/bcm_iproc_tsc.c4
-rw-r--r--drivers/input/touchscreen/bu21013_ts.c740
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c2
-rw-r--r--drivers/input/touchscreen/fsl-imx25-tcq.c8
-rw-r--r--drivers/input/touchscreen/hideep.c3
-rw-r--r--drivers/input/touchscreen/imx6ul_tsc.c8
-rw-r--r--drivers/input/touchscreen/lpc32xx_ts.c4
-rw-r--r--drivers/input/touchscreen/mxs-lradc-ts.c10
-rw-r--r--drivers/input/touchscreen/sun4i-ts.c3
-rw-r--r--drivers/input/touchscreen/ts4800-ts.c4
-rw-r--r--drivers/input/touchscreen/w90p910_ts.c331
-rw-r--r--drivers/input/touchscreen/wacom_w8001.c4
-rw-r--r--drivers/platform/x86/surfacepro3_button.c47
85 files changed, 1161 insertions, 1487 deletions
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 40de6a7be641..e35650930371 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -6,7 +6,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_INPUT) += input-core.o
-input-core-y := input.o input-compat.o input-mt.o ff-core.o
+input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o
obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 867c2cfd0038..d7dd6fcf2db0 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -25,13 +25,6 @@
#include <linux/cdev.h>
#include "input-compat.h"
-enum evdev_clock_type {
- EV_CLK_REAL = 0,
- EV_CLK_MONO,
- EV_CLK_BOOT,
- EV_CLK_MAX
-};
-
struct evdev {
int open;
struct input_handle handle;
@@ -53,7 +46,7 @@ struct evdev_client {
struct fasync_struct *fasync;
struct evdev *evdev;
struct list_head node;
- unsigned int clk_type;
+ enum input_clock_type clk_type;
bool revoked;
unsigned long *evmasks[EV_CNT];
unsigned int bufsize;
@@ -149,17 +142,10 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
static void __evdev_queue_syn_dropped(struct evdev_client *client)
{
+ ktime_t *ev_time = input_get_timestamp(client->evdev->handle.dev);
+ struct timespec64 ts = ktime_to_timespec64(ev_time[client->clk_type]);
struct input_event ev;
- ktime_t time;
- struct timespec64 ts;
- time = client->clk_type == EV_CLK_REAL ?
- ktime_get_real() :
- client->clk_type == EV_CLK_MONO ?
- ktime_get() :
- ktime_get_boottime();
-
- ts = ktime_to_timespec64(time);
ev.input_event_sec = ts.tv_sec;
ev.input_event_usec = ts.tv_nsec / NSEC_PER_USEC;
ev.type = EV_SYN;
@@ -188,18 +174,18 @@ static void evdev_queue_syn_dropped(struct evdev_client *client)
static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
{
unsigned long flags;
- unsigned int clk_type;
+ enum input_clock_type clk_type;
switch (clkid) {
case CLOCK_REALTIME:
- clk_type = EV_CLK_REAL;
+ clk_type = INPUT_CLK_REAL;
break;
case CLOCK_MONOTONIC:
- clk_type = EV_CLK_MONO;
+ clk_type = INPUT_CLK_MONO;
break;
case CLOCK_BOOTTIME:
- clk_type = EV_CLK_BOOT;
+ clk_type = INPUT_CLK_BOOT;
break;
default:
return -EINVAL;
@@ -307,12 +293,7 @@ static void evdev_events(struct input_handle *handle,
{
struct evdev *evdev = handle->private;
struct evdev_client *client;
- ktime_t ev_time[EV_CLK_MAX];
-
- ev_time[EV_CLK_MONO] = ktime_get();
- ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
- ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
- TK_OFFS_BOOT);
+ ktime_t *ev_time = input_get_timestamp(handle->dev);
rcu_read_lock();
diff --git a/drivers/input/input-poller.c b/drivers/input/input-poller.c
new file mode 100644
index 000000000000..1b3d28964bb2
--- /dev/null
+++ b/drivers/input/input-poller.c
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Support for polling mode for input devices.
+ */
+
+#include <linux/device.h>
+#include <linux/input.h>
+#include <linux/jiffies.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+#include "input-poller.h"
+
+struct input_dev_poller {
+ void (*poll)(struct input_dev *dev);
+
+ unsigned int poll_interval; /* msec */
+ unsigned int poll_interval_max; /* msec */
+ unsigned int poll_interval_min; /* msec */
+
+ struct input_dev *input;
+ struct delayed_work work;
+};
+
+static void input_dev_poller_queue_work(struct input_dev_poller *poller)
+{
+ unsigned long delay;
+
+ delay = msecs_to_jiffies(poller->poll_interval);
+ if (delay >= HZ)
+ delay = round_jiffies_relative(delay);
+
+ queue_delayed_work(system_freezable_wq, &poller->work, delay);
+}
+
+static void input_dev_poller_work(struct work_struct *work)
+{
+ struct input_dev_poller *poller =
+ container_of(work, struct input_dev_poller, work.work);
+
+ poller->poll(poller->input);
+ input_dev_poller_queue_work(poller);
+}
+
+void input_dev_poller_finalize(struct input_dev_poller *poller)
+{
+ if (!poller->poll_interval)
+ poller->poll_interval = 500;
+ if (!poller->poll_interval_max)
+ poller->poll_interval_max = poller->poll_interval;
+}
+
+void input_dev_poller_start(struct input_dev_poller *poller)
+{
+ /* Only start polling if polling is enabled */
+ if (poller->poll_interval > 0) {
+ poller->poll(poller->input);
+ input_dev_poller_queue_work(poller);
+ }
+}
+
+void input_dev_poller_stop(struct input_dev_poller *poller)
+{
+ cancel_delayed_work_sync(&poller->work);
+}
+
+int input_setup_polling(struct input_dev *dev,
+ void (*poll_fn)(struct input_dev *dev))
+{
+ struct input_dev_poller *poller;
+
+ poller = kzalloc(sizeof(*poller), GFP_KERNEL);
+ if (!poller) {
+ /*
+ * We want to show message even though kzalloc() may have
+ * printed backtrace as knowing what instance of input
+ * device we were dealing with is helpful.
+ */
+ dev_err(dev->dev.parent ?: &dev->dev,
+ "%s: unable to allocate poller structure\n", __func__);
+ return -ENOMEM;
+ }
+
+ INIT_DELAYED_WORK(&poller->work, input_dev_poller_work);
+ poller->input = dev;
+ poller->poll = poll_fn;
+
+ dev->poller = poller;
+ return 0;
+}
+EXPORT_SYMBOL(input_setup_polling);
+
+static bool input_dev_ensure_poller(struct input_dev *dev)
+{
+ if (!dev->poller) {
+ dev_err(dev->dev.parent ?: &dev->dev,
+ "poller structure has not been set up\n");
+ return false;
+ }
+
+ return true;
+}
+
+void input_set_poll_interval(struct input_dev *dev, unsigned int interval)
+{
+ if (input_dev_ensure_poller(dev))
+ dev->poller->poll_interval = interval;
+}
+EXPORT_SYMBOL(input_set_poll_interval);
+
+void input_set_min_poll_interval(struct input_dev *dev, unsigned int interval)
+{
+ if (input_dev_ensure_poller(dev))
+ dev->poller->poll_interval_min = interval;
+}
+EXPORT_SYMBOL(input_set_min_poll_interval);
+
+void input_set_max_poll_interval(struct input_dev *dev, unsigned int interval)
+{
+ if (input_dev_ensure_poller(dev))
+ dev->poller->poll_interval_max = interval;
+}
+EXPORT_SYMBOL(input_set_max_poll_interval);
+
+/* SYSFS interface */
+
+static ssize_t input_dev_get_poll_interval(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct input_dev *input = to_input_dev(dev);
+
+ return sprintf(buf, "%d\n", input->poller->poll_interval);
+}
+
+static ssize_t input_dev_set_poll_interval(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct input_dev *input = to_input_dev(dev);
+ struct input_dev_poller *poller = input->poller;
+ unsigned int interval;
+ int err;
+
+ err = kstrtouint(buf, 0, &interval);
+ if (err)
+ return err;
+
+ if (interval < poller->poll_interval_min)
+ return -EINVAL;
+
+ if (interval > poller->poll_interval_max)
+ return -EINVAL;
+
+ mutex_lock(&input->mutex);
+
+ poller->poll_interval = interval;
+
+ if (input->users) {
+ cancel_delayed_work_sync(&poller->work);
+ if (poller->poll_interval > 0)
+ input_dev_poller_queue_work(poller);
+ }
+
+ mutex_unlock(&input->mutex);
+
+ return count;
+}
+
+static DEVICE_ATTR(poll, 0644,
+ input_dev_get_poll_interval, input_dev_set_poll_interval);
+
+static ssize_t input_dev_get_poll_max(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct input_dev *input = to_input_dev(dev);
+
+ return sprintf(buf, "%d\n", input->poller->poll_interval_max);
+}
+
+static DEVICE_ATTR(max, 0444, input_dev_get_poll_max, NULL);
+
+static ssize_t input_dev_get_poll_min(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct input_dev *input = to_input_dev(dev);
+
+ return sprintf(buf, "%d\n", input->poller->poll_interval_min);
+}
+
+static DEVICE_ATTR(min, 0444, input_dev_get_poll_min, NULL);
+
+static umode_t input_poller_attrs_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct input_dev *input = to_input_dev(dev);
+
+ return input->poller ? attr->mode : 0;
+}
+
+static struct attribute *input_poller_attrs[] = {
+ &dev_attr_poll.attr,
+ &dev_attr_max.attr,
+ &dev_attr_min.attr,
+ NULL
+};
+
+struct attribute_group input_poller_attribute_group = {
+ .is_visible = input_poller_attrs_visible,
+ .attrs = input_poller_attrs,
+};
diff --git a/drivers/input/input-poller.h b/drivers/input/input-poller.h
new file mode 100644
index 000000000000..e3fca0be1d32
--- /dev/null
+++ b/drivers/input/input-poller.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _INPUT_POLLER_H
+#define _INPUT_POLLER_H
+
+/*
+ * Support for polling mode for input devices.
+ */
+#include <linux/sysfs.h>
+
+struct input_dev_poller;
+
+void input_dev_poller_finalize(struct input_dev_poller *poller);
+void input_dev_poller_start(struct input_dev_poller *poller);
+void input_dev_poller_stop(struct input_dev_poller *poller);
+
+extern struct attribute_group input_poller_attribute_group;
+
+#endif /* _INPUT_POLLER_H */
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7f3c5fcb9ed6..55086279d044 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -24,6 +24,7 @@
#include <linux/mutex.h>
#include <linux/rcupdate.h>
#include "input-compat.h"
+#include "input-poller.h"
MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
MODULE_DESCRIPTION("Input core");
@@ -396,6 +397,13 @@ static void input_handle_event(struct input_dev *dev,
if (dev->num_vals >= 2)
input_pass_values(dev, dev->vals, dev->num_vals);
dev->num_vals = 0;
+ /*
+ * Reset the timestamp on flush so we won't end up
+ * with a stale one. Note we only need to reset the
+ * monolithic one as we use its presence when deciding
+ * whether to generate a synthetic timestamp.
+ */
+ dev->timestamp[INPUT_CLK_MONO] = ktime_set(0, 0);
} else if (dev->num_vals >= dev->max_vals - 2) {
dev->vals[dev->num_vals++] = input_value_sync;
input_pass_values(dev, dev->vals, dev->num_vals);
@@ -603,20 +611,31 @@ int input_open_device(struct input_handle *handle)
handle->open++;
- if (!dev->users++ && dev->open)
- retval = dev->open(dev);
+ if (dev->users++) {
+ /*
+ * Device is already opened, so we can exit immediately and
+ * report success.
+ */
+ goto out;
+ }
- if (retval) {
- dev->users--;
- if (!--handle->open) {
+ if (dev->open) {
+ retval = dev->open(dev);
+ if (retval) {
+ dev->users--;
+ handle->open--;
/*
* Make sure we are not delivering any more events
* through this handle
*/
synchronize_rcu();
+ goto out;
}
}
+ if (dev->poller)
+ input_dev_poller_start(dev->poller);
+
out:
mutex_unlock(&dev->mutex);
return retval;
@@ -655,8 +674,13 @@ void input_close_device(struct input_handle *handle)
__input_release_device(handle);
- if (!--dev->users && dev->close)
- dev->close(dev);
+ if (!--dev->users) {
+ if (dev->poller)
+ input_dev_poller_stop(dev->poller);
+
+ if (dev->close)
+ dev->close(dev);
+ }
if (!--handle->open) {
/*
@@ -1502,6 +1526,7 @@ static const struct attribute_group *input_dev_attr_groups[] = {
&input_dev_attr_group,
&input_dev_id_attr_group,
&input_dev_caps_attr_group,
+ &input_poller_attribute_group,
NULL
};
@@ -1511,6 +1536,7 @@ static void input_dev_release(struct device *device)
input_ff_destroy(dev);
input_mt_destroy_slots(dev);
+ kfree(dev->poller);
kfree(dev->absinfo);
kfree(dev->vals);
kfree(dev);
@@ -1895,6 +1921,46 @@ void input_free_device(struct input_dev *dev)
EXPORT_SYMBOL(input_free_device);
/**
+ * input_set_timestamp - set timestamp for input events
+ * @dev: input device to set timestamp for
+ * @timestamp: the time at which the event has occurred
+ * in CLOCK_MONOTONIC
+ *
+ * This function is intended to provide to the input system a more
+ * accurate time of when an event actually occurred. The driver should
+ * call this function as soon as a timestamp is acquired ensuring
+ * clock conversions in input_set_timestamp are done correctly.
+ *
+ * The system entering suspend state between timestamp acquisition and
+ * calling input_set_timestamp can result in inaccurate conversions.
+ */
+void input_set_timestamp(struct input_dev *dev, ktime_t timestamp)
+{
+ dev->timestamp[INPUT_CLK_MONO] = timestamp;
+ dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp);
+ dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(timestamp,
+ TK_OFFS_BOOT);
+}
+EXPORT_SYMBOL(input_set_timestamp);
+
+/**
+ * input_get_timestamp - get timestamp for input events
+ * @dev: input device to get timestamp from
+ *
+ * A valid timestamp is a timestamp of non-zero value.
+ */
+ktime_t *input_get_timestamp(struct input_dev *dev)
+{
+ const ktime_t invalid_timestamp = ktime_set(0, 0);
+
+ if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp))
+ input_set_timestamp(dev, ktime_get());
+
+ return dev->timestamp;
+}
+EXPORT_SYMBOL(input_get_timestamp);
+
+/**
* input_set_capability - mark device as capable of a certain event
* @dev: device that is capable of emitting or accepting event
* @type: type of the event (EV_KEY, EV_REL, etc...)
@@ -2135,6 +2201,9 @@ int input_register_device(struct input_dev *dev)
if (!dev->setkeycode)
dev->setkeycode = input_default_setkeycode;
+ if (dev->poller)
+ input_dev_poller_finalize(dev->poller);
+
error = device_add(&dev->dev);
if (error)
goto err_free_vals;
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
index 72b932901d00..312b854b5506 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -362,4 +362,14 @@ config JOYSTICK_PXRC
To compile this driver as a module, choose M here: the
module will be called pxrc.
+config JOYSTICK_FSIA6B
+ tristate "FlySky FS-iA6B RC Receiver"
+ select SERIO
+ help
+ Say Y here if you use a FlySky FS-i6 RC remote control along with the
+ FS-iA6B RC receiver as a joystick input device.
+
+ To compile this driver as a module, choose M here: the
+ module will be called fsia6b.
+
endif
diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
index dd0492ebbed7..8656023f6ef5 100644
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_JOYSTICK_AS5011) += as5011.o
obj-$(CONFIG_JOYSTICK_ANALOG) += analog.o
obj-$(CONFIG_JOYSTICK_COBRA) += cobra.o
obj-$(CONFIG_JOYSTICK_DB9) += db9.o
+obj-$(CONFIG_JOYSTICK_FSIA6B) += fsia6b.o
obj-$(CONFIG_JOYSTICK_GAMECON) += gamecon.o
obj-$(CONFIG_JOYSTICK_GF2K) += gf2k.o
obj-$(CONFIG_JOYSTICK_GRIP) += grip.o
@@ -23,7 +24,7 @@ obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydump.o
obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o
obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o
obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o
-obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o
+obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o
obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o
obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o
obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o
@@ -32,7 +33,7 @@ obj-$(CONFIG_JOYSTICK_TMDC) += tmdc.o
obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += turbografx.o
obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
+obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o
obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o
obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o
-obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o
diff --git a/drivers/input/joystick/fsia6b.c b/drivers/input/joystick/fsia6b.c
new file mode 100644
index 000000000000..e78c4c768990
--- /dev/null
+++ b/drivers/input/joystick/fsia6b.c
@@ -0,0 +1,231 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * FS-iA6B iBus RC receiver driver
+ *
+ * This driver provides all 14 channels of the FlySky FS-ia6B RC receiver
+ * as analog values.
+ *
+ * Additionally, the channels can be converted to discrete switch values.
+ * By default, it is configured for the offical FS-i6 remote control.
+ * If you use a different hardware configuration, you can configure it
+ * using the `switch_config` parameter.
+ */
+
+#include <linux/device.h>
+#include <linux/input.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/serio.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#define DRIVER_DESC "FS-iA6B iBus RC receiver"
+
+MODULE_AUTHOR("Markus Koch <markus@notsyncing.net>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+
+#define IBUS_SERVO_COUNT 14
+
+static char *switch_config = "00000022320000";
+module_param(switch_config, charp, 0444);
+MODULE_PARM_DESC(switch_config,
+ "Amount of switch positions per channel (14 characters, 0-3)");
+
+static int fsia6b_axes[IBUS_SERVO_COUNT] = {
+ ABS_X, ABS_Y,
+ ABS_Z, ABS_RX,
+ ABS_RY, ABS_RZ,
+ ABS_HAT0X, ABS_HAT0Y,
+ ABS_HAT1X, ABS_HAT1Y,
+ ABS_HAT2X, ABS_HAT2Y,
+ ABS_HAT3X, ABS_HAT3Y
+};
+
+enum ibus_state { SYNC, COLLECT, PROCESS };
+
+struct ibus_packet {
+ enum ibus_state state;
+
+ int offset;
+ u16 ibuf;
+ u16 channel[IBUS_SERVO_COUNT];
+};
+
+struct fsia6b {
+ struct input_dev *dev;
+ struct ibus_packet packet;
+
+ char phys[32];
+};
+
+static irqreturn_t fsia6b_serio_irq(struct serio *serio,
+ unsigned char data, unsigned int flags)
+{
+ struct fsia6b *fsia6b = serio_get_drvdata(serio);
+ int i;
+ int sw_state;
+ int sw_id = BTN_0;
+
+ fsia6b->packet.ibuf = (data << 8) | ((fsia6b->packet.ibuf >> 8) & 0xFF);
+
+ switch (fsia6b->packet.state) {
+ case SYNC:
+ if (fsia6b->packet.ibuf == 0x4020)
+ fsia6b->packet.state = COLLECT;
+ break;
+
+ case COLLECT:
+ fsia6b->packet.state = PROCESS;
+ break;
+
+ case PROCESS:
+ fsia6b->packet.channel[fsia6b->packet.offset] =
+ fsia6b->packet.ibuf;
+ fsia6b->packet.offset++;
+
+ if (fsia6b->packet.offset == IBUS_SERVO_COUNT) {
+ fsia6b->packet.offset = 0;
+ fsia6b->packet.state = SYNC;
+ for (i = 0; i < IBUS_SERVO_COUNT; ++i) {
+ input_report_abs(fsia6b->dev, fsia6b_axes[i],
+ fsia6b->packet.channel[i]);
+
+ sw_state = 0;
+ if (fsia6b->packet.channel[i] > 1900)
+ sw_state = 1;
+ else if (fsia6b->packet.channel[i] < 1100)
+ sw_state = 2;
+
+ switch (switch_config[i]) {
+ case '3':
+ input_report_key(fsia6b->dev,
+ sw_id++,
+ sw_state == 0);
+ /* fall-through */
+ case '2':
+ input_report_key(fsia6b->dev,
+ sw_id++,
+ sw_state == 1);
+ /* fall-through */
+ case '1':
+ input_report_key(fsia6b->dev,
+ sw_id++,
+ sw_state == 2);
+ }
+ }
+ input_sync(fsia6b->dev);
+ } else {
+ fsia6b->packet.state = COLLECT;
+ }
+ break;
+ }
+
+ return IRQ_HANDLED;
+}
+
+static int fsia6b_serio_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct fsia6b *fsia6b;
+ struct input_dev *input_dev;
+ int err;
+ int i, j;
+ int sw_id = 0;
+
+ fsia6b = kzalloc(sizeof(*fsia6b), GFP_KERNEL);
+ if (!fsia6b)
+ return -ENOMEM;
+
+ fsia6b->packet.ibuf = 0;
+ fsia6b->packet.offset = 0;
+ fsia6b->packet.state = SYNC;
+
+ serio_set_drvdata(serio, fsia6b);
+
+ input_dev = input_allocate_device();
+ if (!input_dev) {
+ err = -ENOMEM;
+ goto fail1;
+ }
+ fsia6b->dev = input_dev;
+
+ snprintf(fsia6b->phys, sizeof(fsia6b->phys), "%s/input0", serio->phys);
+
+ input_dev->name = DRIVER_DESC;
+ input_dev->phys = fsia6b->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_FSIA6B;
+ input_dev->id.product = serio->id.id;
+ input_dev->id.version = 0x0100;
+ input_dev->dev.parent = &serio->dev;
+
+ for (i = 0; i < IBUS_SERVO_COUNT; i++)
+ input_set_abs_params(input_dev, fsia6b_axes[i],
+ 1000, 2000, 2, 2);
+
+ /* Register switch configuration */
+ for (i = 0; i < IBUS_SERVO_COUNT; i++) {
+ if (switch_config[i] < '0' || switch_config[i] > '3') {
+ dev_err(&fsia6b->dev->dev,
+ "Invalid switch configuration supplied for fsia6b.\n");
+ err = -EINVAL;
+ goto fail2;
+ }
+
+ for (j = '1'; j <= switch_config[i]; j++) {
+ input_set_capability(input_dev, EV_KEY, BTN_0 + sw_id);
+ sw_id++;
+ }
+ }
+
+ err = serio_open(serio, drv);
+ if (err)
+ goto fail2;
+
+ err = input_register_device(fsia6b->dev);
+ if (err)
+ goto fail3;
+
+ return 0;
+
+fail3: serio_close(serio);
+fail2: input_free_device(input_dev);
+fail1: serio_set_drvdata(serio, NULL);
+ kfree(fsia6b);
+ return err;
+}
+
+static void fsia6b_serio_disconnect(struct serio *serio)
+{
+ struct fsia6b *fsia6b = serio_get_drvdata(serio);
+
+ serio_close(serio);
+ serio_set_drvdata(serio, NULL);
+ input_unregister_device(fsia6b->dev);
+ kfree(fsia6b);
+}
+
+static const struct serio_device_id fsia6b_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_FSIA6B,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, fsia6b_serio_ids);
+
+static struct serio_driver fsia6b_serio_drv = {
+ .driver = {
+ .name = "fsia6b"
+ },
+ .description = DRIVER_DESC,
+ .id_table = fsia6b_serio_ids,
+ .interrupt = fsia6b_serio_irq,
+ .connect = fsia6b_serio_connect,
+ .disconnect = fsia6b_serio_disconnect
+};
+
+module_serio_driver(fsia6b_serio_drv)
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 0284da874a2b..1777e68c9f02 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -223,7 +223,7 @@ static __u64 sw_get_bits(unsigned char *buf, int pos, int num, char bits)
static void sw_init_digital(struct gameport *gameport)
{
- int seq[] = { 140, 140+725, 140+300, 0 };
+ static const int seq[] = { 140, 140+725, 140+300, 0 };
unsigned long flags;
int i, t;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 90e8a7f2f07c..2e6d2887eec1 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -733,17 +733,6 @@ config KEYBOARD_XTKBD
To compile this driver as a module, choose M here: the
module will be called xtkbd.
-config KEYBOARD_W90P910
- tristate "W90P910 Matrix Keypad support"
- depends on ARCH_W90X900
- select INPUT_MATRIXKMAP
- help
- Say Y here to enable the matrix keypad on evaluation board
- based on W90P910.
-
- To compile this driver as a module, choose M here: the
- module will be called w90p910_keypad.
-
config KEYBOARD_CROS_EC
tristate "ChromeOS EC keyboard"
select INPUT_MATRIXKMAP
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 06a0af6efeae..9510325c0c5d 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -68,4 +68,3 @@ obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o
obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY) += tm2-touchkey.o
obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
-obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index 584289b67fb3..d38398526965 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -1797,30 +1797,12 @@ static int applespi_probe(struct spi_device *spi)
/* set up debugfs entries for touchpad dimensions logging */
applespi->debugfs_root = debugfs_create_dir("applespi", NULL);
- if (IS_ERR(applespi->debugfs_root)) {
- if (PTR_ERR(applespi->debugfs_root) != -ENODEV)
- dev_warn(&applespi->spi->dev,
- "Error creating debugfs root entry (%ld)\n",
- PTR_ERR(applespi->debugfs_root));
- } else {
- struct dentry *ret;
-
- ret = debugfs_create_bool("enable_tp_dim", 0600,
- applespi->debugfs_root,
- &applespi->debug_tp_dim);
- if (IS_ERR(ret))
- dev_dbg(&applespi->spi->dev,
- "Error creating debugfs entry enable_tp_dim (%ld)\n",
- PTR_ERR(ret));
-
- ret = debugfs_create_file("tp_dim", 0400,
- applespi->debugfs_root, applespi,
- &applespi_tp_dim_fops);
- if (IS_ERR(ret))
- dev_dbg(&applespi->spi->dev,
- "Error creating debugfs entry tp_dim (%ld)\n",
- PTR_ERR(ret));
- }
+
+ debugfs_create_bool("enable_tp_dim", 0600, applespi->debugfs_root,
+ &applespi->debug_tp_dim);
+
+ debugfs_create_file("tp_dim", 0400, applespi->debugfs_root, applespi,
+ &applespi_tp_dim_fops);
return 0;
}
diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c
index e1cf63ee148f..2b771c3a5578 100644
--- a/drivers/input/keyboard/bcm-keypad.c
+++ b/drivers/input/keyboard/bcm-keypad.c
@@ -413,10 +413,8 @@ static int bcm_kp_probe(struct platform_device *pdev)
bcm_kp_stop(kp);
kp->irq = platform_get_irq(pdev, 0);
- if (kp->irq < 0) {
- dev_err(&pdev->dev, "no IRQ specified\n");
+ if (kp->irq < 0)
return -EINVAL;
- }
error = devm_request_threaded_irq(&pdev->dev, kp->irq,
NULL, bcm_kp_isr_thread,
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 38cb6d82d8fe..bef7bee6f05e 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -226,6 +226,8 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
{
struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb,
notifier);
+ uint8_t mkbp_event_type = ckdev->ec->event_data.event_type &
+ EC_MKBP_EVENT_TYPE_MASK;
u32 val;
unsigned int ev_type;
@@ -237,7 +239,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
return NOTIFY_OK;
- switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) {
+ switch (mkbp_event_type) {
case EC_MKBP_EVENT_KEY_MATRIX:
pm_wakeup_event(ckdev->dev, 0);
@@ -264,7 +266,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
case EC_MKBP_EVENT_SWITCH:
pm_wakeup_event(ckdev->dev, 0);
- if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
+ if (mkbp_event_type == EC_MKBP_EVENT_BUTTON) {
val = get_unaligned_le32(
&ckdev->ec->event_data.data.buttons);
ev_type = EV_KEY;
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
index 1d94928db922..f489cd585b33 100644
--- a/drivers/input/keyboard/davinci_keyscan.c
+++ b/drivers/input/keyboard/davinci_keyscan.c
@@ -192,7 +192,6 @@ static int __init davinci_ks_probe(struct platform_device *pdev)
davinci_ks->irq = platform_get_irq(pdev, 0);
if (davinci_ks->irq < 0) {
- dev_err(dev, "no key scan irq\n");
error = davinci_ks->irq;
goto fail2;
}
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 03f4d152f6b7..1373dc5b0765 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -351,10 +351,7 @@ static struct attribute *gpio_keys_attrs[] = {
&dev_attr_disabled_switches.attr,
NULL,
};
-
-static const struct attribute_group gpio_keys_attr_group = {
- .attrs = gpio_keys_attrs,
-};
+ATTRIBUTE_GROUPS(gpio_keys);
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
{
@@ -851,13 +848,6 @@ static int gpio_keys_probe(struct platform_device *pdev)
fwnode_handle_put(child);
- error = devm_device_add_group(dev, &gpio_keys_attr_group);
- if (error) {
- dev_err(dev, "Unable to export keys/switches, error: %d\n",
- error);
- return error;
- }
-
error = input_register_device(input);
if (error) {
dev_err(dev, "Unable to register input device, error: %d\n",
@@ -1026,6 +1016,7 @@ static struct platform_driver gpio_keys_device_driver = {
.name = "gpio-keys",
.pm = &gpio_keys_pm_ops,
.of_match_table = gpio_keys_of_match,
+ .dev_groups = gpio_keys_groups,
}
};
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 97500a2de2d5..5a46d113e909 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -430,10 +430,8 @@ static int imx_keypad_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "no irq defined in platform data\n");
+ if (irq < 0)
return irq;
- }
input_dev = devm_input_allocate_device(&pdev->dev);
if (!input_dev) {
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c
index a34e3271b0c9..348af2aeb5de 100644
--- a/drivers/input/keyboard/lpc32xx-keys.c
+++ b/drivers/input/keyboard/lpc32xx-keys.c
@@ -172,10 +172,8 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get platform irq\n");
+ if (irq < 0)
return -EINVAL;
- }
kscandat = devm_kzalloc(&pdev->dev, sizeof(*kscandat),
GFP_KERNEL);
diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c
index e9ceaa16b46a..ee80de44ce3f 100644
--- a/drivers/input/keyboard/mpr121_touchkey.c
+++ b/drivers/input/keyboard/mpr121_touchkey.c
@@ -253,8 +253,7 @@ static int mpr_touchkey_probe(struct i2c_client *client,
mpr121->client = client;
mpr121->input_dev = input_dev;
- mpr121->keycount = device_property_read_u32_array(dev, "linux,keycodes",
- NULL, 0);
+ mpr121->keycount = device_property_count_u32(dev, "linux,keycodes");
if (mpr121->keycount > MPR121_MAX_KEY_COUNT) {
dev_err(dev, "too many keys defined (%d)\n", mpr121->keycount);
return -EINVAL;
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index fa265fdce2c4..608446e14614 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -235,10 +235,8 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get keypad irq\n");
+ if (irq < 0)
return -EINVAL;
- }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index 57eac91ecd76..63d5e488137d 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -165,10 +165,8 @@ static int nspire_keypad_probe(struct platform_device *pdev)
int error;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get keypad irq\n");
+ if (irq < 0)
return -EINVAL;
- }
keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad),
GFP_KERNEL);
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
index 159346cb4060..b0ea387414c1 100644
--- a/drivers/input/keyboard/opencores-kbd.c
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -49,10 +49,8 @@ static int opencores_kbd_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "missing board IRQ resource\n");
+ if (irq < 0)
return -EINVAL;
- }
opencores_kbd = devm_kzalloc(&pdev->dev, sizeof(*opencores_kbd),
GFP_KERNEL);
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index d529768a1d06..91d5811d6f0e 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -544,16 +544,12 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
}
kp->key_sense_irq = platform_get_irq(pdev, 0);
- if (kp->key_sense_irq < 0) {
- dev_err(&pdev->dev, "unable to get keypad sense irq\n");
+ if (kp->key_sense_irq < 0)
return kp->key_sense_irq;
- }
kp->key_stuck_irq = platform_get_irq(pdev, 1);
- if (kp->key_stuck_irq < 0) {
- dev_err(&pdev->dev, "unable to get keypad stuck irq\n");
+ if (kp->key_stuck_irq < 0)
return kp->key_stuck_irq;
- }
kp->input->name = "PMIC8XXX keypad";
kp->input->phys = "pmic8xxx_keypad/input0";
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 39023664d2f2..7e65708b25a4 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -727,10 +727,8 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
return -EINVAL;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get keypad irq\n");
+ if (irq < 0)
return -ENXIO;
- }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
diff --git a/drivers/input/keyboard/pxa930_rotary.c b/drivers/input/keyboard/pxa930_rotary.c
index 585e7765cbf0..f7414091d94e 100644
--- a/drivers/input/keyboard/pxa930_rotary.c
+++ b/drivers/input/keyboard/pxa930_rotary.c
@@ -89,10 +89,8 @@ static int pxa930_rotary_probe(struct platform_device *pdev)
int err;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "no irq for rotary controller\n");
+ if (irq < 0)
return -ENXIO;
- }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index 08ba41a81f14..27ad73f43451 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -181,10 +181,8 @@ static int sh_keysc_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get irq\n");
+ if (irq < 0)
goto err0;
- }
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (priv == NULL) {
diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index 5342d8d45f81..e76b7a400a1c 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -118,10 +118,8 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
pdata->wakeup = of_property_read_bool(np, "wakeup-source");
pdata->irq = platform_get_irq(pdev, 0);
- if (pdata->irq < 0) {
- dev_err(&pdev->dev, "no irq defined in platform data\n");
+ if (pdata->irq < 0)
return -EINVAL;
- }
regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN);
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 7d25fa338ab4..9b8d78f87253 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -191,10 +191,8 @@ static int spear_kbd_probe(struct platform_device *pdev)
int error;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "not able to get irq for the device\n");
+ if (irq < 0)
return irq;
- }
kbd = devm_kzalloc(&pdev->dev, sizeof(*kbd), GFP_KERNEL);
if (!kbd) {
diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c
index f097128b93fe..27562cd67fb6 100644
--- a/drivers/input/keyboard/st-keyscan.c
+++ b/drivers/input/keyboard/st-keyscan.c
@@ -187,10 +187,8 @@ static int keyscan_probe(struct platform_device *pdev)
keyscan_stop(keypad_data);
keypad_data->irq = platform_get_irq(pdev, 0);
- if (keypad_data->irq < 0) {
- dev_err(&pdev->dev, "no IRQ specified\n");
+ if (keypad_data->irq < 0)
return -EINVAL;
- }
error = devm_request_irq(&pdev->dev, keypad_data->irq, keyscan_isr, 0,
pdev->name, keypad_data);
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index a37a7a9e9171..d34d6947960f 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -631,10 +631,8 @@ static int tegra_kbc_probe(struct platform_device *pdev)
return -EINVAL;
kbc->irq = platform_get_irq(pdev, 0);
- if (kbc->irq < 0) {
- dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
+ if (kbc->irq < 0)
return -ENXIO;
- }
kbc->idev = devm_input_allocate_device(&pdev->dev);
if (!kbc->idev) {
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c
deleted file mode 100644
index c88d05d6108a..000000000000
--- a/drivers/input/keyboard/w90p910_keypad.c
+++ /dev/null
@@ -1,264 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2008-2009 Nuvoton technology corporation.
- *
- * Wan ZongShun <mcuos.com@gmail.com>
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/input.h>
-#include <linux/device.h>
-#include <linux/platform_device.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/slab.h>
-
-#include <linux/platform_data/keypad-w90p910.h>
-
-/* Keypad Interface Control Registers */
-#define KPI_CONF 0x00
-#define KPI_3KCONF 0x04
-#define KPI_LPCONF 0x08
-#define KPI_STATUS 0x0C
-
-#define IS1KEY (0x01 << 16)
-#define INTTR (0x01 << 21)
-#define KEY0R (0x0f << 3)
-#define KEY0C 0x07
-#define DEBOUNCE_BIT 0x08
-#define KSIZE0 (0x01 << 16)
-#define KSIZE1 (0x01 << 17)
-#define KPSEL (0x01 << 19)
-#define ENKP (0x01 << 18)
-
-#define KGET_RAW(n) (((n) & KEY0R) >> 3)
-#define KGET_COLUMN(n) ((n) & KEY0C)
-
-#define W90P910_NUM_ROWS 8
-#define W90P910_NUM_COLS 8
-#define W90P910_ROW_SHIFT 3
-
-struct w90p910_keypad {
- const struct w90p910_keypad_platform_data *pdata;
- struct clk *clk;
- struct input_dev *input_dev;
- void __iomem *mmio_base;
- int irq;
- unsigned short keymap[W90P910_NUM_ROWS * W90P910_NUM_COLS];
-};
-
-static void w90p910_keypad_scan_matrix(struct w90p910_keypad *keypad,
- unsigned int status)
-{
- struct input_dev *input_dev = keypad->input_dev;
- unsigned int row = KGET_RAW(status);
- unsigned int col = KGET_COLUMN(status);
- unsigned int code = MATRIX_SCAN_CODE(row, col, W90P910_ROW_SHIFT);
- unsigned int key = keypad->keymap[code];
-
- input_event(input_dev, EV_MSC, MSC_SCAN, code);
- input_report_key(input_dev, key, 1);
- input_sync(input_dev);
-
- input_event(input_dev, EV_MSC, MSC_SCAN, code);
- input_report_key(input_dev, key, 0);
- input_sync(input_dev);
-}
-
-static irqreturn_t w90p910_keypad_irq_handler(int irq, void *dev_id)
-{
- struct w90p910_keypad *keypad = dev_id;
- unsigned int kstatus, val;
-
- kstatus = __raw_readl(keypad->mmio_base + KPI_STATUS);
-
- val = INTTR | IS1KEY;
-
- if (kstatus & val)
- w90p910_keypad_scan_matrix(keypad, kstatus);
-
- return IRQ_HANDLED;
-}
-
-static int w90p910_keypad_open(struct input_dev *dev)
-{
- struct w90p910_keypad *keypad = input_get_drvdata(dev);
- const struct w90p910_keypad_platform_data *pdata = keypad->pdata;
- unsigned int val, config;
-
- /* Enable unit clock */
- clk_enable(keypad->clk);
-
- val = __raw_readl(keypad->mmio_base + KPI_CONF);
- val |= (KPSEL | ENKP);
- val &= ~(KSIZE0 | KSIZE1);
-
- config = pdata->prescale | (pdata->debounce << DEBOUNCE_BIT);
-
- val |= config;
-
- __raw_writel(val, keypad->mmio_base + KPI_CONF);
-
- return 0;
-}
-
-static void w90p910_keypad_close(struct input_dev *dev)
-{
- struct w90p910_keypad *keypad = input_get_drvdata(dev);
-
- /* Disable clock unit */
- clk_disable(keypad->clk);
-}
-
-static int w90p910_keypad_probe(struct platform_device *pdev)
-{
- const struct w90p910_keypad_platform_data *pdata =
- dev_get_platdata(&pdev->dev);
- const struct matrix_keymap_data *keymap_data;
- struct w90p910_keypad *keypad;
- struct input_dev *input_dev;
- struct resource *res;
- int irq;
- int error;
-
- if (!pdata) {
- dev_err(&pdev->dev, "no platform data defined\n");
- return -EINVAL;
- }
-
- keymap_data = pdata->keymap_data;
-
- irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get keypad irq\n");
- return -ENXIO;
- }
-
- keypad = kzalloc(sizeof(struct w90p910_keypad), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!keypad || !input_dev) {
- dev_err(&pdev->dev, "failed to allocate driver data\n");
- error = -ENOMEM;
- goto failed_free;
- }
-
- keypad->pdata = pdata;
- keypad->input_dev = input_dev;
- keypad->irq = irq;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (res == NULL) {
- dev_err(&pdev->dev, "failed to get I/O memory\n");
- error = -ENXIO;
- goto failed_free;
- }
-
- res = request_mem_region(res->start, resource_size(res), pdev->name);
- if (res == NULL) {
- dev_err(&pdev->dev, "failed to request I/O memory\n");
- error = -EBUSY;
- goto failed_free;
- }
-
- keypad->mmio_base = ioremap(res->start, resource_size(res));
- if (keypad->mmio_base == NULL) {
- dev_err(&pdev->dev, "failed to remap I/O memory\n");
- error = -ENXIO;
- goto failed_free_res;
- }
-
- keypad->clk = clk_get(&pdev->dev, NULL);
- if (IS_ERR(keypad->clk)) {
- dev_err(&pdev->dev, "failed to get keypad clock\n");
- error = PTR_ERR(keypad->clk);
- goto failed_free_io;
- }
-
- /* set multi-function pin for w90p910 kpi. */
- mfp_set_groupi(&pdev->dev);
-
- input_dev->name = pdev->name;
- input_dev->id.bustype = BUS_HOST;
- input_dev->open = w90p910_keypad_open;
- input_dev->close = w90p910_keypad_close;
- input_dev->dev.parent = &pdev->dev;
-
- error = matrix_keypad_build_keymap(keymap_data, NULL,
- W90P910_NUM_ROWS, W90P910_NUM_COLS,
- keypad->keymap, input_dev);
- if (error) {
- dev_err(&pdev->dev, "failed to build keymap\n");
- goto failed_put_clk;
- }
-
- error = request_irq(keypad->irq, w90p910_keypad_irq_handler,
- 0, pdev->name, keypad);
- if (error) {
- dev_err(&pdev->dev, "failed to request IRQ\n");
- goto failed_put_clk;
- }
-
- __set_bit(EV_REP, input_dev->evbit);
- input_set_capability(input_dev, EV_MSC, MSC_SCAN);
- input_set_drvdata(input_dev, keypad);
-
- /* Register the input device */
- error = input_register_device(input_dev);
- if (error) {
- dev_err(&pdev->dev, "failed to register input device\n");
- goto failed_free_irq;
- }
-
- platform_set_drvdata(pdev, keypad);
- return 0;
-
-failed_free_irq:
- free_irq(irq, keypad);
-failed_put_clk:
- clk_put(keypad->clk);
-failed_free_io:
- iounmap(keypad->mmio_base);
-failed_free_res:
- release_mem_region(res->start, resource_size(res));
-failed_free:
- input_free_device(input_dev);
- kfree(keypad);
- return error;
-}
-
-static int w90p910_keypad_remove(struct platform_device *pdev)
-{
- struct w90p910_keypad *keypad = platform_get_drvdata(pdev);
- struct resource *res;
-
- free_irq(keypad->irq, keypad);
-
- clk_put(keypad->clk);
-
- input_unregister_device(keypad->input_dev);
-
- iounmap(keypad->mmio_base);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-
- kfree(keypad);
-
- return 0;
-}
-
-static struct platform_driver w90p910_keypad_driver = {
- .probe = w90p910_keypad_probe,
- .remove = w90p910_keypad_remove,
- .driver = {
- .name = "nuc900-kpi",
- },
-};
-module_platform_driver(w90p910_keypad_driver);
-
-MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
-MODULE_DESCRIPTION("w90p910 keypad driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:nuc900-keypad");
diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c
index da312be94c3a..4fa53423f56c 100644
--- a/drivers/input/matrix-keymap.c
+++ b/drivers/input/matrix-keymap.c
@@ -81,7 +81,7 @@ static int matrix_keypad_parse_keymap(const char *propname,
if (!propname)
propname = "linux,keymap";
- size = device_property_read_u32_array(dev, propname, NULL, 0);
+ size = device_property_count_u32(dev, propname);
if (size <= 0) {
dev_err(dev, "missing or malformed property %s: %d\n",
propname, size);
diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c
index 45a09497f680..51c8a326fd06 100644
--- a/drivers/input/misc/88pm80x_onkey.c
+++ b/drivers/input/misc/88pm80x_onkey.c
@@ -77,7 +77,6 @@ static int pm80x_onkey_probe(struct platform_device *pdev)
info->irq = platform_get_irq(pdev, 0);
if (info->irq < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
err = -EINVAL;
goto out;
}
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
index cc87443aa2ee..685995cad73f 100644
--- a/drivers/input/misc/88pm860x_onkey.c
+++ b/drivers/input/misc/88pm860x_onkey.c
@@ -64,10 +64,8 @@ static int pm860x_onkey_probe(struct platform_device *pdev)
int irq, ret;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
+ if (irq < 0)
return -EINVAL;
- }
info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info),
GFP_KERNEL);
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index d07c1eb15aa6..7d9ae394e597 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -813,10 +813,10 @@ config INPUT_IDEAPAD_SLIDEBAR
config INPUT_SOC_BUTTON_ARRAY
tristate "Windows-compatible SoC Button Array"
- depends on KEYBOARD_GPIO
+ depends on KEYBOARD_GPIO && ACPI
help
- Say Y here if you have a SoC-based tablet that originally
- runs Windows 8.
+ Say Y here if you have a SoC-based tablet that originally runs
+ Windows 8 or a Microsoft Surface Book 2, Pro 5, Laptop 1 or later.
To compile this driver as a module, choose M here: the
module will be called soc_button_array.
diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c
index 12b18a8db315..ea3b8292acdd 100644
--- a/drivers/input/misc/ab8500-ponkey.c
+++ b/drivers/input/misc/ab8500-ponkey.c
@@ -55,16 +55,12 @@ static int ab8500_ponkey_probe(struct platform_device *pdev)
int error;
irq_dbf = platform_get_irq_byname(pdev, "ONKEY_DBF");
- if (irq_dbf < 0) {
- dev_err(&pdev->dev, "No IRQ for ONKEY_DBF, error=%d\n", irq_dbf);
+ if (irq_dbf < 0)
return irq_dbf;
- }
irq_dbr = platform_get_irq_byname(pdev, "ONKEY_DBR");
- if (irq_dbr < 0) {
- dev_err(&pdev->dev, "No IRQ for ONKEY_DBR, error=%d\n", irq_dbr);
+ if (irq_dbr < 0)
return irq_dbr;
- }
ponkey = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_ponkey),
GFP_KERNEL);
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index debeeaeb8812..17c1cca74498 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -195,15 +195,12 @@ DEVICE_ATTR(startup, 0644, axp20x_show_attr_startup, axp20x_store_attr_startup);
DEVICE_ATTR(shutdown, 0644, axp20x_show_attr_shutdown,
axp20x_store_attr_shutdown);
-static struct attribute *axp20x_attributes[] = {
+static struct attribute *axp20x_attrs[] = {
&dev_attr_startup.attr,
&dev_attr_shutdown.attr,
NULL,
};
-
-static const struct attribute_group axp20x_attribute_group = {
- .attrs = axp20x_attributes,
-};
+ATTRIBUTE_GROUPS(axp20x);
static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
{
@@ -232,20 +229,14 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
int error;
axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
- if (axp20x_pek->irq_dbr < 0) {
- dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n",
- axp20x_pek->irq_dbr);
+ if (axp20x_pek->irq_dbr < 0)
return axp20x_pek->irq_dbr;
- }
axp20x_pek->irq_dbr = regmap_irq_get_virq(axp20x->regmap_irqc,
axp20x_pek->irq_dbr);
axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF");
- if (axp20x_pek->irq_dbf < 0) {
- dev_err(&pdev->dev, "No IRQ for PEK_DBF, error=%d\n",
- axp20x_pek->irq_dbf);
+ if (axp20x_pek->irq_dbf < 0)
return axp20x_pek->irq_dbf;
- }
axp20x_pek->irq_dbf = regmap_irq_get_virq(axp20x->regmap_irqc,
axp20x_pek->irq_dbf);
@@ -356,13 +347,6 @@ static int axp20x_pek_probe(struct platform_device *pdev)
axp20x_pek->info = (struct axp20x_info *)match->driver_data;
- error = devm_device_add_group(&pdev->dev, &axp20x_attribute_group);
- if (error) {
- dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n",
- error);
- return error;
- }
-
platform_set_drvdata(pdev, axp20x_pek);
return 0;
@@ -411,6 +395,7 @@ static struct platform_driver axp20x_pek_driver = {
.driver = {
.name = "axp20x-pek",
.pm = &axp20x_pek_pm_ops,
+ .dev_groups = axp20x_groups,
},
};
module_platform_driver(axp20x_pek_driver);
diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c
index a4ff4782e605..7a0d3a1d503c 100644
--- a/drivers/input/misc/da9055_onkey.c
+++ b/drivers/input/misc/da9055_onkey.c
@@ -76,11 +76,8 @@ static int da9055_onkey_probe(struct platform_device *pdev)
int irq, err;
irq = platform_get_irq_byname(pdev, "ONKEY");
- if (irq < 0) {
- dev_err(&pdev->dev,
- "Failed to get an IRQ for input device, %d\n", irq);
+ if (irq < 0)
return -EINVAL;
- }
onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
if (!onkey) {
diff --git a/drivers/input/misc/da9063_onkey.c b/drivers/input/misc/da9063_onkey.c
index fd355cf59397..dace8577fa43 100644
--- a/drivers/input/misc/da9063_onkey.c
+++ b/drivers/input/misc/da9063_onkey.c
@@ -248,11 +248,8 @@ static int da9063_onkey_probe(struct platform_device *pdev)
}
irq = platform_get_irq_byname(pdev, "ONKEY");
- if (irq < 0) {
- error = irq;
- dev_err(&pdev->dev, "Failed to get platform IRQ: %d\n", error);
- return error;
- }
+ if (irq < 0)
+ return irq;
error = devm_request_threaded_irq(&pdev->dev, irq,
NULL, da9063_onkey_irq_handler,
diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c
index 4d7217f43888..e2fde6e1553f 100644
--- a/drivers/input/misc/e3x0-button.c
+++ b/drivers/input/misc/e3x0-button.c
@@ -65,18 +65,12 @@ static int e3x0_button_probe(struct platform_device *pdev)
int error;
irq_press = platform_get_irq_byname(pdev, "press");
- if (irq_press < 0) {
- dev_err(&pdev->dev, "No IRQ for 'press', error=%d\n",
- irq_press);
+ if (irq_press < 0)
return irq_press;
- }
irq_release = platform_get_irq_byname(pdev, "release");
- if (irq_release < 0) {
- dev_err(&pdev->dev, "No IRQ for 'release', error=%d\n",
- irq_release);
+ if (irq_release < 0)
return irq_release;
- }
input = devm_input_allocate_device(&pdev->dev);
if (!input)
diff --git a/drivers/input/misc/hisi_powerkey.c b/drivers/input/misc/hisi_powerkey.c
index dee6245f38d7..d3c293a95d32 100644
--- a/drivers/input/misc/hisi_powerkey.c
+++ b/drivers/input/misc/hisi_powerkey.c
@@ -90,12 +90,8 @@ static int hi65xx_powerkey_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(hi65xx_irq_info); i++) {
irq = platform_get_irq_byname(pdev, hi65xx_irq_info[i].name);
- if (irq < 0) {
- error = irq;
- dev_err(dev, "couldn't get irq %s: %d\n",
- hi65xx_irq_info[i].name, error);
- return error;
- }
+ if (irq < 0)
+ return irq;
error = devm_request_any_context_irq(dev, irq,
hi65xx_irq_info[i].handler,
diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
index 7c49b8d23894..ffab4a490c75 100644
--- a/drivers/input/misc/max8925_onkey.c
+++ b/drivers/input/misc/max8925_onkey.c
@@ -71,16 +71,12 @@ static int max8925_onkey_probe(struct platform_device *pdev)
int irq[2], error;
irq[0] = platform_get_irq(pdev, 0);
- if (irq[0] < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
+ if (irq[0] < 0)
return -EINVAL;
- }
irq[1] = platform_get_irq(pdev, 1);
- if (irq[1] < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
+ if (irq[1] < 0)
return -EINVAL;
- }
info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_onkey_info),
GFP_KERNEL);
diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
index 017f81a66658..cf8104454e74 100644
--- a/drivers/input/misc/pm8941-pwrkey.c
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -205,10 +205,8 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
return error;
pwrkey->irq = platform_get_irq(pdev, 0);
- if (pwrkey->irq < 0) {
- dev_err(&pdev->dev, "failed to get irq\n");
+ if (pwrkey->irq < 0)
return pwrkey->irq;
- }
error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2,
&pwrkey->revision);
diff --git a/drivers/input/misc/rk805-pwrkey.c b/drivers/input/misc/rk805-pwrkey.c
index 4a6d4a5746e5..3fb64dbda1a2 100644
--- a/drivers/input/misc/rk805-pwrkey.c
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -53,16 +53,12 @@ static int rk805_pwrkey_probe(struct platform_device *pdev)
input_set_capability(pwr, EV_KEY, KEY_POWER);
fall_irq = platform_get_irq(pdev, 0);
- if (fall_irq < 0) {
- dev_err(&pdev->dev, "Can't get fall irq: %d\n", fall_irq);
+ if (fall_irq < 0)
return fall_irq;
- }
rise_irq = platform_get_irq(pdev, 1);
- if (rise_irq < 0) {
- dev_err(&pdev->dev, "Can't get rise irq: %d\n", rise_irq);
+ if (rise_irq < 0)
return rise_irq;
- }
err = devm_request_any_context_irq(&pwr->dev, fall_irq,
pwrkey_fall_irq,
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 5e59f8e57f8e..97e3639e99d0 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -25,6 +25,11 @@ struct soc_button_info {
bool wakeup;
};
+struct soc_device_data {
+ const struct soc_button_info *button_info;
+ int (*check)(struct device *dev);
+};
+
/*
* Some of the buttons like volume up/down are auto repeat, while others
* are not. To support both, we register two platform devices, and put
@@ -87,8 +92,13 @@ soc_button_device_create(struct platform_device *pdev,
continue;
gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
- if (!gpio_is_valid(gpio))
+ if (gpio < 0 && gpio != -ENOENT) {
+ error = gpio;
+ goto err_free_mem;
+ } else if (!gpio_is_valid(gpio)) {
+ /* Skip GPIO if not present */
continue;
+ }
gpio_keys[n_buttons].type = info->event_type;
gpio_keys[n_buttons].code = info->event_code;
@@ -110,25 +120,19 @@ soc_button_device_create(struct platform_device *pdev,
gpio_keys_pdata->nbuttons = n_buttons;
gpio_keys_pdata->rep = autorepeat;
- pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
- if (!pd) {
- error = -ENOMEM;
+ pd = platform_device_register_resndata(&pdev->dev, "gpio-keys",
+ PLATFORM_DEVID_AUTO, NULL, 0,
+ gpio_keys_pdata,
+ sizeof(*gpio_keys_pdata));
+ error = PTR_ERR_OR_ZERO(pd);
+ if (error) {
+ dev_err(&pdev->dev,
+ "failed registering gpio-keys: %d\n", error);
goto err_free_mem;
}
- error = platform_device_add_data(pd, gpio_keys_pdata,
- sizeof(*gpio_keys_pdata));
- if (error)
- goto err_free_pdev;
-
- error = platform_device_add(pd);
- if (error)
- goto err_free_pdev;
-
return pd;
-err_free_pdev:
- platform_device_put(pd);
err_free_mem:
devm_kfree(&pdev->dev, gpio_keys_pdata);
return ERR_PTR(error);
@@ -309,23 +313,26 @@ static int soc_button_remove(struct platform_device *pdev)
static int soc_button_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- const struct acpi_device_id *id;
- struct soc_button_info *button_info;
+ const struct soc_device_data *device_data;
+ const struct soc_button_info *button_info;
struct soc_button_data *priv;
struct platform_device *pd;
int i;
int error;
- id = acpi_match_device(dev->driver->acpi_match_table, dev);
- if (!id)
- return -ENODEV;
+ device_data = acpi_device_get_match_data(dev);
+ if (device_data && device_data->check) {
+ error = device_data->check(dev);
+ if (error)
+ return error;
+ }
- if (!id->driver_data) {
+ if (device_data && device_data->button_info) {
+ button_info = device_data->button_info;
+ } else {
button_info = soc_button_get_button_info(dev);
if (IS_ERR(button_info))
return PTR_ERR(button_info);
- } else {
- button_info = (struct soc_button_info *)id->driver_data;
}
error = gpiod_count(dev, NULL);
@@ -357,7 +364,7 @@ static int soc_button_probe(struct platform_device *pdev)
if (!priv->children[0] && !priv->children[1])
return -ENODEV;
- if (!id->driver_data)
+ if (!device_data || !device_data->button_info)
devm_kfree(dev, button_info);
return 0;
@@ -368,7 +375,7 @@ static int soc_button_probe(struct platform_device *pdev)
* is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
* Platforms"
*/
-static struct soc_button_info soc_button_PNP0C40[] = {
+static const struct soc_button_info soc_button_PNP0C40[] = {
{ "power", 0, EV_KEY, KEY_POWER, false, true },
{ "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
{ "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
@@ -377,9 +384,77 @@ static struct soc_button_info soc_button_PNP0C40[] = {
{ }
};
+static const struct soc_device_data soc_device_PNP0C40 = {
+ .button_info = soc_button_PNP0C40,
+};
+
+/*
+ * Special device check for Surface Book 2 and Surface Pro (2017).
+ * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned
+ * devices use MSHW0040 for power and volume buttons, however the way they
+ * have to be addressed differs. Make sure that we only load this drivers
+ * for the correct devices by checking the OEM Platform Revision provided by
+ * the _DSM method.
+ */
+#define MSHW0040_DSM_REVISION 0x01
+#define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision
+static const guid_t MSHW0040_DSM_UUID =
+ GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65,
+ 0x49, 0x80, 0x35);
+
+static int soc_device_check_MSHW0040(struct device *dev)
+{
+ acpi_handle handle = ACPI_HANDLE(dev);
+ union acpi_object *result;
+ u64 oem_platform_rev = 0; // valid revisions are nonzero
+
+ // get OEM platform revision
+ result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
+ MSHW0040_DSM_REVISION,
+ MSHW0040_DSM_GET_OMPR, NULL,
+ ACPI_TYPE_INTEGER);
+
+ if (result) {
+ oem_platform_rev = result->integer.value;
+ ACPI_FREE(result);
+ }
+
+ /*
+ * If the revision is zero here, the _DSM evaluation has failed. This
+ * indicates that we have a Pro 4 or Book 1 and this driver should not
+ * be used.
+ */
+ if (oem_platform_rev == 0)
+ return -ENODEV;
+
+ dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);
+
+ return 0;
+}
+
+/*
+ * Button infos for Microsoft Surface Book 2 and Surface Pro (2017).
+ * Obtained from DSDT/testing.
+ */
+static const struct soc_button_info soc_button_MSHW0040[] = {
+ { "power", 0, EV_KEY, KEY_POWER, false, true },
+ { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
+ { "volume_down", 4, EV_KEY, KEY_VOLUMEDOWN, true, false },
+ { }
+};
+
+static const struct soc_device_data soc_device_MSHW0040 = {
+ .button_info = soc_button_MSHW0040,
+ .check = soc_device_check_MSHW0040,
+};
+
static const struct acpi_device_id soc_button_acpi_match[] = {
- { "PNP0C40", (unsigned long)soc_button_PNP0C40 },
+ { "PNP0C40", (unsigned long)&soc_device_PNP0C40 },
{ "ACPI0011", 0 },
+
+ /* Microsoft Surface Devices (5th and 6th generation) */
+ { "MSHW0040", (unsigned long)&soc_device_MSHW0040 },
+
{ }
};
diff --git a/drivers/input/misc/stpmic1_onkey.c b/drivers/input/misc/stpmic1_onkey.c
index 7b49c9997df7..d8dc2f2f8000 100644
--- a/drivers/input/misc/stpmic1_onkey.c
+++ b/drivers/input/misc/stpmic1_onkey.c
@@ -61,18 +61,12 @@ static int stpmic1_onkey_probe(struct platform_device *pdev)
return -ENOMEM;
onkey->irq_falling = platform_get_irq_byname(pdev, "onkey-falling");
- if (onkey->irq_falling < 0) {
- dev_err(dev, "failed: request IRQ onkey-falling %d\n",
- onkey->irq_falling);
+ if (onkey->irq_falling < 0)
return onkey->irq_falling;
- }
onkey->irq_rising = platform_get_irq_byname(pdev, "onkey-rising");
- if (onkey->irq_rising < 0) {
- dev_err(dev, "failed: request IRQ onkey-rising %d\n",
- onkey->irq_rising);
+ if (onkey->irq_rising < 0)
return onkey->irq_rising;
- }
if (!device_property_read_u32(dev, "power-off-time-sec", &val)) {
if (val > 0 && val <= 16) {
diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c
index a4455bb12ae0..f011447c44fb 100644
--- a/drivers/input/misc/tps65218-pwrbutton.c
+++ b/drivers/input/misc/tps65218-pwrbutton.c
@@ -124,10 +124,8 @@ static int tps6521x_pb_probe(struct platform_device *pdev)
device_init_wakeup(dev, true);
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(dev, "No IRQ resource!\n");
+ if (irq < 0)
return -EINVAL;
- }
error = devm_request_threaded_irq(dev, irq, NULL, tps6521x_pb_irq,
IRQF_TRIGGER_RISING |
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 93235a007d07..bf6644927630 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -272,10 +272,8 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
}
info->irq = platform_get_irq(pdev, 0);
- if (info->irq < 0) {
- dev_err(info->dev, "invalid irq\n");
+ if (info->irq < 0)
return -EINVAL;
- }
error = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
twl6040_vib_irq_handler,
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index f4bab629739c..0a1048cf23f6 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -323,18 +323,7 @@ struct alps_data {
#define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
-#ifdef CONFIG_MOUSE_PS2_ALPS
int alps_detect(struct psmouse *psmouse, bool set_properties);
int alps_init(struct psmouse *psmouse);
-#else
-inline int alps_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-inline int alps_init(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_ALPS */
#endif
diff --git a/drivers/input/mouse/byd.h b/drivers/input/mouse/byd.h
index 8cb90d904186..ff2771e2dd2e 100644
--- a/drivers/input/mouse/byd.h
+++ b/drivers/input/mouse/byd.h
@@ -2,18 +2,7 @@
#ifndef _BYD_H
#define _BYD_H
-#ifdef CONFIG_MOUSE_PS2_BYD
int byd_detect(struct psmouse *psmouse, bool set_properties);
int byd_init(struct psmouse *psmouse);
-#else
-static inline int byd_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-static inline int byd_init(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_BYD */
#endif /* _BYD_H */
diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index dfd3873513e4..c675f156948b 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -1238,13 +1238,6 @@ static const struct attribute_group cyapa_sysfs_group = {
.attrs = cyapa_sysfs_entries,
};
-static void cyapa_remove_sysfs_group(void *data)
-{
- struct cyapa *cyapa = data;
-
- sysfs_remove_group(&cyapa->client->dev.kobj, &cyapa_sysfs_group);
-}
-
static void cyapa_disable_regulator(void *data)
{
struct cyapa *cyapa = data;
@@ -1312,19 +1305,12 @@ static int cyapa_probe(struct i2c_client *client,
return error;
}
- error = sysfs_create_group(&dev->kobj, &cyapa_sysfs_group);
+ error = devm_device_add_group(dev, &cyapa_sysfs_group);
if (error) {
dev_err(dev, "failed to create sysfs entries: %d\n", error);
return error;
}
- error = devm_add_action(dev, cyapa_remove_sysfs_group, cyapa);
- if (error) {
- cyapa_remove_sysfs_group(cyapa);
- dev_err(dev, "failed to add sysfs cleanup action: %d\n", error);
- return error;
- }
-
error = cyapa_prepare_wakeup_controls(cyapa);
if (error) {
dev_err(dev, "failed to prepare wakeup controls: %d\n", error);
diff --git a/drivers/input/mouse/cypress_ps2.h b/drivers/input/mouse/cypress_ps2.h
index 1eaddd818004..bb4979d06bf9 100644
--- a/drivers/input/mouse/cypress_ps2.h
+++ b/drivers/input/mouse/cypress_ps2.h
@@ -170,18 +170,7 @@ struct cytp_data {
};
-#ifdef CONFIG_MOUSE_PS2_CYPRESS
int cypress_detect(struct psmouse *psmouse, bool set_properties);
int cypress_init(struct psmouse *psmouse);
-#else
-inline int cypress_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-inline int cypress_init(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_CYPRESS */
#endif /* _CYPRESS_PS2_H */
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index d9b103a81a79..8719da540383 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1138,13 +1138,6 @@ static void elan_disable_regulator(void *_data)
regulator_disable(data->vcc);
}
-static void elan_remove_sysfs_groups(void *_data)
-{
- struct elan_tp_data *data = _data;
-
- sysfs_remove_groups(&data->client->dev.kobj, elan_sysfs_groups);
-}
-
static int elan_probe(struct i2c_client *client,
const struct i2c_device_id *dev_id)
{
@@ -1194,9 +1187,8 @@ static int elan_probe(struct i2c_client *client,
return error;
}
- error = devm_add_action(dev, elan_disable_regulator, data);
+ error = devm_add_action_or_reset(dev, elan_disable_regulator, data);
if (error) {
- regulator_disable(data->vcc);
dev_err(dev, "Failed to add disable regulator action: %d\n",
error);
return error;
@@ -1269,20 +1261,12 @@ static int elan_probe(struct i2c_client *client,
return error;
}
- error = sysfs_create_groups(&dev->kobj, elan_sysfs_groups);
+ error = devm_device_add_groups(dev, elan_sysfs_groups);
if (error) {
dev_err(dev, "failed to create sysfs attributes: %d\n", error);
return error;
}
- error = devm_add_action(dev, elan_remove_sysfs_groups, data);
- if (error) {
- elan_remove_sysfs_groups(data);
- dev_err(dev, "Failed to add sysfs cleanup action: %d\n",
- error);
- return error;
- }
-
error = input_register_device(data->input);
if (error) {
dev_err(dev, "failed to register input device: %d\n", error);
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index 46343998522b..e0a3e59d4f1b 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -184,32 +184,18 @@ struct elantech_data {
void (*original_set_rate)(struct psmouse *psmouse, unsigned int rate);
};
-#ifdef CONFIG_MOUSE_PS2_ELANTECH
int elantech_detect(struct psmouse *psmouse, bool set_properties);
int elantech_init_ps2(struct psmouse *psmouse);
+
+#ifdef CONFIG_MOUSE_PS2_ELANTECH
int elantech_init(struct psmouse *psmouse);
#else
-static inline int elantech_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
static inline int elantech_init(struct psmouse *psmouse)
{
return -ENOSYS;
}
-static inline int elantech_init_ps2(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
#endif /* CONFIG_MOUSE_PS2_ELANTECH */
-#if defined(CONFIG_MOUSE_PS2_ELANTECH_SMBUS)
int elantech_init_smbus(struct psmouse *psmouse);
-#else
-static inline int elantech_init_smbus(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_ELANTECH_SMBUS */
#endif
diff --git a/drivers/input/mouse/hgpk.h b/drivers/input/mouse/hgpk.h
index 98b7b384229b..ce041591f1a8 100644
--- a/drivers/input/mouse/hgpk.h
+++ b/drivers/input/mouse/hgpk.h
@@ -47,22 +47,15 @@ struct hgpk_data {
int xsaw_secondary, ysaw_secondary; /* jumpiness detection */
};
-#ifdef CONFIG_MOUSE_PS2_OLPC
-void hgpk_module_init(void);
int hgpk_detect(struct psmouse *psmouse, bool set_properties);
int hgpk_init(struct psmouse *psmouse);
+
+#ifdef CONFIG_MOUSE_PS2_OLPC
+void hgpk_module_init(void);
#else
static inline void hgpk_module_init(void)
{
}
-static inline int hgpk_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENODEV;
-}
-static inline int hgpk_init(struct psmouse *psmouse)
-{
- return -ENODEV;
-}
#endif
#endif
diff --git a/drivers/input/mouse/lifebook.h b/drivers/input/mouse/lifebook.h
index 573f2ca1983d..d989cca62dd6 100644
--- a/drivers/input/mouse/lifebook.h
+++ b/drivers/input/mouse/lifebook.h
@@ -8,22 +8,15 @@
#ifndef _LIFEBOOK_H
#define _LIFEBOOK_H
-#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
-void lifebook_module_init(void);
int lifebook_detect(struct psmouse *psmouse, bool set_properties);
int lifebook_init(struct psmouse *psmouse);
+
+#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
+void lifebook_module_init(void);
#else
static inline void lifebook_module_init(void)
{
}
-static inline int lifebook_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-static inline int lifebook_init(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
#endif
#endif
diff --git a/drivers/input/mouse/logips2pp.h b/drivers/input/mouse/logips2pp.h
index 5f9344135f70..df885c4874df 100644
--- a/drivers/input/mouse/logips2pp.h
+++ b/drivers/input/mouse/logips2pp.h
@@ -8,13 +8,6 @@
#ifndef _LOGIPS2PP_H
#define _LOGIPS2PP_H
-#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
int ps2pp_detect(struct psmouse *psmouse, bool set_properties);
-#else
-static inline int ps2pp_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_LOGIPS2PP */
#endif
diff --git a/drivers/input/mouse/pxa930_trkball.c b/drivers/input/mouse/pxa930_trkball.c
index 87bac8cff6f7..41acde60b60f 100644
--- a/drivers/input/mouse/pxa930_trkball.c
+++ b/drivers/input/mouse/pxa930_trkball.c
@@ -147,10 +147,8 @@ static int pxa930_trkball_probe(struct platform_device *pdev)
int irq, error;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "failed to get trkball irq\n");
+ if (irq < 0)
return -ENXIO;
- }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
diff --git a/drivers/input/mouse/sentelic.h b/drivers/input/mouse/sentelic.h
index dc88a93adf85..02cac0e7ad63 100644
--- a/drivers/input/mouse/sentelic.h
+++ b/drivers/input/mouse/sentelic.h
@@ -106,19 +106,8 @@ struct fsp_data {
unsigned int last_mt_fgr; /* Last seen finger(multitouch) */
};
-#ifdef CONFIG_MOUSE_PS2_SENTELIC
extern int fsp_detect(struct psmouse *psmouse, bool set_properties);
extern int fsp_init(struct psmouse *psmouse);
-#else
-static inline int fsp_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-static inline int fsp_init(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
-#endif
#endif /* __KERNEL__ */
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 46bbe99d6511..56fae3472114 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -193,7 +193,7 @@ static const char * const forcepad_pnp_ids[] = {
};
/*
- * Send a command to the synpatics touchpad by special commands
+ * Send a command to the synaptics touchpad by special commands
*/
static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param)
{
diff --git a/drivers/input/mouse/touchkit_ps2.h b/drivers/input/mouse/touchkit_ps2.h
index 5acb76464a5b..c808fe6c782f 100644
--- a/drivers/input/mouse/touchkit_ps2.h
+++ b/drivers/input/mouse/touchkit_ps2.h
@@ -9,14 +9,6 @@
#ifndef _TOUCHKIT_PS2_H
#define _TOUCHKIT_PS2_H
-#ifdef CONFIG_MOUSE_PS2_TOUCHKIT
int touchkit_ps2_detect(struct psmouse *psmouse, bool set_properties);
-#else
-static inline int touchkit_ps2_detect(struct psmouse *psmouse,
- bool set_properties)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_TOUCHKIT */
#endif
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h
index 77110f3ec21d..5cb93ed26085 100644
--- a/drivers/input/mouse/trackpoint.h
+++ b/drivers/input/mouse/trackpoint.h
@@ -155,14 +155,6 @@ struct trackpoint_data {
bool ext_dev;
};
-#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
int trackpoint_detect(struct psmouse *psmouse, bool set_properties);
-#else
-static inline int trackpoint_detect(struct psmouse *psmouse,
- bool set_properties)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_MOUSE_PS2_TRACKPOINT */
#endif /* _TRACKPOINT_H */
diff --git a/drivers/input/mouse/vmmouse.h b/drivers/input/mouse/vmmouse.h
index 774549a12930..90157aecade7 100644
--- a/drivers/input/mouse/vmmouse.h
+++ b/drivers/input/mouse/vmmouse.h
@@ -8,20 +8,9 @@
#ifndef _VMMOUSE_H
#define _VMMOUSE_H
-#ifdef CONFIG_MOUSE_PS2_VMMOUSE
#define VMMOUSE_PSNAME "VirtualPS/2"
int vmmouse_detect(struct psmouse *psmouse, bool set_properties);
int vmmouse_init(struct psmouse *psmouse);
-#else
-static inline int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
-{
- return -ENOSYS;
-}
-static inline int vmmouse_init(struct psmouse *psmouse)
-{
- return -ENOSYS;
-}
-#endif
#endif
diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
index ea549efe4bc4..b7fe6eb35a4e 100644
--- a/drivers/input/rmi4/rmi_2d_sensor.c
+++ b/drivers/input/rmi4/rmi_2d_sensor.c
@@ -204,7 +204,6 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
if (sensor->topbuttonpad)
set_bit(INPUT_PROP_TOPBUTTONPAD, input->propbit);
}
-EXPORT_SYMBOL_GPL(rmi_2d_sensor_set_input_params);
int rmi_2d_sensor_configure_input(struct rmi_function *fn,
struct rmi_2d_sensor *sensor)
diff --git a/drivers/input/serio/arc_ps2.c b/drivers/input/serio/arc_ps2.c
index 443194a2b9e3..0af9fba5d16d 100644
--- a/drivers/input/serio/arc_ps2.c
+++ b/drivers/input/serio/arc_ps2.c
@@ -187,10 +187,8 @@ static int arc_ps2_probe(struct platform_device *pdev)
int error, id, i;
irq = platform_get_irq_byname(pdev, "arc_ps2_irq");
- if (irq < 0) {
- dev_err(&pdev->dev, "no IRQ defined\n");
+ if (irq < 0)
return -EINVAL;
- }
arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(struct arc_ps2_data),
GFP_KERNEL);
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index b695094290ab..20ff2bed3917 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -432,6 +432,20 @@ static int i8042_start(struct serio *serio)
{
struct i8042_port *port = serio->port_data;
+ device_set_wakeup_capable(&serio->dev, true);
+
+ /*
+ * On platforms using suspend-to-idle, allow the keyboard to
+ * wake up the system from sleep by enabling keyboard wakeups
+ * by default. This is consistent with keyboard wakeup
+ * behavior on many platforms using suspend-to-RAM (ACPI S3)
+ * by default.
+ */
+ if (pm_suspend_default_s2idle() &&
+ serio == i8042_ports[I8042_KBD_PORT_NO].serio) {
+ device_set_wakeup_enable(&serio->dev, true);
+ }
+
spin_lock_irq(&i8042_lock);
port->exists = true;
spin_unlock_irq(&i8042_lock);
@@ -1397,17 +1411,6 @@ static void __init i8042_register_ports(void)
(unsigned long) I8042_COMMAND_REG,
i8042_ports[i].irq);
serio_register_port(serio);
- device_set_wakeup_capable(&serio->dev, true);
-
- /*
- * On platforms using suspend-to-idle, allow the keyboard to
- * wake up the system from sleep by enabling keyboard wakeups
- * by default. This is consistent with keyboard wakeup
- * behavior on many platforms using suspend-to-RAM (ACPI S3)
- * by default.
- */
- if (pm_suspend_default_s2idle() && i == I8042_KBD_PORT_NO)
- device_set_wakeup_enable(&serio->dev, true);
}
}
diff --git a/drivers/input/serio/ps2-gpio.c b/drivers/input/serio/ps2-gpio.c
index e0f18469d01b..8970b49ea09a 100644
--- a/drivers/input/serio/ps2-gpio.c
+++ b/drivers/input/serio/ps2-gpio.c
@@ -369,8 +369,6 @@ static int ps2_gpio_probe(struct platform_device *pdev)
drvdata->irq = platform_get_irq(pdev, 0);
if (drvdata->irq < 0) {
- dev_err(dev, "failed to get irq from platform resource: %d\n",
- drvdata->irq);
error = drvdata->irq;
goto err_free_serio;
}
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
index 1d1bbc8da949..81a3ea4b9a3d 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -185,10 +185,8 @@ static int pm860x_touch_probe(struct platform_device *pdev)
int irq, ret, res_x = 0, data = 0;
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "No IRQ resource!\n");
+ if (irq < 0)
return -EINVAL;
- }
if (pm860x_touch_dt_init(pdev, chip, &res_x)) {
if (pdata) {
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index fb91f2d4049e..46ad9090493b 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1112,15 +1112,6 @@ config TOUCHSCREEN_TSC2007_IIO
or ambient light monitoring), temperature and raw input
values.
-config TOUCHSCREEN_W90X900
- tristate "W90P910 touchscreen driver"
- depends on ARCH_W90X900
- help
- Say Y here if you have a W90P910 based touchscreen.
-
- To compile this driver as a module, choose M here: the
- module will be called w90p910_ts.
-
config TOUCHSCREEN_PCAP
tristate "Motorola PCAP touchscreen"
depends on EZX_PCAP
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 084a596a0c8b..94c6162409b3 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -102,7 +102,6 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o
obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o
-obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o
obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
obj-$(CONFIG_TOUCHSCREEN_ZET6223) += zet6223.o
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index accbbe8d2966..51ddb204ca1b 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -20,6 +20,7 @@
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/input.h>
+#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/pm.h>
@@ -129,6 +130,8 @@ struct ads7846 {
u16 penirq_recheck_delay_usecs;
+ struct touchscreen_properties core_prop;
+
struct mutex lock;
bool stopped; /* P: lock */
bool disabled; /* P: lock */
@@ -823,17 +826,13 @@ static void ads7846_report_state(struct ads7846 *ts)
if (Rt) {
struct input_dev *input = ts->input;
- if (ts->swap_xy)
- swap(x, y);
-
if (!ts->pendown) {
input_report_key(input, BTN_TOUCH, 1);
ts->pendown = true;
dev_vdbg(&ts->spi->dev, "DOWN\n");
}
- input_report_abs(input, ABS_X, x);
- input_report_abs(input, ABS_Y, y);
+ touchscreen_report_pos(input, &ts->core_prop, x, y, false);
input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt);
input_sync(input);
@@ -1185,6 +1184,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
struct ads7846_platform_data *pdata;
struct device_node *node = dev->of_node;
const struct of_device_id *match;
+ u32 value;
if (!node) {
dev_err(dev, "Device does not have associated DT data\n");
@@ -1223,10 +1223,18 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
of_property_read_u16(node, "ti,x-max", &pdata->x_max);
of_property_read_u16(node, "ti,y-max", &pdata->y_max);
+ /*
+ * touchscreen-max-pressure gets parsed during
+ * touchscreen_parse_properties()
+ */
of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min);
+ if (!of_property_read_u32(node, "touchscreen-min-pressure", &value))
+ pdata->pressure_min = (u16) value;
of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max);
of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max);
+ if (!of_property_read_u32(node, "touchscreen-average-samples", &value))
+ pdata->debounce_max = (u16) value;
of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol);
of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep);
@@ -1309,10 +1317,7 @@ static int ads7846_probe(struct spi_device *spi)
ts->model = pdata->model ? : 7846;
ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
- ts->pressure_max = pdata->pressure_max ? : ~0;
-
ts->vref_mv = pdata->vref_mv;
- ts->swap_xy = pdata->swap_xy;
if (pdata->filter != NULL) {
if (pdata->filter_init != NULL) {
@@ -1364,6 +1369,23 @@ static int ads7846_probe(struct spi_device *spi)
input_set_abs_params(input_dev, ABS_PRESSURE,
pdata->pressure_min, pdata->pressure_max, 0, 0);
+ /*
+ * Parse common framework properties. Must be done here to ensure the
+ * correct behaviour in case of using the legacy vendor bindings. The
+ * general binding value overrides the vendor specific one.
+ */
+ touchscreen_parse_properties(ts->input, false, &ts->core_prop);
+ ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0;
+
+ /*
+ * Check if legacy ti,swap-xy binding is used instead of
+ * touchscreen-swapped-x-y
+ */
+ if (!ts->core_prop.swap_x_y && pdata->swap_xy) {
+ swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]);
+ ts->core_prop.swap_x_y = true;
+ }
+
ads7846_setup_spi_msg(ts, pdata);
ts->reg = regulator_get(&spi->dev, "vcc");
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4a5f482cf1af..24c4b691b1c9 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2990,8 +2990,7 @@ static int mxt_parse_device_properties(struct mxt_data *data)
int error;
if (device_property_present(dev, keymap_property)) {
- n_keys = device_property_read_u32_array(dev, keymap_property,
- NULL, 0);
+ n_keys = device_property_count_u32(dev, keymap_property);
if (n_keys <= 0) {
error = n_keys < 0 ? n_keys : -EINVAL;
dev_err(dev, "invalid/malformed '%s' property: %d\n",
diff --git a/drivers/input/touchscreen/bcm_iproc_tsc.c b/drivers/input/touchscreen/bcm_iproc_tsc.c
index 4d11b27c7c43..7de1fd24ce36 100644
--- a/drivers/input/touchscreen/bcm_iproc_tsc.c
+++ b/drivers/input/touchscreen/bcm_iproc_tsc.c
@@ -489,10 +489,8 @@ static int iproc_ts_probe(struct platform_device *pdev)
/* get interrupt */
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "platform_get_irq failed: %d\n", irq);
+ if (irq < 0)
return irq;
- }
error = devm_request_irq(&pdev->dev, irq,
iproc_touchscreen_interrupt,
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 1d703e230ac3..2f1f0d7607f8 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -4,21 +4,21 @@
* Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson
*/
-#include <linux/kernel.h>
+#include <linux/bitops.h>
#include <linux/delay.h>
-#include <linux/interrupt.h>
+#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
-#include <linux/workqueue.h>
#include <linux/input.h>
-#include <linux/input/bu21013.h>
-#include <linux/slab.h>
-#include <linux/regulator/consumer.h>
+#include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/gpio.h>
-#include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/property.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+#include <linux/types.h>
-#define PEN_DOWN_INTR 0
#define MAX_FINGERS 2
#define RESET_DELAY 30
#define PENUP_TIMEOUT (10)
@@ -137,69 +137,63 @@
#define DRIVER_TP "bu21013_tp"
/**
- * struct bu21013_ts_data - touch panel data structure
+ * struct bu21013_ts - touch panel data structure
* @client: pointer to the i2c client
- * @wait: variable to wait_queue_head_t structure
- * @touch_stopped: touch stop flag
- * @chip: pointer to the touch panel controller
* @in_dev: pointer to the input device structure
- * @intr_pin: interrupt pin value
+ * @props: the device coordinate transformation properties
* @regulator: pointer to the Regulator used for touch screen
+ * @cs_gpiod: chip select GPIO line
+ * @int_gpiod: touch interrupt GPIO line
+ * @touch_x_max: maximum X coordinate reported by the device
+ * @touch_y_max: maximum Y coordinate reported by the device
+ * @x_flip: indicates that the driver should invert X coordinate before
+ * reporting
+ * @y_flip: indicates that the driver should invert Y coordinate before
+ * reporting
+ * @touch_stopped: touch stop flag
*
* Touch panel device data structure
*/
-struct bu21013_ts_data {
+struct bu21013_ts {
struct i2c_client *client;
- wait_queue_head_t wait;
- const struct bu21013_platform_device *chip;
struct input_dev *in_dev;
+ struct touchscreen_properties props;
struct regulator *regulator;
- unsigned int irq;
- unsigned int intr_pin;
+ struct gpio_desc *cs_gpiod;
+ struct gpio_desc *int_gpiod;
+ u32 touch_x_max;
+ u32 touch_y_max;
+ bool x_flip;
+ bool y_flip;
bool touch_stopped;
};
-/**
- * bu21013_read_block_data(): read the touch co-ordinates
- * @data: bu21013_ts_data structure pointer
- * @buf: byte pointer
- *
- * Read the touch co-ordinates using i2c read block into buffer
- * and returns integer.
- */
-static int bu21013_read_block_data(struct bu21013_ts_data *data, u8 *buf)
+static int bu21013_read_block_data(struct bu21013_ts *ts, u8 *buf)
{
int ret, i;
for (i = 0; i < I2C_RETRY_COUNT; i++) {
- ret = i2c_smbus_read_i2c_block_data
- (data->client, BU21013_SENSORS_BTN_0_7_REG,
- LENGTH_OF_BUFFER, buf);
+ ret = i2c_smbus_read_i2c_block_data(ts->client,
+ BU21013_SENSORS_BTN_0_7_REG,
+ LENGTH_OF_BUFFER, buf);
if (ret == LENGTH_OF_BUFFER)
return 0;
}
+
return -EINVAL;
}
-/**
- * bu21013_do_touch_report(): Get the touch co-ordinates
- * @data: bu21013_ts_data structure pointer
- *
- * Get the touch co-ordinates from touch sensor registers and writes
- * into device structure and returns integer.
- */
-static int bu21013_do_touch_report(struct bu21013_ts_data *data)
+static int bu21013_do_touch_report(struct bu21013_ts *ts)
{
- u8 buf[LENGTH_OF_BUFFER];
- unsigned int pos_x[2], pos_y[2];
- bool has_x_sensors, has_y_sensors;
- int finger_down_count = 0;
- int i;
-
- if (data == NULL)
- return -EINVAL;
-
- if (bu21013_read_block_data(data, buf) < 0)
+ struct input_dev *input = ts->in_dev;
+ struct input_mt_pos pos[MAX_FINGERS];
+ int slots[MAX_FINGERS];
+ u8 buf[LENGTH_OF_BUFFER];
+ bool has_x_sensors, has_y_sensors;
+ int finger_down_count = 0;
+ int i;
+
+ if (bu21013_read_block_data(ts, buf) < 0)
return -EINVAL;
has_x_sensors = hweight32(buf[0] & BU21013_SENSORS_EN_0_7);
@@ -209,501 +203,411 @@ static int bu21013_do_touch_report(struct bu21013_ts_data *data)
return 0;
for (i = 0; i < MAX_FINGERS; i++) {
- const u8 *p = &buf[4 * i + 3];
- unsigned int x = p[0] << SHIFT_2 | (p[1] & MASK_BITS);
- unsigned int y = p[2] << SHIFT_2 | (p[3] & MASK_BITS);
- if (x == 0 || y == 0)
- continue;
- pos_x[finger_down_count] = x;
- pos_y[finger_down_count] = y;
- finger_down_count++;
- }
-
- if (finger_down_count) {
- if (finger_down_count == 2 &&
- (abs(pos_x[0] - pos_x[1]) < DELTA_MIN ||
- abs(pos_y[0] - pos_y[1]) < DELTA_MIN)) {
- return 0;
- }
+ const u8 *data = &buf[4 * i + 3];
+ unsigned int x, y;
+
+ x = data[0] << SHIFT_2 | (data[1] & MASK_BITS);
+ y = data[2] << SHIFT_2 | (data[3] & MASK_BITS);
+ if (x != 0 && y != 0)
+ touchscreen_set_mt_pos(&pos[finger_down_count++],
+ &ts->props, x, y);
+ }
- for (i = 0; i < finger_down_count; i++) {
- if (data->chip->x_flip)
- pos_x[i] = data->chip->touch_x_max - pos_x[i];
- if (data->chip->y_flip)
- pos_y[i] = data->chip->touch_y_max - pos_y[i];
-
- input_report_abs(data->in_dev,
- ABS_MT_POSITION_X, pos_x[i]);
- input_report_abs(data->in_dev,
- ABS_MT_POSITION_Y, pos_y[i]);
- input_mt_sync(data->in_dev);
- }
- } else
- input_mt_sync(data->in_dev);
+ if (finger_down_count == 2 &&
+ (abs(pos[0].x - pos[1].x) < DELTA_MIN ||
+ abs(pos[0].y - pos[1].y) < DELTA_MIN)) {
+ return 0;
+ }
+
+ input_mt_assign_slots(input, slots, pos, finger_down_count, DELTA_MIN);
+ for (i = 0; i < finger_down_count; i++) {
+ input_mt_slot(input, slots[i]);
+ input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
+ input_report_abs(input, ABS_MT_POSITION_X, pos[i].x);
+ input_report_abs(input, ABS_MT_POSITION_Y, pos[i].y);
+ }
- input_sync(data->in_dev);
+ input_mt_sync_frame(input);
+ input_sync(input);
return 0;
}
-/**
- * bu21013_gpio_irq() - gpio thread function for touch interrupt
- * @irq: irq value
- * @device_data: void pointer
- *
- * This gpio thread function for touch interrupt
- * and returns irqreturn_t.
- */
+
static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
{
- struct bu21013_ts_data *data = device_data;
- struct i2c_client *i2c = data->client;
- int retval;
+ struct bu21013_ts *ts = device_data;
+ int keep_polling;
+ int error;
do {
- retval = bu21013_do_touch_report(data);
- if (retval < 0) {
- dev_err(&i2c->dev, "bu21013_do_touch_report failed\n");
- return IRQ_NONE;
+ error = bu21013_do_touch_report(ts);
+ if (error) {
+ dev_err(&ts->client->dev, "%s failed\n", __func__);
+ break;
}
- data->intr_pin = gpio_get_value(data->chip->touch_pin);
- if (data->intr_pin == PEN_DOWN_INTR)
- wait_event_timeout(data->wait, data->touch_stopped,
- msecs_to_jiffies(2));
- } while (!data->intr_pin && !data->touch_stopped);
+ if (unlikely(ts->touch_stopped))
+ break;
+
+ keep_polling = ts->int_gpiod ?
+ gpiod_get_value(ts->int_gpiod) : false;
+ if (keep_polling)
+ usleep_range(2000, 2500);
+ } while (keep_polling);
return IRQ_HANDLED;
}
-/**
- * bu21013_init_chip() - power on sequence for the bu21013 controller
- * @data: device structure pointer
- *
- * This function is used to power on
- * the bu21013 controller and returns integer.
- */
-static int bu21013_init_chip(struct bu21013_ts_data *data)
+static int bu21013_init_chip(struct bu21013_ts *ts)
{
- int retval;
- struct i2c_client *i2c = data->client;
+ struct i2c_client *client = ts->client;
+ int error;
- retval = i2c_smbus_write_byte_data(i2c, BU21013_RESET_REG,
- BU21013_RESET_ENABLE);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_RESET reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_RESET_REG,
+ BU21013_RESET_ENABLE);
+ if (error) {
+ dev_err(&client->dev, "BU21013_RESET reg write failed\n");
+ return error;
}
msleep(RESET_DELAY);
- retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_0_7_REG,
- BU21013_SENSORS_EN_0_7);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_SENSOR_0_7 reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_0_7_REG,
+ BU21013_SENSORS_EN_0_7);
+ if (error) {
+ dev_err(&client->dev, "BU21013_SENSOR_0_7 reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_8_15_REG,
- BU21013_SENSORS_EN_8_15);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_SENSOR_8_15 reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_8_15_REG,
+ BU21013_SENSORS_EN_8_15);
+ if (error) {
+ dev_err(&client->dev, "BU21013_SENSOR_8_15 reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_16_23_REG,
- BU21013_SENSORS_EN_16_23);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_SENSOR_16_23 reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_SENSOR_16_23_REG,
+ BU21013_SENSORS_EN_16_23);
+ if (error) {
+ dev_err(&client->dev, "BU21013_SENSOR_16_23 reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE1_REG,
- (BU21013_POS_MODE1_0 | BU21013_POS_MODE1_1));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_POS_MODE1 reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_POS_MODE1_REG,
+ BU21013_POS_MODE1_0 |
+ BU21013_POS_MODE1_1);
+ if (error) {
+ dev_err(&client->dev, "BU21013_POS_MODE1 reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE2_REG,
- (BU21013_POS_MODE2_ZERO | BU21013_POS_MODE2_AVG1 |
- BU21013_POS_MODE2_AVG2 | BU21013_POS_MODE2_EN_RAW |
- BU21013_POS_MODE2_MULTI));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_POS_MODE2 reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_POS_MODE2_REG,
+ BU21013_POS_MODE2_ZERO |
+ BU21013_POS_MODE2_AVG1 |
+ BU21013_POS_MODE2_AVG2 |
+ BU21013_POS_MODE2_EN_RAW |
+ BU21013_POS_MODE2_MULTI);
+ if (error) {
+ dev_err(&client->dev, "BU21013_POS_MODE2 reg write failed\n");
+ return error;
}
- if (data->chip->ext_clk)
- retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG,
- (BU21013_CLK_MODE_EXT | BU21013_CLK_MODE_CALIB));
- else
- retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG,
- (BU21013_CLK_MODE_DIV | BU21013_CLK_MODE_CALIB));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_CLK_MODE reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_CLK_MODE_REG,
+ BU21013_CLK_MODE_DIV |
+ BU21013_CLK_MODE_CALIB);
+ if (error) {
+ dev_err(&client->dev, "BU21013_CLK_MODE reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_IDLE_REG,
- (BU21013_IDLET_0 | BU21013_IDLE_INTERMIT_EN));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_IDLE reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_IDLE_REG,
+ BU21013_IDLET_0 |
+ BU21013_IDLE_INTERMIT_EN);
+ if (error) {
+ dev_err(&client->dev, "BU21013_IDLE reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_INT_MODE_REG,
- BU21013_INT_MODE_LEVEL);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_INT_MODE reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_INT_MODE_REG,
+ BU21013_INT_MODE_LEVEL);
+ if (error) {
+ dev_err(&client->dev, "BU21013_INT_MODE reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_FILTER_REG,
- (BU21013_DELTA_0_6 |
- BU21013_FILTER_EN));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_FILTER reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_FILTER_REG,
+ BU21013_DELTA_0_6 |
+ BU21013_FILTER_EN);
+ if (error) {
+ dev_err(&client->dev, "BU21013_FILTER reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_ON_REG,
- BU21013_TH_ON_5);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_TH_ON reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_TH_ON_REG,
+ BU21013_TH_ON_5);
+ if (error) {
+ dev_err(&client->dev, "BU21013_TH_ON reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_OFF_REG,
- BU21013_TH_OFF_4 | BU21013_TH_OFF_3);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_TH_OFF reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_TH_OFF_REG,
+ BU21013_TH_OFF_4 | BU21013_TH_OFF_3);
+ if (error) {
+ dev_err(&client->dev, "BU21013_TH_OFF reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_GAIN_REG,
- (BU21013_GAIN_0 | BU21013_GAIN_1));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_GAIN reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_GAIN_REG,
+ BU21013_GAIN_0 | BU21013_GAIN_1);
+ if (error) {
+ dev_err(&client->dev, "BU21013_GAIN reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_OFFSET_MODE_REG,
- BU21013_OFFSET_MODE_DEFAULT);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_OFFSET_MODE reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_OFFSET_MODE_REG,
+ BU21013_OFFSET_MODE_DEFAULT);
+ if (error) {
+ dev_err(&client->dev, "BU21013_OFFSET_MODE reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_XY_EDGE_REG,
- (BU21013_X_EDGE_0 | BU21013_X_EDGE_2 |
- BU21013_Y_EDGE_1 | BU21013_Y_EDGE_3));
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_XY_EDGE reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_XY_EDGE_REG,
+ BU21013_X_EDGE_0 |
+ BU21013_X_EDGE_2 |
+ BU21013_Y_EDGE_1 |
+ BU21013_Y_EDGE_3);
+ if (error) {
+ dev_err(&client->dev, "BU21013_XY_EDGE reg write failed\n");
+ return error;
}
- retval = i2c_smbus_write_byte_data(i2c, BU21013_DONE_REG,
- BU21013_DONE);
- if (retval < 0) {
- dev_err(&i2c->dev, "BU21013_REG_DONE reg write failed\n");
- return retval;
+ error = i2c_smbus_write_byte_data(client, BU21013_DONE_REG,
+ BU21013_DONE);
+ if (error) {
+ dev_err(&client->dev, "BU21013_REG_DONE reg write failed\n");
+ return error;
}
return 0;
}
-/**
- * bu21013_free_irq() - frees IRQ registered for touchscreen
- * @bu21013_data: device structure pointer
- *
- * This function signals interrupt thread to stop processing and
- * frees interrupt.
- */
-static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
-{
- bu21013_data->touch_stopped = true;
- wake_up(&bu21013_data->wait);
- free_irq(bu21013_data->irq, bu21013_data);
-}
-
-/**
- * bu21013_cs_disable() - deconfigures the touch panel controller
- * @bu21013_data: device structure pointer
- *
- * This function is used to deconfigure the chip selection
- * for touch panel controller.
- */
-static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
+static void bu21013_power_off(void *_ts)
{
- int error;
+ struct bu21013_ts *ts = _ts;
- error = gpio_direction_output(bu21013_data->chip->cs_pin, 0);
- if (error < 0)
- dev_warn(&bu21013_data->client->dev,
- "%s: gpio direction failed, error: %d\n",
- __func__, error);
- else
- gpio_set_value(bu21013_data->chip->cs_pin, 0);
-
- gpio_free(bu21013_data->chip->cs_pin);
+ regulator_disable(ts->regulator);
}
-#ifdef CONFIG_OF
-static const struct bu21013_platform_device *
-bu21013_parse_dt(struct device *dev)
+static void bu21013_disable_chip(void *_ts)
{
- struct device_node *np = dev->of_node;
- struct bu21013_platform_device *pdata;
+ struct bu21013_ts *ts = _ts;
- if (!np) {
- dev_err(dev, "no device tree or platform data\n");
- return ERR_PTR(-EINVAL);
- }
-
- pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
- if (!pdata)
- return ERR_PTR(-ENOMEM);
-
- pdata->y_flip = pdata->x_flip = false;
-
- pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
- pdata->y_flip = of_property_read_bool(np, "rohm,flip-y");
-
- of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
- of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
-
- pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
- pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
-
- pdata->ext_clk = false;
-
- return pdata;
-}
-#else
-static inline const struct bu21013_platform_device *
-bu21013_parse_dt(struct device *dev)
-{
- dev_err(dev, "no platform data available\n");
- return ERR_PTR(-EINVAL);
+ gpiod_set_value(ts->cs_gpiod, 0);
}
-#endif
-/**
- * bu21013_probe() - initializes the i2c-client touchscreen driver
- * @client: i2c client structure pointer
- * @id: i2c device id pointer
- *
- * This function used to initializes the i2c-client touchscreen
- * driver and returns integer.
- */
static int bu21013_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- const struct bu21013_platform_device *pdata =
- dev_get_platdata(&client->dev);
- struct bu21013_ts_data *bu21013_data;
+ struct bu21013_ts *ts;
struct input_dev *in_dev;
+ struct input_absinfo *info;
+ u32 max_x = 0, max_y = 0;
int error;
if (!i2c_check_functionality(client->adapter,
- I2C_FUNC_SMBUS_BYTE_DATA)) {
+ I2C_FUNC_SMBUS_BYTE_DATA)) {
dev_err(&client->dev, "i2c smbus byte data not supported\n");
return -EIO;
}
- if (!pdata) {
- pdata = bu21013_parse_dt(&client->dev);
- if (IS_ERR(pdata))
- return PTR_ERR(pdata);
- }
-
- if (!gpio_is_valid(pdata->touch_pin)) {
- dev_err(&client->dev, "invalid touch_pin supplied\n");
+ if (!client->irq) {
+ dev_err(&client->dev, "No IRQ set up\n");
return -EINVAL;
}
- bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
- in_dev = input_allocate_device();
- if (!bu21013_data || !in_dev) {
+ ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
+ if (!ts)
+ return -ENOMEM;
+
+ ts->client = client;
+
+ ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x");
+ ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y");
+
+ in_dev = devm_input_allocate_device(&client->dev);
+ if (!in_dev) {
dev_err(&client->dev, "device memory alloc failed\n");
- error = -ENOMEM;
- goto err_free_mem;
+ return -ENOMEM;
}
+ ts->in_dev = in_dev;
+ input_set_drvdata(in_dev, ts);
- bu21013_data->in_dev = in_dev;
- bu21013_data->chip = pdata;
- bu21013_data->client = client;
- bu21013_data->irq = gpio_to_irq(pdata->touch_pin);
+ /* register the device to input subsystem */
+ in_dev->name = DRIVER_TP;
+ in_dev->id.bustype = BUS_I2C;
+
+ device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x);
+ device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y);
+
+ input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0);
+ input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
+
+ touchscreen_parse_properties(in_dev, true, &ts->props);
+
+ /* Adjust for the legacy "flip" properties, if present */
+ if (!ts->props.invert_x &&
+ device_property_read_bool(&client->dev, "rohm,flip-x")) {
+ info = &in_dev->absinfo[ABS_MT_POSITION_X];
+ info->maximum -= info->minimum;
+ info->minimum = 0;
+ }
- bu21013_data->regulator = regulator_get(&client->dev, "avdd");
- if (IS_ERR(bu21013_data->regulator)) {
+ if (!ts->props.invert_y &&
+ device_property_read_bool(&client->dev, "rohm,flip-y")) {
+ info = &in_dev->absinfo[ABS_MT_POSITION_Y];
+ info->maximum -= info->minimum;
+ info->minimum = 0;
+ }
+
+ error = input_mt_init_slots(in_dev, MAX_FINGERS,
+ INPUT_MT_DIRECT | INPUT_MT_TRACK |
+ INPUT_MT_DROP_UNUSED);
+ if (error) {
+ dev_err(&client->dev, "failed to initialize MT slots");
+ return error;
+ }
+
+ ts->regulator = devm_regulator_get(&client->dev, "avdd");
+ if (IS_ERR(ts->regulator)) {
dev_err(&client->dev, "regulator_get failed\n");
- error = PTR_ERR(bu21013_data->regulator);
- goto err_free_mem;
+ return PTR_ERR(ts->regulator);
}
- error = regulator_enable(bu21013_data->regulator);
- if (error < 0) {
+ error = regulator_enable(ts->regulator);
+ if (error) {
dev_err(&client->dev, "regulator enable failed\n");
- goto err_put_regulator;
+ return error;
}
- bu21013_data->touch_stopped = false;
- init_waitqueue_head(&bu21013_data->wait);
+ error = devm_add_action_or_reset(&client->dev, bu21013_power_off, ts);
+ if (error) {
+ dev_err(&client->dev, "failed to install power off handler\n");
+ return error;
+ }
- /* configure the gpio pins */
- error = gpio_request_one(pdata->cs_pin, GPIOF_OUT_INIT_HIGH,
- "touchp_reset");
- if (error < 0) {
- dev_err(&client->dev, "Unable to request gpio reset_pin\n");
- goto err_disable_regulator;
+ /* Named "CS" on the chip, DT binding is "reset" */
+ ts->cs_gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
+ error = PTR_ERR_OR_ZERO(ts->cs_gpiod);
+ if (error) {
+ if (error != -EPROBE_DEFER)
+ dev_err(&client->dev, "failed to get CS GPIO\n");
+ return error;
+ }
+ gpiod_set_consumer_name(ts->cs_gpiod, "BU21013 CS");
+
+ error = devm_add_action_or_reset(&client->dev,
+ bu21013_disable_chip, ts);
+ if (error) {
+ dev_err(&client->dev,
+ "failed to install chip disable handler\n");
+ return error;
}
+ /* Named "INT" on the chip, DT binding is "touch" */
+ ts->int_gpiod = devm_gpiod_get_optional(&client->dev,
+ "touch", GPIOD_IN);
+ error = PTR_ERR_OR_ZERO(ts->int_gpiod);
+ if (error) {
+ if (error != -EPROBE_DEFER)
+ dev_err(&client->dev, "failed to get INT GPIO\n");
+ return error;
+ }
+
+ if (ts->int_gpiod)
+ gpiod_set_consumer_name(ts->int_gpiod, "BU21013 INT");
+
/* configure the touch panel controller */
- error = bu21013_init_chip(bu21013_data);
+ error = bu21013_init_chip(ts);
if (error) {
dev_err(&client->dev, "error in bu21013 config\n");
- goto err_cs_disable;
+ return error;
}
- /* register the device to input subsystem */
- in_dev->name = DRIVER_TP;
- in_dev->id.bustype = BUS_I2C;
- in_dev->dev.parent = &client->dev;
-
- __set_bit(EV_SYN, in_dev->evbit);
- __set_bit(EV_KEY, in_dev->evbit);
- __set_bit(EV_ABS, in_dev->evbit);
-
- input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0,
- pdata->touch_x_max, 0, 0);
- input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0,
- pdata->touch_y_max, 0, 0);
- input_set_drvdata(in_dev, bu21013_data);
-
- error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq,
- IRQF_TRIGGER_FALLING | IRQF_SHARED |
- IRQF_ONESHOT,
- DRIVER_TP, bu21013_data);
+ error = devm_request_threaded_irq(&client->dev, client->irq,
+ NULL, bu21013_gpio_irq,
+ IRQF_ONESHOT, DRIVER_TP, ts);
if (error) {
dev_err(&client->dev, "request irq %d failed\n",
- bu21013_data->irq);
- goto err_cs_disable;
+ client->irq);
+ return error;
}
error = input_register_device(in_dev);
if (error) {
dev_err(&client->dev, "failed to register input device\n");
- goto err_free_irq;
+ return error;
}
- device_init_wakeup(&client->dev, pdata->wakeup);
- i2c_set_clientdata(client, bu21013_data);
+ i2c_set_clientdata(client, ts);
return 0;
-
-err_free_irq:
- bu21013_free_irq(bu21013_data);
-err_cs_disable:
- bu21013_cs_disable(bu21013_data);
-err_disable_regulator:
- regulator_disable(bu21013_data->regulator);
-err_put_regulator:
- regulator_put(bu21013_data->regulator);
-err_free_mem:
- input_free_device(in_dev);
- kfree(bu21013_data);
-
- return error;
}
-/**
- * bu21013_remove() - removes the i2c-client touchscreen driver
- * @client: i2c client structure pointer
- *
- * This function uses to remove the i2c-client
- * touchscreen driver and returns integer.
- */
+
static int bu21013_remove(struct i2c_client *client)
{
- struct bu21013_ts_data *bu21013_data = i2c_get_clientdata(client);
+ struct bu21013_ts *ts = i2c_get_clientdata(client);
- bu21013_free_irq(bu21013_data);
-
- bu21013_cs_disable(bu21013_data);
-
- input_unregister_device(bu21013_data->in_dev);
-
- regulator_disable(bu21013_data->regulator);
- regulator_put(bu21013_data->regulator);
-
- kfree(bu21013_data);
+ /* Make sure IRQ will exit quickly even if there is contact */
+ ts->touch_stopped = true;
+ /* The resources will be freed by devm */
return 0;
}
-#ifdef CONFIG_PM
-/**
- * bu21013_suspend() - suspend the touch screen controller
- * @dev: pointer to device structure
- *
- * This function is used to suspend the
- * touch panel controller and returns integer
- */
-static int bu21013_suspend(struct device *dev)
+static int __maybe_unused bu21013_suspend(struct device *dev)
{
- struct bu21013_ts_data *bu21013_data = dev_get_drvdata(dev);
- struct i2c_client *client = bu21013_data->client;
+ struct i2c_client *client = to_i2c_client(dev);
+ struct bu21013_ts *ts = i2c_get_clientdata(client);
- bu21013_data->touch_stopped = true;
- if (device_may_wakeup(&client->dev))
- enable_irq_wake(bu21013_data->irq);
- else
- disable_irq(bu21013_data->irq);
+ ts->touch_stopped = true;
+ mb();
+ disable_irq(client->irq);
- regulator_disable(bu21013_data->regulator);
+ if (!device_may_wakeup(&client->dev))
+ regulator_disable(ts->regulator);
return 0;
}
-/**
- * bu21013_resume() - resume the touch screen controller
- * @dev: pointer to device structure
- *
- * This function is used to resume the touch panel
- * controller and returns integer.
- */
-static int bu21013_resume(struct device *dev)
+static int __maybe_unused bu21013_resume(struct device *dev)
{
- struct bu21013_ts_data *bu21013_data = dev_get_drvdata(dev);
- struct i2c_client *client = bu21013_data->client;
- int retval;
+ struct i2c_client *client = to_i2c_client(dev);
+ struct bu21013_ts *ts = i2c_get_clientdata(client);
+ int error;
- retval = regulator_enable(bu21013_data->regulator);
- if (retval < 0) {
- dev_err(&client->dev, "bu21013 regulator enable failed\n");
- return retval;
- }
+ if (!device_may_wakeup(&client->dev)) {
+ error = regulator_enable(ts->regulator);
+ if (error) {
+ dev_err(&client->dev,
+ "failed to re-enable regulator when resuming\n");
+ return error;
+ }
- retval = bu21013_init_chip(bu21013_data);
- if (retval < 0) {
- dev_err(&client->dev, "bu21013 controller config failed\n");
- return retval;
+ error = bu21013_init_chip(ts);
+ if (error) {
+ dev_err(&client->dev,
+ "failed to reinitialize chip when resuming\n");
+ return error;
+ }
}
- bu21013_data->touch_stopped = false;
-
- if (device_may_wakeup(&client->dev))
- disable_irq_wake(bu21013_data->irq);
- else
- enable_irq(bu21013_data->irq);
+ ts->touch_stopped = false;
+ mb();
+ enable_irq(client->irq);
return 0;
}
-static const struct dev_pm_ops bu21013_dev_pm_ops = {
- .suspend = bu21013_suspend,
- .resume = bu21013_resume,
-};
-#endif
+static SIMPLE_DEV_PM_OPS(bu21013_dev_pm_ops, bu21013_suspend, bu21013_resume);
static const struct i2c_device_id bu21013_id[] = {
{ DRIVER_TP, 0 },
@@ -714,9 +618,7 @@ MODULE_DEVICE_TABLE(i2c, bu21013_id);
static struct i2c_driver bu21013_driver = {
.driver = {
.name = DRIVER_TP,
-#ifdef CONFIG_PM
.pm = &bu21013_dev_pm_ops,
-#endif
},
.probe = bu21013_probe,
.remove = bu21013_remove,
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 3cc4341bbdff..5525f1fb1526 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -764,8 +764,6 @@ edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
const char *debugfs_name)
{
tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL);
- if (!tsdata->debug_dir)
- return;
debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x);
debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y);
diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c
index 1d6c8f490b40..60a7246c5157 100644
--- a/drivers/input/touchscreen/fsl-imx25-tcq.c
+++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
@@ -503,7 +503,6 @@ static int mx25_tcq_probe(struct platform_device *pdev)
struct input_dev *idev;
struct mx25_tcq_priv *priv;
struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent);
- struct resource *res;
void __iomem *mem;
int error;
@@ -512,8 +511,7 @@ static int mx25_tcq_probe(struct platform_device *pdev)
return -ENOMEM;
priv->dev = dev;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- mem = devm_ioremap_resource(dev, res);
+ mem = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(mem))
return PTR_ERR(mem);
@@ -528,10 +526,8 @@ static int mx25_tcq_probe(struct platform_device *pdev)
}
priv->irq = platform_get_irq(pdev, 0);
- if (priv->irq <= 0) {
- dev_err(dev, "Failed to get IRQ\n");
+ if (priv->irq <= 0)
return priv->irq;
- }
idev = devm_input_allocate_device(dev);
if (!idev) {
diff --git a/drivers/input/touchscreen/hideep.c b/drivers/input/touchscreen/hideep.c
index 84fbbf415c43..ddad4a82a5e5 100644
--- a/drivers/input/touchscreen/hideep.c
+++ b/drivers/input/touchscreen/hideep.c
@@ -811,8 +811,7 @@ static int hideep_init_input(struct hideep_ts *ts)
if (error)
return error;
- ts->key_num = device_property_read_u32_array(dev, "linux,keycodes",
- NULL, 0);
+ ts->key_num = device_property_count_u32(dev, "linux,keycodes");
if (ts->key_num > HIDEEP_KEY_MAX) {
dev_err(dev, "too many keys defined: %d\n",
ts->key_num);
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index e04eecd65bbb..9ed258854349 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -430,16 +430,12 @@ static int imx6ul_tsc_probe(struct platform_device *pdev)
}
tsc_irq = platform_get_irq(pdev, 0);
- if (tsc_irq < 0) {
- dev_err(&pdev->dev, "no tsc irq resource?\n");
+ if (tsc_irq < 0)
return tsc_irq;
- }
adc_irq = platform_get_irq(pdev, 1);
- if (adc_irq < 0) {
- dev_err(&pdev->dev, "no adc irq resource?\n");
+ if (adc_irq < 0)
return adc_irq;
- }
err = devm_request_threaded_irq(tsc->dev, tsc_irq,
NULL, tsc_irq_fn, IRQF_ONESHOT,
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
index 567ed64b5392..b2cd9472e2d1 100644
--- a/drivers/input/touchscreen/lpc32xx_ts.c
+++ b/drivers/input/touchscreen/lpc32xx_ts.c
@@ -212,10 +212,8 @@ static int lpc32xx_ts_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "Can't get interrupt resource\n");
+ if (irq < 0)
return irq;
- }
tsc = kzalloc(sizeof(*tsc), GFP_KERNEL);
input = input_allocate_device();
diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
index 593b8d3e90b5..9e36fee38d61 100644
--- a/drivers/input/touchscreen/mxs-lradc-ts.c
+++ b/drivers/input/touchscreen/mxs-lradc-ts.c
@@ -606,7 +606,6 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
struct device_node *node = dev->parent->of_node;
struct mxs_lradc *lradc = dev_get_drvdata(dev->parent);
struct mxs_lradc_ts *ts;
- struct resource *iores;
int ret, irq, virq, i;
u32 ts_wires = 0, adapt;
@@ -620,12 +619,9 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
ts->dev = dev;
spin_lock_init(&ts->lock);
- iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!iores)
- return -EINVAL;
- ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
- if (!ts->base)
- return -ENOMEM;
+ ts->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(ts->base))
+ return PTR_ERR(ts->base);
ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires",
&ts_wires);
diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
index f11ba7f2dca7..0af0fe8c40d7 100644
--- a/drivers/input/touchscreen/sun4i-ts.c
+++ b/drivers/input/touchscreen/sun4i-ts.c
@@ -300,8 +300,7 @@ static int sun4i_ts_probe(struct platform_device *pdev)
input_set_drvdata(ts->input, ts);
}
- ts->base = devm_ioremap_resource(dev,
- platform_get_resource(pdev, IORESOURCE_MEM, 0));
+ ts->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ts->base))
return PTR_ERR(ts->base);
diff --git a/drivers/input/touchscreen/ts4800-ts.c b/drivers/input/touchscreen/ts4800-ts.c
index fed73eeb47b3..5b4f5362c67b 100644
--- a/drivers/input/touchscreen/ts4800-ts.c
+++ b/drivers/input/touchscreen/ts4800-ts.c
@@ -148,7 +148,6 @@ static int ts4800_ts_probe(struct platform_device *pdev)
{
struct input_polled_dev *poll_dev;
struct ts4800_ts *ts;
- struct resource *res;
int error;
ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
@@ -159,8 +158,7 @@ static int ts4800_ts_probe(struct platform_device *pdev)
if (error)
return error;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- ts->base = devm_ioremap_resource(&pdev->dev, res);
+ ts->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ts->base))
return PTR_ERR(ts->base);
diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c
deleted file mode 100644
index 7893d7fa398c..000000000000
--- a/drivers/input/touchscreen/w90p910_ts.c
+++ /dev/null
@@ -1,331 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2008 Nuvoton technology corporation.
- *
- * Wan ZongShun <mcuos.com@gmail.com>
- */
-
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/io.h>
-#include <linux/clk.h>
-#include <linux/input.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-
-/* ADC controller bit defines */
-#define ADC_DELAY 0xf00
-#define ADC_DOWN 0x01
-#define ADC_TSC_Y (0x01 << 8)
-#define ADC_TSC_X (0x00 << 8)
-#define TSC_FOURWIRE (~(0x03 << 1))
-#define ADC_CLK_EN (0x01 << 28) /* ADC clock enable */
-#define ADC_READ_CON (0x01 << 12)
-#define ADC_CONV (0x01 << 13)
-#define ADC_SEMIAUTO (0x01 << 14)
-#define ADC_WAITTRIG (0x03 << 14)
-#define ADC_RST1 (0x01 << 16)
-#define ADC_RST0 (0x00 << 16)
-#define ADC_EN (0x01 << 17)
-#define ADC_INT (0x01 << 18)
-#define WT_INT (0x01 << 20)
-#define ADC_INT_EN (0x01 << 21)
-#define LVD_INT_EN (0x01 << 22)
-#define WT_INT_EN (0x01 << 23)
-#define ADC_DIV (0x04 << 1) /* div = 6 */
-
-enum ts_state {
- TS_WAIT_NEW_PACKET, /* We are waiting next touch report */
- TS_WAIT_X_COORD, /* We are waiting for ADC to report X coord */
- TS_WAIT_Y_COORD, /* We are waiting for ADC to report Y coord */
- TS_IDLE, /* Input device is closed, don't do anything */
-};
-
-struct w90p910_ts {
- struct input_dev *input;
- struct timer_list timer;
- struct clk *clk;
- int irq_num;
- void __iomem *ts_reg;
- spinlock_t lock;
- enum ts_state state;
-};
-
-static void w90p910_report_event(struct w90p910_ts *w90p910_ts, bool down)
-{
- struct input_dev *dev = w90p910_ts->input;
-
- if (down) {
- input_report_abs(dev, ABS_X,
- __raw_readl(w90p910_ts->ts_reg + 0x0c));
- input_report_abs(dev, ABS_Y,
- __raw_readl(w90p910_ts->ts_reg + 0x10));
- }
-
- input_report_key(dev, BTN_TOUCH, down);
- input_sync(dev);
-}
-
-static void w90p910_prepare_x_reading(struct w90p910_ts *w90p910_ts)
-{
- unsigned long ctlreg;
-
- __raw_writel(ADC_TSC_X, w90p910_ts->ts_reg + 0x04);
- ctlreg = __raw_readl(w90p910_ts->ts_reg);
- ctlreg &= ~(ADC_WAITTRIG | WT_INT | WT_INT_EN);
- ctlreg |= ADC_SEMIAUTO | ADC_INT_EN | ADC_CONV;
- __raw_writel(ctlreg, w90p910_ts->ts_reg);
-
- w90p910_ts->state = TS_WAIT_X_COORD;
-}
-
-static void w90p910_prepare_y_reading(struct w90p910_ts *w90p910_ts)
-{
- unsigned long ctlreg;
-
- __raw_writel(ADC_TSC_Y, w90p910_ts->ts_reg + 0x04);
- ctlreg = __raw_readl(w90p910_ts->ts_reg);
- ctlreg &= ~(ADC_WAITTRIG | ADC_INT | WT_INT_EN);
- ctlreg |= ADC_SEMIAUTO | ADC_INT_EN | ADC_CONV;
- __raw_writel(ctlreg, w90p910_ts->ts_reg);
-
- w90p910_ts->state = TS_WAIT_Y_COORD;
-}
-
-static void w90p910_prepare_next_packet(struct w90p910_ts *w90p910_ts)
-{
- unsigned long ctlreg;
-
- ctlreg = __raw_readl(w90p910_ts->ts_reg);
- ctlreg &= ~(ADC_INT | ADC_INT_EN | ADC_SEMIAUTO | ADC_CONV);
- ctlreg |= ADC_WAITTRIG | WT_INT_EN;
- __raw_writel(ctlreg, w90p910_ts->ts_reg);
-
- w90p910_ts->state = TS_WAIT_NEW_PACKET;
-}
-
-static irqreturn_t w90p910_ts_interrupt(int irq, void *dev_id)
-{
- struct w90p910_ts *w90p910_ts = dev_id;
- unsigned long flags;
-
- spin_lock_irqsave(&w90p910_ts->lock, flags);
-
- switch (w90p910_ts->state) {
- case TS_WAIT_NEW_PACKET:
- /*
- * The controller only generates interrupts when pen
- * is down.
- */
- del_timer(&w90p910_ts->timer);
- w90p910_prepare_x_reading(w90p910_ts);
- break;
-
-
- case TS_WAIT_X_COORD:
- w90p910_prepare_y_reading(w90p910_ts);
- break;
-
- case TS_WAIT_Y_COORD:
- w90p910_report_event(w90p910_ts, true);
- w90p910_prepare_next_packet(w90p910_ts);
- mod_timer(&w90p910_ts->timer, jiffies + msecs_to_jiffies(100));
- break;
-
- case TS_IDLE:
- break;
- }
-
- spin_unlock_irqrestore(&w90p910_ts->lock, flags);
-
- return IRQ_HANDLED;
-}
-
-static void w90p910_check_pen_up(struct timer_list *t)
-{
- struct w90p910_ts *w90p910_ts = from_timer(w90p910_ts, t, timer);
- unsigned long flags;
-
- spin_lock_irqsave(&w90p910_ts->lock, flags);
-
- if (w90p910_ts->state == TS_WAIT_NEW_PACKET &&
- !(__raw_readl(w90p910_ts->ts_reg + 0x04) & ADC_DOWN)) {
-
- w90p910_report_event(w90p910_ts, false);
- }
-
- spin_unlock_irqrestore(&w90p910_ts->lock, flags);
-}
-
-static int w90p910_open(struct input_dev *dev)
-{
- struct w90p910_ts *w90p910_ts = input_get_drvdata(dev);
- unsigned long val;
-
- /* enable the ADC clock */
- clk_enable(w90p910_ts->clk);
-
- __raw_writel(ADC_RST1, w90p910_ts->ts_reg);
- msleep(1);
- __raw_writel(ADC_RST0, w90p910_ts->ts_reg);
- msleep(1);
-
- /* set delay and screen type */
- val = __raw_readl(w90p910_ts->ts_reg + 0x04);
- __raw_writel(val & TSC_FOURWIRE, w90p910_ts->ts_reg + 0x04);
- __raw_writel(ADC_DELAY, w90p910_ts->ts_reg + 0x08);
-
- w90p910_ts->state = TS_WAIT_NEW_PACKET;
- wmb();
-
- /* set trigger mode */
- val = __raw_readl(w90p910_ts->ts_reg);
- val |= ADC_WAITTRIG | ADC_DIV | ADC_EN | WT_INT_EN;
- __raw_writel(val, w90p910_ts->ts_reg);
-
- return 0;
-}
-
-static void w90p910_close(struct input_dev *dev)
-{
- struct w90p910_ts *w90p910_ts = input_get_drvdata(dev);
- unsigned long val;
-
- /* disable trigger mode */
-
- spin_lock_irq(&w90p910_ts->lock);
-
- w90p910_ts->state = TS_IDLE;
-
- val = __raw_readl(w90p910_ts->ts_reg);
- val &= ~(ADC_WAITTRIG | ADC_DIV | ADC_EN | WT_INT_EN | ADC_INT_EN);
- __raw_writel(val, w90p910_ts->ts_reg);
-
- spin_unlock_irq(&w90p910_ts->lock);
-
- /* Now that interrupts are shut off we can safely delete timer */
- del_timer_sync(&w90p910_ts->timer);
-
- /* stop the ADC clock */
- clk_disable(w90p910_ts->clk);
-}
-
-static int w90x900ts_probe(struct platform_device *pdev)
-{
- struct w90p910_ts *w90p910_ts;
- struct input_dev *input_dev;
- struct resource *res;
- int err;
-
- w90p910_ts = kzalloc(sizeof(struct w90p910_ts), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!w90p910_ts || !input_dev) {
- err = -ENOMEM;
- goto fail1;
- }
-
- w90p910_ts->input = input_dev;
- w90p910_ts->state = TS_IDLE;
- spin_lock_init(&w90p910_ts->lock);
- timer_setup(&w90p910_ts->timer, w90p910_check_pen_up, 0);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- err = -ENXIO;
- goto fail1;
- }
-
- if (!request_mem_region(res->start, resource_size(res),
- pdev->name)) {
- err = -EBUSY;
- goto fail1;
- }
-
- w90p910_ts->ts_reg = ioremap(res->start, resource_size(res));
- if (!w90p910_ts->ts_reg) {
- err = -ENOMEM;
- goto fail2;
- }
-
- w90p910_ts->clk = clk_get(&pdev->dev, NULL);
- if (IS_ERR(w90p910_ts->clk)) {
- err = PTR_ERR(w90p910_ts->clk);
- goto fail3;
- }
-
- input_dev->name = "W90P910 TouchScreen";
- input_dev->phys = "w90p910ts/event0";
- input_dev->id.bustype = BUS_HOST;
- input_dev->id.vendor = 0x0005;
- input_dev->id.product = 0x0001;
- input_dev->id.version = 0x0100;
- input_dev->dev.parent = &pdev->dev;
- input_dev->open = w90p910_open;
- input_dev->close = w90p910_close;
-
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
- input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
-
- input_set_abs_params(input_dev, ABS_X, 0, 0x400, 0, 0);
- input_set_abs_params(input_dev, ABS_Y, 0, 0x400, 0, 0);
-
- input_set_drvdata(input_dev, w90p910_ts);
-
- w90p910_ts->irq_num = platform_get_irq(pdev, 0);
- if (request_irq(w90p910_ts->irq_num, w90p910_ts_interrupt,
- 0, "w90p910ts", w90p910_ts)) {
- err = -EBUSY;
- goto fail4;
- }
-
- err = input_register_device(w90p910_ts->input);
- if (err)
- goto fail5;
-
- platform_set_drvdata(pdev, w90p910_ts);
-
- return 0;
-
-fail5: free_irq(w90p910_ts->irq_num, w90p910_ts);
-fail4: clk_put(w90p910_ts->clk);
-fail3: iounmap(w90p910_ts->ts_reg);
-fail2: release_mem_region(res->start, resource_size(res));
-fail1: input_free_device(input_dev);
- kfree(w90p910_ts);
- return err;
-}
-
-static int w90x900ts_remove(struct platform_device *pdev)
-{
- struct w90p910_ts *w90p910_ts = platform_get_drvdata(pdev);
- struct resource *res;
-
- free_irq(w90p910_ts->irq_num, w90p910_ts);
- del_timer_sync(&w90p910_ts->timer);
- iounmap(w90p910_ts->ts_reg);
-
- clk_put(w90p910_ts->clk);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-
- input_unregister_device(w90p910_ts->input);
- kfree(w90p910_ts);
-
- return 0;
-}
-
-static struct platform_driver w90x900ts_driver = {
- .probe = w90x900ts_probe,
- .remove = w90x900ts_remove,
- .driver = {
- .name = "nuc900-ts",
- },
-};
-module_platform_driver(w90x900ts_driver);
-
-MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
-MODULE_DESCRIPTION("w90p910 touch screen driver!");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:nuc900-ts");
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index 3715d1eace92..691285ace228 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -27,6 +27,8 @@ MODULE_AUTHOR("Jaya Kumar <jayakumar.lkml@gmail.com>");
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
+#define W8001_MAX_PHYS 42
+
#define W8001_MAX_LENGTH 13
#define W8001_LEAD_MASK 0x80
#define W8001_LEAD_BYTE 0x80
@@ -89,7 +91,7 @@ struct w8001 {
unsigned char response_type;
unsigned char response[W8001_MAX_LENGTH];
unsigned char data[W8001_MAX_LENGTH];
- char phys[32];
+ char phys[W8001_MAX_PHYS];
int type;
unsigned int pktlen;
u16 max_touch_x;
diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c
index 47c6d000465a..ec515223f654 100644
--- a/drivers/platform/x86/surfacepro3_button.c
+++ b/drivers/platform/x86/surfacepro3_button.c
@@ -20,6 +20,12 @@
#define SURFACE_BUTTON_OBJ_NAME "VGBI"
#define SURFACE_BUTTON_DEVICE_NAME "Surface Pro 3/4 Buttons"
+#define MSHW0040_DSM_REVISION 0x01
+#define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision
+static const guid_t MSHW0040_DSM_UUID =
+ GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65,
+ 0x49, 0x80, 0x35);
+
#define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8
#define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6
@@ -142,6 +148,44 @@ static int surface_button_resume(struct device *dev)
}
#endif
+/*
+ * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
+ * ID (MSHW0040) for the power/volume buttons. Make sure this is the right
+ * device by checking for the _DSM method and OEM Platform Revision.
+ *
+ * Returns true if the driver should bind to this device, i.e. the device is
+ * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1.
+ */
+static bool surface_button_check_MSHW0040(struct acpi_device *dev)
+{
+ acpi_handle handle = dev->handle;
+ union acpi_object *result;
+ u64 oem_platform_rev = 0; // valid revisions are nonzero
+
+ // get OEM platform revision
+ result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
+ MSHW0040_DSM_REVISION,
+ MSHW0040_DSM_GET_OMPR,
+ NULL, ACPI_TYPE_INTEGER);
+
+ /*
+ * If evaluating the _DSM fails, the method is not present. This means
+ * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we
+ * should use this driver. We use revision 0 indicating it is
+ * unavailable.
+ */
+
+ if (result) {
+ oem_platform_rev = result->integer.value;
+ ACPI_FREE(result);
+ }
+
+ dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev);
+
+ return oem_platform_rev == 0;
+}
+
+
static int surface_button_add(struct acpi_device *device)
{
struct surface_button *button;
@@ -154,6 +198,9 @@ static int surface_button_add(struct acpi_device *device)
strlen(SURFACE_BUTTON_OBJ_NAME)))
return -ENODEV;
+ if (!surface_button_check_MSHW0040(device))
+ return -ENODEV;
+
button = kzalloc(sizeof(struct surface_button), GFP_KERNEL);
if (!button)
return -ENOMEM;