From: Gavin Li <redacted>
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 <redacted>
---
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