[PATCH] HID: mcp2221: fix hang on probe while setting up gpiochip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Gavin Li <gavin@xxxxxxxxxxxx>

The driver expects HID events to be delivered to it during probe()
because the devm_gpiochip_add_data() call indirectly calls
get_direction(), which fires an HID command that expects an HID
response. Without this patch, the get_direction() would timeout (of 4
seconds) once per pin, leading to a 16 second delay before the device is
usable.

This patch adds calls to hid_device_io_start() and hid_device_io_stop()
to notify the HID subsystem that the driver is ready to receive events
before the probe() finishes.

Signed-off-by: Gavin Li <gavin@xxxxxxxxxxxx>
---
 drivers/hid/hid-mcp2221.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index 4211b9839209b..567ef8b93376d 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -877,6 +877,9 @@ static int mcp2221_probe(struct hid_device *hdev,
 	}
 	i2c_set_adapdata(&mcp->adapter, mcp);
 
+	/* gpiolib calls get_direction(), so become ready to process events */
+	hid_device_io_start(hdev);
+
 	/* Setup GPIO chip */
 	mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL);
 	if (!mcp->gc) {
@@ -902,6 +905,7 @@ static int mcp2221_probe(struct hid_device *hdev,
 	return 0;
 
 err_gc:
+	hid_device_io_stop(hdev);
 	i2c_del_adapter(&mcp->adapter);
 err_i2c:
 	hid_hw_close(mcp->hdev);
-- 
2.34.1




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux