From 547a915d379be9f41c73357892b38a1b326d2a1f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:14:59 -0700 Subject: [PATCH 01/76] Input: serio - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 6862 1008 4 7874 1ec2 drivers/input/serio/serio.o File size After adding 'const': text data bss dec hex filename 6990 880 4 7874 1ec2 drivers/input/serio/serio.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/serio/serio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 30d6230d48f7..24a90c8db5b3 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -469,7 +469,7 @@ static struct attribute *serio_device_id_attrs[] = { NULL }; -static struct attribute_group serio_id_attr_group = { +static const struct attribute_group serio_id_attr_group = { .name = "id", .attrs = serio_device_id_attrs, }; @@ -489,7 +489,7 @@ static struct attribute *serio_device_attrs[] = { NULL }; -static struct attribute_group serio_device_attr_group = { +static const struct attribute_group serio_device_attr_group = { .attrs = serio_device_attrs, }; From c4043b57c867a548f888530351505cc1f86dbfb3 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:15:30 -0700 Subject: [PATCH 02/76] Input: aiptek - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 9941 1560 0 11501 2ced drivers/input/tablet/aiptek.o File size After adding 'const': text data bss dec hex filename 10005 1496 0 11501 2ced drivers/input/tablet/aiptek.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/aiptek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c index d67547bded3e..0b55e1f375b3 100644 --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c @@ -1676,7 +1676,7 @@ static struct attribute *aiptek_attributes[] = { NULL }; -static struct attribute_group aiptek_attribute_group = { +static const struct attribute_group aiptek_attribute_group = { .attrs = aiptek_attributes, }; From 5e895b74169a00d865a80536a424ddd918f1c6c0 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:15:49 -0700 Subject: [PATCH 03/76] Input: constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 17755 1312 16 19083 4a8b drivers/input/input.o File size After adding 'const': text data bss dec hex filename 17947 1120 16 19083 4a8b drivers/input/input.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 7e6842bd525c..d268fdc23c64 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1398,7 +1398,7 @@ static struct attribute *input_dev_attrs[] = { NULL }; -static struct attribute_group input_dev_attr_group = { +static const struct attribute_group input_dev_attr_group = { .attrs = input_dev_attrs, }; @@ -1425,7 +1425,7 @@ static struct attribute *input_dev_id_attrs[] = { NULL }; -static struct attribute_group input_dev_id_attr_group = { +static const struct attribute_group input_dev_id_attr_group = { .name = "id", .attrs = input_dev_id_attrs, }; @@ -1495,7 +1495,7 @@ static struct attribute *input_dev_caps_attrs[] = { NULL }; -static struct attribute_group input_dev_caps_attr_group = { +static const struct attribute_group input_dev_caps_attr_group = { .name = "capabilities", .attrs = input_dev_caps_attrs, }; From fab2f5e0f3b79d9d2de2c375f9a5ad9a5ced826e Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:16:07 -0700 Subject: [PATCH 04/76] Input: synaptics-rmi4 - constify attribute_group structures in F34 attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 5287 448 0 5735 1667 drivers/input/rmi4/rmi_f34.o File size After adding 'const': text data bss dec hex filename 5339 384 0 5723 165b drivers/input/rmi4/rmi_f34.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f34.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c index b8ee78e0d61f..4cfe9703a8e7 100644 --- a/drivers/input/rmi4/rmi_f34.c +++ b/drivers/input/rmi4/rmi_f34.c @@ -516,7 +516,7 @@ static struct attribute *rmi_firmware_attrs[] = { NULL }; -static struct attribute_group rmi_firmware_attr_group = { +static const struct attribute_group rmi_firmware_attr_group = { .attrs = rmi_firmware_attrs, }; From 0d4b8e36b9861d678c454d6bb4c4849827071ebd Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:17:05 -0700 Subject: [PATCH 05/76] Input: synaptics-rmi4 - constify attribute_group structures in F01 attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 4777 480 0 5257 1489 drivers/input/rmi4/rmi_f01.o File size After adding 'const': text data bss dec hex filename 4817 416 0 5233 1471 drivers/input/rmi4/rmi_f01.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c index 7f7e9176f7ea..aa1aabfdbe7c 100644 --- a/drivers/input/rmi4/rmi_f01.c +++ b/drivers/input/rmi4/rmi_f01.c @@ -334,7 +334,7 @@ static struct attribute *rmi_f01_attrs[] = { NULL }; -static struct attribute_group rmi_f01_attr_group = { +static const struct attribute_group rmi_f01_attr_group = { .attrs = rmi_f01_attrs, }; From b06ae14803a264a61fa4c9fbb6a2304c78851bac Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:18:03 -0700 Subject: [PATCH 06/76] Input: ims-pcu - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 13547 1600 0 15147 3b2b drivers/input/misc/ims-pcu.o File size After adding 'const': text data bss dec hex filename 13675 1472 0 15147 3b2b drivers/input/misc/ims-pcu.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/misc/ims-pcu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index f4e8fbec6a94..6bf82ea8c918 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -1261,7 +1261,7 @@ static umode_t ims_pcu_is_attr_visible(struct kobject *kobj, return mode; } -static struct attribute_group ims_pcu_attr_group = { +static const struct attribute_group ims_pcu_attr_group = { .is_visible = ims_pcu_is_attr_visible, .attrs = ims_pcu_attrs, }; @@ -1480,7 +1480,7 @@ static struct attribute *ims_pcu_ofn_attrs[] = { NULL }; -static struct attribute_group ims_pcu_ofn_attr_group = { +static const struct attribute_group ims_pcu_ofn_attr_group = { .name = "ofn", .attrs = ims_pcu_ofn_attrs, }; From aa3350718a2662a87742b923b80c5925ac9b5c43 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:21:06 -0700 Subject: [PATCH 07/76] Input: yealink - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 6039 944 0 6983 1b47 drivers/input/misc/yealink.o File size After adding 'const': text data bss dec hex filename 6103 880 0 6983 1b47 drivers/input/misc/yealink.o Signed-off-by: Arvind Yadav Signed-off-by: Henk Vergonet Signed-off-by: Dmitry Torokhov --- drivers/input/misc/yealink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c index 6e7ff9561d92..a1e0ff59d2f2 100644 --- a/drivers/input/misc/yealink.c +++ b/drivers/input/misc/yealink.c @@ -798,7 +798,7 @@ static struct attribute *yld_attributes[] = { NULL }; -static struct attribute_group yld_attr_group = { +static const struct attribute_group yld_attr_group = { .attrs = yld_attributes }; From 21563a7eaba9720e53fc1a56d0b89bf69afca6bd Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:22:20 -0700 Subject: [PATCH 08/76] Input: gpio_keys - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 5693 464 0 6157 180d drivers/input/keyboard/gpio_keys.o File size After adding 'const': text data bss dec hex filename 5749 400 0 6149 1805 drivers/input/keyboard/gpio_keys.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/gpio_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index a047b9af8369..f52812db91bc 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -353,7 +353,7 @@ static struct attribute *gpio_keys_attrs[] = { NULL, }; -static struct attribute_group gpio_keys_attr_group = { +static const struct attribute_group gpio_keys_attr_group = { .attrs = gpio_keys_attrs, }; From 579994334df06372ca57c5418edcb79e2c8864f8 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:22:40 -0700 Subject: [PATCH 09/76] Input: elantech - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 16815 1424 0 18239 473f drivers/input/mouse/elantech.o File size After adding 'const': text data bss dec hex filename 16879 1360 0 18239 473f drivers/input/mouse/elantech.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/elantech.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index e8cc223373ae..65c9de3f516c 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1375,7 +1375,7 @@ static struct attribute *elantech_attrs[] = { NULL }; -static struct attribute_group elantech_attr_group = { +static const struct attribute_group elantech_attr_group = { .attrs = elantech_attrs, }; From ebc6a3709e5272405afe75e3cab10dbec82b6bca Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:22:54 -0700 Subject: [PATCH 10/76] Input: psmouse - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 12850 740 12 13602 3522 drivers/input/mouse/psmouse-base.o File size After adding 'const': text data bss dec hex filename 12914 676 12 13602 3522 drivers/input/mouse/psmouse-base.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/psmouse-base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index f73b47b8c578..6a5649e52eed 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -101,7 +101,7 @@ static struct attribute *psmouse_attributes[] = { NULL }; -static struct attribute_group psmouse_attribute_group = { +static const struct attribute_group psmouse_attribute_group = { .attrs = psmouse_attributes, }; From d653386da19cfd5ca4d00ca0f83b16ccf94d355f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:23:06 -0700 Subject: [PATCH 11/76] Input: raydium_i2c_ts - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 7801 560 0 8361 20a9 drivers/input/touchscreen/raydium_i2c_ts.o File size After adding 'const': text data bss dec hex filename 7849 496 0 8345 2099 drivers/input/touchscreen/raydium_i2c_ts.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/raydium_i2c_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c index 1252e49ccfa1..4f1d3fd5d412 100644 --- a/drivers/input/touchscreen/raydium_i2c_ts.c +++ b/drivers/input/touchscreen/raydium_i2c_ts.c @@ -939,7 +939,7 @@ static struct attribute *raydium_i2c_attributes[] = { NULL }; -static struct attribute_group raydium_i2c_attribute_group = { +static const struct attribute_group raydium_i2c_attribute_group = { .attrs = raydium_i2c_attributes, }; From 48f960ddd79235e7840fd07f75766c160296d91c Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:23:18 -0700 Subject: [PATCH 12/76] Input: elants_i2c - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 9448 1008 0 10456 28d8 drivers/input/touchscreen/elants_i2c.o File size After adding 'const': text data bss dec hex filename 9496 944 0 10440 28c8 drivers/input/touchscreen/elants_i2c.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/elants_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 872750eeca93..0f4cda7282a2 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -1066,7 +1066,7 @@ static struct attribute *elants_attributes[] = { NULL }; -static struct attribute_group elants_attribute_group = { +static const struct attribute_group elants_attribute_group = { .attrs = elants_attributes, }; From 9e938deceaea1496af4dda420e8f854691d4321f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 10 Jul 2017 20:23:34 -0700 Subject: [PATCH 13/76] Input: ads7846 - constify attribute_group structures attribute_groups are not supposed to change at runtime. All functions working with attribute_groups provided by work with const attribute_group. So mark the non-const structs as const. File size before: text data bss dec hex filename 9086 624 0 9710 25ee drivers/input/touchscreen/ads7846.o File size After adding 'const': text data bss dec hex filename 9198 496 0 9694 25de drivers/input/touchscreen/ads7846.o Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/ads7846.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 735a0be1ad95..a2f45aefce08 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -499,7 +499,7 @@ static struct attribute *ads7846_attributes[] = { NULL, }; -static struct attribute_group ads7846_attr_group = { +static const struct attribute_group ads7846_attr_group = { .attrs = ads7846_attributes, .is_visible = ads7846_is_visible, }; @@ -599,7 +599,7 @@ static struct attribute *ads784x_attributes[] = { NULL, }; -static struct attribute_group ads784x_attr_group = { +static const struct attribute_group ads784x_attr_group = { .attrs = ads784x_attributes, }; From 435915eae2d796f1141cb1c3280c4388f852bd98 Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Mon, 10 Jul 2017 10:39:27 -0700 Subject: [PATCH 14/76] Input: sur40 - add additional reverse-engineered information Due to recent reverse engineering efforts, a lot more information is now available about the internals of the SUR40. We document this in the kernel driver for future use. Signed-off-by: Martin Kaltenbrunner Signed-off-by: Florian Echtler Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/sur40.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 128e5bd74720..259aef505042 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -59,7 +59,7 @@ struct sur40_blob { __le16 blob_id; u8 action; /* 0x02 = enter/exit, 0x03 = update (?) */ - u8 unknown; /* always 0x01 or 0x02 (no idea what this is?) */ + u8 type; /* bitmask (0x01 blob, 0x02 touch, 0x04 tag) */ __le16 bb_pos_x; /* upper left corner of bounding box */ __le16 bb_pos_y; @@ -133,12 +133,19 @@ struct sur40_image_header { /* control commands */ #define SUR40_GET_VERSION 0xb0 /* 12 bytes string */ -#define SUR40_UNKNOWN1 0xb3 /* 5 bytes */ -#define SUR40_UNKNOWN2 0xc1 /* 24 bytes */ +#define SUR40_ACCEL_CAPS 0xb3 /* 5 bytes */ +#define SUR40_SENSOR_CAPS 0xc1 /* 24 bytes */ + +#define SUR40_POKE 0xc5 /* poke register byte */ +#define SUR40_PEEK 0xc4 /* 48 bytes registers */ #define SUR40_GET_STATE 0xc5 /* 4 bytes state (?) */ #define SUR40_GET_SENSORS 0xb1 /* 8 bytes sensors */ +#define SUR40_BLOB 0x01 +#define SUR40_TOUCH 0x02 +#define SUR40_TAG 0x04 + static const struct v4l2_pix_format sur40_pix_format[] = { { .pixelformat = V4L2_TCH_FMT_TU08, @@ -238,11 +245,11 @@ static int sur40_init(struct sur40_state *dev) if (result < 0) goto error; - result = sur40_command(dev, SUR40_UNKNOWN2, 0x00, buffer, 24); + result = sur40_command(dev, SUR40_SENSOR_CAPS, 0x00, buffer, 24); if (result < 0) goto error; - result = sur40_command(dev, SUR40_UNKNOWN1, 0x00, buffer, 5); + result = sur40_command(dev, SUR40_ACCEL_CAPS, 0x00, buffer, 5); if (result < 0) goto error; From 335abaea7a27b8a2dfb1ae4573f25019b5d6f68e Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Mon, 10 Jul 2017 10:39:48 -0700 Subject: [PATCH 15/76] Input: sur40 - silence unnecessary noisy debug output This information is unneccessary, even as debug output. Leave commented out as documentation of the packet ID quirk. Signed-off-by: Martin Kaltenbrunner Signed-off-by: Florian Echtler Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/sur40.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index 259aef505042..f04adeaa45b3 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -374,10 +374,13 @@ static void sur40_poll(struct input_polled_dev *polldev) /* * Sanity check. when video data is also being retrieved, the * packet ID will usually increase in the middle of a series - * instead of at the end. - */ + * instead of at the end. However, the data is still consistent, + * so the packet ID is probably just valid for the first packet + * in a series. + if (packet_id != le32_to_cpu(header->packet_id)) dev_dbg(sur40->dev, "packet ID mismatch\n"); + */ packet_blobs = result / sizeof(struct sur40_blob); dev_dbg(sur40->dev, "received %d blobs\n", packet_blobs); From 4323418d62fefe48ee5019f2c744c918be06ec69 Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Mon, 10 Jul 2017 10:40:28 -0700 Subject: [PATCH 16/76] Input: sur40 - skip all blobs that are not touches The SUR40 labels all reported blobs as touch, token, or generic blob. Previously, all blobs were reported as touch regardless of type, causing lots of false positives. Present patch fixes this. Signed-off-by: Martin Kaltenbrunner Signed-off-by: Florian Echtler Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/sur40.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index f04adeaa45b3..f16f8358c70a 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c @@ -296,20 +296,24 @@ static void sur40_close(struct input_polled_dev *polldev) static void sur40_report_blob(struct sur40_blob *blob, struct input_dev *input) { int wide, major, minor; + int bb_size_x, bb_size_y, pos_x, pos_y, ctr_x, ctr_y, slotnum; - int bb_size_x = le16_to_cpu(blob->bb_size_x); - int bb_size_y = le16_to_cpu(blob->bb_size_y); + if (blob->type != SUR40_TOUCH) + return; - int pos_x = le16_to_cpu(blob->pos_x); - int pos_y = le16_to_cpu(blob->pos_y); - - int ctr_x = le16_to_cpu(blob->ctr_x); - int ctr_y = le16_to_cpu(blob->ctr_y); - - int slotnum = input_mt_get_slot_by_key(input, blob->blob_id); + slotnum = input_mt_get_slot_by_key(input, blob->blob_id); if (slotnum < 0 || slotnum >= MAX_CONTACTS) return; + bb_size_x = le16_to_cpu(blob->bb_size_x); + bb_size_y = le16_to_cpu(blob->bb_size_y); + + pos_x = le16_to_cpu(blob->pos_x); + pos_y = le16_to_cpu(blob->pos_y); + + ctr_x = le16_to_cpu(blob->ctr_x); + ctr_y = le16_to_cpu(blob->ctr_y); + input_mt_slot(input, slotnum); input_mt_report_slot_state(input, MT_TOOL_FINGER, 1); wide = (bb_size_x > bb_size_y); From 5a35b85c2d92f7205d2f9f3878662fefd70b9a65 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Mon, 24 Jul 2017 15:57:12 -0700 Subject: [PATCH 17/76] Input: add power key driver for Rockchip RK805 PMIC This driver provides a input driver for the power key on the Rockchip RK805 PMIC. Signed-off-by: Joseph Chen Signed-off-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 11 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/rk805-pwrkey.c | 111 ++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 drivers/input/misc/rk805-pwrkey.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 3872488c3fd7..f47e836eaa0f 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -581,6 +581,17 @@ config INPUT_PWM_BEEPER To compile this driver as a module, choose M here: the module will be called pwm-beeper. +config INPUT_RK805_PWRKEY + tristate "Rockchip RK805 PMIC power key support" + depends on MFD_RK808 + help + Select this option to enable power key driver for RK805. + + If unsure, say N. + + To compile this driver as a module, choose M here: the module will be + called rk805_pwrkey. + config INPUT_GPIO_ROTARY_ENCODER tristate "Rotary encoders connected to GPIO pins" depends on GPIOLIB || COMPILE_TEST diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index b923a9828c88..1072e0760c19 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -64,6 +64,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o +obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o diff --git a/drivers/input/misc/rk805-pwrkey.c b/drivers/input/misc/rk805-pwrkey.c new file mode 100644 index 000000000000..921003963a53 --- /dev/null +++ b/drivers/input/misc/rk805-pwrkey.c @@ -0,0 +1,111 @@ +/* + * Rockchip RK805 PMIC Power Key driver + * + * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd + * + * Author: Joseph Chen + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + +static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr) +{ + struct input_dev *pwr = _pwr; + + input_report_key(pwr, KEY_POWER, 1); + input_sync(pwr); + + return IRQ_HANDLED; +} + +static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr) +{ + struct input_dev *pwr = _pwr; + + input_report_key(pwr, KEY_POWER, 0); + input_sync(pwr); + + return IRQ_HANDLED; +} + +static int rk805_pwrkey_probe(struct platform_device *pdev) +{ + struct input_dev *pwr; + int fall_irq, rise_irq; + int err; + + pwr = devm_input_allocate_device(&pdev->dev); + if (!pwr) { + dev_err(&pdev->dev, "Can't allocate power button\n"); + return -ENOMEM; + } + + pwr->name = "rk805 pwrkey"; + pwr->phys = "rk805_pwrkey/input0"; + pwr->id.bustype = BUS_HOST; + 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); + 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); + return rise_irq; + } + + err = devm_request_any_context_irq(&pwr->dev, fall_irq, + pwrkey_fall_irq, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "rk805_pwrkey_fall", pwr); + if (err < 0) { + dev_err(&pdev->dev, "Can't register fall irq: %d\n", err); + return err; + } + + err = devm_request_any_context_irq(&pwr->dev, rise_irq, + pwrkey_rise_irq, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "rk805_pwrkey_rise", pwr); + if (err < 0) { + dev_err(&pdev->dev, "Can't register rise irq: %d\n", err); + return err; + } + + err = input_register_device(pwr); + if (err) { + dev_err(&pdev->dev, "Can't register power button: %d\n", err); + return err; + } + + platform_set_drvdata(pdev, pwr); + device_init_wakeup(&pdev->dev, true); + + return 0; +} + +static struct platform_driver rk805_pwrkey_driver = { + .probe = rk805_pwrkey_probe, + .driver = { + .name = "rk805-pwrkey", + }, +}; +module_platform_driver(rk805_pwrkey_driver); + +MODULE_AUTHOR("Joseph Chen "); +MODULE_DESCRIPTION("RK805 PMIC Power Key driver"); +MODULE_LICENSE("GPL"); From 3dabc19acf79fa77e3a59a43b764b24d5be453be Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 22 Jan 2017 23:46:50 -0800 Subject: [PATCH 18/76] ARM: pxa/raumfeld: mark rotary encoder properties as __initconst device_add_properties() performs deep copy of supplied array of properties, which means that we can discard the original array. Signed-off-by: Dmitry Torokhov --- arch/arm/mach-pxa/raumfeld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index e2c97728b3c6..9d662fed03ec 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -377,7 +377,7 @@ static struct gpiod_lookup_table raumfeld_rotary_gpios_table = { }, }; -static struct property_entry raumfeld_rotary_properties[] = { +static const struct property_entry raumfeld_rotary_properties[] __initconst = { PROPERTY_ENTRY_INTEGER("rotary-encoder,steps-per-period", u32, 24), PROPERTY_ENTRY_INTEGER("linux,axis", u32, REL_X), PROPERTY_ENTRY_INTEGER("rotary-encoder,relative_axis", u32, 1), From dae1a432ab1fe79ae53129ededeaece35a2dc14d Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Sat, 24 Jun 2017 22:50:12 -0700 Subject: [PATCH 19/76] Input: mousedev - fix implicit conversion warning Clang warns: drivers/input/mousedev.c:653:63: error: implicit conversion from 'int' to 'signed char' changes value from 200 to -56 [-Wconstant-conversion] client->ps2[1] = 0x60; client->ps2[2] = 3; client->ps2[3] = 200; ~ ^~~ As the PS2 data is really a stream of bytes, let's switch to using u8 type for it, which silences this warning. Signed-off-by: Nick Desaulniers Signed-off-by: Dmitry Torokhov --- drivers/input/mousedev.c | 62 ++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 0e0ff84088fd..2d7f691ec71c 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c @@ -15,6 +15,7 @@ #define MOUSEDEV_MINORS 31 #define MOUSEDEV_MIX 63 +#include #include #include #include @@ -103,7 +104,7 @@ struct mousedev_client { spinlock_t packet_lock; int pos_x, pos_y; - signed char ps2[6]; + u8 ps2[6]; unsigned char ready, buffer, bufsiz; unsigned char imexseq, impsseq; enum mousedev_emul mode; @@ -291,11 +292,10 @@ static void mousedev_notify_readers(struct mousedev *mousedev, } client->pos_x += packet->dx; - client->pos_x = client->pos_x < 0 ? - 0 : (client->pos_x >= xres ? xres : client->pos_x); + client->pos_x = clamp_val(client->pos_x, 0, xres); + client->pos_y += packet->dy; - client->pos_y = client->pos_y < 0 ? - 0 : (client->pos_y >= yres ? yres : client->pos_y); + client->pos_y = clamp_val(client->pos_y, 0, yres); p->dx += packet->dx; p->dy += packet->dy; @@ -571,44 +571,50 @@ static int mousedev_open(struct inode *inode, struct file *file) return error; } -static inline int mousedev_limit_delta(int delta, int limit) -{ - return delta > limit ? limit : (delta < -limit ? -limit : delta); -} - -static void mousedev_packet(struct mousedev_client *client, - signed char *ps2_data) +static void mousedev_packet(struct mousedev_client *client, u8 *ps2_data) { struct mousedev_motion *p = &client->packets[client->tail]; + s8 dx, dy, dz; - ps2_data[0] = 0x08 | - ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07); - ps2_data[1] = mousedev_limit_delta(p->dx, 127); - ps2_data[2] = mousedev_limit_delta(p->dy, 127); - p->dx -= ps2_data[1]; - p->dy -= ps2_data[2]; + dx = clamp_val(p->dx, -127, 127); + p->dx -= dx; + + dy = clamp_val(p->dy, -127, 127); + p->dy -= dy; + + ps2_data[0] = BIT(3); + ps2_data[0] |= ((dx & BIT(7)) >> 3) | ((dy & BIT(7)) >> 2); + ps2_data[0] |= p->buttons & 0x07; + ps2_data[1] = dx; + ps2_data[2] = dy; switch (client->mode) { case MOUSEDEV_EMUL_EXPS: - ps2_data[3] = mousedev_limit_delta(p->dz, 7); - p->dz -= ps2_data[3]; - ps2_data[3] = (ps2_data[3] & 0x0f) | ((p->buttons & 0x18) << 1); + dz = clamp_val(p->dz, -7, 7); + p->dz -= dz; + + ps2_data[3] = (dz & 0x0f) | ((p->buttons & 0x18) << 1); client->bufsiz = 4; break; case MOUSEDEV_EMUL_IMPS: - ps2_data[0] |= - ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); - ps2_data[3] = mousedev_limit_delta(p->dz, 127); - p->dz -= ps2_data[3]; + dz = clamp_val(p->dz, -127, 127); + p->dz -= dz; + + ps2_data[0] |= ((p->buttons & 0x10) >> 3) | + ((p->buttons & 0x08) >> 1); + ps2_data[3] = dz; + client->bufsiz = 4; break; case MOUSEDEV_EMUL_PS2: default: - ps2_data[0] |= - ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); p->dz = 0; + + ps2_data[0] |= ((p->buttons & 0x10) >> 3) | + ((p->buttons & 0x08) >> 1); + client->bufsiz = 3; break; } @@ -714,7 +720,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer, { struct mousedev_client *client = file->private_data; struct mousedev *mousedev = client->mousedev; - signed char data[sizeof(client->ps2)]; + u8 data[sizeof(client->ps2)]; int retval = 0; if (!client->ready && !client->buffer && mousedev->exist && From c129585112c74b82f6e77320e0e885275a781195 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:43:18 -0700 Subject: [PATCH 20/76] Input: iforce - constify usb_device_id and fix space before '[' error usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Fix checkpatch.pl error: ERROR: space prohibited before open square bracket '['. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/iforce/iforce-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index db64adfbe1af..e8724f1a4a25 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c @@ -209,7 +209,7 @@ static void iforce_usb_disconnect(struct usb_interface *intf) kfree(iforce); } -static struct usb_device_id iforce_usb_ids [] = { +static const struct usb_device_id iforce_usb_ids[] = { { USB_DEVICE(0x044f, 0xa01c) }, /* Thrustmaster Motor Sport GT */ { USB_DEVICE(0x046d, 0xc281) }, /* Logitech WingMan Force */ { USB_DEVICE(0x046d, 0xc291) }, /* Logitech WingMan Formula Force */ From 0360b3f661b542f91016872fec3292f4cade307c Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:43:52 -0700 Subject: [PATCH 21/76] Input: keyspan_remote - constify usb_device_id usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/misc/keyspan_remote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c index a3fe4a990cc9..77c47d6325fe 100644 --- a/drivers/input/misc/keyspan_remote.c +++ b/drivers/input/misc/keyspan_remote.c @@ -85,7 +85,7 @@ static const unsigned short keyspan_key_table[] = { }; /* table of devices that work with this driver */ -static struct usb_device_id keyspan_table[] = { +static const struct usb_device_id keyspan_table[] = { { USB_DEVICE(USB_KEYSPAN_VENDOR_ID, USB_KEYSPAN_PRODUCT_UIA11) }, { } /* Terminating entry */ }; From 81c3d81c9404855f072eb4e5a2764f06c243d338 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:44:10 -0700 Subject: [PATCH 22/76] Input: powermate - constify usb_device_id and fix space before '[' error usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Fix checkpatch.pl error: ERROR: space prohibited before open square bracket '['. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/misc/powermate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c index 84909a12ff36..5c8c79623c87 100644 --- a/drivers/input/misc/powermate.c +++ b/drivers/input/misc/powermate.c @@ -432,7 +432,7 @@ static void powermate_disconnect(struct usb_interface *intf) } } -static struct usb_device_id powermate_devices [] = { +static const struct usb_device_id powermate_devices[] = { { USB_DEVICE(POWERMATE_VENDOR, POWERMATE_PRODUCT_NEW) }, { USB_DEVICE(POWERMATE_VENDOR, POWERMATE_PRODUCT_OLD) }, { USB_DEVICE(CONTOUR_VENDOR, CONTOUR_JOG) }, From a45232d66063fc8264c3e1ccf8e8f0d984de9f45 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:44:25 -0700 Subject: [PATCH 23/76] Input: appletouch - constify usb_device_id usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/appletouch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index ef234c9b2f2f..81a695d0b4e0 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c @@ -125,7 +125,7 @@ static const struct atp_info geyser4_info = { * According to Info.plist Geyser IV is the same as Geyser III.) */ -static struct usb_device_id atp_table[] = { +static const struct usb_device_id atp_table[] = { /* PowerBooks Feb 2005, iBooks G4 */ ATP_DEVICE(0x020e, fountain_info), /* FOUNTAIN ANSI */ ATP_DEVICE(0x020f, fountain_info), /* FOUNTAIN ISO */ From 3cafe41227afcf1632fa8ab41e7cf57a033eac4d Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:44:37 -0700 Subject: [PATCH 24/76] Input: synaptics_usb - constify usb_device_id usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/synaptics_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/synaptics_usb.c b/drivers/input/mouse/synaptics_usb.c index 6bcc0189c1c9..cb7d15d826d0 100644 --- a/drivers/input/mouse/synaptics_usb.c +++ b/drivers/input/mouse/synaptics_usb.c @@ -525,7 +525,7 @@ static int synusb_reset_resume(struct usb_interface *intf) return synusb_resume(intf); } -static struct usb_device_id synusb_idtable[] = { +static const struct usb_device_id synusb_idtable[] = { { USB_DEVICE_SYNAPTICS(TP, SYNUSB_TOUCHPAD) }, { USB_DEVICE_SYNAPTICS(INT_TP, SYNUSB_TOUCHPAD) }, { USB_DEVICE_SYNAPTICS(CPAD, From 803088fa27e2641a939d0f3f18d83af6c0bdac5e Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:44:49 -0700 Subject: [PATCH 25/76] Input: acecad - constify usb_device_idi and fix space before '[' error usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Fix checkpatch.pl error: ERROR: space prohibited before open square bracket '['. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/acecad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c index e86e377a90f5..aebb3f9090cd 100644 --- a/drivers/input/tablet/acecad.c +++ b/drivers/input/tablet/acecad.c @@ -260,7 +260,7 @@ static void usb_acecad_disconnect(struct usb_interface *intf) kfree(acecad); } -static struct usb_device_id usb_acecad_id_table [] = { +static const struct usb_device_id usb_acecad_id_table[] = { { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_FLAIR), .driver_info = 0 }, { USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_302), .driver_info = 1 }, { } From 95ac4cb0042993b7a7ee7d72b47ec5c963feabc7 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 19:45:14 -0700 Subject: [PATCH 26/76] Input: kbtab - constify usb_device_id usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/kbtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c index 4d9d64908b59..a41c3ff7c9af 100644 --- a/drivers/input/tablet/kbtab.c +++ b/drivers/input/tablet/kbtab.c @@ -88,7 +88,7 @@ static void kbtab_irq(struct urb *urb) __func__, retval); } -static struct usb_device_id kbtab_ids[] = { +static const struct usb_device_id kbtab_ids[] = { { USB_DEVICE(USB_VENDOR_ID_KBGEAR, 0x1001), .driver_info = 0 }, { } }; From 94aef061c796d3d47f1a2eed41e651ffaaade402 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 7 Aug 2017 20:04:13 -0700 Subject: [PATCH 27/76] Input: xpad - constify usb_device_id usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/xpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 298a6ba51411..2578a7677040 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -408,7 +408,7 @@ static const signed short xpad_abs_triggers[] = { #define XPAD_XBOXONE_VENDOR(vend) \ { XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) } -static struct usb_device_id xpad_table[] = { +static const struct usb_device_id xpad_table[] = { { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */ XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ From e48060ce2c7f73e424272bd6f5d9f996f1853064 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 14 Aug 2017 10:26:27 -0700 Subject: [PATCH 28/76] Input: mxs-lradc - do a NULL check on iores platform_get_resource() may fail, so we should better do a NULL check and return error on failure. Signed-off-by: Fabio Estevam Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/mxs-lradc-ts.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c index 58c016cd6809..71bf493e8b58 100644 --- a/drivers/input/touchscreen/mxs-lradc-ts.c +++ b/drivers/input/touchscreen/mxs-lradc-ts.c @@ -630,6 +630,8 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev) 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 (IS_ERR(ts->base)) return PTR_ERR(ts->base); From 6ecd36d732886ecb07768432212efce9cfb6ac2f Mon Sep 17 00:00:00 2001 From: Pan Bian Date: Mon, 14 Aug 2017 10:29:13 -0700 Subject: [PATCH 29/76] Input: mxs-lradc - use correct error check Function devm_ioremap() will return a NULL pointer on failure. However, in function mxs_lradc_ts_probe(), its return value is checked with IS_ERR(), which cannot detect the exceptional case. Signed-off-by: Pan Bian Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/mxs-lradc-ts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c index 71bf493e8b58..816f5c8c101d 100644 --- a/drivers/input/touchscreen/mxs-lradc-ts.c +++ b/drivers/input/touchscreen/mxs-lradc-ts.c @@ -633,8 +633,8 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev) if (!iores) return -EINVAL; ts->base = devm_ioremap(dev, iores->start, resource_size(iores)); - if (IS_ERR(ts->base)) - return PTR_ERR(ts->base); + if (!ts->base) + return -ENOMEM; ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires", &ts_wires); From 2e53d52c0108f03fb9fc67419c20a0b31acade52 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 14 Aug 2017 10:31:13 -0700 Subject: [PATCH 30/76] Input: mxs-lradc - make symbol mxs_lradc_ts_irq_names static Fixes the following sparse warning: drivers/input/touchscreen/mxs-lradc-ts.c:33:12: warning: symbol 'mxs_lradc_ts_irq_names' was not declared. Should it be static? Signed-off-by: Wei Yongjun [dtor: changed to static const char * const] Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/mxs-lradc-ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c index 816f5c8c101d..3707e927f770 100644 --- a/drivers/input/touchscreen/mxs-lradc-ts.c +++ b/drivers/input/touchscreen/mxs-lradc-ts.c @@ -30,7 +30,7 @@ #include #include -const char *mxs_lradc_ts_irq_names[] = { +static const char * const mxs_lradc_ts_irq_names[] = { "mxs-lradc-touchscreen", "mxs-lradc-channel6", "mxs-lradc-channel7", From 9e04b79ce432b8be2419dc52021afb6f07b78540 Mon Sep 17 00:00:00 2001 From: Munir Contractor Date: Mon, 14 Aug 2017 22:02:08 -0700 Subject: [PATCH 31/76] Input: pcspkr - fix code style and error value in pcspkr_event This patch fixes the following issues in pcspkr: * Return -EINVAL when input arguments are not valid in pcspkr_event function instead of -1. * Replace with * Fix indentation of case blocks in switch statement * Reduce length of line 28 to less than 80 characters The style issues were discovered by checkpatch.pl script. Signed-off-by: Munir Contractor Signed-off-by: Dmitry Torokhov --- drivers/input/misc/pcspkr.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c index 72b1fc3ab910..56ddba21de84 100644 --- a/drivers/input/misc/pcspkr.c +++ b/drivers/input/misc/pcspkr.c @@ -18,25 +18,30 @@ #include #include #include -#include +#include MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("PC Speaker beeper driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:pcspkr"); -static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) +static int pcspkr_event(struct input_dev *dev, unsigned int type, + unsigned int code, int value) { unsigned int count = 0; unsigned long flags; if (type != EV_SND) - return -1; + return -EINVAL; switch (code) { - case SND_BELL: if (value) value = 1000; - case SND_TONE: break; - default: return -1; + case SND_BELL: + if (value) + value = 1000; + case SND_TONE: + break; + default: + return -EINVAL; } if (value > 20 && value < 32767) From d54cf213744709cae30271c4e9acf5ddd11ca49a Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 14 Aug 2017 22:10:11 -0700 Subject: [PATCH 32/76] Input: sun4i-ts - constify thermal_zone_of_device_ops structures The thermal_zone_of_device_ops structure is only passed as the fourth argument to devm_thermal_zone_of_sensor_register, which is declared as const. Thus the thermal_zone_of_device_ops structure itself can be const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/sun4i-ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c index d07dd29d4848..d2e14d9e5975 100644 --- a/drivers/input/touchscreen/sun4i-ts.c +++ b/drivers/input/touchscreen/sun4i-ts.c @@ -206,7 +206,7 @@ static int sun4i_get_tz_temp(void *data, int *temp) return sun4i_get_temp(data, temp); } -static struct thermal_zone_of_device_ops sun4i_ts_tz_ops = { +static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = { .get_temp = sun4i_get_tz_temp, }; From 64954e344257b7660839151b3f30bd1bacb6eb38 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 22:10:55 -0700 Subject: [PATCH 33/76] Input: ati_remote2 - constify usb_device_id usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/misc/ati_remote2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index 1c5914cae853..ebf4448b31b9 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c @@ -110,7 +110,7 @@ static const struct kernel_param_ops param_ops_mode_mask = { module_param(mode_mask, mode_mask, 0644); MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>"); -static struct usb_device_id ati_remote2_id_table[] = { +static const struct usb_device_id ati_remote2_id_table[] = { { USB_DEVICE(0x0471, 0x0602) }, /* ATI Remote Wonder II */ { } }; From fbc1b323d1f97c3880ed3377a127e2c0417d96ea Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Mon, 14 Aug 2017 22:16:27 -0700 Subject: [PATCH 34/76] Input: axp20x-pek - use driver_data of platform_device_id instead of extended attributes To prepare an upcoming patch adding support for another PMIC that has different startup and shutdown time, use driver_data of platform_device_id instead of a fixed extended device attribute. By doing so, we also remove a lot of nested structures that aren't useful. With this patch, a new PMIC can be easily supported by just filling correctly its ax20x_info structure and adding a platform_device_id. Moreover, since we get rid of extended attributes, rename axp20x_store_ext_attr to axp20x_store_attr and axp20x_show_ext_attr to axp20x_show_attr. Signed-off-by: Quentin Schulz Acked-by: Chen-Yu Tsai Signed-off-by: Dmitry Torokhov --- drivers/input/misc/axp20x-pek.c | 135 +++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 45 deletions(-) diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c index cfeb0e943de6..95f33f78fce6 100644 --- a/drivers/input/misc/axp20x-pek.c +++ b/drivers/input/misc/axp20x-pek.c @@ -29,9 +29,17 @@ #define AXP20X_PEK_STARTUP_MASK (0xc0) #define AXP20X_PEK_SHUTDOWN_MASK (0x03) +struct axp20x_info { + const struct axp20x_time *startup_time; + unsigned int startup_mask; + const struct axp20x_time *shutdown_time; + unsigned int shutdown_mask; +}; + struct axp20x_pek { struct axp20x_dev *axp20x; struct input_dev *input; + struct axp20x_info *info; int irq_dbr; int irq_dbf; }; @@ -55,31 +63,18 @@ static const struct axp20x_time shutdown_time[] = { { .time = 10000, .idx = 3 }, }; -struct axp20x_pek_ext_attr { - const struct axp20x_time *p_time; - unsigned int mask; +static const struct axp20x_info axp20x_info = { + .startup_time = startup_time, + .startup_mask = AXP20X_PEK_STARTUP_MASK, + .shutdown_time = shutdown_time, + .shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK, }; -static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = { - .p_time = startup_time, - .mask = AXP20X_PEK_STARTUP_MASK, -}; - -static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = { - .p_time = shutdown_time, - .mask = AXP20X_PEK_SHUTDOWN_MASK, -}; - -static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute *attr) -{ - return container_of(attr, struct dev_ext_attribute, attr)->var; -} - -static ssize_t axp20x_show_ext_attr(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t axp20x_show_attr(struct device *dev, + const struct axp20x_time *time, + unsigned int mask, char *buf) { struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); - struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr); unsigned int val; int ret, i; @@ -87,22 +82,42 @@ static ssize_t axp20x_show_ext_attr(struct device *dev, if (ret != 0) return ret; - val &= axp20x_ea->mask; - val >>= ffs(axp20x_ea->mask) - 1; + val &= mask; + val >>= ffs(mask) - 1; for (i = 0; i < 4; i++) - if (val == axp20x_ea->p_time[i].idx) - val = axp20x_ea->p_time[i].time; + if (val == time[i].idx) + val = time[i].time; return sprintf(buf, "%u\n", val); } -static ssize_t axp20x_store_ext_attr(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t axp20x_show_attr_startup(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); + + return axp20x_show_attr(dev, axp20x_pek->info->startup_time, + axp20x_pek->info->startup_mask, buf); +} + +static ssize_t axp20x_show_attr_shutdown(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); + + return axp20x_show_attr(dev, axp20x_pek->info->shutdown_time, + axp20x_pek->info->shutdown_mask, buf); +} + +static ssize_t axp20x_store_attr(struct device *dev, + const struct axp20x_time *time, + unsigned int mask, const char *buf, + size_t count) { struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); - struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr); char val_str[20]; size_t len; int ret, i; @@ -123,39 +138,52 @@ static ssize_t axp20x_store_ext_attr(struct device *dev, for (i = 3; i >= 0; i--) { unsigned int err; - err = abs(axp20x_ea->p_time[i].time - val); + err = abs(time[i].time - val); if (err < best_err) { best_err = err; - idx = axp20x_ea->p_time[i].idx; + idx = time[i].idx; } if (!err) break; } - idx <<= ffs(axp20x_ea->mask) - 1; - ret = regmap_update_bits(axp20x_pek->axp20x->regmap, - AXP20X_PEK_KEY, - axp20x_ea->mask, idx); + idx <<= ffs(mask) - 1; + ret = regmap_update_bits(axp20x_pek->axp20x->regmap, AXP20X_PEK_KEY, + mask, idx); if (ret != 0) return -EINVAL; return count; } -static struct dev_ext_attribute axp20x_dev_attr_startup = { - .attr = __ATTR(startup, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr), - .var = &axp20x_pek_startup_ext_attr, -}; +static ssize_t axp20x_store_attr_startup(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); -static struct dev_ext_attribute axp20x_dev_attr_shutdown = { - .attr = __ATTR(shutdown, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr), - .var = &axp20x_pek_shutdown_ext_attr, -}; + return axp20x_store_attr(dev, axp20x_pek->info->startup_time, + axp20x_pek->info->startup_mask, buf, count); +} + +static ssize_t axp20x_store_attr_shutdown(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev); + + return axp20x_store_attr(dev, axp20x_pek->info->shutdown_time, + axp20x_pek->info->shutdown_mask, buf, count); +} + +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[] = { - &axp20x_dev_attr_startup.attr.attr, - &axp20x_dev_attr_shutdown.attr.attr, + &dev_attr_startup.attr, + &dev_attr_shutdown.attr, NULL, }; @@ -291,8 +319,14 @@ static bool axp20x_pek_should_register_input(struct axp20x_pek *axp20x_pek, static int axp20x_pek_probe(struct platform_device *pdev) { struct axp20x_pek *axp20x_pek; + const struct platform_device_id *match = platform_get_device_id(pdev); int error; + if (!match) { + dev_err(&pdev->dev, "Failed to get platform_device_id\n"); + return -EINVAL; + } + axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek), GFP_KERNEL); if (!axp20x_pek) @@ -306,6 +340,8 @@ static int axp20x_pek_probe(struct platform_device *pdev) return error; } + 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", @@ -342,8 +378,17 @@ static const struct dev_pm_ops axp20x_pek_pm_ops = { #endif }; +static const struct platform_device_id axp_pek_id_match[] = { + { + .name = "axp20x-pek", + .driver_data = (kernel_ulong_t)&axp20x_info, + }, + { /* sentinel */ } +}; + static struct platform_driver axp20x_pek_driver = { .probe = axp20x_pek_probe, + .id_table = axp_pek_id_match, .driver = { .name = "axp20x-pek", .pm = &axp20x_pek_pm_ops, From c3cc94470bd3aff4eef1d80a91086afc7abce847 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Mon, 14 Aug 2017 22:19:42 -0700 Subject: [PATCH 35/76] Input: axp20x-pek - add support for AXP221 PEK The AXP221 has different values for startup time bits from the AXP20X. Signed-off-by: Quentin Schulz Reviewed-by: Chen-Yu Tsai Signed-off-by: Dmitry Torokhov --- drivers/input/misc/axp20x-pek.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c index 95f33f78fce6..6cee5adc3b5c 100644 --- a/drivers/input/misc/axp20x-pek.c +++ b/drivers/input/misc/axp20x-pek.c @@ -56,6 +56,13 @@ static const struct axp20x_time startup_time[] = { { .time = 2000, .idx = 3 }, }; +static const struct axp20x_time axp221_startup_time[] = { + { .time = 128, .idx = 0 }, + { .time = 1000, .idx = 1 }, + { .time = 2000, .idx = 2 }, + { .time = 3000, .idx = 3 }, +}; + static const struct axp20x_time shutdown_time[] = { { .time = 4000, .idx = 0 }, { .time = 6000, .idx = 1 }, @@ -70,6 +77,13 @@ static const struct axp20x_info axp20x_info = { .shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK, }; +static const struct axp20x_info axp221_info = { + .startup_time = axp221_startup_time, + .startup_mask = AXP20X_PEK_STARTUP_MASK, + .shutdown_time = shutdown_time, + .shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK, +}; + static ssize_t axp20x_show_attr(struct device *dev, const struct axp20x_time *time, unsigned int mask, char *buf) @@ -383,6 +397,10 @@ static const struct platform_device_id axp_pek_id_match[] = { .name = "axp20x-pek", .driver_data = (kernel_ulong_t)&axp20x_info, }, + { + .name = "axp221-pek", + .driver_data = (kernel_ulong_t)&axp221_info, + }, { /* sentinel */ } }; From a2ae5f0afde34eaecf3fbb13223b772ceaec6227 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 16 Aug 2017 17:43:10 -0700 Subject: [PATCH 36/76] Input: i8042 - constify pnp_device_id pnp_device_id are not supposed to change at runtime. All functions working with pnp_device_id provided by work with const pnp_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/serio/i8042-x86ia64io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index f932a83b4990..ae81e57e13b9 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -927,7 +927,7 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id * return 0; } -static struct pnp_device_id pnp_kbd_devids[] = { +static const struct pnp_device_id pnp_kbd_devids[] = { { .id = "PNP0300", .driver_data = 0 }, { .id = "PNP0301", .driver_data = 0 }, { .id = "PNP0302", .driver_data = 0 }, @@ -957,7 +957,7 @@ static struct pnp_driver i8042_pnp_kbd_driver = { }, }; -static struct pnp_device_id pnp_aux_devids[] = { +static const struct pnp_device_id pnp_aux_devids[] = { { .id = "AUI0200", .driver_data = 0 }, { .id = "FJC6000", .driver_data = 0 }, { .id = "FJC6001", .driver_data = 0 }, From 991368818df4a50f50d2ce673b308f946ed635a6 Mon Sep 17 00:00:00 2001 From: KT Liao Date: Fri, 18 Aug 2017 16:49:53 -0700 Subject: [PATCH 37/76] Input: elan_i2c - support touchpads with two physical buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Elan touchpads on Asus ROG G752xx series laptops have 2 physical buttons. Luckily we can query the touchpad to see if it is a clickpad variant and adjust the behavior accordingly. Signed-off-by: KT Liao Tested-by: Maxime Bellengé Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/elan_i2c.h | 2 +- drivers/input/mouse/elan_i2c_core.c | 9 +++++++-- drivers/input/mouse/elan_i2c_i2c.c | 13 ++++++++++++- drivers/input/mouse/elan_i2c_smbus.c | 4 +++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h index 61c202436250..599544c1a91c 100644 --- a/drivers/input/mouse/elan_i2c.h +++ b/drivers/input/mouse/elan_i2c.h @@ -58,7 +58,7 @@ struct elan_transport_ops { int (*get_version)(struct i2c_client *client, bool iap, u8 *version); int (*get_sm_version)(struct i2c_client *client, - u16 *ic_type, u8 *version); + u16 *ic_type, u8 *version, u8 *clickpad); int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum); int (*get_product_id)(struct i2c_client *client, u16 *id); diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 3b616cb7c67f..07a9b6db7478 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -95,6 +95,7 @@ struct elan_tp_data { u8 min_baseline; u8 max_baseline; bool baseline_ready; + u8 clickpad; }; static int elan_get_fwinfo(u16 ic_type, u16 *validpage_count, @@ -213,7 +214,7 @@ static int elan_query_product(struct elan_tp_data *data) return error; error = data->ops->get_sm_version(data->client, &data->ic_type, - &data->sm_version); + &data->sm_version, &data->clickpad); if (error) return error; @@ -923,6 +924,7 @@ static void elan_report_absolute(struct elan_tp_data *data, u8 *packet) } input_report_key(input, BTN_LEFT, tp_info & 0x01); + input_report_key(input, BTN_RIGHT, tp_info & 0x02); input_report_abs(input, ABS_DISTANCE, hover_event != 0); input_mt_report_pointer_emulation(input, true); input_sync(input); @@ -991,7 +993,10 @@ static int elan_setup_input_device(struct elan_tp_data *data) __set_bit(EV_ABS, input->evbit); __set_bit(INPUT_PROP_POINTER, input->propbit); - __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); + if (data->clickpad) + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); + else + __set_bit(BTN_RIGHT, input->keybit); __set_bit(BTN_LEFT, input->keybit); /* Set up ST parameters */ diff --git a/drivers/input/mouse/elan_i2c_i2c.c b/drivers/input/mouse/elan_i2c_i2c.c index 80172f25974d..15b1330606c1 100644 --- a/drivers/input/mouse/elan_i2c_i2c.c +++ b/drivers/input/mouse/elan_i2c_i2c.c @@ -288,7 +288,8 @@ static int elan_i2c_get_version(struct i2c_client *client, } static int elan_i2c_get_sm_version(struct i2c_client *client, - u16 *ic_type, u8 *version) + u16 *ic_type, u8 *version, + u8 *clickpad) { int error; u8 pattern_ver; @@ -317,6 +318,7 @@ static int elan_i2c_get_sm_version(struct i2c_client *client, return error; } *version = val[1]; + *clickpad = val[0] & 0x10; } else { error = elan_i2c_read_cmd(client, ETP_I2C_OSM_VERSION_CMD, val); if (error) { @@ -326,6 +328,15 @@ static int elan_i2c_get_sm_version(struct i2c_client *client, } *version = val[0]; *ic_type = val[1]; + + error = elan_i2c_read_cmd(client, ETP_I2C_NSM_VERSION_CMD, + val); + if (error) { + dev_err(&client->dev, "failed to get SM version: %d\n", + error); + return error; + } + *clickpad = val[0] & 0x10; } return 0; diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c index df7a57ca7331..29f99529b187 100644 --- a/drivers/input/mouse/elan_i2c_smbus.c +++ b/drivers/input/mouse/elan_i2c_smbus.c @@ -166,7 +166,8 @@ static int elan_smbus_get_version(struct i2c_client *client, } static int elan_smbus_get_sm_version(struct i2c_client *client, - u16 *ic_type, u8 *version) + u16 *ic_type, u8 *version, + u8 *clickpad) { int error; u8 val[3]; @@ -180,6 +181,7 @@ static int elan_smbus_get_sm_version(struct i2c_client *client, *version = val[0]; *ic_type = val[1]; + *clickpad = val[0] & 0x10; return 0; } From b9e8cbc437103b30f3289b3fe174c678c725258e Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:07:32 -0700 Subject: [PATCH 38/76] Input: iforce - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/iforce/iforce-serio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c index 46d5041d2d9d..154e827b559b 100644 --- a/drivers/input/joystick/iforce/iforce-serio.c +++ b/drivers/input/joystick/iforce/iforce-serio.c @@ -164,7 +164,7 @@ static void iforce_serio_disconnect(struct serio *serio) kfree(iforce); } -static struct serio_device_id iforce_serio_ids[] = { +static const struct serio_device_id iforce_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_IFORCE, From f31103f8ed17297f900d319bfdb7140877d9c057 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:07:48 -0700 Subject: [PATCH 39/76] Input: magellan - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/magellan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c index c5358ba1f571..a9d0e3edca94 100644 --- a/drivers/input/joystick/magellan.c +++ b/drivers/input/joystick/magellan.c @@ -198,7 +198,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id magellan_serio_ids[] = { +static const struct serio_device_id magellan_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_MAGELLAN, From c62c68f81dc92e5d162230c924ca83b682272697 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:08:02 -0700 Subject: [PATCH 40/76] Input: spaceball - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/spaceball.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index f4445a4e8d6a..e9712a1b7cad 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c @@ -272,7 +272,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id spaceball_serio_ids[] = { +static const struct serio_device_id spaceball_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_SPACEBALL, From ecfd71af894ab2f0ce24df59232479d4a088ebce Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:08:17 -0700 Subject: [PATCH 41/76] Input: spaceorb - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/spaceorb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index f2667820e8c5..05da0ed514e2 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c @@ -213,7 +213,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id spaceorb_serio_ids[] = { +static const struct serio_device_id spaceorb_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_SPACEORB, From fa0426c6cfdf89726f4e9495d6870f01374459f9 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:08:29 -0700 Subject: [PATCH 42/76] Input: stinger - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/stinger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index 099c6d7b5e08..cb10e7b097ae 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c @@ -184,7 +184,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id stinger_serio_ids[] = { +static const struct serio_device_id stinger_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_STINGER, From a1e29643bc10873821a1b9fe4551224370379f78 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:08:41 -0700 Subject: [PATCH 43/76] Input: twidjoy - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/twidjoy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index 7f7e5ab3f9e3..e60cb004cb8c 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c @@ -233,7 +233,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id twidjoy_serio_ids[] = { +static const struct serio_device_id twidjoy_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_TWIDJOY, From bee186de9ad116a5e0fb6c67578e430257afbdcf Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:08:52 -0700 Subject: [PATCH 44/76] Input: warrior - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/warrior.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index e13a9144a25d..ef5391ba4470 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c @@ -193,7 +193,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id warrior_serio_ids[] = { +static const struct serio_device_id warrior_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_WARRIOR, From b06bc6b6bf8cf68daca123ddcc3391ef08411f58 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:09:05 -0700 Subject: [PATCH 45/76] Input: zhenhua - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/zhenhua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/zhenhua.c b/drivers/input/joystick/zhenhua.c index 4a8258bf13fd..5c6d5de743f1 100644 --- a/drivers/input/joystick/zhenhua.c +++ b/drivers/input/joystick/zhenhua.c @@ -192,7 +192,7 @@ static int zhenhua_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id zhenhua_serio_ids[] = { +static const struct serio_device_id zhenhua_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_ZHENHUA, From af2e7d77957afdf08f7e12a1d1e24f51eb51c7db Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:09:14 -0700 Subject: [PATCH 46/76] Input: iatkbd - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/atkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index ec876b5b1382..7e75835e220f 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -1270,7 +1270,7 @@ static int atkbd_reconnect(struct serio *serio) return retval; } -static struct serio_device_id atkbd_serio_ids[] = { +static const struct serio_device_id atkbd_serio_ids[] = { { .type = SERIO_8042, .proto = SERIO_ANY, From ea6aba4b06f1c71e912c817a2f24792f0d971441 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:09:21 -0700 Subject: [PATCH 47/76] Input: hil_kbd - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/hil_kbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 5b152f25a8e1..bb29a7c9a1c0 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c @@ -559,7 +559,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) return error; } -static struct serio_device_id hil_dev_ids[] = { +static const struct serio_device_id hil_dev_ids[] = { { .type = SERIO_HIL_MLC, .proto = SERIO_HIL, From e87dc8734c251bc0e22c4844323069a18b780cb4 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:09:31 -0700 Subject: [PATCH 48/76] Input: lkkbd - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/lkkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 9fcd9f1d5dc8..471d53815c6d 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c @@ -707,7 +707,7 @@ static void lkkbd_disconnect(struct serio *serio) kfree(lk); } -static struct serio_device_id lkkbd_serio_ids[] = { +static const struct serio_device_id lkkbd_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_LKKBD, From 9780930ae602982bd1b9859c07b09c800ae12d04 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:09:41 -0700 Subject: [PATCH 49/76] Input: newtonkbd - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/newtonkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 20f044377990..fb9b8e23ab93 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c @@ -142,7 +142,7 @@ static void nkbd_disconnect(struct serio *serio) kfree(nkbd); } -static struct serio_device_id nkbd_serio_ids[] = { +static const struct serio_device_id nkbd_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_NEWTON, From 1fa802171fafae9f7a46ced622585692b8588f6d Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:09:50 -0700 Subject: [PATCH 50/76] Input: stowaway - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/stowaway.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c index a6e0d565e306..8b6de9a692dc 100644 --- a/drivers/input/keyboard/stowaway.c +++ b/drivers/input/keyboard/stowaway.c @@ -146,7 +146,7 @@ static void skbd_disconnect(struct serio *serio) kfree(skbd); } -static struct serio_device_id skbd_serio_ids[] = { +static const struct serio_device_id skbd_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_STOWAWAY, From 1966e005ce9abe275a5c2db912175c4da3fe9b59 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:10:05 -0700 Subject: [PATCH 51/76] Input: sunkbd - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/sunkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index dc6bb9d5b4f0..c95707ea2656 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -339,7 +339,7 @@ static void sunkbd_disconnect(struct serio *serio) kfree(sunkbd); } -static struct serio_device_id sunkbd_serio_ids[] = { +static const struct serio_device_id sunkbd_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_SUNKBD, From e527a87caa5b937917ba7598c472e8a77f0778b7 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:10:13 -0700 Subject: [PATCH 52/76] Input: xtkbd - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/xtkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 7c2325bd7408..8f64b9ded8d0 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c @@ -145,7 +145,7 @@ static void xtkbd_disconnect(struct serio *serio) kfree(xtkbd); } -static struct serio_device_id xtkbd_serio_ids[] = { +static const struct serio_device_id xtkbd_serio_ids[] = { { .type = SERIO_XT, .proto = SERIO_ANY, From 0aea22b30f7688b9fad463d98e81608463c2a39d Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:10:24 -0700 Subject: [PATCH 53/76] Input: constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/serio/serio_raw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index 71ef5d65a0c6..516f9fe77a17 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c @@ -410,7 +410,7 @@ static void serio_raw_disconnect(struct serio *serio) serio_set_drvdata(serio, NULL); } -static struct serio_device_id serio_raw_serio_ids[] = { +static const struct serio_device_id serio_raw_serio_ids[] = { { .type = SERIO_8042, .proto = SERIO_ANY, From a7082ac4705b5abd8a61db4b1650765919cc718b Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:10:33 -0700 Subject: [PATCH 54/76] Input: wacom_serial4 - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_serial4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/tablet/wacom_serial4.c b/drivers/input/tablet/wacom_serial4.c index 20ab802461e7..38bfaca48eab 100644 --- a/drivers/input/tablet/wacom_serial4.c +++ b/drivers/input/tablet/wacom_serial4.c @@ -594,7 +594,7 @@ free_device: return err; } -static struct serio_device_id wacom_serio_ids[] = { +static const struct serio_device_id wacom_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_WACOM_IV, From fe11d25e365d56d5a958589a2ff004b2ac538e11 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:10:41 -0700 Subject: [PATCH 55/76] Input: dynapro - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/dynapro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/dynapro.c b/drivers/input/touchscreen/dynapro.c index 86237a910876..5b1b66fffbe3 100644 --- a/drivers/input/touchscreen/dynapro.c +++ b/drivers/input/touchscreen/dynapro.c @@ -164,7 +164,7 @@ static int dynapro_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id dynapro_serio_ids[] = { +static const struct serio_device_id dynapro_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_DYNAPRO, From 4f8d5241dd4c11d99bad8cc7cccddd39b20be94c Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:10:53 -0700 Subject: [PATCH 56/76] Input: elo - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/elo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 8051a4b704ea..83433e8efff7 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c @@ -381,7 +381,7 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id elo_serio_ids[] = { +static const struct serio_device_id elo_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_ELO, From 0e2ba64e1e993c3a832a02cf81fc5d4b1a35dd27 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:04 -0700 Subject: [PATCH 57/76] Input: fujitsu_ts - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/fujitsu_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/fujitsu_ts.c b/drivers/input/touchscreen/fujitsu_ts.c index d0e46a7e183b..a0fbb454499d 100644 --- a/drivers/input/touchscreen/fujitsu_ts.c +++ b/drivers/input/touchscreen/fujitsu_ts.c @@ -151,7 +151,7 @@ static int fujitsu_connect(struct serio *serio, struct serio_driver *drv) /* * The serio driver structure. */ -static struct serio_device_id fujitsu_serio_ids[] = { +static const struct serio_device_id fujitsu_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_FUJITSU, From 7330090429c59894a42c3f750d377e27e371ff07 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:12 -0700 Subject: [PATCH 58/76] Input: gunze - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/gunze.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index e2ee62615273..481586909d28 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c @@ -162,7 +162,7 @@ static int gunze_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id gunze_serio_ids[] = { +static const struct serio_device_id gunze_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_GUNZE, From 9c4f4ba74558a38dc0956fdecd98ee8279a41231 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:20 -0700 Subject: [PATCH 59/76] Input: hampshire - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/hampshire.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/hampshire.c b/drivers/input/touchscreen/hampshire.c index ecb1e0e01328..eb052d559e54 100644 --- a/drivers/input/touchscreen/hampshire.c +++ b/drivers/input/touchscreen/hampshire.c @@ -163,7 +163,7 @@ static int hampshire_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id hampshire_serio_ids[] = { +static const struct serio_device_id hampshire_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_HAMPSHIRE, From 79308587cf6b303ae73f0bf724ce91b6caeb98da Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:32 -0700 Subject: [PATCH 60/76] Input: inexio - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/inexio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/inexio.c b/drivers/input/touchscreen/inexio.c index adb80b65a259..b9bc56233ccc 100644 --- a/drivers/input/touchscreen/inexio.c +++ b/drivers/input/touchscreen/inexio.c @@ -165,7 +165,7 @@ static int inexio_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id inexio_serio_ids[] = { +static const struct serio_device_id inexio_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_INEXIO, From a012cad6308cad83f71efe8418df417175bb8150 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:40 -0700 Subject: [PATCH 61/76] Input: mtouch - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/mtouch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index 9b5552a26169..a3707fad4d1c 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c @@ -178,7 +178,7 @@ static int mtouch_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id mtouch_serio_ids[] = { +static const struct serio_device_id mtouch_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_MICROTOUCH, From bb5da0d3c0a77f81aca782311464fc4f71b4570d Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:48 -0700 Subject: [PATCH 62/76] Input: penmount - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/penmount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c index 417d87379265..6e6d7fd98cd2 100644 --- a/drivers/input/touchscreen/penmount.c +++ b/drivers/input/touchscreen/penmount.c @@ -293,7 +293,7 @@ static int pm_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id pm_serio_ids[] = { +static const struct serio_device_id pm_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_PENMOUNT, From b84704c323456c5d153e82691751dfb67262dd95 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:11:56 -0700 Subject: [PATCH 63/76] Input: touchit213 - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/touchit213.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/touchit213.c b/drivers/input/touchscreen/touchit213.c index c27cf8f3d1ca..98a16698be8e 100644 --- a/drivers/input/touchscreen/touchit213.c +++ b/drivers/input/touchscreen/touchit213.c @@ -192,7 +192,7 @@ static int touchit213_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id touchit213_serio_ids[] = { +static const struct serio_device_id touchit213_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_TOUCHIT213, From ef2bc04e74ec502688efb6c3a2b7f21adad61e95 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:12:03 -0700 Subject: [PATCH 64/76] Input: touchright - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/touchright.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c index 4000e5205407..45c325c33f21 100644 --- a/drivers/input/touchscreen/touchright.c +++ b/drivers/input/touchscreen/touchright.c @@ -152,7 +152,7 @@ static int tr_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id tr_serio_ids[] = { +static const struct serio_device_id tr_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_TOUCHRIGHT, From a110a953bbe3ee338301fdd30783a2a8033bff11 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:12:14 -0700 Subject: [PATCH 65/76] Input: touchwin - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/touchwin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c index ba90f447df75..2ba6b4ca28cb 100644 --- a/drivers/input/touchscreen/touchwin.c +++ b/drivers/input/touchscreen/touchwin.c @@ -159,7 +159,7 @@ static int tw_connect(struct serio *serio, struct serio_driver *drv) * The serio driver structure. */ -static struct serio_device_id tw_serio_ids[] = { +static const struct serio_device_id tw_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_TOUCHWIN, From 57952335feb04abcaecb14c641fe106da749d447 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:12:29 -0700 Subject: [PATCH 66/76] Input: tsc40 - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/tsc40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/tsc40.c b/drivers/input/touchscreen/tsc40.c index 29687872cb94..d4ae4ba84c1f 100644 --- a/drivers/input/touchscreen/tsc40.c +++ b/drivers/input/touchscreen/tsc40.c @@ -141,7 +141,7 @@ static void tsc_disconnect(struct serio *serio) serio_set_drvdata(serio, NULL); } -static struct serio_device_id tsc_serio_ids[] = { +static const struct serio_device_id tsc_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_TSC40, From 663c8b55d0ab5512d9aeb6536683271cfdb166f2 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:12:40 -0700 Subject: [PATCH 67/76] Input: wacom_w8001 - constify serio_device_id serio_device_id are not supposed to change at runtime. All functions working with serio_device_id provided by work with const serio_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/wacom_w8001.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 85e95725d0df..3715d1eace92 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -681,7 +681,7 @@ fail1: return err; } -static struct serio_device_id w8001_serio_ids[] = { +static const struct serio_device_id w8001_serio_ids[] = { { .type = SERIO_RS232, .proto = SERIO_W8001, From 8cc8446b9b62ef954b630ed30e53bd1553e916a6 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Tue, 25 Jul 2017 14:08:48 -0700 Subject: [PATCH 68/76] Input: atmel_mxt_ts - use more managed resources Switch mxt_data and interrupt to resource managed allocation methods, which cleans up the driver slightly and prepares for adding reset GPIO support. Signed-off-by: Sebastian Reichel Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/atmel_mxt_ts.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index dd042a9b0aaa..aeb46522073a 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3117,11 +3117,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) if (IS_ERR(pdata)) return PTR_ERR(pdata); - data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL); - if (!data) { - dev_err(&client->dev, "Failed to allocate memory\n"); + data = devm_kzalloc(&client->dev, sizeof(struct mxt_data), GFP_KERNEL); + if (!data) return -ENOMEM; - } snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", client->adapter->nr, client->addr); @@ -3135,19 +3133,20 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) init_completion(&data->reset_completion); init_completion(&data->crc_completion); - error = request_threaded_irq(client->irq, NULL, mxt_interrupt, - pdata->irqflags | IRQF_ONESHOT, - client->name, data); + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, mxt_interrupt, + pdata->irqflags | IRQF_ONESHOT, + client->name, data); if (error) { dev_err(&client->dev, "Failed to register interrupt\n"); - goto err_free_mem; + return error; } disable_irq(client->irq); error = mxt_initialize(data); if (error) - goto err_free_irq; + return error; error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); if (error) { @@ -3161,10 +3160,6 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) err_free_object: mxt_free_input_device(data); mxt_free_object_table(data); -err_free_irq: - free_irq(client->irq, data); -err_free_mem: - kfree(data); return error; } @@ -3172,11 +3167,10 @@ static int mxt_remove(struct i2c_client *client) { struct mxt_data *data = i2c_get_clientdata(client); + disable_irq(data->irq); sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); - free_irq(data->irq, data); mxt_free_input_device(data); mxt_free_object_table(data); - kfree(data); return 0; } From f657b00df22e231da217ca0162a75db452475e8f Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Tue, 25 Jul 2017 14:11:34 -0700 Subject: [PATCH 69/76] Input: atmel_mxt_ts - add support for reset line Provide support for controlling reset pin. If this is not driven correctly the device will be held in reset and will not respond. Acked-by: Rob Herring Signed-off-by: Sebastian Reichel Signed-off-by: Dmitry Torokhov --- .../bindings/input/atmel,maxtouch.txt | 2 ++ drivers/input/touchscreen/atmel_mxt_ts.c | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt index 1852906517ab..23e3abc3fdef 100644 --- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt +++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt @@ -22,6 +22,8 @@ Optional properties for main touchpad device: experiment to determine which bit corresponds to which input. Use KEY_RESERVED for unused padding values. +- reset-gpios: GPIO specifier for the touchscreen's reset pin (active low) + Example: touch@4b { diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index aeb46522073a..7659bc48f1db 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -300,6 +301,7 @@ struct mxt_data { u8 multitouch; struct t7_config t7_cfg; struct mxt_dbg dbg; + struct gpio_desc *reset_gpio; /* Cached parameters from object table */ u16 T5_address; @@ -3133,6 +3135,14 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) init_completion(&data->reset_completion); init_completion(&data->crc_completion); + data->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(data->reset_gpio)) { + error = PTR_ERR(data->reset_gpio); + dev_err(&client->dev, "Failed to get reset gpio: %d\n", error); + return error; + } + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, mxt_interrupt, pdata->irqflags | IRQF_ONESHOT, @@ -3142,6 +3152,18 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } + if (data->reset_gpio) { + data->in_bootloader = true; + msleep(MXT_RESET_TIME); + reinit_completion(&data->bl_completion); + gpiod_set_value(data->reset_gpio, 1); + error = mxt_wait_for_completion(data, &data->bl_completion, + MXT_RESET_TIMEOUT); + if (error) + return error; + data->in_bootloader = false; + } + disable_irq(client->irq); error = mxt_initialize(data); From b54bf2fd156c6294eaaac2861939f679f8616b55 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 23 Aug 2017 11:37:05 -0700 Subject: [PATCH 70/76] Input: ambakmi - constify amba_id amba_id are not supposed to change at runtime. All functions working with const amba_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/serio/ambakmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index c6606cacb6a7..ff3875cf3da1 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -187,7 +187,7 @@ static int __maybe_unused amba_kmi_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(amba_kmi_dev_pm_ops, NULL, amba_kmi_resume); -static struct amba_id amba_kmi_idtable[] = { +static const struct amba_id amba_kmi_idtable[] = { { .id = 0x00041050, .mask = 0x000fffff, From 0ca0681002587d56ebadc16a6c6653028c3c5cbf Mon Sep 17 00:00:00 2001 From: Liang Yan Date: Mon, 28 Aug 2017 09:41:08 -0700 Subject: [PATCH 71/76] Input: xen-kbdfront - enable auto repeat for xen keyboard frontend driver Long pressed key could not show right in XEN vncviewer after tigervnc client changed the way how to send repeat keys, from "Down Up Down Up ..." to "Down Down ... Up". This will report autorepeat to input by checking if same key being pressed, and let handler process it finally. Signed-off-by: Liang Yan Signed-off-by: Dmitry Torokhov --- drivers/input/misc/xen-kbdfront.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index fa130e7b734c..6bf56bb5f8d9 100644 --- a/drivers/input/misc/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c @@ -84,17 +84,20 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info, struct xenkbd_key *key) { struct input_dev *dev; + int value = key->pressed; if (test_bit(key->keycode, info->ptr->keybit)) { dev = info->ptr; } else if (test_bit(key->keycode, info->kbd->keybit)) { dev = info->kbd; + if (key->pressed && test_bit(key->keycode, info->kbd->key)) + value = 2; /* Mark as autorepeat */ } else { pr_warn("unhandled keycode 0x%x\n", key->keycode); return; } - input_report_key(dev, key->keycode, key->pressed); + input_event(dev, EV_KEY, key->keycode, value); input_sync(dev); } From 9ee0a0558819e63d189426c953668fe1ce7cb637 Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Mon, 28 Aug 2017 09:59:20 -0700 Subject: [PATCH 72/76] Input: PS/2 gpio bit banging driver for serio bus This driver provides PS/2 serio bus support by implementing bit banging with the GPIO API. The GPIO pins, data and clock, can be configured with a node in the device tree or by generic device properties (GDP). Writing to a device is supported as well, though it is possible timings can not be halt as they are tough and difficult to reach with bit banging. Therefore it can be configured (also in DT and GDP) whether the serio write function should be available for clients. This driver is for development purposes and not recommended for productive use. However, this driver can be useful e.g. when no USB port is available or using old peripherals is desired as PS/2 controller chips getting rare. This driver was tested on bcm2825 and on Kirin 960 and it worked well together with the atkbd and psmouse driver. Signed-off-by: Danilo Krummrich Reviewed-by: Linus Walleij Acked-by: Rob Herring Signed-off-by: Dmitry Torokhov --- .../devicetree/bindings/serio/ps2-gpio.txt | 23 + Documentation/gpio/drivers-on-gpio.txt | 5 + drivers/input/serio/Kconfig | 11 + drivers/input/serio/Makefile | 1 + drivers/input/serio/ps2-gpio.c | 453 ++++++++++++++++++ 5 files changed, 493 insertions(+) create mode 100644 Documentation/devicetree/bindings/serio/ps2-gpio.txt create mode 100644 drivers/input/serio/ps2-gpio.c diff --git a/Documentation/devicetree/bindings/serio/ps2-gpio.txt b/Documentation/devicetree/bindings/serio/ps2-gpio.txt new file mode 100644 index 000000000000..7b7bc9cdf986 --- /dev/null +++ b/Documentation/devicetree/bindings/serio/ps2-gpio.txt @@ -0,0 +1,23 @@ +Device-Tree binding for ps/2 gpio device + +Required properties: + - compatible = "ps2-gpio" + - data-gpios: the data pin + - clk-gpios: the clock pin + - interrupts: Should trigger on the falling edge of the clock line. + +Optional properties: + - write-enable: Indicates whether write function is provided + to serio device. Possibly providing the write fn will not work, because + of the tough timing requirements. + +Example nodes: + +ps2@0 { + compatible = "ps2-gpio"; + interrupt-parent = <&gpio>; + interrupts = <23 IRQ_TYPE_EDGE_FALLING>; + data-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + clk-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>; + write-enable; +}; diff --git a/Documentation/gpio/drivers-on-gpio.txt b/Documentation/gpio/drivers-on-gpio.txt index 306513251713..9a78d385b92e 100644 --- a/Documentation/gpio/drivers-on-gpio.txt +++ b/Documentation/gpio/drivers-on-gpio.txt @@ -84,6 +84,11 @@ hardware descriptions such as device tree or ACPI: NAND flash MTD subsystem and provides chip access and partition parsing like any other NAND driving hardware. +- ps2-gpio: drivers/input/serio/ps2-gpio.c is used to drive a PS/2 (IBM) serio + bus, data and clock line, by bit banging two GPIO lines. It will appear as + any other serio bus to the system and makes it possible to connect drivers + for e.g. keyboards and other PS/2 protocol based devices. + Apart from this there are special GPIO drivers in subsystems like MMC/SD to read card detect and write protect GPIO lines, and in the TTY serial subsystem to emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index c3d05b4d3118..21488c048fa3 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig @@ -292,6 +292,17 @@ config SERIO_SUN4I_PS2 To compile this driver as a module, choose M here: the module will be called sun4i-ps2. +config SERIO_GPIO_PS2 + tristate "GPIO PS/2 bit banging driver" + depends on GPIOLIB + help + Say Y here if you want PS/2 bit banging support via GPIO. + + To compile this driver as a module, choose M here: the + module will be called ps2-gpio. + + If you are unsure, say N. + config USERIO tristate "User space serio port driver support" help diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile index 2374ef9b33d7..767bd9b6e1ed 100644 --- a/drivers/input/serio/Makefile +++ b/drivers/input/serio/Makefile @@ -30,4 +30,5 @@ obj-$(CONFIG_SERIO_APBPS2) += apbps2.o obj-$(CONFIG_SERIO_OLPC_APSP) += olpc_apsp.o obj-$(CONFIG_HYPERV_KEYBOARD) += hyperv-keyboard.o obj-$(CONFIG_SERIO_SUN4I_PS2) += sun4i-ps2.o +obj-$(CONFIG_SERIO_GPIO_PS2) += ps2-gpio.o obj-$(CONFIG_USERIO) += userio.o diff --git a/drivers/input/serio/ps2-gpio.c b/drivers/input/serio/ps2-gpio.c new file mode 100644 index 000000000000..b50e3817f3c4 --- /dev/null +++ b/drivers/input/serio/ps2-gpio.c @@ -0,0 +1,453 @@ +/* + * GPIO based serio bus driver for bit banging the PS/2 protocol + * + * Author: Danilo Krummrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "ps2-gpio" + +#define PS2_MODE_RX 0 +#define PS2_MODE_TX 1 + +#define PS2_START_BIT 0 +#define PS2_DATA_BIT0 1 +#define PS2_DATA_BIT1 2 +#define PS2_DATA_BIT2 3 +#define PS2_DATA_BIT3 4 +#define PS2_DATA_BIT4 5 +#define PS2_DATA_BIT5 6 +#define PS2_DATA_BIT6 7 +#define PS2_DATA_BIT7 8 +#define PS2_PARITY_BIT 9 +#define PS2_STOP_BIT 10 +#define PS2_TX_TIMEOUT 11 +#define PS2_ACK_BIT 12 + +#define PS2_DEV_RET_ACK 0xfa +#define PS2_DEV_RET_NACK 0xfe + +#define PS2_CMD_RESEND 0xfe + +struct ps2_gpio_data { + struct device *dev; + struct serio *serio; + unsigned char mode; + struct gpio_desc *gpio_clk; + struct gpio_desc *gpio_data; + bool write_enable; + int irq; + unsigned char rx_cnt; + unsigned char rx_byte; + unsigned char tx_cnt; + unsigned char tx_byte; + struct completion tx_done; + struct mutex tx_mutex; + struct delayed_work tx_work; +}; + +static int ps2_gpio_open(struct serio *serio) +{ + struct ps2_gpio_data *drvdata = serio->port_data; + + enable_irq(drvdata->irq); + return 0; +} + +static void ps2_gpio_close(struct serio *serio) +{ + struct ps2_gpio_data *drvdata = serio->port_data; + + disable_irq(drvdata->irq); +} + +static int __ps2_gpio_write(struct serio *serio, unsigned char val) +{ + struct ps2_gpio_data *drvdata = serio->port_data; + + disable_irq_nosync(drvdata->irq); + gpiod_direction_output(drvdata->gpio_clk, 0); + + drvdata->mode = PS2_MODE_TX; + drvdata->tx_byte = val; + + schedule_delayed_work(&drvdata->tx_work, usecs_to_jiffies(200)); + + return 0; +} + +static int ps2_gpio_write(struct serio *serio, unsigned char val) +{ + struct ps2_gpio_data *drvdata = serio->port_data; + int ret = 0; + + if (in_task()) { + mutex_lock(&drvdata->tx_mutex); + __ps2_gpio_write(serio, val); + if (!wait_for_completion_timeout(&drvdata->tx_done, + msecs_to_jiffies(10000))) + ret = SERIO_TIMEOUT; + mutex_unlock(&drvdata->tx_mutex); + } else { + __ps2_gpio_write(serio, val); + } + + return ret; +} + +static void ps2_gpio_tx_work_fn(struct work_struct *work) +{ + struct delayed_work *dwork = to_delayed_work(work); + struct ps2_gpio_data *drvdata = container_of(dwork, + struct ps2_gpio_data, + tx_work); + + enable_irq(drvdata->irq); + gpiod_direction_output(drvdata->gpio_data, 0); + gpiod_direction_input(drvdata->gpio_clk); +} + +static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata) +{ + unsigned char byte, cnt; + int data; + int rxflags = 0; + static unsigned long old_jiffies; + + byte = drvdata->rx_byte; + cnt = drvdata->rx_cnt; + + if (old_jiffies == 0) + old_jiffies = jiffies; + + if ((jiffies - old_jiffies) > usecs_to_jiffies(100)) { + dev_err(drvdata->dev, + "RX: timeout, probably we missed an interrupt\n"); + goto err; + } + old_jiffies = jiffies; + + data = gpiod_get_value(drvdata->gpio_data); + if (unlikely(data < 0)) { + dev_err(drvdata->dev, "RX: failed to get data gpio val: %d\n", + data); + goto err; + } + + switch (cnt) { + case PS2_START_BIT: + /* start bit should be low */ + if (unlikely(data)) { + dev_err(drvdata->dev, "RX: start bit should be low\n"); + goto err; + } + break; + case PS2_DATA_BIT0: + case PS2_DATA_BIT1: + case PS2_DATA_BIT2: + case PS2_DATA_BIT3: + case PS2_DATA_BIT4: + case PS2_DATA_BIT5: + case PS2_DATA_BIT6: + case PS2_DATA_BIT7: + /* processing data bits */ + if (data) + byte |= (data << (cnt - 1)); + break; + case PS2_PARITY_BIT: + /* check odd parity */ + if (!((hweight8(byte) & 1) ^ data)) { + rxflags |= SERIO_PARITY; + dev_warn(drvdata->dev, "RX: parity error\n"); + if (!drvdata->write_enable) + goto err; + } + + /* Do not send spurious ACK's and NACK's when write fn is + * not provided. + */ + if (!drvdata->write_enable) { + if (byte == PS2_DEV_RET_NACK) + goto err; + else if (byte == PS2_DEV_RET_ACK) + break; + } + + /* Let's send the data without waiting for the stop bit to be + * sent. It may happen that we miss the stop bit. When this + * happens we have no way to recover from this, certainly + * missing the parity bit would be recognized when processing + * the stop bit. When missing both, data is lost. + */ + serio_interrupt(drvdata->serio, byte, rxflags); + dev_dbg(drvdata->dev, "RX: sending byte 0x%x\n", byte); + break; + case PS2_STOP_BIT: + /* stop bit should be high */ + if (unlikely(!data)) { + dev_err(drvdata->dev, "RX: stop bit should be high\n"); + goto err; + } + cnt = byte = 0; + old_jiffies = 0; + goto end; /* success */ + default: + dev_err(drvdata->dev, "RX: got out of sync with the device\n"); + goto err; + } + + cnt++; + goto end; /* success */ + +err: + cnt = byte = 0; + old_jiffies = 0; + __ps2_gpio_write(drvdata->serio, PS2_CMD_RESEND); +end: + drvdata->rx_cnt = cnt; + drvdata->rx_byte = byte; + return IRQ_HANDLED; +} + +static irqreturn_t ps2_gpio_irq_tx(struct ps2_gpio_data *drvdata) +{ + unsigned char byte, cnt; + int data; + static unsigned long old_jiffies; + + cnt = drvdata->tx_cnt; + byte = drvdata->tx_byte; + + if (old_jiffies == 0) + old_jiffies = jiffies; + + if ((jiffies - old_jiffies) > usecs_to_jiffies(100)) { + dev_err(drvdata->dev, + "TX: timeout, probably we missed an interrupt\n"); + goto err; + } + old_jiffies = jiffies; + + switch (cnt) { + case PS2_START_BIT: + /* should never happen */ + dev_err(drvdata->dev, + "TX: start bit should have been sent already\n"); + goto err; + case PS2_DATA_BIT0: + case PS2_DATA_BIT1: + case PS2_DATA_BIT2: + case PS2_DATA_BIT3: + case PS2_DATA_BIT4: + case PS2_DATA_BIT5: + case PS2_DATA_BIT6: + case PS2_DATA_BIT7: + data = byte & BIT(cnt - 1); + gpiod_set_value(drvdata->gpio_data, data); + break; + case PS2_PARITY_BIT: + /* do odd parity */ + data = !(hweight8(byte) & 1); + gpiod_set_value(drvdata->gpio_data, data); + break; + case PS2_STOP_BIT: + /* release data line to generate stop bit */ + gpiod_direction_input(drvdata->gpio_data); + break; + case PS2_TX_TIMEOUT: + /* Devices generate one extra clock pulse before sending the + * acknowledgment. + */ + break; + case PS2_ACK_BIT: + gpiod_direction_input(drvdata->gpio_data); + data = gpiod_get_value(drvdata->gpio_data); + if (data) { + dev_warn(drvdata->dev, "TX: received NACK, retry\n"); + goto err; + } + + drvdata->mode = PS2_MODE_RX; + complete(&drvdata->tx_done); + + cnt = 1; + old_jiffies = 0; + goto end; /* success */ + default: + /* Probably we missed the stop bit. Therefore we release data + * line and try again. + */ + gpiod_direction_input(drvdata->gpio_data); + dev_err(drvdata->dev, "TX: got out of sync with the device\n"); + goto err; + } + + cnt++; + goto end; /* success */ + +err: + cnt = 1; + old_jiffies = 0; + gpiod_direction_input(drvdata->gpio_data); + __ps2_gpio_write(drvdata->serio, drvdata->tx_byte); +end: + drvdata->tx_cnt = cnt; + return IRQ_HANDLED; +} + +static irqreturn_t ps2_gpio_irq(int irq, void *dev_id) +{ + struct ps2_gpio_data *drvdata = dev_id; + + return drvdata->mode ? ps2_gpio_irq_tx(drvdata) : + ps2_gpio_irq_rx(drvdata); +} + +static int ps2_gpio_get_props(struct device *dev, + struct ps2_gpio_data *drvdata) +{ + drvdata->gpio_data = devm_gpiod_get(dev, "data", GPIOD_IN); + if (IS_ERR(drvdata->gpio_data)) { + dev_err(dev, "failed to request data gpio: %ld", + PTR_ERR(drvdata->gpio_data)); + return PTR_ERR(drvdata->gpio_data); + } + + drvdata->gpio_clk = devm_gpiod_get(dev, "clk", GPIOD_IN); + if (IS_ERR(drvdata->gpio_clk)) { + dev_err(dev, "failed to request clock gpio: %ld", + PTR_ERR(drvdata->gpio_clk)); + return PTR_ERR(drvdata->gpio_clk); + } + + drvdata->write_enable = device_property_read_bool(dev, + "write-enable"); + + return 0; +} + +static int ps2_gpio_probe(struct platform_device *pdev) +{ + struct ps2_gpio_data *drvdata; + struct serio *serio; + struct device *dev = &pdev->dev; + int error; + + drvdata = devm_kzalloc(dev, sizeof(struct ps2_gpio_data), GFP_KERNEL); + serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + if (!drvdata || !serio) { + error = -ENOMEM; + goto err_free_serio; + } + + error = ps2_gpio_get_props(dev, drvdata); + if (error) + goto err_free_serio; + + if (gpiod_cansleep(drvdata->gpio_data) || + gpiod_cansleep(drvdata->gpio_clk)) { + dev_err(dev, "GPIO data or clk are connected via slow bus\n"); + error = -EINVAL; + } + + 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; + } + + error = devm_request_irq(dev, drvdata->irq, ps2_gpio_irq, + IRQF_NO_THREAD, DRIVER_NAME, drvdata); + if (error) { + dev_err(dev, "failed to request irq %d: %d\n", + drvdata->irq, error); + goto err_free_serio; + } + + /* Keep irq disabled until serio->open is called. */ + disable_irq(drvdata->irq); + + serio->id.type = SERIO_8042; + serio->open = ps2_gpio_open; + serio->close = ps2_gpio_close; + /* Write can be enabled in platform/dt data, but possibly it will not + * work because of the tough timings. + */ + serio->write = drvdata->write_enable ? ps2_gpio_write : NULL; + serio->port_data = drvdata; + serio->dev.parent = dev; + strlcpy(serio->name, dev_name(dev), sizeof(serio->name)); + strlcpy(serio->phys, dev_name(dev), sizeof(serio->phys)); + + drvdata->serio = serio; + drvdata->dev = dev; + drvdata->mode = PS2_MODE_RX; + + /* Tx count always starts at 1, as the start bit is sent implicitly by + * host-to-device communication initialization. + */ + drvdata->tx_cnt = 1; + + INIT_DELAYED_WORK(&drvdata->tx_work, ps2_gpio_tx_work_fn); + init_completion(&drvdata->tx_done); + mutex_init(&drvdata->tx_mutex); + + serio_register_port(serio); + platform_set_drvdata(pdev, drvdata); + + return 0; /* success */ + +err_free_serio: + kfree(serio); + return error; +} + +static int ps2_gpio_remove(struct platform_device *pdev) +{ + struct ps2_gpio_data *drvdata = platform_get_drvdata(pdev); + + serio_unregister_port(drvdata->serio); + return 0; +} + +#if defined(CONFIG_OF) +static const struct of_device_id ps2_gpio_match[] = { + { .compatible = "ps2-gpio", }, + { }, +}; +MODULE_DEVICE_TABLE(of, ps2_gpio_match); +#endif + +static struct platform_driver ps2_gpio_driver = { + .probe = ps2_gpio_probe, + .remove = ps2_gpio_remove, + .driver = { + .name = DRIVER_NAME, + .of_match_table = of_match_ptr(ps2_gpio_match), + }, +}; +module_platform_driver(ps2_gpio_driver); + +MODULE_AUTHOR("Danilo Krummrich "); +MODULE_DESCRIPTION("GPIO PS2 driver"); +MODULE_LICENSE("GPL v2"); From 8a7f102c4b15940e43b712d35da357a2c05ffb84 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 31 Aug 2017 11:35:29 -0700 Subject: [PATCH 73/76] Input: tegra-kbc - handle return value of clk_prepare_enable clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/tegra-kbc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index 0c07e1023a46..edc1385ca00b 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -370,8 +370,11 @@ static int tegra_kbc_start(struct tegra_kbc *kbc) { unsigned int debounce_cnt; u32 val = 0; + int ret; - clk_prepare_enable(kbc->clk); + ret = clk_prepare_enable(kbc->clk); + if (ret) + return ret; /* Reset the KBC controller to clear all previous status.*/ reset_control_assert(kbc->rst); From 117b2dc58c07924da7f545f93a1f5862f46e14f7 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 31 Aug 2017 11:39:13 -0700 Subject: [PATCH 74/76] Input: pxa27x_keypad - handle return value of clk_prepare_enable clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/pxa27x_keypad.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index 3841fa30db33..d0bdaeadf86d 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c @@ -644,9 +644,12 @@ static void pxa27x_keypad_config(struct pxa27x_keypad *keypad) static int pxa27x_keypad_open(struct input_dev *dev) { struct pxa27x_keypad *keypad = input_get_drvdata(dev); - + int ret; /* Enable unit clock */ - clk_prepare_enable(keypad->clk); + ret = clk_prepare_enable(keypad->clk); + if (ret) + return ret; + pxa27x_keypad_config(keypad); return 0; @@ -683,6 +686,7 @@ static int pxa27x_keypad_resume(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); struct input_dev *input_dev = keypad->input_dev; + int ret = 0; /* * If the keypad is used as wake up source, the clock is not turned @@ -695,14 +699,15 @@ static int pxa27x_keypad_resume(struct device *dev) if (input_dev->users) { /* Enable unit clock */ - clk_prepare_enable(keypad->clk); - pxa27x_keypad_config(keypad); + ret = clk_prepare_enable(keypad->clk); + if (!ret) + pxa27x_keypad_config(keypad); } mutex_unlock(&input_dev->mutex); } - return 0; + return ret; } #endif From da1a42cd457fb06c2fd141c670b2ca3397234322 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 31 Aug 2017 14:55:45 -0700 Subject: [PATCH 75/76] Input: xilinx_ps2 - fix multiline comment style Fix multiline comments style not to be reported by checkpatch. Signed-off-by: Michal Simek Signed-off-by: Dmitry Torokhov --- drivers/input/serio/xilinx_ps2.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c index 14c40892ed82..07de1b49293c 100644 --- a/drivers/input/serio/xilinx_ps2.c +++ b/drivers/input/serio/xilinx_ps2.c @@ -45,8 +45,10 @@ #define XPS2_STATUS_RX_FULL 0x00000001 /* Receive Full */ #define XPS2_STATUS_TX_FULL 0x00000002 /* Transmit Full */ -/* Bit definitions for ISR/IER registers. Both the registers have the same bit - * definitions and are only defined once. */ +/* + * Bit definitions for ISR/IER registers. Both the registers have the same bit + * definitions and are only defined once. + */ #define XPS2_IPIXR_WDT_TOUT 0x00000001 /* Watchdog Timeout Interrupt */ #define XPS2_IPIXR_TX_NOACK 0x00000002 /* Transmit No ACK Interrupt */ #define XPS2_IPIXR_TX_ACK 0x00000004 /* Transmit ACK (Data) Interrupt */ @@ -292,8 +294,10 @@ static int xps2_of_probe(struct platform_device *ofdev) /* Disable all the interrupts, just in case */ out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, 0); - /* Reset the PS2 device and abort any current transaction, to make sure - * we have the PS2 in a good state */ + /* + * Reset the PS2 device and abort any current transaction, + * to make sure we have the PS2 in a good state. + */ out_be32(drvdata->base_address + XPS2_SRST_OFFSET, XPS2_SRST_RESET); dev_info(dev, "Xilinx PS2 at 0x%08llX mapped to 0x%p, irq=%d\n", From 08d6ac9ee5fedd82040bc878705981b67a116a3f Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 31 Aug 2017 09:30:44 -0700 Subject: [PATCH 76/76] Input: byd - make array seq static, reduces object code size Don't populate the array seq on the stack, instead make it static. Makes the object code smaller by over 1100 bytes: Before: text data bss dec hex filename 6152 1216 64 7432 1d08 drivers/input/mouse/byd.o After: text data bss dec hex filename 4974 1280 64 6318 18ae drivers/input/mouse/byd.o Signed-off-by: Colin Ian King Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/byd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index b27aa637f877..b64b81599f7e 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -344,7 +344,7 @@ static int byd_reset_touchpad(struct psmouse *psmouse) u8 param[4]; size_t i; - const struct { + static const struct { u16 command; u8 arg; } seq[] = {