linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 00/63] atmel_mxt_ts misc
@ 2019-08-16  8:28 Jiada Wang
  2019-08-16  8:28 ` [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive Jiada Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
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	[flat|nested] 15+ messages in thread

* [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive
  2019-08-16  8:28 [PATCH v1 00/63] atmel_mxt_ts misc Jiada Wang
@ 2019-08-16  8:28 ` Jiada Wang
  2019-08-16 17:12   ` Dmitry Torokhov
  2019-08-16  8:28 ` [PATCH v1 02/63] Input: atmel_mxt_ts - rework sysfs init/remove Jiada Wang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Jiada Wang @ 2019-08-16  8:28 UTC (permalink / raw)
  To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis

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	[flat|nested] 15+ messages in thread

* [PATCH v1 02/63] Input: atmel_mxt_ts - rework sysfs init/remove
  2019-08-16  8:28 [PATCH v1 00/63] atmel_mxt_ts misc Jiada Wang
  2019-08-16  8:28 ` [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive Jiada Wang
@ 2019-08-16  8:28 ` Jiada Wang
  2019-08-16  8:28 ` [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary Jiada Wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Jiada Wang @ 2019-08-16  8:28 UTC (permalink / raw)
  To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis

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	[flat|nested] 15+ messages in thread

* [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
  2019-08-16  8:28 [PATCH v1 00/63] atmel_mxt_ts misc Jiada Wang
  2019-08-16  8:28 ` [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive Jiada Wang
  2019-08-16  8:28 ` [PATCH v1 02/63] Input: atmel_mxt_ts - rework sysfs init/remove Jiada Wang
@ 2019-08-16  8:28 ` Jiada Wang
  2019-08-16 17:16   ` Dmitry Torokhov
  2019-08-16  8:28 ` [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks Jiada Wang
  2019-08-16 17:32 ` [PATCH v1 00/63] atmel_mxt_ts misc Dmitry Torokhov
  4 siblings, 1 reply; 15+ messages in thread
From: Jiada Wang @ 2019-08-16  8:28 UTC (permalink / raw)
  To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis

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	[flat|nested] 15+ messages in thread

* [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks
  2019-08-16  8:28 [PATCH v1 00/63] atmel_mxt_ts misc Jiada Wang
                   ` (2 preceding siblings ...)
  2019-08-16  8:28 ` [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary Jiada Wang
@ 2019-08-16  8:28 ` Jiada Wang
  2019-08-16 17:18   ` Dmitry Torokhov
  2019-08-16 17:32 ` [PATCH v1 00/63] atmel_mxt_ts misc Dmitry Torokhov
  4 siblings, 1 reply; 15+ messages in thread
From: Jiada Wang @ 2019-08-16  8:28 UTC (permalink / raw)
  To: nick, dmitry.torokhov; +Cc: linux-input, linux-kernel, jiada_wang, george_davis

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	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive
  2019-08-16  8:28 ` [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive Jiada Wang
@ 2019-08-16 17:12   ` Dmitry Torokhov
  2019-08-21  9:13     ` Jiada Wang
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2019-08-16 17:12 UTC (permalink / raw)
  To: Jiada Wang; +Cc: nick, linux-input, linux-kernel, george_davis

Hi Jiada,

On Fri, Aug 16, 2019 at 05:28:50PM +0900, Jiada Wang wrote:
> 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.

This seems to actually contain 2 changes:

- switching to use return value of input_mt_report_slot_state()
- actually introducing and using input_mt_report_slot_inactive()

Please split them.

>  
> +/**
> + * 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);

I think this should be a static inline, there is no need to have out of
line implementation for a 1-liner.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
  2019-08-16  8:28 ` [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary Jiada Wang
@ 2019-08-16 17:16   ` Dmitry Torokhov
  2019-08-21 13:26     ` Jiada Wang
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2019-08-16 17:16 UTC (permalink / raw)
  To: Jiada Wang; +Cc: nick, linux-input, linux-kernel, george_davis

On Fri, Aug 16, 2019 at 05:28:52PM +0900, Jiada Wang wrote:
> 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.

Instead of trying to work around of misconfiguration for IRQ/firmware,
can we simply error out of probe if we see a level interrupt with
!RETRIGEN firmware?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks
  2019-08-16  8:28 ` [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks Jiada Wang
@ 2019-08-16 17:18   ` Dmitry Torokhov
  2019-08-22  5:24     ` Jiada Wang
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2019-08-16 17:18 UTC (permalink / raw)
  To: Jiada Wang; +Cc: nick, linux-input, linux-kernel, george_davis

On Fri, Aug 16, 2019 at 05:28:53PM +0900, Jiada Wang wrote:
> 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)

Can we call this __mxt_read_reg() and the original read reg call
__mxt_read_chunk()?

> +{
> +	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;
> +}

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 00/63] atmel_mxt_ts misc
  2019-08-16  8:28 [PATCH v1 00/63] atmel_mxt_ts misc Jiada Wang
                   ` (3 preceding siblings ...)
  2019-08-16  8:28 ` [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks Jiada Wang
@ 2019-08-16 17:32 ` Dmitry Torokhov
  2019-08-19  9:29   ` Jiada Wang
  4 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2019-08-16 17:32 UTC (permalink / raw)
  To: Jiada Wang; +Cc: nick, linux-input, linux-kernel, george_davis

Hi Jiada,

On Fri, Aug 16, 2019 at 05:28:49PM +0900, Jiada Wang wrote:
> This patch-set forward ports Nick Dyer's work in ndyer/linux github repository
> as long as some other features and fixes

I see a lot of chages that are fixups for older changes in your series.
They need to be identified and squashed together, as we do not need to
be aware of your development history.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 00/63] atmel_mxt_ts misc
  2019-08-16 17:32 ` [PATCH v1 00/63] atmel_mxt_ts misc Dmitry Torokhov
@ 2019-08-19  9:29   ` Jiada Wang
  0 siblings, 0 replies; 15+ messages in thread
From: Jiada Wang @ 2019-08-19  9:29 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: nick, linux-input, linux-kernel, george_davis

  HiDmitrij

On 2019/08/17 2:32, Dmitry Torokhov wrote:
> Hi Jiada,
> 
> On Fri, Aug 16, 2019 at 05:28:49PM +0900, Jiada Wang wrote:
>> This patch-set forward ports Nick Dyer's work in ndyer/linux github repository
>> as long as some other features and fixes
> 
> I see a lot of chages that are fixups for older changes in your series.
> They need to be identified and squashed together, as we do not need to
> be aware of your development history.
> 

Thanks for your comments,
in v1, I already squashed several of our internal changes,
but seems there are still some can be squashed,
I will try to squash all possible changes in v2 patch-set

Thanks,
Jiada
> Thanks.
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive
  2019-08-16 17:12   ` Dmitry Torokhov
@ 2019-08-21  9:13     ` Jiada Wang
  0 siblings, 0 replies; 15+ messages in thread
From: Jiada Wang @ 2019-08-21  9:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: nick, linux-input, linux-kernel, george_davis

Hi Dmitry

On 2019/08/17 2:12, Dmitry Torokhov wrote:
> Hi Jiada,
> 
> On Fri, Aug 16, 2019 at 05:28:50PM +0900, Jiada Wang wrote:
>> 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.
> 
> This seems to actually contain 2 changes:
> 
> - switching to use return value of input_mt_report_slot_state()
> - actually introducing and using input_mt_report_slot_inactive()
> 
> Please split them.
> 
will split this patch into two in v2 patchset

>>   
>> +/**
>> + * 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);
> 
> I think this should be a static inline, there is no need to have out of
> line implementation for a 1-liner.
>
will change to a inline function in v2 patchset.

Thanks,
Jiada

> Thanks.
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
  2019-08-16 17:16   ` Dmitry Torokhov
@ 2019-08-21 13:26     ` Jiada Wang
  2019-08-21 17:54       ` Dmitry Torokhov
  0 siblings, 1 reply; 15+ messages in thread
From: Jiada Wang @ 2019-08-21 13:26 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: nick, linux-input, linux-kernel, george_davis

Hi Dmitry

On 2019/08/17 2:16, Dmitry Torokhov wrote:
> On Fri, Aug 16, 2019 at 05:28:52PM +0900, Jiada Wang wrote:
>> 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.
> 
> Instead of trying to work around of misconfiguration for IRQ/firmware,
> can we simply error out of probe if we see a level interrupt with
> !RETRIGEN firmware?
> 
I think for old firmwares, which doesn't support RETRIGEN feature, this 
workaround is needed, otherwise we will break all old firmwares, which 
configured with edge-triggered IRQ

for recent firmwares which support RETRIGEN feature, we can fail probe, 
if RETRIGEN is not enabled, and configured with edge-triggered IRQ.

what is your thought?

Thanks,
Jiada
> Thanks.
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
  2019-08-21 13:26     ` Jiada Wang
@ 2019-08-21 17:54       ` Dmitry Torokhov
  2019-08-22  3:37         ` Jiada Wang
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2019-08-21 17:54 UTC (permalink / raw)
  To: Jiada Wang; +Cc: nick, linux-input, linux-kernel, george_davis

On Wed, Aug 21, 2019 at 10:26:31PM +0900, Jiada Wang wrote:
> Hi Dmitry
> 
> On 2019/08/17 2:16, Dmitry Torokhov wrote:
> > On Fri, Aug 16, 2019 at 05:28:52PM +0900, Jiada Wang wrote:
> > > 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.
> > 
> > Instead of trying to work around of misconfiguration for IRQ/firmware,
> > can we simply error out of probe if we see a level interrupt with
> > !RETRIGEN firmware?
> > 
> I think for old firmwares, which doesn't support RETRIGEN feature, this
> workaround is needed, otherwise we will break all old firmwares, which
> configured with edge-triggered IRQ

Do you know if there are any? I know Chrome OS firmware have RETRIGEN
activated and they are pretty old (original Pixel is from 2013). But if
we indeed have devices with edge interrupt and old not firmware that
does not retrigger, I guess we'll have to keep it... 

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary
  2019-08-21 17:54       ` Dmitry Torokhov
@ 2019-08-22  3:37         ` Jiada Wang
  0 siblings, 0 replies; 15+ messages in thread
From: Jiada Wang @ 2019-08-22  3:37 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: nick, linux-input, linux-kernel, george_davis

Hi

On 2019/08/22 2:54, Dmitry Torokhov wrote:
> On Wed, Aug 21, 2019 at 10:26:31PM +0900, Jiada Wang wrote:
>> Hi Dmitry
>>
>> On 2019/08/17 2:16, Dmitry Torokhov wrote:
>>> On Fri, Aug 16, 2019 at 05:28:52PM +0900, Jiada Wang wrote:
>>>> 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.
>>>
>>> Instead of trying to work around of misconfiguration for IRQ/firmware,
>>> can we simply error out of probe if we see a level interrupt with
>>> !RETRIGEN firmware?
>>>
>> I think for old firmwares, which doesn't support RETRIGEN feature, this
>> workaround is needed, otherwise we will break all old firmwares, which
>> configured with edge-triggered IRQ
> 
> Do you know if there are any? I know Chrome OS firmware have RETRIGEN
> activated and they are pretty old (original Pixel is from 2013). But if
> we indeed have devices with edge interrupt and old not firmware that
> does not retrigger, I guess we'll have to keep it...
> 

Honestly I don't know firmwares/chips which don't support RETRIGEN feature.

BUT Dyer originally authored this patch in 2012, I assume here "old" 
firmware/chips means, those before 2012.


Thanks,
Jiada

> Thanks.
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks
  2019-08-16 17:18   ` Dmitry Torokhov
@ 2019-08-22  5:24     ` Jiada Wang
  0 siblings, 0 replies; 15+ messages in thread
From: Jiada Wang @ 2019-08-22  5:24 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: nick, linux-input, linux-kernel, george_davis

Hi Dmitry

On 2019/08/17 2:18, Dmitry Torokhov wrote:
> On Fri, Aug 16, 2019 at 05:28:53PM +0900, Jiada Wang wrote:
>> 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)
> 
> Can we call this __mxt_read_reg() and the original read reg call
> __mxt_read_chunk()?
>
yes, I will update in v2 patch-set,
so that every call to __mxt_read_reg() in atmel driver,
can have the feature to split large size transfer.

Thanks,
Jiada

>> +{
>> +	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;
>> +}
> 
> Thanks.
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-08-22  5:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-16  8:28 [PATCH v1 00/63] atmel_mxt_ts misc Jiada Wang
2019-08-16  8:28 ` [PATCH v1 01/63] Input: introduce input_mt_report_slot_inactive Jiada Wang
2019-08-16 17:12   ` Dmitry Torokhov
2019-08-21  9:13     ` Jiada Wang
2019-08-16  8:28 ` [PATCH v1 02/63] Input: atmel_mxt_ts - rework sysfs init/remove Jiada Wang
2019-08-16  8:28 ` [PATCH v1 03/63] Input: atmel_mxt_ts - only read messages in mxt_acquire_irq() when necessary Jiada Wang
2019-08-16 17:16   ` Dmitry Torokhov
2019-08-21 13:26     ` Jiada Wang
2019-08-21 17:54       ` Dmitry Torokhov
2019-08-22  3:37         ` Jiada Wang
2019-08-16  8:28 ` [PATCH v1 04/63] Input: atmel_mxt_ts - split large i2c transfers into blocks Jiada Wang
2019-08-16 17:18   ` Dmitry Torokhov
2019-08-22  5:24     ` Jiada Wang
2019-08-16 17:32 ` [PATCH v1 00/63] atmel_mxt_ts misc Dmitry Torokhov
2019-08-19  9:29   ` Jiada Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).