leds: trigger: gpio: fix warning in gpio trigger for gpios whose accessor function...
authorLothar Waßmann <LW@karo-electronics.de>
Tue, 9 Sep 2014 07:40:32 +0000 (00:40 -0700)
committerBryan Wu <cooloney@gmail.com>
Thu, 11 Sep 2014 23:57:51 +0000 (16:57 -0700)
When using a GPIO driver whose accessor functions may sleep (e.g. an
I2C GPIO extender like PCA9554) the following warning is issued:
WARNING: CPU: 0 PID: 665 at drivers/gpio/gpiolib.c:2274 gpiod_get_raw_value+0x3c/0x48()
Modules linked in:
CPU: 0 PID: 665 Comm: kworker/0:2 Not tainted 3.16.0-karo+ #115
Workqueue: events gpio_trig_work
[<c00142cc>] (unwind_backtrace) from [<c00118f8>] (show_stack+0x10/0x14)
[<c00118f8>] (show_stack) from [<c001bf10>] (warn_slowpath_common+0x64/0x84)
[<c001bf10>] (warn_slowpath_common) from [<c001bf4c>] (warn_slowpath_null+0x1c/0x24)
[<c001bf4c>] (warn_slowpath_null) from [<c020a1b8>] (gpiod_get_raw_value+0x3c/0x48)
[<c020a1b8>] (gpiod_get_raw_value) from [<c02f68a0>] (gpio_trig_work+0x1c/0xb0)
[<c02f68a0>] (gpio_trig_work) from [<c0030c1c>] (process_one_work+0x144/0x38c)
[<c0030c1c>] (process_one_work) from [<c0030ef8>] (worker_thread+0x60/0x5cc)
[<c0030ef8>] (worker_thread) from [<c0036dd4>] (kthread+0xb4/0xd0)
[<c0036dd4>] (kthread) from [<c000f0f0>] (ret_from_fork+0x14/0x24)
---[ end trace cd51a1dad8b86c9c ]---

Fix this by using the _cansleep() variant of gpio_get_value().

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/trigger/ledtrig-gpio.c

index 35812e3a37f24edfd4a7694e40c705b0ea6054f6..c86c41826476ca48b3fa6f58e0a41db869418cf8 100644 (file)
@@ -48,7 +48,7 @@ static void gpio_trig_work(struct work_struct *work)
        if (!gpio_data->gpio)
                return;
 
-       tmp = gpio_get_value(gpio_data->gpio);
+       tmp = gpio_get_value_cansleep(gpio_data->gpio);
        if (gpio_data->inverted)
                tmp = !tmp;