Skip to content

Commit 2d05dba

Browse files
bentissJiri Kosina
authored andcommitted
HID: cp2112: prevent sleeping function called from invalid context
When calling request_threaded_irq() with a CP2112, the function cp2112_gpio_irq_startup() is called in a IRQ context. Therefore we can not sleep, and we can not call cp2112_gpio_direction_input() there. Move the call to cp2112_gpio_direction_input() earlier to have a working driver. Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent b640be5 commit 2d05dba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/hid/hid-cp2112.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,8 +1153,6 @@ static unsigned int cp2112_gpio_irq_startup(struct irq_data *d)
11531153

11541154
INIT_DELAYED_WORK(&dev->gpio_poll_worker, cp2112_gpio_poll_callback);
11551155

1156-
cp2112_gpio_direction_input(gc, d->hwirq);
1157-
11581156
if (!dev->gpio_poll) {
11591157
dev->gpio_poll = true;
11601158
schedule_delayed_work(&dev->gpio_poll_worker, 0);
@@ -1204,6 +1202,12 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev,
12041202
return PTR_ERR(dev->desc[pin]);
12051203
}
12061204

1205+
ret = cp2112_gpio_direction_input(&dev->gc, pin);
1206+
if (ret < 0) {
1207+
dev_err(dev->gc.parent, "Failed to set GPIO to input dir\n");
1208+
goto err_desc;
1209+
}
1210+
12071211
ret = gpiochip_lock_as_irq(&dev->gc, pin);
12081212
if (ret) {
12091213
dev_err(dev->gc.parent, "Failed to lock GPIO as interrupt\n");

0 commit comments

Comments
 (0)