Thread (10 messages) 10 messages, 2 authors, 2022-12-19
STALE1261d
Revisions (3)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v2 current

[PATCH v2 2/3] HID: mcp2221: enable HID I/O during GPIO probe

From: Enrik Berkhan <hidden>
Date: 2022-11-03 22:27:42
Also in: linux-i2c, lkml
Subsystem: hid core layer, mcp2221a microchip usb-hid to i2c bridge driver, the rest · Maintainers: Jiri Kosina, Benjamin Tissoires, Rishi Gupta, Linus Torvalds

As soon as the GPIO driver part will be enabled in mcp2221_probe(), the
first HID reports will be exchanged with the chip because the GPIO
driver immediately calls mcp_gpio_get_direction(). HID I/O has to be
enabled explicitly during mcp2221_probe() to receive response reports.

Otherwise, all four mcp_gpio_get_direction() calls will run into the
four second timeout of mcp_send_report(), which will block the driver
for about 16s during startup.

A very similar patch appeared some time ago in
https://lore.kernel.org/r/20210818152743.163929-1-tobias.junghans@inhub.de (local)
which obviously got lost somehow.

CC: Tobias Junghans <redacted>

Signed-off-by: Enrik Berkhan <redacted>
---
 drivers/hid/hid-mcp2221.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index e61dd039354b..0705526231ec 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -1178,6 +1178,9 @@ static int mcp2221_probe(struct hid_device *hdev,
 	mcp->gc->can_sleep = 1;
 	mcp->gc->parent = &hdev->dev;
 
+	/* Enable reception of HID reports during GPIO initialization */
+	hid_device_io_start(hdev);
+
 	ret = devm_gpiochip_add_data(&hdev->dev, mcp->gc, mcp);
 	if (ret)
 		return ret;
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help