HID: mcp2221: fix hang on probe while setting up gpiochip
PATCH 1/1 HID: mcp2221: fix hang on probe while setting up gpiochip
From: Gavin Li <[email protected]>
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 <[email protected]>
--- drivers/hid/hid-mcp2221.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hid/hid-mcp2221.c +4 -0
@@ -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);
Signature · 1 line
2.34.1