* [PATCH v1 11/63] Input: atmel_mxt_ts - add debug for T92 gesture and T93 touch seq msgs
From: Jiada Wang @ 2019-08-16 8:31 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816083218.18402-1-jiada_wang@mentor.com>
From: Karl Tsou <karl.funlab@gmail.com>
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
(cherry picked from ndyer/linux/for-upstream commit cb98986f8342107bf4a536aed4160b20839e97c1)
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 40 ++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 482d435c80ea..8f7e1aa01f39 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -71,6 +71,8 @@
#define MXT_SPT_MESSAGECOUNT_T44 44
#define MXT_SPT_CTECONFIG_T46 46
#define MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71 71
+#define MXT_PROCI_SYMBOLGESTUREPROCESSOR 92
+#define MXT_PROCI_TOUCHSEQUENCELOGGER 93
#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100
#define MXT_PROCI_ACTIVESTYLUS_T107 107
@@ -349,6 +351,10 @@ struct mxt_data {
u8 T42_reportid_max;
u16 T44_address;
u8 T48_reportid;
+ u16 T92_address;
+ u8 T92_reportid;
+ u16 T93_address;
+ u8 T93_reportid;
u8 T100_reportid_min;
u8 T100_reportid_max;
u16 T107_address;
@@ -1112,6 +1118,24 @@ static int mxt_proc_t48_messages(struct mxt_data *data, u8 *msg)
return 0;
}
+static void mxt_proc_t92_messages(struct mxt_data *data, u8 *msg)
+{
+ struct device *dev = &data->client->dev;
+ u8 status = msg[1];
+
+ dev_info(dev, "T92 long stroke LSTR=%d %d\n",
+ (status & 0x80) ? 1 : 0,
+ status & 0x0F);
+}
+
+static void mxt_proc_t93_messages(struct mxt_data *data, u8 *msg)
+{
+ struct device *dev = &data->client->dev;
+ u8 status = msg[1];
+
+ dev_info(dev, "T93 report double tap %d\n", status);
+}
+
static int mxt_proc_message(struct mxt_data *data, u8 *message)
{
u8 report_id = message[0];
@@ -1144,6 +1168,10 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
} else if (report_id >= data->T15_reportid_min
&& report_id <= data->T15_reportid_max) {
mxt_proc_t15_messages(data, message);
+ } else if (report_id == data->T92_reportid) {
+ mxt_proc_t92_messages(data, message);
+ } else if (report_id == data->T93_reportid) {
+ mxt_proc_t93_messages(data, message);
} else {
mxt_dump_message(data, message);
}
@@ -1811,6 +1839,10 @@ static void mxt_free_object_table(struct mxt_data *data)
data->T42_reportid_max = 0;
data->T44_address = 0;
data->T48_reportid = 0;
+ data->T92_reportid = 0;
+ data->T92_address = 0;
+ data->T93_reportid = 0;
+ data->T93_address = 0;
data->T100_reportid_min = 0;
data->T100_reportid_max = 0;
data->max_reportid = 0;
@@ -1903,6 +1935,14 @@ static int mxt_parse_object_table(struct mxt_data *data,
case MXT_PROCG_NOISESUPPRESSION_T48:
data->T48_reportid = min_id;
break;
+ case MXT_PROCI_SYMBOLGESTUREPROCESSOR:
+ data->T92_reportid = min_id;
+ data->T92_address = object->start_address;
+ break;
+ case MXT_PROCI_TOUCHSEQUENCELOGGER:
+ data->T93_reportid = min_id;
+ data->T93_address = object->start_address;
+ break;
case MXT_TOUCH_MULTITOUCHSCREEN_T100:
data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100;
data->T100_reportid_min = min_id;
--
2.19.2
^ permalink raw reply related
* [PATCH v1 10/63] Input: atmel_mxt_ts - implement support for T107 active stylus
From: Jiada Wang @ 2019-08-16 8:31 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
From: Nick Dyer <nick.dyer@itdev.co.uk>
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
(cherry picked from ndyer/linux/for-upstream commit 20e357dd9acf8c2040068c8b22d6bc1401a1893f)
[gdavis: Forward port and fix conflicts due to applying upstream commit
96a938aa214e ("Input: atmel_mxt_ts - remove platform data
support").]
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 117 ++++++++++++++++++++++-
1 file changed, 113 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index adf63ecf6b8e..482d435c80ea 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -72,6 +72,7 @@
#define MXT_SPT_CTECONFIG_T46 46
#define MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71 71
#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100
+#define MXT_PROCI_ACTIVESTYLUS_T107 107
/* MXT_GEN_MESSAGE_T5 object */
#define MXT_RPTID_NOMSG 0xff
@@ -181,6 +182,7 @@ struct t37_debug {
enum t100_type {
MXT_T100_TYPE_FINGER = 1,
MXT_T100_TYPE_PASSIVE_STYLUS = 2,
+ MXT_T100_TYPE_ACTIVE_STYLUS = 3,
MXT_T100_TYPE_HOVERING_FINGER = 4,
MXT_T100_TYPE_GLOVE = 5,
MXT_T100_TYPE_LARGE_TOUCH = 6,
@@ -192,6 +194,16 @@ enum t100_type {
#define MXT_TOUCH_MAJOR_DEFAULT 1
#define MXT_PRESSURE_DEFAULT 1
+/* Gen2 Active Stylus */
+#define MXT_T107_STYLUS_STYAUX 42
+#define MXT_T107_STYLUS_STYAUX_PRESSURE BIT(0)
+#define MXT_T107_STYLUS_STYAUX_PEAK BIT(4)
+
+#define MXT_T107_STYLUS_HOVER BIT(0)
+#define MXT_T107_STYLUS_TIPSWITCH BIT(1)
+#define MXT_T107_STYLUS_BUTTON0 BIT(2)
+#define MXT_T107_STYLUS_BUTTON1 BIT(3)
+
/* Delay times */
#define MXT_BACKUP_TIME 50 /* msec */
#define MXT_RESET_GPIO_TIME 20 /* msec */
@@ -313,10 +325,12 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
- bool use_retrigen_workaround;
unsigned long t15_keystatus;
int t15_num_keys;
const unsigned int *t15_keymap;
+ u8 stylus_aux_pressure;
+ u8 stylus_aux_peak;
+ bool use_retrigen_workaround;
/* Cached parameters from object table */
u16 T5_address;
@@ -337,6 +351,7 @@ struct mxt_data {
u8 T48_reportid;
u8 T100_reportid_min;
u8 T100_reportid_max;
+ u16 T107_address;
/* for fw update in bootloader */
struct completion bl_completion;
@@ -907,6 +922,8 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
u8 major = 0;
u8 pressure = 0;
u8 orientation = 0;
+ bool active = false;
+ bool hover = false;
id = message[0] - data->T100_reportid_min - 2;
@@ -925,6 +942,8 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
case MXT_T100_TYPE_HOVERING_FINGER:
tool = MT_TOOL_FINGER;
distance = MXT_DISTANCE_HOVERING;
+ hover = true;
+ active = true;
if (data->t100_aux_vect)
orientation = message[data->t100_aux_vect];
@@ -935,6 +954,8 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
case MXT_T100_TYPE_GLOVE:
tool = MT_TOOL_FINGER;
distance = MXT_DISTANCE_ACTIVE_TOUCH;
+ hover = false;
+ active = true;
if (data->t100_aux_area)
major = message[data->t100_aux_area];
@@ -949,6 +970,9 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
case MXT_T100_TYPE_PASSIVE_STYLUS:
tool = MT_TOOL_PEN;
+ distance = MXT_DISTANCE_ACTIVE_TOUCH;
+ hover = false;
+ active = true;
/*
* Passive stylus is reported with size zero so
@@ -961,6 +985,31 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
break;
+ case MXT_T100_TYPE_ACTIVE_STYLUS:
+ /* Report input buttons */
+ input_report_key(input_dev, BTN_STYLUS,
+ message[6] & MXT_T107_STYLUS_BUTTON0);
+ input_report_key(input_dev, BTN_STYLUS2,
+ message[6] & MXT_T107_STYLUS_BUTTON1);
+
+ /* stylus in range, but position unavailable */
+ if (!(message[6] & MXT_T107_STYLUS_HOVER))
+ break;
+
+ tool = MT_TOOL_PEN;
+ distance = MXT_DISTANCE_ACTIVE_TOUCH;
+ active = true;
+ major = MXT_TOUCH_MAJOR_DEFAULT;
+
+ if (!(message[6] & MXT_T107_STYLUS_TIPSWITCH)) {
+ hover = true;
+ distance = MXT_DISTANCE_HOVERING;
+ } else if (data->stylus_aux_pressure) {
+ pressure = message[data->stylus_aux_pressure];
+ }
+
+ break;
+
case MXT_T100_TYPE_LARGE_TOUCH:
/* Ignore suppressed touch */
break;
@@ -975,12 +1024,12 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
* Values reported should be non-zero if tool is touching the
* device
*/
- if (!pressure && type != MXT_T100_TYPE_HOVERING_FINGER)
+ if (!pressure && !hover)
pressure = MXT_PRESSURE_DEFAULT;
input_mt_slot(input_dev, id);
- if (status & MXT_T100_DETECT) {
+ if (active) {
dev_dbg(dev, "[%u] type:%u x:%u y:%u a:%02X p:%02X v:%02X\n",
id, type, x, y, major, pressure, orientation);
@@ -991,6 +1040,7 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
input_report_abs(input_dev, ABS_MT_PRESSURE, pressure);
input_report_abs(input_dev, ABS_MT_DISTANCE, distance);
input_report_abs(input_dev, ABS_MT_ORIENTATION, orientation);
+
} else {
dev_dbg(dev, "[%u] release\n", id);
@@ -1860,6 +1910,9 @@ static int mxt_parse_object_table(struct mxt_data *data,
/* first two report IDs reserved */
data->num_touchids = object->num_report_ids - 2;
break;
+ case MXT_PROCI_ACTIVESTYLUS_T107:
+ data->T107_address = object->start_address;
+ break;
}
end_address = object->start_address
@@ -2020,6 +2073,54 @@ static int mxt_read_t9_resolution(struct mxt_data *data)
return 0;
}
+static int mxt_set_up_active_stylus(struct input_dev *input_dev,
+ struct mxt_data *data)
+{
+ struct i2c_client *client = data->client;
+ int error;
+ struct mxt_object *object;
+ u8 styaux;
+ int aux;
+ u8 ctrl;
+
+ object = mxt_get_object(data, MXT_PROCI_ACTIVESTYLUS_T107);
+ if (!object)
+ return 0;
+
+ error = __mxt_read_reg(client, object->start_address, 1, &ctrl);
+ if (error)
+ return error;
+
+ /* Check enable bit */
+ if (!(ctrl & 0x01))
+ return 0;
+
+ error = __mxt_read_reg(client,
+ object->start_address + MXT_T107_STYLUS_STYAUX,
+ 1, &styaux);
+ if (error)
+ return error;
+
+ /* map aux bits */
+ aux = 7;
+
+ if (styaux & MXT_T107_STYLUS_STYAUX_PRESSURE)
+ data->stylus_aux_pressure = aux++;
+
+ if (styaux & MXT_T107_STYLUS_STYAUX_PEAK)
+ data->stylus_aux_peak = aux++;
+
+ input_set_capability(input_dev, EV_KEY, BTN_STYLUS);
+ input_set_capability(input_dev, EV_KEY, BTN_STYLUS2);
+ input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, 0, MT_TOOL_MAX, 0, 0);
+
+ dev_dbg(&client->dev,
+ "T107 active stylus, aux map pressure:%u peak:%u\n",
+ data->stylus_aux_pressure, data->stylus_aux_peak);
+
+ return 0;
+}
+
static int mxt_read_t100_config(struct mxt_data *data)
{
struct i2c_client *client = data->client;
@@ -2226,7 +2327,7 @@ static int mxt_initialize_input_device(struct mxt_data *data)
if (data->multitouch == MXT_TOUCH_MULTI_T9 ||
(data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
- data->t100_aux_ampl)) {
+ (data->t100_aux_ampl || data->stylus_aux_pressure))) {
input_set_abs_params(input_dev, ABS_MT_PRESSURE,
0, 255, 0, 0);
}
@@ -2244,6 +2345,14 @@ static int mxt_initialize_input_device(struct mxt_data *data)
0, 255, 0, 0);
}
+ /* For T107 Active Stylus */
+ if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+ data->T107_address) {
+ error = mxt_set_up_active_stylus(input_dev, data);
+ if (error)
+ dev_warn(dev, "Failed to read T107 config\n");
+ }
+
/* For T15 Key Array */
if (data->T15_reportid_min) {
data->t15_keystatus = 0;
--
2.19.2
^ permalink raw reply related
* [PATCH v1 09/63] Input: atmel_mxt_ts - handle reports from T47 Stylus object
From: Jiada Wang @ 2019-08-16 8:30 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816083130.18250-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
(cherry picked from ndyer/linux/for-upstream commit 56405a5ea08eb34cfe83f3121867c9de0a5c48c1)
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 99b87042dfe5..adf63ecf6b8e 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -822,6 +822,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
int area;
int amplitude;
u8 vector;
+ int tool;
id = message[0] - data->T9_reportid_min;
status = message[1];
@@ -835,6 +836,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
y >>= 2;
area = message[5];
+
amplitude = message[6];
vector = message[7];
@@ -864,12 +866,20 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
mxt_input_sync(data);
}
+ /* A size of zero indicates touch is from a linked T47 Stylus */
+ if (area == 0) {
+ area = MXT_TOUCH_MAJOR_DEFAULT;
+ tool = MT_TOOL_PEN;
+ } else {
+ tool = MT_TOOL_FINGER;
+ }
+
/* if active, pressure must be non-zero */
if (!amplitude)
amplitude = MXT_PRESSURE_DEFAULT;
/* Touch active */
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 1);
+ input_mt_report_slot_state(input_dev, tool, 1);
input_report_abs(input_dev, ABS_MT_POSITION_X, x);
input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
input_report_abs(input_dev, ABS_MT_PRESSURE, amplitude);
--
2.19.2
^ permalink raw reply related
* [PATCH v1 08/63] Input: atmel_mxt_ts - implement T15 Key Array support
From: Jiada Wang @ 2019-08-16 8:30 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816083130.18250-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
There is a key array object in many maXTouch chips which allows some X/Y
lines to be used as a key array. This patch maps them to a series of keys
which may be configured in a platform data array.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
(cherry picked from ndyer/linux/for-upstream commit 15bb074b5abf3a101f7b79544213f1c110ea4cab)
[gdavis: Resolve forward port conflicts due to applying upstream
commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform
data support").]
Signed-off-by: George G. Davis <george_davis@mentor.com>
[jiada: Fix compilation warning]
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 56 ++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index c619ac9f3108..99b87042dfe5 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -314,6 +314,9 @@ struct mxt_data {
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
bool use_retrigen_workaround;
+ unsigned long t15_keystatus;
+ int t15_num_keys;
+ const unsigned int *t15_keymap;
/* Cached parameters from object table */
u16 T5_address;
@@ -324,6 +327,8 @@ struct mxt_data {
u16 T71_address;
u8 T9_reportid_min;
u8 T9_reportid_max;
+ u8 T15_reportid_min;
+ u8 T15_reportid_max;
u16 T18_address;
u8 T19_reportid;
u8 T42_reportid_min;
@@ -986,6 +991,38 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
data->update_input = true;
}
+static void mxt_proc_t15_messages(struct mxt_data *data, u8 *msg)
+{
+ struct input_dev *input_dev = data->input_dev;
+ struct device *dev = &data->client->dev;
+ int key;
+ bool curr_state, new_state;
+ bool sync = false;
+ unsigned long keystates = le32_to_cpu((__force __le32)msg[2]);
+
+ for (key = 0; key < data->t15_num_keys; key++) {
+ curr_state = test_bit(key, &data->t15_keystatus);
+ new_state = test_bit(key, &keystates);
+
+ if (!curr_state && new_state) {
+ dev_dbg(dev, "T15 key press: %u\n", key);
+ __set_bit(key, &data->t15_keystatus);
+ input_event(input_dev, EV_KEY,
+ data->t15_keymap[key], 1);
+ sync = true;
+ } else if (curr_state && !new_state) {
+ dev_dbg(dev, "T15 key release: %u\n", key);
+ __clear_bit(key, &data->t15_keystatus);
+ input_event(input_dev, EV_KEY,
+ data->t15_keymap[key], 0);
+ sync = true;
+ }
+ }
+
+ if (sync)
+ input_sync(input_dev);
+}
+
static void mxt_proc_t42_messages(struct mxt_data *data, u8 *msg)
{
struct device *dev = &data->client->dev;
@@ -1044,6 +1081,9 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
} else if (report_id == data->T19_reportid) {
mxt_input_button(data, message);
data->update_input = true;
+ } else if (report_id >= data->T15_reportid_min
+ && report_id <= data->T15_reportid_max) {
+ mxt_proc_t15_messages(data, message);
} else {
mxt_dump_message(data, message);
}
@@ -1703,6 +1743,8 @@ static void mxt_free_object_table(struct mxt_data *data)
data->T71_address = 0;
data->T9_reportid_min = 0;
data->T9_reportid_max = 0;
+ data->T15_reportid_min = 0;
+ data->T15_reportid_max = 0;
data->T18_address = 0;
data->T19_reportid = 0;
data->T42_reportid_min = 0;
@@ -1781,6 +1823,10 @@ static int mxt_parse_object_table(struct mxt_data *data,
object->num_report_ids - 1;
data->num_touchids = object->num_report_ids;
break;
+ case MXT_TOUCH_KEYARRAY_T15:
+ data->T15_reportid_min = min_id;
+ data->T15_reportid_max = max_id;
+ break;
case MXT_SPT_COMMSCONFIG_T18:
data->T18_address = object->start_address;
break;
@@ -2074,6 +2120,7 @@ static int mxt_initialize_input_device(struct mxt_data *data)
int error;
unsigned int num_mt_slots;
unsigned int mt_flags = 0;
+ int i;
switch (data->multitouch) {
case MXT_TOUCH_MULTI_T9:
@@ -2187,6 +2234,15 @@ static int mxt_initialize_input_device(struct mxt_data *data)
0, 255, 0, 0);
}
+ /* For T15 Key Array */
+ if (data->T15_reportid_min) {
+ data->t15_keystatus = 0;
+
+ for (i = 0; i < data->t15_num_keys; i++)
+ input_set_capability(input_dev, EV_KEY,
+ data->t15_keymap[i]);
+ }
+
input_set_drvdata(input_dev, data);
error = input_register_device(input_dev);
--
2.19.2
^ permalink raw reply related
* [PATCH v1 07/63] Input: atmel_mxt_ts - implement T9 vector/orientation support
From: Jiada Wang @ 2019-08-16 8:30 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816083130.18250-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
The atmel touch messages contain orientation information as a byte in a
packed format which can be passed straight on to Android if the input
device configuration is correct.
This requires vector reports to be enabled in maXTouch config (zero
DISVECT bit 3 in T9 CTRL field)
Android converts the format in InputReader.cpp, search for
ORIENTATION_CALIBRATION_VECTOR.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
(cherry picked from ndyer/linux/for-upstream commit a6f0ee919d2631678169b23fb18f55b6dbabcd4c)
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 9226ec528adf..c619ac9f3108 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -816,6 +816,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
int y;
int area;
int amplitude;
+ u8 vector;
id = message[0] - data->T9_reportid_min;
status = message[1];
@@ -830,9 +831,10 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
area = message[5];
amplitude = message[6];
+ vector = message[7];
dev_dbg(dev,
- "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u\n",
+ "[%u] %c%c%c%c%c%c%c%c x: %5u y: %5u area: %3u amp: %3u vector: %02X\n",
id,
(status & MXT_T9_DETECT) ? 'D' : '.',
(status & MXT_T9_PRESS) ? 'P' : '.',
@@ -842,7 +844,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
(status & MXT_T9_AMP) ? 'A' : '.',
(status & MXT_T9_SUPPRESS) ? 'S' : '.',
(status & MXT_T9_UNGRIP) ? 'U' : '.',
- x, y, area, amplitude);
+ x, y, area, amplitude, vector);
input_mt_slot(input_dev, id);
@@ -867,6 +869,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
input_report_abs(input_dev, ABS_MT_PRESSURE, amplitude);
input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area);
+ input_report_abs(input_dev, ABS_MT_ORIENTATION, vector);
} else {
/* Touch no longer active, close out slot */
input_mt_report_slot_inactive(input_dev);
@@ -2177,8 +2180,9 @@ static int mxt_initialize_input_device(struct mxt_data *data)
0, 255, 0, 0);
}
- if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
- data->t100_aux_vect) {
+ if (data->multitouch == MXT_TOUCH_MULTI_T9 ||
+ (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+ data->t100_aux_vect)) {
input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
0, 255, 0, 0);
}
--
2.19.2
^ permalink raw reply related
* [PATCH v1 06/63] Input: atmel_mxt_ts - output status from T42 Touch Suppression
From: Jiada Wang @ 2019-08-16 8:30 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816083130.18250-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
(cherry picked from ndyer/linux/for-upstream commit ab95b5a309999d2c098daaa9f88d9fcfae7eb516)
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 25 ++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index a75c35c6f9f9..9226ec528adf 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -155,6 +155,9 @@ struct t37_debug {
#define MXT_RESET_VALUE 0x01
#define MXT_BACKUP_VALUE 0x55
+/* Define for MXT_PROCI_TOUCHSUPPRESSION_T42 */
+#define MXT_T42_MSG_TCHSUP BIT(0)
+
/* T100 Multiple Touch Touchscreen */
#define MXT_T100_CTRL 0
#define MXT_T100_CFG1 1
@@ -323,6 +326,8 @@ struct mxt_data {
u8 T9_reportid_max;
u16 T18_address;
u8 T19_reportid;
+ u8 T42_reportid_min;
+ u8 T42_reportid_max;
u16 T44_address;
u8 T48_reportid;
u8 T100_reportid_min;
@@ -978,6 +983,17 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
data->update_input = true;
}
+static void mxt_proc_t42_messages(struct mxt_data *data, u8 *msg)
+{
+ struct device *dev = &data->client->dev;
+ u8 status = msg[1];
+
+ if (status & MXT_T42_MSG_TCHSUP)
+ dev_info(dev, "T42 suppress\n");
+ else
+ dev_info(dev, "T42 normal\n");
+}
+
static int mxt_proc_t48_messages(struct mxt_data *data, u8 *msg)
{
struct device *dev = &data->client->dev;
@@ -1005,6 +1021,9 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
if (report_id == data->T6_reportid) {
mxt_proc_t6_messages(data, message);
+ } else if (report_id >= data->T42_reportid_min
+ && report_id <= data->T42_reportid_max) {
+ mxt_proc_t42_messages(data, message);
} else if (report_id == data->T48_reportid) {
mxt_proc_t48_messages(data, message);
} else if (!data->input_dev) {
@@ -1683,6 +1702,8 @@ static void mxt_free_object_table(struct mxt_data *data)
data->T9_reportid_max = 0;
data->T18_address = 0;
data->T19_reportid = 0;
+ data->T42_reportid_min = 0;
+ data->T42_reportid_max = 0;
data->T44_address = 0;
data->T48_reportid = 0;
data->T100_reportid_min = 0;
@@ -1760,6 +1781,10 @@ static int mxt_parse_object_table(struct mxt_data *data,
case MXT_SPT_COMMSCONFIG_T18:
data->T18_address = object->start_address;
break;
+ case MXT_PROCI_TOUCHSUPPRESSION_T42:
+ data->T42_reportid_min = min_id;
+ data->T42_reportid_max = max_id;
+ break;
case MXT_SPT_MESSAGECOUNT_T44:
data->T44_address = object->start_address;
break;
--
2.19.2
^ permalink raw reply related
* [PATCH v1 05/63] Input: atmel_mxt_ts - output status from T48 Noise Supression
From: Jiada Wang @ 2019-08-16 8:30 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
From: Nick Dyer <nick.dyer@itdev.co.uk>
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
(cherry picked from ndyer/linux/for-upstream commit 2895a6ff150a49f27a02938f8d262be238b296d8)
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 25 ++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 2d70ddf71cd9..a75c35c6f9f9 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -324,6 +324,7 @@ struct mxt_data {
u16 T18_address;
u8 T19_reportid;
u16 T44_address;
+ u8 T48_reportid;
u8 T100_reportid_min;
u8 T100_reportid_max;
@@ -977,6 +978,24 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
data->update_input = true;
}
+static int mxt_proc_t48_messages(struct mxt_data *data, u8 *msg)
+{
+ struct device *dev = &data->client->dev;
+ u8 status, state;
+
+ status = msg[1];
+ state = msg[4];
+
+ dev_dbg(dev, "T48 state %d status %02X %s%s%s%s%s\n", state, status,
+ status & 0x01 ? "FREQCHG " : "",
+ status & 0x02 ? "APXCHG " : "",
+ status & 0x04 ? "ALGOERR " : "",
+ status & 0x10 ? "STATCHG " : "",
+ status & 0x20 ? "NLVLCHG " : "");
+
+ return 0;
+}
+
static int mxt_proc_message(struct mxt_data *data, u8 *message)
{
u8 report_id = message[0];
@@ -986,6 +1005,8 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
if (report_id == data->T6_reportid) {
mxt_proc_t6_messages(data, message);
+ } else if (report_id == data->T48_reportid) {
+ mxt_proc_t48_messages(data, message);
} else if (!data->input_dev) {
/*
* Do not report events if input device
@@ -1663,6 +1684,7 @@ static void mxt_free_object_table(struct mxt_data *data)
data->T18_address = 0;
data->T19_reportid = 0;
data->T44_address = 0;
+ data->T48_reportid = 0;
data->T100_reportid_min = 0;
data->T100_reportid_max = 0;
data->max_reportid = 0;
@@ -1744,6 +1766,9 @@ static int mxt_parse_object_table(struct mxt_data *data,
case MXT_SPT_GPIOPWM_T19:
data->T19_reportid = min_id;
break;
+ case MXT_PROCG_NOISESUPPRESSION_T48:
+ data->T48_reportid = min_id;
+ break;
case MXT_TOUCH_MULTITOUCHSCREEN_T100:
data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100;
data->T100_reportid_min = min_id;
--
2.19.2
^ permalink raw reply related
* [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks
From: Jiada Wang @ 2019-08-16 8:28 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816082952.17985-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
On some firmware variants, the size of the info block exceeds what can
be read in a single transfer.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
(cherry picked from ndyer/linux/for-upstream commit 74c4f5277cfa403d43fafc404119dc57a08677db)
[gdavis: Forward port and fix conflicts due to v4.14.51 commit
960fe000b1d3 ("Input: atmel_mxt_ts - fix the firmware
update").]
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 9b165d23e092..2d70ddf71cd9 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -40,7 +40,7 @@
#define MXT_OBJECT_START 0x07
#define MXT_OBJECT_SIZE 6
#define MXT_INFO_CHECKSUM_SIZE 3
-#define MXT_MAX_BLOCK_WRITE 256
+#define MXT_MAX_BLOCK_WRITE 255
/* Object types */
#define MXT_DEBUG_DIAGNOSTIC_T37 37
@@ -659,6 +659,27 @@ static int __mxt_read_reg(struct i2c_client *client,
return ret;
}
+static int mxt_read_blks(struct mxt_data *data, u16 start, u16 count, u8 *buf)
+{
+ u16 offset = 0;
+ int error;
+ u16 size;
+
+ while (offset < count) {
+ size = min(MXT_MAX_BLOCK_WRITE, count - offset);
+
+ error = __mxt_read_reg(data->client,
+ start + offset,
+ size, buf + offset);
+ if (error)
+ return error;
+
+ offset += size;
+ }
+
+ return 0;
+}
+
static int __mxt_write_reg(struct i2c_client *client, u16 reg, u16 len,
const void *val)
{
@@ -1793,7 +1814,7 @@ static int mxt_read_info_block(struct mxt_data *data)
id_buf = buf;
/* Read rest of info block */
- error = __mxt_read_reg(client, MXT_OBJECT_START,
+ error = mxt_read_blks(data, MXT_OBJECT_START,
size - MXT_OBJECT_START,
id_buf + MXT_OBJECT_START);
if (error)
@@ -2783,7 +2804,7 @@ static ssize_t mxt_object_show(struct device *dev,
u16 size = mxt_obj_size(object);
u16 addr = object->start_address + j * size;
- error = __mxt_read_reg(data->client, addr, size, obuf);
+ error = mxt_read_blks(data, addr, size, obuf);
if (error)
goto done;
--
2.19.2
^ permalink raw reply related
* [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
From: Jiada Wang @ 2019-08-16 8:28 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816082952.17985-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
The workaround of reading all messages until an invalid is received is a
way of forcing the CHG line high, which means that when using
edge-triggered interrupts the interrupt can be acquired.
With level-triggered interrupts the workaround is unnecessary.
Also, most recent maXTouch chips have a feature called RETRIGEN which, when
enabled, reasserts the interrupt line every cycle if there are messages
waiting. This also makes the workaround unnecessary.
Note: the RETRIGEN feature is only in some firmware versions/chips, it's
not valid simply to enable the bit.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Benson Leung <bleung@chromium.org>
Acked-by: Yufeng Shen <miletus@chromium.org>
(cherry picked from ndyer/linux/for-upstream commit 1ae4e8281e491b22442cd5acdfca1862555f8ecb)
[gdavis: Fix conflicts due to v4.6-rc7 commit eb43335c4095 ("Input:
atmel_mxt_ts - use mxt_acquire_irq in mxt_soft_reset").]
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 49 ++++++++++++++++++++++--
1 file changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 79e35c929857..9b165d23e092 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -20,6 +20,7 @@
#include <linux/i2c.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
+#include <linux/irq.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/slab.h>
@@ -129,6 +130,7 @@ struct t9_range {
/* MXT_SPT_COMMSCONFIG_T18 */
#define MXT_COMMS_CTRL 0
#define MXT_COMMS_CMD 1
+#define MXT_COMMS_RETRIGEN BIT(6)
/* MXT_DEBUG_DIAGNOSTIC_T37 */
#define MXT_DIAGNOSTIC_PAGEUP 0x01
@@ -308,6 +310,7 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
+ bool use_retrigen_workaround;
/* Cached parameters from object table */
u16 T5_address;
@@ -318,6 +321,7 @@ struct mxt_data {
u16 T71_address;
u8 T9_reportid_min;
u8 T9_reportid_max;
+ u16 T18_address;
u8 T19_reportid;
u16 T44_address;
u8 T100_reportid_min;
@@ -1190,9 +1194,11 @@ static int mxt_acquire_irq(struct mxt_data *data)
enable_irq(data->irq);
- error = mxt_process_messages_until_invalid(data);
- if (error)
- return error;
+ if (data->use_retrigen_workaround) {
+ error = mxt_process_messages_until_invalid(data);
+ if (error)
+ return error;
+ }
return 0;
}
@@ -1282,6 +1288,31 @@ static u32 mxt_calculate_crc(u8 *base, off_t start_off, off_t end_off)
return crc;
}
+static int mxt_check_retrigen(struct mxt_data *data)
+{
+ struct i2c_client *client = data->client;
+ int error;
+ int val;
+
+ if (irq_get_trigger_type(data->irq) & IRQF_TRIGGER_LOW)
+ return 0;
+
+ if (data->T18_address) {
+ error = __mxt_read_reg(client,
+ data->T18_address + MXT_COMMS_CTRL,
+ 1, &val);
+ if (error)
+ return error;
+
+ if (val & MXT_COMMS_RETRIGEN)
+ return 0;
+ }
+
+ dev_warn(&client->dev, "Enabling RETRIGEN workaround\n");
+ data->use_retrigen_workaround = true;
+ return 0;
+}
+
static int mxt_prepare_cfg_mem(struct mxt_data *data, struct mxt_cfg *cfg)
{
struct device *dev = &data->client->dev;
@@ -1561,6 +1592,10 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw)
mxt_update_crc(data, MXT_COMMAND_BACKUPNV, MXT_BACKUP_VALUE);
+ ret = mxt_check_retrigen(data);
+ if (ret)
+ goto release_mem;
+
ret = mxt_soft_reset(data);
if (ret)
goto release_mem;
@@ -1604,6 +1639,7 @@ static void mxt_free_object_table(struct mxt_data *data)
data->T71_address = 0;
data->T9_reportid_min = 0;
data->T9_reportid_max = 0;
+ data->T18_address = 0;
data->T19_reportid = 0;
data->T44_address = 0;
data->T100_reportid_min = 0;
@@ -1678,6 +1714,9 @@ static int mxt_parse_object_table(struct mxt_data *data,
object->num_report_ids - 1;
data->num_touchids = object->num_report_ids;
break;
+ case MXT_SPT_COMMSCONFIG_T18:
+ data->T18_address = object->start_address;
+ break;
case MXT_SPT_MESSAGECOUNT_T44:
data->T44_address = object->start_address;
break;
@@ -2140,6 +2179,10 @@ static int mxt_initialize(struct mxt_data *data)
msleep(MXT_FW_RESET_TIME);
}
+ error = mxt_check_retrigen(data);
+ if (error)
+ return error;
+
error = mxt_acquire_irq(data);
if (error)
return error;
--
2.19.2
^ permalink raw reply related
* [PATCH v1 02/63] Input: atmel_mxt_ts - rework sysfs init/remove
From: Jiada Wang @ 2019-08-16 8:28 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816082952.17985-1-jiada_wang@mentor.com>
From: Nick Dyer <nick.dyer@itdev.co.uk>
An error in the sysfs init may otherwise interfere with the async return
from the firmware loader
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
(cherry picked from ndyer/linux/for-upstream commit 3114584ae77c2b03b6dad87174f010d002e9c05d)
[gdavis: Forward port and fixup conflicts. Also fixed sysfs leaks in
both the mxt_initialize() and mxt_probe() error return cases.]
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 71 +++++++++++++++++++-----
1 file changed, 57 insertions(+), 14 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 573b94a049b2..79e35c929857 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2090,6 +2090,9 @@ static int mxt_initialize_input_device(struct mxt_data *data)
return error;
}
+static int mxt_sysfs_init(struct mxt_data *data);
+static void mxt_sysfs_remove(struct mxt_data *data);
+
static int mxt_configure_objects(struct mxt_data *data,
const struct firmware *cfg);
@@ -2141,16 +2144,24 @@ static int mxt_initialize(struct mxt_data *data)
if (error)
return error;
+ error = mxt_sysfs_init(data);
+ if (error)
+ return error;
+
error = request_firmware_nowait(THIS_MODULE, true, MXT_CFG_NAME,
&client->dev, GFP_KERNEL, data,
mxt_config_cb);
if (error) {
dev_err(&client->dev, "Failed to invoke firmware loader: %d\n",
error);
- return error;
+ goto err_free_sysfs;
}
return 0;
+
+err_free_sysfs:
+ mxt_sysfs_remove(data);
+ return error;
}
static int mxt_set_t7_power_cfg(struct mxt_data *data, u8 sleep)
@@ -2803,6 +2814,7 @@ static int mxt_load_fw(struct device *dev, const char *fn)
if (ret)
goto release_firmware;
+ mxt_sysfs_remove(data);
mxt_free_input_device(data);
mxt_free_object_table(data);
} else {
@@ -2909,16 +2921,25 @@ static ssize_t mxt_update_fw_store(struct device *dev,
return count;
}
+static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);
+
+static struct attribute *mxt_fw_attrs[] = {
+ &dev_attr_update_fw.attr,
+ NULL
+};
+
+static const struct attribute_group mxt_fw_attr_group = {
+ .attrs = mxt_fw_attrs,
+};
+
static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL);
static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL);
static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL);
-static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);
static struct attribute *mxt_attrs[] = {
&dev_attr_fw_version.attr,
&dev_attr_hw_version.attr,
&dev_attr_object.attr,
- &dev_attr_update_fw.attr,
NULL
};
@@ -2926,6 +2947,28 @@ static const struct attribute_group mxt_attr_group = {
.attrs = mxt_attrs,
};
+static int mxt_sysfs_init(struct mxt_data *data)
+{
+ struct i2c_client *client = data->client;
+ int error;
+
+ error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
+ if (error) {
+ dev_err(&client->dev, "Failure %d creating sysfs group\n",
+ error);
+ return error;
+ }
+
+ return 0;
+}
+
+static void mxt_sysfs_remove(struct mxt_data *data)
+{
+ struct i2c_client *client = data->client;
+
+ sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
+}
+
static void mxt_start(struct mxt_data *data)
{
switch (data->suspend_mode) {
@@ -3109,22 +3152,21 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
msleep(MXT_RESET_INVALID_CHG);
}
- error = mxt_initialize(data);
- if (error)
- return error;
-
- error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
+ error = sysfs_create_group(&client->dev.kobj, &mxt_fw_attr_group);
if (error) {
- dev_err(&client->dev, "Failure %d creating sysfs group\n",
+ dev_err(&client->dev, "Failure %d creating fw sysfs group\n",
error);
- goto err_free_object;
+ return error;
}
+ error = mxt_initialize(data);
+ if (error)
+ goto err_sysfs_remove_group;
+
return 0;
-err_free_object:
- mxt_free_input_device(data);
- mxt_free_object_table(data);
+err_sysfs_remove_group:
+ sysfs_remove_group(&client->dev.kobj, &mxt_fw_attr_group);
return error;
}
@@ -3133,7 +3175,8 @@ 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);
+ sysfs_remove_group(&client->dev.kobj, &mxt_fw_attr_group);
+ mxt_sysfs_remove(data);
mxt_free_input_device(data);
mxt_free_object_table(data);
--
2.19.2
^ permalink raw reply related
* [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive
From: Jiada Wang @ 2019-08-16 8:28 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
In-Reply-To: <20190816082952.17985-1-jiada_wang@mentor.com>
input_mt_report_slot_state() ignores the tool when the slot is closed.
which has caused a bit of confusion.
This patch introduces input_mt_report_slot_inactive() to report slot
inactive state.
replaces all input_mt_report_slot_state() with input_mt_report_slot_inactive()
in case of close of slot, also some other related changes.
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
drivers/hid/hid-alps.c | 3 +--
drivers/hid/hid-asus.c | 3 +--
drivers/hid/hid-elan.c | 3 +--
drivers/hid/hid-logitech-hidpp.c | 5 ++---
drivers/hid/hid-magicmouse.c | 3 +--
drivers/hid/hid-multitouch.c | 9 +++------
drivers/hid/hid-sony.c | 8 ++++----
drivers/hid/wacom_wac.c | 15 +++++----------
drivers/input/input-mt.c | 15 ++++++++++++++-
drivers/input/misc/xen-kbdfront.c | 2 +-
drivers/input/mouse/elan_i2c_core.c | 2 +-
drivers/input/mouse/elantech.c | 5 ++---
drivers/input/mouse/focaltech.c | 3 +--
drivers/input/mouse/sentelic.c | 3 +--
drivers/input/mouse/synaptics.c | 3 +--
drivers/input/rmi4/rmi_2d_sensor.c | 6 ++----
drivers/input/touchscreen/atmel_mxt_ts.c | 7 +++----
drivers/input/touchscreen/chipone_icn8505.c | 4 ++--
drivers/input/touchscreen/cyttsp4_core.c | 5 ++---
drivers/input/touchscreen/cyttsp_core.c | 2 +-
drivers/input/touchscreen/egalax_ts.c | 3 +--
drivers/input/touchscreen/hideep.c | 7 +++----
drivers/input/touchscreen/ili210x.c | 3 +--
drivers/input/touchscreen/melfas_mip4.c | 4 ++--
drivers/input/touchscreen/mms114.c | 6 +++---
drivers/input/touchscreen/penmount.c | 5 ++---
drivers/input/touchscreen/raspberrypi-ts.c | 2 +-
drivers/input/touchscreen/raydium_i2c_ts.c | 4 ++--
drivers/input/touchscreen/sis_i2c.c | 5 ++---
drivers/input/touchscreen/stmfts.c | 2 +-
drivers/input/touchscreen/surface3_spi.c | 4 ++--
drivers/input/touchscreen/wacom_w8001.c | 3 +--
drivers/input/touchscreen/zforce_ts.c | 6 ++----
include/linux/input/mt.h | 1 +
34 files changed, 73 insertions(+), 88 deletions(-)
diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
index ae79a7c66737..36ca1d815d53 100644
--- a/drivers/hid/hid-alps.c
+++ b/drivers/hid/hid-alps.c
@@ -387,8 +387,7 @@ static int u1_raw_event(struct alps_dev *hdata, u8 *data, int size)
input_report_abs(hdata->input,
ABS_MT_PRESSURE, z);
} else {
- input_mt_report_slot_state(hdata->input,
- MT_TOOL_FINGER, 0);
+ input_mt_report_slot_inactive(hdata->input);
}
}
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 8063b1d567b1..55f1004f0e58 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -240,9 +240,8 @@ static int asus_report_input(struct asus_drvdata *drvdat, u8 *data, int size)
MT_TOOL_PALM : MT_TOOL_FINGER;
input_mt_slot(drvdat->input, i);
- input_mt_report_slot_state(drvdat->input, toolType, down);
- if (down) {
+ if (input_mt_report_slot_state(drvdat->input, toolType, down)) {
asus_report_contact_down(drvdat, toolType, contactData);
contactData += drvdat->tp->contact_size;
}
diff --git a/drivers/hid/hid-elan.c b/drivers/hid/hid-elan.c
index 45c4f888b7c4..84a317c6feb6 100644
--- a/drivers/hid/hid-elan.c
+++ b/drivers/hid/hid-elan.c
@@ -216,8 +216,7 @@ static void elan_report_mt_slot(struct elan_drvdata *drvdata, u8 *data,
bool active = !!data;
input_mt_slot(input, slot_num);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, active);
- if (active) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, active)) {
x = ((data[0] & 0xF0) << 4) | data[1];
y = drvdata->max_y -
(((data[0] & 0x07) << 8) | data[2]);
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 21268c9fa71a..a7b552a797f1 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -2295,9 +2295,8 @@ static void wtp_touch_event(struct hidpp_device *hidpp,
slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id);
input_mt_slot(hidpp->input, slot);
- input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER,
- touch_report->contact_status);
- if (touch_report->contact_status) {
+ if (input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER,
+ touch_report->contact_status)) {
input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X,
touch_report->x);
input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y,
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 34138667f8af..5f9f6426d7b8 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -282,10 +282,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
msc->ntouches++;
input_mt_slot(input, id);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, down);
/* Generate the input events for this touch. */
- if (down) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, down)) {
input_report_abs(input, ABS_MT_TOUCH_MAJOR, touch_major << 2);
input_report_abs(input, ABS_MT_TOUCH_MINOR, touch_minor << 2);
input_report_abs(input, ABS_MT_ORIENTATION, -orientation);
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index b603c14d043b..b2221f2030c1 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -880,7 +880,7 @@ static void mt_release_pending_palms(struct mt_device *td,
clear_bit(slotnum, app->pending_palm_slots);
input_mt_slot(input, slotnum);
- input_mt_report_slot_state(input, MT_TOOL_PALM, false);
+ input_mt_report_slot_inactive(input);
need_sync = true;
}
@@ -1020,8 +1020,7 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,
}
input_mt_slot(input, slotnum);
- input_mt_report_slot_state(input, tool, active);
- if (active) {
+ if (input_mt_report_slot_state(input, tool, active)) {
/* this finger is in proximity of the sensor */
int wide = (*slot->w > *slot->h);
int major = max(*slot->w, *slot->h);
@@ -1621,9 +1620,7 @@ static void mt_release_contacts(struct hid_device *hid)
if (mt) {
for (i = 0; i < mt->num_slots; i++) {
input_mt_slot(input_dev, i);
- input_mt_report_slot_state(input_dev,
- MT_TOOL_FINGER,
- false);
+ input_mt_report_slot_inactive(input_dev);
}
input_mt_sync_frame(input_dev);
input_sync(input_dev);
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 49dd2d905c7f..8ba21584a84a 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1092,9 +1092,9 @@ static void dualshock4_parse_report(struct sony_sc *sc, u8 *rd, int size)
active = !(rd[offset] >> 7);
input_mt_slot(sc->touchpad, n);
- input_mt_report_slot_state(sc->touchpad, MT_TOOL_FINGER, active);
- if (active) {
+ if (input_mt_report_slot_state(sc->touchpad,
+ MT_TOOL_FINGER, active)) {
input_report_abs(sc->touchpad, ABS_MT_POSITION_X, x);
input_report_abs(sc->touchpad, ABS_MT_POSITION_Y, y);
}
@@ -1146,9 +1146,9 @@ static void nsg_mrxu_parse_report(struct sony_sc *sc, u8 *rd, int size)
y = ((rd[offset+1] & 0xF0) >> 4) | (rd[offset+2] << 4);
input_mt_slot(sc->touchpad, n);
- input_mt_report_slot_state(sc->touchpad, MT_TOOL_FINGER, active & 0x03);
- if (active & 0x03) {
+ if (input_mt_report_slot_state(sc->touchpad,
+ MT_TOOL_FINGER, active & 0x03)) {
contactx = rd[offset+3] & 0x0F;
contacty = rd[offset+3] >> 4;
input_report_abs(sc->touchpad, ABS_MT_TOUCH_MAJOR,
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 7a8ddc999a8e..c49b261753f0 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1504,9 +1504,8 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
if (slot < 0)
continue;
input_mt_slot(input, slot);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
- if (touch) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) {
int t_x = get_unaligned_le16(&data[offset + 2]);
int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
@@ -1570,8 +1569,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
continue;
input_mt_slot(input, slot);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
- if (touch) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) {
int x = get_unaligned_le16(&data[offset + x_offset + 7]);
int y = get_unaligned_le16(&data[offset + x_offset + 9]);
input_report_abs(input, ABS_MT_POSITION_X, x);
@@ -1599,8 +1597,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
bool touch = p && report_touch_events(wacom);
input_mt_slot(input, i);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
- if (touch) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) {
int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
@@ -2842,8 +2839,7 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
&& (data[offset + 3] & 0x80);
input_mt_slot(input, i);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
- if (touch) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) {
int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
@@ -2879,9 +2875,8 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
touch = touch && report_touch_events(wacom);
input_mt_slot(input, slot);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
- if (touch) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) {
int x = (data[2] << 4) | (data[4] >> 4);
int y = (data[3] << 4) | (data[4] & 0x0f);
int width, height;
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index a81e14148407..acfe05af1269 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -117,6 +117,19 @@ void input_mt_destroy_slots(struct input_dev *dev)
}
EXPORT_SYMBOL(input_mt_destroy_slots);
+/**
+ * input_mt_report_slot_inactive() - report contact inactive state
+ * @dev: input device with allocated MT slots
+ *
+ * Reports the contact inactive state via ABS_MT_TRACKING_ID
+ *
+ */
+void input_mt_report_slot_inactive(struct input_dev *dev)
+{
+ input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
+}
+EXPORT_SYMBOL(input_mt_report_slot_inactive);
+
/**
* input_mt_report_slot_state() - report contact state
* @dev: input device with allocated MT slots
@@ -145,7 +158,7 @@ bool input_mt_report_slot_state(struct input_dev *dev,
slot->frame = mt->frame;
if (!active) {
- input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
+ input_mt_report_slot_inactive(dev);
return false;
}
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 24bc5c5d876f..a1bba722b234 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -146,7 +146,7 @@ static void xenkbd_handle_mt_event(struct xenkbd_info *info,
break;
case XENKBD_MT_EV_UP:
- input_mt_report_slot_state(info->mtouch, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(info->mtouch);
break;
case XENKBD_MT_EV_SYN:
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index d9b103a81a79..b72358d4b35c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -938,7 +938,7 @@ static void elan_report_contact(struct elan_tp_data *data,
input_report_abs(input, ABS_MT_TOUCH_MINOR, minor);
} else {
input_mt_slot(input, contact_num);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(input);
}
}
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 2d8434b7b623..da06490bb914 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -343,8 +343,7 @@ static void elantech_set_slot(struct input_dev *dev, int slot, bool active,
unsigned int x, unsigned int y)
{
input_mt_slot(dev, slot);
- input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
- if (active) {
+ if (input_mt_report_slot_state(dev, MT_TOOL_FINGER, active)) {
input_report_abs(dev, ABS_MT_POSITION_X, x);
input_report_abs(dev, ABS_MT_POSITION_Y, y);
}
@@ -608,7 +607,7 @@ static void process_packet_status_v4(struct psmouse *psmouse)
for (i = 0; i < ETP_MAX_FINGERS; i++) {
if ((fingers & (1 << i)) == 0) {
input_mt_slot(dev, i);
- input_mt_report_slot_state(dev, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(dev);
}
}
diff --git a/drivers/input/mouse/focaltech.c b/drivers/input/mouse/focaltech.c
index 6fd5fff0cbff..fd627fab16c0 100644
--- a/drivers/input/mouse/focaltech.c
+++ b/drivers/input/mouse/focaltech.c
@@ -124,8 +124,7 @@ static void focaltech_report_state(struct psmouse *psmouse)
bool active = finger->active && finger->valid;
input_mt_slot(dev, i);
- input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
- if (active) {
+ if (input_mt_report_slot_state(dev, MT_TOOL_FINGER, active)) {
unsigned int clamped_x, clamped_y;
/*
* The touchpad might report invalid data, so we clamp
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index e99d9bf1a267..1a8a2e19c514 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -683,8 +683,7 @@ static void fsp_set_slot(struct input_dev *dev, int slot, bool active,
unsigned int x, unsigned int y)
{
input_mt_slot(dev, slot);
- input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
- if (active) {
+ if (input_mt_report_slot_state(dev, MT_TOOL_FINGER, active)) {
input_report_abs(dev, ABS_MT_POSITION_X, x);
input_report_abs(dev, ABS_MT_POSITION_Y, y);
}
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index b1956ed4c0dd..6969b37ba731 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -882,8 +882,7 @@ static void synaptics_report_semi_mt_slot(struct input_dev *dev, int slot,
bool active, int x, int y)
{
input_mt_slot(dev, slot);
- input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
- if (active) {
+ if (input_mt_report_slot_state(dev, MT_TOOL_FINGER, active)) {
input_report_abs(dev, ABS_MT_POSITION_X, x);
input_report_abs(dev, ABS_MT_POSITION_Y, synaptics_invert_y(y));
}
diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
index ea549efe4bc4..c0f7be7c3737 100644
--- a/drivers/input/rmi4/rmi_2d_sensor.c
+++ b/drivers/input/rmi4/rmi_2d_sensor.c
@@ -76,10 +76,8 @@ void rmi_2d_sensor_abs_report(struct rmi_2d_sensor *sensor,
else
input_mt_slot(input, slot);
- input_mt_report_slot_state(input, obj->mt_tool,
- obj->type != RMI_2D_OBJECT_NONE);
-
- if (obj->type != RMI_2D_OBJECT_NONE) {
+ if (input_mt_report_slot_state(input, obj->mt_tool,
+ obj->type != RMI_2D_OBJECT_NONE)) {
obj->x = sensor->tracking_pos[slot].x;
obj->y = sensor->tracking_pos[slot].y;
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4a5f482cf1af..573b94a049b2 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -822,8 +822,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
* have happened.
*/
if (status & MXT_T9_RELEASE) {
- input_mt_report_slot_state(input_dev,
- MT_TOOL_FINGER, 0);
+ input_mt_report_slot_inactive(input_dev);
mxt_input_sync(data);
}
@@ -839,7 +838,7 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, area);
} else {
/* Touch no longer active, close out slot */
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 0);
+ input_mt_report_slot_inactive(input_dev);
}
data->update_input = true;
@@ -947,7 +946,7 @@ static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
dev_dbg(dev, "[%u] release\n", id);
/* close out slot */
- input_mt_report_slot_state(input_dev, 0, 0);
+ input_mt_report_slot_inactive(input_dev);
}
data->update_input = true;
diff --git a/drivers/input/touchscreen/chipone_icn8505.c b/drivers/input/touchscreen/chipone_icn8505.c
index c768186ce856..9880101cd14b 100644
--- a/drivers/input/touchscreen/chipone_icn8505.c
+++ b/drivers/input/touchscreen/chipone_icn8505.c
@@ -344,8 +344,8 @@ static irqreturn_t icn8505_irq(int irq, void *dev_id)
bool act = icn8505_touch_active(touch->event);
input_mt_slot(icn8505->input, touch->slot);
- input_mt_report_slot_state(icn8505->input, MT_TOOL_FINGER, act);
- if (!act)
+ if (!input_mt_report_slot_state(icn8505->input,
+ MT_TOOL_FINGER, act))
continue;
touchscreen_report_pos(icn8505->input, &icn8505->prop,
diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index 4b22d49a0f49..a3a85e2348a2 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -744,8 +744,7 @@ static void cyttsp4_report_slot_liftoff(struct cyttsp4_mt_data *md,
for (t = 0; t < max_slots; t++) {
input_mt_slot(md->input, t);
- input_mt_report_slot_state(md->input,
- MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(md->input);
}
}
@@ -845,7 +844,7 @@ static void cyttsp4_final_sync(struct input_dev *input, int max_slots, int *ids)
if (ids[t])
continue;
input_mt_slot(input, t);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(input);
}
input_sync(input);
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 3f5d463dbeed..697aa2c158f7 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -340,7 +340,7 @@ static void cyttsp_report_tchdata(struct cyttsp *ts)
continue;
input_mt_slot(input, i);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(input);
}
input_sync(input);
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 83ac8c128192..c0774c29e496 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -99,12 +99,11 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
}
input_mt_slot(input_dev, id);
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
down ? "down" : "up", id, x, y, z);
- if (down) {
+ if (input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down)) {
input_report_abs(input_dev, ABS_MT_POSITION_X, x);
input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
input_report_abs(input_dev, ABS_MT_PRESSURE, z);
diff --git a/drivers/input/touchscreen/hideep.c b/drivers/input/touchscreen/hideep.c
index 84fbbf415c43..6f4c96f45a02 100644
--- a/drivers/input/touchscreen/hideep.c
+++ b/drivers/input/touchscreen/hideep.c
@@ -693,10 +693,9 @@ static void hideep_report_slot(struct input_dev *input,
const struct hideep_event *event)
{
input_mt_slot(input, event->index & 0x0f);
- input_mt_report_slot_state(input,
- __GET_MT_TOOL_TYPE(event->type),
- !(event->flag & HIDEEP_MT_RELEASED));
- if (!(event->flag & HIDEEP_MT_RELEASED)) {
+ if (input_mt_report_slot_state(input,
+ __GET_MT_TOOL_TYPE(event->type),
+ !(event->flag & HIDEEP_MT_RELEASED))) {
input_report_abs(input, ABS_MT_POSITION_X,
le16_to_cpup(&event->x));
input_report_abs(input, ABS_MT_POSITION_Y,
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index e9006407c9bc..2a5698e129d8 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -154,8 +154,7 @@ static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
}
input_mt_slot(input, i);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
- if (!touch)
+ if (!input_mt_report_slot_state(input, MT_TOOL_FINGER, touch))
continue;
touchscreen_report_pos(input, &priv->prop, x, y,
true);
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 247c3aaba2d8..f67efdd040b2 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -391,7 +391,7 @@ static void mip4_clear_input(struct mip4_ts *ts)
/* Screen */
for (i = 0; i < MIP4_MAX_FINGERS; i++) {
input_mt_slot(ts->input, i);
- input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, 0);
+ input_mt_report_slot_inactive(ts->input);
}
/* Keys */
@@ -534,7 +534,7 @@ static void mip4_report_touch(struct mip4_ts *ts, u8 *packet)
} else {
/* Release event */
input_mt_slot(ts->input, id);
- input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, 0);
+ input_mt_report_slot_inactive(ts->input);
}
input_mt_sync_frame(ts->input);
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index a5ab774da4cc..d4e088364bed 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -178,9 +178,9 @@ static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *tou
x, y, touch->width, touch->strength);
input_mt_slot(input_dev, id);
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, touch->pressed);
- if (touch->pressed) {
+ if (input_mt_report_slot_state(input_dev,
+ MT_TOOL_FINGER, touch->pressed)) {
touchscreen_report_pos(input_dev, &data->props, x, y, true);
input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, touch->width);
input_report_abs(input_dev, ABS_MT_PRESSURE, touch->strength);
@@ -550,7 +550,7 @@ static int __maybe_unused mms114_suspend(struct device *dev)
/* Release all touch */
for (id = 0; id < MMS114_MAX_TOUCH; id++) {
input_mt_slot(input_dev, id);
- input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(input_dev);
}
input_mt_report_pointer_emulation(input_dev, true);
diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c
index 12abb3b36128..2721a608d7fc 100644
--- a/drivers/input/touchscreen/penmount.c
+++ b/drivers/input/touchscreen/penmount.c
@@ -69,9 +69,8 @@ static void pm_mtevent(struct pm *pm, struct input_dev *input)
for (i = 0; i < pm->maxcontacts; ++i) {
input_mt_slot(input, i);
- input_mt_report_slot_state(input, MT_TOOL_FINGER,
- pm->slots[i].active);
- if (pm->slots[i].active) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER,
+ pm->slots[i].active)) {
input_event(input, EV_ABS, ABS_MT_POSITION_X, pm->slots[i].x);
input_event(input, EV_ABS, ABS_MT_POSITION_Y, pm->slots[i].y);
}
diff --git a/drivers/input/touchscreen/raspberrypi-ts.c b/drivers/input/touchscreen/raspberrypi-ts.c
index 69881265d121..147ea4f8f87b 100644
--- a/drivers/input/touchscreen/raspberrypi-ts.c
+++ b/drivers/input/touchscreen/raspberrypi-ts.c
@@ -102,7 +102,7 @@ static void rpi_ts_poll(struct input_polled_dev *dev)
released_ids = ts->known_ids & ~modified_ids;
for_each_set_bit(i, &released_ids, RPI_TS_MAX_SUPPORTED_POINTS) {
input_mt_slot(input, i);
- input_mt_report_slot_state(input, MT_TOOL_FINGER, 0);
+ input_mt_report_slot_inactive(input);
modified_ids &= ~(BIT(i));
}
ts->known_ids = modified_ids;
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index 6ed9f22e6401..d9f253a82eba 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -801,9 +801,9 @@ static void raydium_mt_event(struct raydium_data *ts)
u8 wx, wy;
input_mt_slot(ts->input, i);
- input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, state);
- if (!state)
+ if (!input_mt_report_slot_state(ts->input,
+ MT_TOOL_FINGER, state))
continue;
input_report_abs(ts->input, ABS_MT_POSITION_X,
diff --git a/drivers/input/touchscreen/sis_i2c.c b/drivers/input/touchscreen/sis_i2c.c
index 6274555f1673..55857328bbc7 100644
--- a/drivers/input/touchscreen/sis_i2c.c
+++ b/drivers/input/touchscreen/sis_i2c.c
@@ -189,10 +189,9 @@ static int sis_ts_report_contact(struct sis_ts_data *ts, const u8 *data, u8 id)
return -ENOENT;
input_mt_slot(input, slot);
- input_mt_report_slot_state(input, MT_TOOL_FINGER,
- status == SIS_STATUS_DOWN);
- if (status == SIS_STATUS_DOWN) {
+ if (input_mt_report_slot_state(input, MT_TOOL_FINGER,
+ status == SIS_STATUS_DOWN)) {
pressure = height = width = 1;
if (id != SIS_ALL_IN_ONE_PACKAGE) {
if (SIS_PKT_HAS_AREA(id)) {
diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index b6f95f20f924..b54cc64e4ea6 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -198,7 +198,7 @@ static void stmfts_report_contact_release(struct stmfts_data *sdata,
u8 slot_id = (event[0] & STMFTS_MASK_TOUCH_ID) >> 4;
input_mt_slot(sdata->input, slot_id);
- input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, false);
+ input_mt_report_slot_inactive(sdata->input);
input_sync(sdata->input);
}
diff --git a/drivers/input/touchscreen/surface3_spi.c b/drivers/input/touchscreen/surface3_spi.c
index ce4828b1415a..6981790dd541 100644
--- a/drivers/input/touchscreen/surface3_spi.c
+++ b/drivers/input/touchscreen/surface3_spi.c
@@ -75,8 +75,8 @@ static void surface3_spi_report_touch(struct surface3_ts_data *ts_data,
return;
input_mt_slot(ts_data->input_dev, slot);
- input_mt_report_slot_state(ts_data->input_dev, MT_TOOL_FINGER, st);
- if (st) {
+ if (input_mt_report_slot_state(ts_data->input_dev,
+ MT_TOOL_FINGER, st)) {
input_report_abs(ts_data->input_dev,
ABS_MT_POSITION_X,
get_unaligned_le16(&finger->x));
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index 3715d1eace92..cf2f233cdbfb 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -155,8 +155,7 @@ static void parse_multi_touch(struct w8001 *w8001)
bool touch = data[0] & (1 << i);
input_mt_slot(dev, i);
- input_mt_report_slot_state(dev, MT_TOOL_FINGER, touch);
- if (touch) {
+ if (input_mt_report_slot_state(dev, MT_TOOL_FINGER, touch)) {
x = (data[6 * i + 1] << 7) | data[6 * i + 2];
y = (data[6 * i + 3] << 7) | data[6 * i + 4];
/* data[5,6] and [11,12] is finger capacity */
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 5230519b0f74..37ae4599c0db 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -386,10 +386,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
/* the zforce id starts with "1", so needs to be decreased */
input_mt_slot(ts->input, point.id - 1);
- input_mt_report_slot_state(ts->input, MT_TOOL_FINGER,
- point.state != STATE_UP);
-
- if (point.state != STATE_UP) {
+ if (input_mt_report_slot_state(ts->input, MT_TOOL_FINGER,
+ point.state != STATE_UP)) {
input_report_abs(ts->input, ABS_MT_POSITION_X,
point.coord_x);
input_report_abs(ts->input, ABS_MT_POSITION_Y,
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index 9e409bb13642..a127348a2bf3 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -97,6 +97,7 @@ static inline bool input_is_mt_axis(int axis)
return axis == ABS_MT_SLOT || input_is_mt_value(axis);
}
+void input_mt_report_slot_inactive(struct input_dev *dev);
bool input_mt_report_slot_state(struct input_dev *dev,
unsigned int tool_type, bool active);
--
2.19.2
^ permalink raw reply related
* [PATCH v1 00/63] atmel_mxt_ts misc
From: Jiada Wang @ 2019-08-16 8:28 UTC (permalink / raw)
To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis
This patch-set forward ports Nick Dyer's work in ndyer/linux github repository
as long as some other features and fixes
Balasubramani Vivekanandan (4):
Input: atmel_mxt_ts: Limit the max bytes transferred in an i2c
transaction
Input: atmel_mxt_ts: update stale use_retrigen_workaround flag
Input: atmel_mxt_ts: use gpiod_set_value_cansleep for reset pin
input: atmel_mxt_ts: Add NULL check for sysfs attribute debug_msg_attr
Bhuvanesh Surachari (3):
Input: touchscreen: Atmel: Enable IRQ_DISABLE_UNLAZY flag for
interrupt
Input: atmel_mxt_ts: Avoid race condition in freeing of input device
Input: atmel_mxt_ts: Prevent crash due to freeing of input device
Daniel Gong (1):
Input: touchscreen: Atmel: Add device tree support for T15 key array
objects
Dean Jenkins (3):
Input: atmel_mxt_ts: return error from
mxt_process_messages_until_invalid()
Input: atmel_mxt_ts: Use msecs_to_jiffies() instead of HZ
Input: atmel_mxt_ts: Use complete when in_bootloader true
Deepak Das (8):
Input: Atmel: improve error handling in mxt_start()
Input: Atmel: improve error handling in mxt_initialize()
Input: Atmel: improve error handling in mxt_update_cfg()
input: atmel_mxt_ts: move bootloader probe from mxt_initialize()
Input: Atmel: Improve error handling in mxt_initialize_input_device()
Input: Atmel: handle ReportID "0x00" while processing T5 messages
input: Atmel: limit the max bytes transferred while reading T5
messages
Input: Atmel: use T44 object to process T5 messages
George G. Davis (1):
input: atmel_mxt_ts: export GPIO reset line via sysfs
Janus Cheng (1):
Input: atmel_mxt_ts - check data->input_dev is not null in
mxt_input_sync()
Jiada Wang (3):
Input: introduce input_mt_report_slot_inactive
Input: atmel_mxt_ts - eliminate data->raw_info_block
Input: atmel_mxt_ts - Fix compilation warning
Karl Tsou (1):
Input: atmel_mxt_ts - add debug for T92 gesture and T93 touch seq msgs
Kautuk Consul (3):
Input: atmel_mxt_ts - Change call-points of mxt_free_* functions
Input: atmel_mxt_ts - rely on calculated_crc rather than file
config_crc
Input: atmel_mxt_ts - configure and use gpios as real gpios
Naveen Chakka (2):
input: touchscreen: atmel_mxt_ts: Added sysfs entry for touchscreen
status
input: atmel_mxt_ts: added sysfs interface to update atmel T38 data
Nick Dyer (28):
Input: atmel_mxt_ts - rework sysfs init/remove
Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when
necessary
Input: atmel_mxt_ts - split large i2c transfers into blocks
Input: atmel_mxt_ts - output status from T48 Noise Supression
Input: atmel_mxt_ts - output status from T42 Touch Suppression
Input: atmel_mxt_ts - implement T9 vector/orientation support
Input: atmel_mxt_ts - implement T15 Key Array support
Input: atmel_mxt_ts - handle reports from T47 Stylus object
Input: atmel_mxt_ts - implement support for T107 active stylus
Input: atmel_mxt_ts - release touch state during suspend
Input: atmel_mxt_ts - add regulator control support
Input: atmel_mxt_ts - report failures in suspend/resume
Input: atmel_mxt_ts - allow specification of firmware file name
Input: atmel_mxt_ts - handle cfg filename via pdata/sysfs
Input: atmel_mxt_ts - allow input name to be specified in platform
data
Input: atmel_mxt_ts - refactor firmware flash to extract context into
struct
Input: atmel_mxt_ts - refactor code to enter bootloader into separate
func
Input: atmel_mxt_ts - combine bootloader version query with probe
Input: atmel_mxt_ts - improve bootloader state machine handling
Input: atmel_mxt_ts - check firmware format before entering bootloader
Input: atmel_mxt_ts - rename bl_completion to chg_completion
Input: atmel_mxt_ts - make bootloader interrupt driven
Input: atmel_mxt_ts - delay enabling IRQ when not using regulators
Input: atmel_mxt_ts - implement I2C retries
Input: atmel_mxt_ts - orientation is not present in hover
Input: atmel_mxt_ts - implement debug output for messages
Input: atmel_mxt_ts - add memory access interface via sysfs
Input: atmel_mxt_ts - implement improved debug message interface
Nikhil Ravindran (1):
Input: atmel_mxt_ts: Add support for run self-test routine.
Sanjeev Chugh (2):
Input: atmel_mxt_ts: Remove sysfs attributes during driver detach
Input: atmel_mxt_ts: Implement synchronization during various
operation
karl tsou (1):
Input: atmel_mxt_ts - add config checksum attribute to sysfs
keerthikumarp (1):
input: atmel_mxt_ts: Add Missing Delay for reset handling of Atmel
touch panel controller in detachable displays.
.../bindings/input/atmel,maxtouch.txt | 29 +
MAINTAINERS | 1 +
drivers/hid/hid-alps.c | 3 +-
drivers/hid/hid-asus.c | 3 +-
drivers/hid/hid-elan.c | 3 +-
drivers/hid/hid-logitech-hidpp.c | 5 +-
drivers/hid/hid-magicmouse.c | 3 +-
drivers/hid/hid-multitouch.c | 9 +-
drivers/hid/hid-sony.c | 8 +-
drivers/hid/wacom_wac.c | 15 +-
drivers/input/input-mt.c | 15 +-
drivers/input/misc/xen-kbdfront.c | 2 +-
drivers/input/mouse/elan_i2c_core.c | 2 +-
drivers/input/mouse/elantech.c | 5 +-
drivers/input/mouse/focaltech.c | 3 +-
drivers/input/mouse/sentelic.c | 3 +-
drivers/input/mouse/synaptics.c | 3 +-
drivers/input/rmi4/rmi_2d_sensor.c | 6 +-
drivers/input/touchscreen/atmel_mxt_ts.c | 2612 ++++++++++++++---
drivers/input/touchscreen/chipone_icn8505.c | 4 +-
drivers/input/touchscreen/cyttsp4_core.c | 5 +-
drivers/input/touchscreen/cyttsp_core.c | 2 +-
drivers/input/touchscreen/egalax_ts.c | 3 +-
drivers/input/touchscreen/hideep.c | 7 +-
drivers/input/touchscreen/ili210x.c | 3 +-
drivers/input/touchscreen/melfas_mip4.c | 4 +-
drivers/input/touchscreen/mms114.c | 6 +-
drivers/input/touchscreen/penmount.c | 5 +-
drivers/input/touchscreen/raspberrypi-ts.c | 2 +-
drivers/input/touchscreen/raydium_i2c_ts.c | 4 +-
drivers/input/touchscreen/sis_i2c.c | 5 +-
drivers/input/touchscreen/stmfts.c | 2 +-
drivers/input/touchscreen/surface3_spi.c | 4 +-
drivers/input/touchscreen/wacom_w8001.c | 3 +-
drivers/input/touchscreen/zforce_ts.c | 6 +-
include/dt-bindings/input/atmel_mxt_ts.h | 22 +
include/linux/input/mt.h | 1 +
37 files changed, 2324 insertions(+), 494 deletions(-)
create mode 100644 include/dt-bindings/input/atmel_mxt_ts.h
--
2.19.2
^ permalink raw reply
* Re: general protection fault in __pm_runtime_resume
From: Alan Stern @ 2019-08-15 17:43 UTC (permalink / raw)
To: syzbot, Jiri Kosina
Cc: andreyknvl, gregkh, gustavo, hdanton, Kernel development list,
USB list, Oliver Neukum, syzkaller-bugs, linux-input
In-Reply-To: <000000000000b1729e058fecdcee@google.com>
On Mon, 12 Aug 2019, syzbot wrote:
> Hello,
>
> syzbot has tested the proposed patch and the reproducer did not trigger
> crash:
>
> Reported-and-tested-by:
> syzbot+3cbe5cd105d2ad56a1df@syzkaller.appspotmail.com
>
> Tested on:
>
> commit: 7f7867ff usb-fuzzer: main usb gadget fuzzer driver
> git tree: https://github.com/google/kasan.git
> kernel config: https://syzkaller.appspot.com/x/.config?x=792eb47789f57810
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> patch: https://syzkaller.appspot.com/x/patch.diff?x=177252d2600000
>
> Note: testing is done by a robot and is best-effort only.
That was the result from testing Hillf's patch:
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1410,6 +1410,7 @@ static void usbhid_disconnect(struct usb
spin_lock_irq(&usbhid->lock); /* Sync with error and led handlers */
set_bit(HID_DISCONNECTED, &usbhid->iofl);
spin_unlock_irq(&usbhid->lock);
+ hid_hw_stop(hid);
hid_destroy_device(hid);
kfree(usbhid);
}
There is very good reason to believe this patch is not the correct
solution to the problem. For one thing, in some circumstances the
patch ends up calling hid_hw_stop() twice (not shown here, but we have
seen this in other bug reports from syzbot).
For another, I have just tested a different patch and found that it
also prevents this particular crash:
> Hello,
>
> syzbot has tested the proposed patch and the reproducer did not trigger
> crash:
>
> Reported-and-tested-by:
> syzbot+3cbe5cd105d2ad56a1df@syzkaller.appspotmail.com
>
> Tested on:
>
> commit: 6a3599ce usb-fuzzer: main usb gadget fuzzer driver
> git tree: https://github.com/google/kasan.git
> kernel config: https://syzkaller.appspot.com/x/.config?x=700ca426ab83faae
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> patch: https://syzkaller.appspot.com/x/patch.diff?x=170b66a6600000
>
> Note: testing is done by a robot and is best-effort only.
My patch:
Index: usb-devel/drivers/hid/hid-lg.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-lg.c
+++ usb-devel/drivers/hid/hid-lg.c
@@ -818,7 +818,7 @@ static int lg_probe(struct hid_device *h
if (!buf) {
ret = -ENOMEM;
- goto err_free;
+ goto err_stop;
}
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
@@ -850,9 +850,12 @@ static int lg_probe(struct hid_device *h
ret = lg4ff_init(hdev);
if (ret)
- goto err_free;
+ goto err_stop;
return 0;
+
+err_stop:
+ hid_hw_stop(hdev);
err_free:
kfree(drv_data);
return ret;
@@ -863,8 +866,7 @@ static void lg_remove(struct hid_device
struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
if (drv_data->quirks & LG_FF4)
lg4ff_deinit(hdev);
- else
- hid_hw_stop(hdev);
+ hid_hw_stop(hdev);
kfree(drv_data);
}
Index: usb-devel/drivers/hid/hid-lg4ff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-lg4ff.c
+++ usb-devel/drivers/hid/hid-lg4ff.c
@@ -1477,7 +1477,6 @@ int lg4ff_deinit(struct hid_device *hid)
}
}
#endif
- hid_hw_stop(hid);
drv_data->device_props = NULL;
kfree(entry);
This fixes a fairly obvious bug in the hid-lg driver: It does not
always call hid_hw_stop() in all pathways after calling hid_hw_start().
Presumably the same is true for the other related bugs found by syzbot.
I'm doing some more testing and we will see...
Alan Stern
^ permalink raw reply
* Re: [PATCH] Input: cros_ec_keyb: Add back missing mask for event_type
From: Dmitry Torokhov @ 2019-08-14 22:06 UTC (permalink / raw)
To: Nicolas Boichat
Cc: Fei Shao, linux-arm Mailing List, Benson Leung,
Enric Balletbo i Serra, Guenter Roeck, Ting Shen, Brian Norris,
open list:HID CORE LAYER, lkml
In-Reply-To: <CANMq1KCNFfWA=ApVUFoPctgTftHDSAvGjtk-Xu2hcKWBq9R1zw@mail.gmail.com>
On Tue, Aug 13, 2019 at 05:47:22PM +0800, Nicolas Boichat wrote:
> On Tue, Aug 13, 2019 at 5:38 PM Fei Shao <fshao@chromium.org> wrote:
> >
> > In the previous patch we didn't mask out event_type in case statement,
> > so switches are always picked instead of buttons, which results in
> > ChromeOS devices misbehaving when power button is pressed.
> > This patch adds back the missing mask.
> >
> > Fixes: d096aa3eb604 ("Input: cros_ec_keyb: mask out extra flags in event_type")
> > Signed-off-by: Fei Shao <fshao@chromium.org>
>
> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Applied, thank you.
>
> > ---
> > drivers/input/keyboard/cros_ec_keyb.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> > index 38cb6d82d8fe..bef7bee6f05e 100644
> > --- a/drivers/input/keyboard/cros_ec_keyb.c
> > +++ b/drivers/input/keyboard/cros_ec_keyb.c
> > @@ -226,6 +226,8 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
> > {
> > struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb,
> > notifier);
> > + uint8_t mkbp_event_type = ckdev->ec->event_data.event_type &
> > + EC_MKBP_EVENT_TYPE_MASK;
> > u32 val;
> > unsigned int ev_type;
> >
> > @@ -237,7 +239,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
> > if (queued_during_suspend && !device_may_wakeup(ckdev->dev))
> > return NOTIFY_OK;
> >
> > - switch (ckdev->ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK) {
> > + switch (mkbp_event_type) {
> > case EC_MKBP_EVENT_KEY_MATRIX:
> > pm_wakeup_event(ckdev->dev, 0);
> >
> > @@ -264,7 +266,7 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
> > case EC_MKBP_EVENT_SWITCH:
> > pm_wakeup_event(ckdev->dev, 0);
> >
> > - if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) {
> > + if (mkbp_event_type == EC_MKBP_EVENT_BUTTON) {
> > val = get_unaligned_le32(
> > &ckdev->ec->event_data.data.buttons);
> > ev_type = EV_KEY;
> > --
> > 2.23.0.rc1.153.gdeed80330f-goog
--
Dmitry
^ permalink raw reply
* Re: [PATCH v4 9/9] Input: add IOC3 serio driver
From: Dmitry Torokhov @ 2019-08-14 18:04 UTC (permalink / raw)
To: Jonas Gorski
Cc: Thomas Bogendoerfer, Ralf Baechle, Paul Burton, James Hogan,
Lee Jones, David S. Miller, Srinivas Kandagatla, Alessandro Zummo,
Alexandre Belloni, Greg Kroah-Hartman, Jiri Slaby,
Evgeniy Polyakov, linux-mips, linux-kernel, linux-input,
Network Development, linux-rtc, linux-serial
In-Reply-To: <CAOiHx=mjLpLg9r=mE25T7RQFNRT8wEPkRcy2ZkfT7H=Y5RT-vw@mail.gmail.com>
On Wed, Aug 14, 2019 at 06:57:55PM +0200, Jonas Gorski wrote:
> On Wed, 14 Aug 2019 at 16:37, Thomas Bogendoerfer <tbogendoerfer@suse.de> wrote:
> >
> > On Wed, 14 Aug 2019 15:20:14 +0200
> > Jonas Gorski <jonas.gorski@gmail.com> wrote:
> >
> > > > + d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
> > >
> > > &pdev->dev => dev
> >
> > will change.
> >
> > >
> > > > + if (!d)
> > > > + return -ENOMEM;
> > > > +
> > > > + sk = kzalloc(sizeof(*sk), GFP_KERNEL);
> > >
> > > any reason not to devm_kzalloc this as well? Then you won't need to
> > > manually free it in the error cases.
> >
> > it has different life time than the device, so it may not allocated
> > via devm_kzalloc
> >
> > > > +static int ioc3kbd_remove(struct platform_device *pdev)
> > > > +{
> > > > + struct ioc3kbd_data *d = platform_get_drvdata(pdev);
> > > > +
> > > > + devm_free_irq(&pdev->dev, d->irq, d);
> > > > + serio_unregister_port(d->kbd);
> > > > + serio_unregister_port(d->aux);
> > > > + return 0;
> > > > +}
> > >
> > > and on that topic, won't you need to kfree d->kbd and d->aux here?
> >
> > that's done in serio_release_port() by the serio core.
>
> i see. But in that case, don't the kfree's after the
> serio_unregister_port's in the error path of the .probe function cause
> a double free?
Yes they do, we need to drop kfree()s from there. Nicely spotted.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v6 21/57] Input: Remove dev_err() usage after platform_get_irq()
From: Dmitry Torokhov @ 2019-08-14 17:48 UTC (permalink / raw)
To: Stephen Boyd; +Cc: linux-kernel, linux-input, Greg Kroah-Hartman
In-Reply-To: <20190730181557.90391-22-swboyd@chromium.org>
On Tue, Jul 30, 2019 at 11:15:21AM -0700, Stephen Boyd wrote:
> We don't need dev_err() messages when platform_get_irq() fails now that
> platform_get_irq() prints an error message itself when something goes
> wrong. Let's remove these prints with a simple semantic patch.
>
> // <smpl>
> @@
> expression ret;
> struct platform_device *E;
> @@
>
> ret =
> (
> platform_get_irq(E, ...)
> |
> platform_get_irq_byname(E, ...)
> );
>
> if ( \( ret < 0 \| ret <= 0 \) )
> {
> (
> -if (ret != -EPROBE_DEFER)
> -{ ...
> -dev_err(...);
> -... }
> |
> ...
> -dev_err(...);
> )
> ...
> }
> // </smpl>
>
> While we're here, remove braces on if statements that only have one
> statement (manually).
>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Applied, thank you.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v4 9/9] Input: add IOC3 serio driver
From: Jonas Gorski @ 2019-08-14 16:57 UTC (permalink / raw)
To: Thomas Bogendoerfer
Cc: Ralf Baechle, Paul Burton, James Hogan, Dmitry Torokhov,
Lee Jones, David S. Miller, Srinivas Kandagatla, Alessandro Zummo,
Alexandre Belloni, Greg Kroah-Hartman, Jiri Slaby,
Evgeniy Polyakov, linux-mips, linux-kernel, linux-input,
Network Development, linux-rtc, linux-serial
In-Reply-To: <20190814163733.82f624e342d061866ba8ff87@suse.de>
On Wed, 14 Aug 2019 at 16:37, Thomas Bogendoerfer <tbogendoerfer@suse.de> wrote:
>
> On Wed, 14 Aug 2019 15:20:14 +0200
> Jonas Gorski <jonas.gorski@gmail.com> wrote:
>
> > > + d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
> >
> > &pdev->dev => dev
>
> will change.
>
> >
> > > + if (!d)
> > > + return -ENOMEM;
> > > +
> > > + sk = kzalloc(sizeof(*sk), GFP_KERNEL);
> >
> > any reason not to devm_kzalloc this as well? Then you won't need to
> > manually free it in the error cases.
>
> it has different life time than the device, so it may not allocated
> via devm_kzalloc
>
> > > +static int ioc3kbd_remove(struct platform_device *pdev)
> > > +{
> > > + struct ioc3kbd_data *d = platform_get_drvdata(pdev);
> > > +
> > > + devm_free_irq(&pdev->dev, d->irq, d);
> > > + serio_unregister_port(d->kbd);
> > > + serio_unregister_port(d->aux);
> > > + return 0;
> > > +}
> >
> > and on that topic, won't you need to kfree d->kbd and d->aux here?
>
> that's done in serio_release_port() by the serio core.
i see. But in that case, don't the kfree's after the
serio_unregister_port's in the error path of the .probe function cause
a double free?
Regards
Jonas
^ permalink raw reply
* Re: [PATCH v4 9/9] Input: add IOC3 serio driver
From: Thomas Bogendoerfer @ 2019-08-14 14:37 UTC (permalink / raw)
To: Jonas Gorski
Cc: Ralf Baechle, Paul Burton, James Hogan, Dmitry Torokhov,
Lee Jones, David S. Miller, Srinivas Kandagatla, Alessandro Zummo,
Alexandre Belloni, Greg Kroah-Hartman, Jiri Slaby,
Evgeniy Polyakov, linux-mips, linux-kernel, linux-input,
Network Development, linux-rtc, linux-serial
In-Reply-To: <CAOiHx=kuQtOuNfsJ+fDrps+hbrbp5cPujmQpi8Vfy+0qeP8dtA@mail.gmail.com>
On Wed, 14 Aug 2019 15:20:14 +0200
Jonas Gorski <jonas.gorski@gmail.com> wrote:
> > + d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
>
> &pdev->dev => dev
will change.
>
> > + if (!d)
> > + return -ENOMEM;
> > +
> > + sk = kzalloc(sizeof(*sk), GFP_KERNEL);
>
> any reason not to devm_kzalloc this as well? Then you won't need to
> manually free it in the error cases.
it has different life time than the device, so it may not allocated
via devm_kzalloc
> > +static int ioc3kbd_remove(struct platform_device *pdev)
> > +{
> > + struct ioc3kbd_data *d = platform_get_drvdata(pdev);
> > +
> > + devm_free_irq(&pdev->dev, d->irq, d);
> > + serio_unregister_port(d->kbd);
> > + serio_unregister_port(d->aux);
> > + return 0;
> > +}
>
> and on that topic, won't you need to kfree d->kbd and d->aux here?
that's done in serio_release_port() by the serio core.
Thomas.
--
SUSE Linux GmbH
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
^ permalink raw reply
* Re: [PATCH v4 9/9] Input: add IOC3 serio driver
From: Jonas Gorski @ 2019-08-14 13:20 UTC (permalink / raw)
To: Thomas Bogendoerfer
Cc: Ralf Baechle, Paul Burton, James Hogan, Dmitry Torokhov,
Lee Jones, David S. Miller, Srinivas Kandagatla, Alessandro Zummo,
Alexandre Belloni, Greg Kroah-Hartman, Jiri Slaby,
Evgeniy Polyakov, linux-mips, linux-kernel, linux-input,
Network Development, linux-rtc, linux-serial
In-Reply-To: <20190809103235.16338-10-tbogendoerfer@suse.de>
Hi,
On Fri, 9 Aug 2019 at 12:33, Thomas Bogendoerfer <tbogendoerfer@suse.de> wrote:
>
> This patch adds a platform driver for supporting keyboard and mouse
> interface of SGI IOC3 chips.
>
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
> drivers/input/serio/Kconfig | 10 +++
> drivers/input/serio/Makefile | 1 +
> drivers/input/serio/ioc3kbd.c | 163 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 174 insertions(+)
> create mode 100644 drivers/input/serio/ioc3kbd.c
>
> diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
> index f3e18f8ef9ca..373a1646019e 100644
> --- a/drivers/input/serio/Kconfig
> +++ b/drivers/input/serio/Kconfig
> @@ -165,6 +165,16 @@ config SERIO_MACEPS2
> To compile this driver as a module, choose M here: the
> module will be called maceps2.
>
> +config SERIO_SGI_IOC3
> + tristate "SGI IOC3 PS/2 controller"
> + depends on SGI_MFD_IOC3
> + help
> + Say Y here if you have an SGI Onyx2, SGI Octane or IOC3 PCI card
> + and you want to attach and use a keyboard, mouse, or both.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called ioc3kbd.
> +
> config SERIO_LIBPS2
> tristate "PS/2 driver library"
> depends on SERIO_I8042 || SERIO_I8042=n
> diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
> index 67950a5ccb3f..6d97bad7b844 100644
> --- a/drivers/input/serio/Makefile
> +++ b/drivers/input/serio/Makefile
> @@ -20,6 +20,7 @@ obj-$(CONFIG_HIL_MLC) += hp_sdc_mlc.o hil_mlc.o
> obj-$(CONFIG_SERIO_PCIPS2) += pcips2.o
> obj-$(CONFIG_SERIO_PS2MULT) += ps2mult.o
> obj-$(CONFIG_SERIO_MACEPS2) += maceps2.o
> +obj-$(CONFIG_SERIO_SGI_IOC3) += ioc3kbd.o
> obj-$(CONFIG_SERIO_LIBPS2) += libps2.o
> obj-$(CONFIG_SERIO_RAW) += serio_raw.o
> obj-$(CONFIG_SERIO_AMS_DELTA) += ams_delta_serio.o
> diff --git a/drivers/input/serio/ioc3kbd.c b/drivers/input/serio/ioc3kbd.c
> new file mode 100644
> index 000000000000..6840e3c23fed
> --- /dev/null
> +++ b/drivers/input/serio/ioc3kbd.c
> @@ -0,0 +1,163 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * SGI IOC3 PS/2 controller driver for linux
> + *
> + * Copyright (C) 2019 Thomas Bogendoerfer <tbogendoerfer@suse.de>
> + *
> + * Based on code Copyright (C) 2005 Stanislaw Skowronek <skylark@unaligned.org>
> + * Copyright (C) 2009 Johannes Dickgreber <tanzy@gmx.de>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/init.h>
> +#include <linux/io.h>
> +#include <linux/serio.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +
> +#include <asm/sn/ioc3.h>
> +
> +struct ioc3kbd_data {
> + struct ioc3_serioregs __iomem *regs;
> + struct serio *kbd, *aux;
> + int irq;
> +};
> +
> +static int ioc3kbd_write(struct serio *dev, u8 val)
> +{
> + struct ioc3kbd_data *d = dev->port_data;
> + unsigned long timeout = 0;
> + u32 mask;
> +
> + mask = (dev == d->aux) ? KM_CSR_M_WRT_PEND : KM_CSR_K_WRT_PEND;
> + while ((readl(&d->regs->km_csr) & mask) && (timeout < 1000)) {
> + udelay(100);
> + timeout++;
> + }
> +
> + if (timeout >= 1000)
> + return -ETIMEDOUT;
> +
> + writel(val, dev == d->aux ? &d->regs->m_wd : &d->regs->k_wd);
> +
> + return 0;
> +}
> +
> +static irqreturn_t ioc3kbd_intr(int itq, void *dev_id)
> +{
> + struct ioc3kbd_data *d = dev_id;
> + u32 data_k, data_m;
> +
> + data_k = readl(&d->regs->k_rd);
> + data_m = readl(&d->regs->m_rd);
> +
> + if (data_k & KM_RD_VALID_0)
> + serio_interrupt(d->kbd, (data_k >> KM_RD_DATA_0_SHIFT) & 0xff,
> + 0);
> + if (data_k & KM_RD_VALID_1)
> + serio_interrupt(d->kbd, (data_k >> KM_RD_DATA_1_SHIFT) & 0xff,
> + 0);
> + if (data_k & KM_RD_VALID_2)
> + serio_interrupt(d->kbd, (data_k >> KM_RD_DATA_2_SHIFT) & 0xff,
> + 0);
> + if (data_m & KM_RD_VALID_0)
> + serio_interrupt(d->aux, (data_m >> KM_RD_DATA_0_SHIFT) & 0xff,
> + 0);
> + if (data_m & KM_RD_VALID_1)
> + serio_interrupt(d->aux, (data_m >> KM_RD_DATA_1_SHIFT) & 0xff,
> + 0);
> + if (data_m & KM_RD_VALID_2)
> + serio_interrupt(d->aux, (data_m >> KM_RD_DATA_2_SHIFT) & 0xff,
> + 0);
> +
> + return 0;
> +}
> +
> +static int ioc3kbd_probe(struct platform_device *pdev)
> +{
> + struct ioc3_serioregs __iomem *regs;
> + struct device *dev = &pdev->dev;
> + struct ioc3kbd_data *d;
> + struct serio *sk, *sa;
> + int irq, ret;
> +
> + regs = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(regs))
> + return PTR_ERR(regs);
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return -ENXIO;
> +
> + d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
&pdev->dev => dev
> + if (!d)
> + return -ENOMEM;
> +
> + sk = kzalloc(sizeof(*sk), GFP_KERNEL);
any reason not to devm_kzalloc this as well? Then you won't need to
manually free it in the error cases.
> + if (!sk)
> + return -ENOMEM;
> +
> + sa = kzalloc(sizeof(*sa), GFP_KERNEL);
same here.
> + if (!sa) {
> + kfree(sk);
> + return -ENOMEM;
> + }
> +
> + sk->id.type = SERIO_8042;
> + sk->write = ioc3kbd_write;
> + snprintf(sk->name, sizeof(sk->name), "IOC3 keyboard %d", pdev->id);
> + snprintf(sk->phys, sizeof(sk->phys), "ioc3/serio%dkbd", pdev->id);
> + sk->port_data = d;
> + sk->dev.parent = &pdev->dev;
&pdev->dev => dev
> +
> + sa->id.type = SERIO_8042;
> + sa->write = ioc3kbd_write;
> + snprintf(sa->name, sizeof(sa->name), "IOC3 auxiliary %d", pdev->id);
> + snprintf(sa->phys, sizeof(sa->phys), "ioc3/serio%daux", pdev->id);
> + sa->port_data = d;
> + sa->dev.parent = dev;
> +
> + d->regs = regs;
> + d->kbd = sk;
> + d->aux = sa;
> + d->irq = irq;
> +
> + platform_set_drvdata(pdev, d);
> + serio_register_port(d->kbd);
> + serio_register_port(d->aux);
> +
> + ret = devm_request_irq(&pdev->dev, irq, ioc3kbd_intr, IRQF_SHARED,
> + "ioc3-kbd", d);
> + if (ret) {
> + dev_err(&pdev->dev, "could not request IRQ %d\n", irq);
> + serio_unregister_port(d->kbd);
> + serio_unregister_port(d->aux);
> + kfree(sk);
> + kfree(sa);
> + return ret;
> + }
> + return 0;
> +}
> +
> +static int ioc3kbd_remove(struct platform_device *pdev)
> +{
> + struct ioc3kbd_data *d = platform_get_drvdata(pdev);
> +
> + devm_free_irq(&pdev->dev, d->irq, d);
> + serio_unregister_port(d->kbd);
> + serio_unregister_port(d->aux);
> + return 0;
> +}
and on that topic, won't you need to kfree d->kbd and d->aux here?
Unless you devm_kzalloc'd them.
Alternatively you could also just embed the two serio structs into
ioc3kbd_data, then you only need one allocation instead of three.
Regards
Jonas
^ permalink raw reply
* Re: [PATCH v4 3/9] nvmem: core: add nvmem_device_find
From: Srinivas Kandagatla @ 2019-08-14 12:52 UTC (permalink / raw)
To: Thomas Bogendoerfer
Cc: Ralf Baechle, Paul Burton, James Hogan, Dmitry Torokhov,
Lee Jones, David S. Miller, Alessandro Zummo, Alexandre Belloni,
Greg Kroah-Hartman, Jiri Slaby, Evgeniy Polyakov, linux-mips,
linux-kernel, linux-input, netdev, linux-rtc, linux-serial
In-Reply-To: <20190814134616.b4dab3c0aa6ac913d78edb6a@suse.de>
On 14/08/2019 12:46, Thomas Bogendoerfer wrote:
> On Tue, 13 Aug 2019 10:40:34 +0100
> Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:
>
>>
>>
>> On 09/08/2019 11:32, Thomas Bogendoerfer wrote:
>>> nvmem_device_find provides a way to search for nvmem devices with
>>> the help of a match function simlair to bus_find_device.
>>>
>>> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
>>> ---
>>> drivers/nvmem/core.c | 62 ++++++++++++++++++++++--------------------
>>> include/linux/nvmem-consumer.h | 9 ++++++
>>> 2 files changed, 41 insertions(+), 30 deletions(-)
>>
>> Have you considered using nvmem_register_notifier() ?
>
> yes, that was the first idea. But then I realized I need to build up
> a private database of information already present in nvmem bus. So I
> looked for a way to retrieve it from there. Unfortunately I couldn't
> use bus_find_device directly, because nvmem_bus_type and struct nvmem_device
> is hidden. So I refactured the lookup code and added a more universal
> lookup function, which fits my needs and should be usable for more.
I see your point.
overall the patch as it is look good, but recently we added more generic
lookups for DT node, looks like part of your patch is un-doing generic
device name lookup.
DT node match lookup is in
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/log/?h=generic_lookup_helpers
of_nvmem_match and nvmem_match_name are duplicating the code here.
Looks like its possible to use generic lookups along with custom match
by splitting __nvmem_device_get() to two functions, one for lookup and
other for refcounting.
Other missing bit is adding this api to documentation in
./Documentation/driver-api/nvmem.rst
thanks,
srini
>
> Thomas.
>
^ permalink raw reply
* Re: [PATCH v4 3/9] nvmem: core: add nvmem_device_find
From: Thomas Bogendoerfer @ 2019-08-14 11:46 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Ralf Baechle, Paul Burton, James Hogan, Dmitry Torokhov,
Lee Jones, David S. Miller, Alessandro Zummo, Alexandre Belloni,
Greg Kroah-Hartman, Jiri Slaby, Evgeniy Polyakov, linux-mips,
linux-kernel, linux-input, netdev, linux-rtc, linux-serial
In-Reply-To: <8d18de64-9234-fcba-aa3d-b46789eb62a5@linaro.org>
On Tue, 13 Aug 2019 10:40:34 +0100
Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:
>
>
> On 09/08/2019 11:32, Thomas Bogendoerfer wrote:
> > nvmem_device_find provides a way to search for nvmem devices with
> > the help of a match function simlair to bus_find_device.
> >
> > Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> > ---
> > drivers/nvmem/core.c | 62 ++++++++++++++++++++++--------------------
> > include/linux/nvmem-consumer.h | 9 ++++++
> > 2 files changed, 41 insertions(+), 30 deletions(-)
>
> Have you considered using nvmem_register_notifier() ?
yes, that was the first idea. But then I realized I need to build up
a private database of information already present in nvmem bus. So I
looked for a way to retrieve it from there. Unfortunately I couldn't
use bus_find_device directly, because nvmem_bus_type and struct nvmem_device
is hidden. So I refactured the lookup code and added a more universal
lookup function, which fits my needs and should be usable for more.
Thomas.
--
SUSE Linux GmbH
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
^ permalink raw reply
* Re: [PATCH v4 8/9] MIPS: SGI-IP27: fix readb/writeb addressing
From: Thomas Bogendoerfer @ 2019-08-14 11:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Greg Kroah-Hartman, Andy Shevchenko, Ralf Baechle, Paul Burton,
James Hogan, Dmitry Torokhov, Lee Jones, David S. Miller,
Srinivas Kandagatla, Alessandro Zummo, Alexandre Belloni,
Jiri Slaby, Evgeniy Polyakov, linux-mips,
Linux Kernel Mailing List, linux-input, netdev,
open list:REAL TIME CLOCK (RTC) SUBSYSTEM
In-Reply-To: <90129235-58c2-aeed-a9d3-96f4a8f45709@amsat.org>
On Tue, 13 Aug 2019 10:47:13 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Hi Thomas,
>
> On 8/11/19 9:29 AM, Greg Kroah-Hartman wrote:
> > On Sat, Aug 10, 2019 at 04:22:23PM +0300, Andy Shevchenko wrote:
> >> On Fri, Aug 9, 2019 at 1:34 PM Thomas Bogendoerfer
> >> <tbogendoerfer@suse.de> wrote:
> >>>
> >>> Our chosen byte swapping, which is what firmware already uses, is to
> >>> do readl/writel by normal lw/sw intructions (data invariance). This
> >>> also means we need to mangle addresses for u8 and u16 accesses. The
> >>> mangling for 16bit has been done aready, but 8bit one was missing.
> >>> Correcting this causes different addresses for accesses to the
> >>> SuperIO and local bus of the IOC3 chip. This is fixed by changing
> >>> byte order in ioc3 and m48rtc_rtc structs.
> >>
> >>> /* serial port register map */
> >>> struct ioc3_serialregs {
> >>> - uint32_t sscr;
> >>> - uint32_t stpir;
> >>> - uint32_t stcir;
> >>> - uint32_t srpir;
> >>> - uint32_t srcir;
> >>> - uint32_t srtr;
> >>> - uint32_t shadow;
> >>> + u32 sscr;
> >>> + u32 stpir;
> >>> + u32 stcir;
> >>> + u32 srpir;
> >>> + u32 srcir;
> >>> + u32 srtr;
> >>> + u32 shadow;
> >>> };
> >>
> >> Isn't it a churn? AFAIU kernel documentation the uint32_t is okay to
> >> use, just be consistent inside one module / driver.
> >> Am I mistaken?
> >
> > No, but really it uint* shouldn't be used anywhere in the kernel source
> > as it does not make sense.
>
> If you respin your series, please send this cleanup as a separate patch.
no need for an extra patch. I realized that patch 7 in this series introduces
all of these uint32_t. So i already fixed it there.
Thomas.
--
SUSE Linux GmbH
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
^ permalink raw reply
* Re: [PATCH] HID: uhid: actually use the err number from userspace
From: David Rheinsberg @ 2019-08-14 8:30 UTC (permalink / raw)
To: Benjamin Tissoires; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml
In-Reply-To: <CAO-hwJ+z0szwuQrUxpQhii2z_jwxMX91df0ynK5QbZpMhg79-g@mail.gmail.com>
Hey
> > 2) I think you have to filter some of the error codes. For instance,
> > if you return one of the -ERESTARTSYS codes, this might cause the
> > syscall to restart (if auto-restart is enabled on this context). At
> > the same time, this is not *that* bad. It might even be useful for the
> > userspace driver to trigger an EINTR. At least we should be aware of
> > this. So maybe filters are not necessary.. Mhhh. Comments?
>
> I haven't thought at all of the side effects of letting the user
> return a random error code.
> I have the impression that anything below EHWPOISON (133) is
> relatively safe. So maybe we should just make sure the error code is
> below 134?
>
> The ERESTARTSYS has a few warnings in the include file, so I guess the
> side effects might be too much for what we want to deal with.
How about `err < ERESTARTSYS`? That is, we grant user-space the entire
range [1-511]. This seems to be the range reserved for uapi.
I think the ERESTART* codes would be fine as well, but I also don't
believe there to be any actual use-case for them. Anyway, I am fine
with either range.
Thanks
David
^ permalink raw reply
* [PATCH AUTOSEL 4.4 22/28] Input: iforce - add sanity checks
From: Sasha Levin @ 2019-08-14 2:25 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Oliver Neukum, syzbot+5efc10c005014d061a74, Dmitry Torokhov,
Sasha Levin, linux-input
In-Reply-To: <20190814022550.17463-1-sashal@kernel.org>
From: Oliver Neukum <oneukum@suse.com>
[ Upstream commit 849f5ae3a513c550cad741c68dd3d7eb2bcc2a2c ]
The endpoint type should also be checked before a device
is accepted.
Reported-by: syzbot+5efc10c005014d061a74@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/input/joystick/iforce/iforce-usb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index db64adfbe1aff..3e1ea912b41d1 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -145,7 +145,12 @@ static int iforce_usb_probe(struct usb_interface *intf,
return -ENODEV;
epirq = &interface->endpoint[0].desc;
+ if (!usb_endpoint_is_int_in(epirq))
+ return -ENODEV;
+
epout = &interface->endpoint[1].desc;
+ if (!usb_endpoint_is_int_out(epout))
+ return -ENODEV;
if (!(iforce = kzalloc(sizeof(struct iforce) + 32, GFP_KERNEL)))
goto fail;
--
2.20.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.4 21/28] HID: hiddev: do cleanup in failure of opening a device
From: Sasha Levin @ 2019-08-14 2:25 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Hillf Danton, syzbot, Andrey Konovalov, Jiri Kosina, Sasha Levin,
linux-usb, linux-input
In-Reply-To: <20190814022550.17463-1-sashal@kernel.org>
From: Hillf Danton <hdanton@sina.com>
[ Upstream commit 6d4472d7bec39917b54e4e80245784ea5d60ce49 ]
Undo what we did for opening before releasing the memory slice.
Reported-by: syzbot <syzbot+62a1e04fd3ec2abf099e@syzkaller.appspotmail.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/usbhid/hiddev.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 0bfc2009e4071..8903ea09ac587 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -330,6 +330,10 @@ static int hiddev_open(struct inode *inode, struct file *file)
return 0;
bail_unlock:
mutex_unlock(&hiddev->existancelock);
+
+ spin_lock_irq(&list->hiddev->list_lock);
+ list_del(&list->node);
+ spin_unlock_irq(&list->hiddev->list_lock);
bail:
file->private_data = NULL;
vfree(list);
--
2.20.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox