From a3ef300e4f0f89664331e60fa46212933b646298 Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 5 Oct 2011 11:43:34 +1100 Subject: [PATCH] drivers/leds/leds-gpio.c: use gpio_get_value_cansleep() when initializing I get the following warning: ------------[ cut here ]------------ WARNING: at drivers/gpio/gpiolib.c:1559 __gpio_get_value+0x90/0x98() Modules linked in: Call Trace: [] dump_stack+0x8/0x34 [] warn_slowpath_common+0x78/0xa0 [] __gpio_get_value+0x90/0x98 [] create_gpio_led+0xdc/0x194 [] gpio_led_probe+0x290/0x36c [] driver_probe_device+0x78/0x1b0 [] __driver_attach+0xc0/0xc8 [] bus_for_each_dev+0x64/0xb0 [] bus_add_driver+0x1c8/0x2a8 [] driver_register+0x90/0x180 [] do_one_initcall+0x38/0x160 ---[ end trace ee38723fbefcd65c ]--- My GPIOs are on an I2C port expander, so we must use the *_cansleep() variant of the GPIO functions. This is was not being done in create_gpio_led(). We can change gpio_get_value() to gpio_get_value_cansleep() because it is only called from the platform_driver probe function, which is a context where we can sleep. Only tested on my gpio_cansleep() system, but it seems safe for all systems. Signed-off-by: David Daney Cc: Richard Purdie Acked-by: Trent Piepho Cc: Grant Likely Signed-off-by: Andrew Morton --- drivers/leds/leds-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 2ba756b035de..399a86f2013a 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -122,7 +122,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template, } led_dat->cdev.brightness_set = gpio_led_set; if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) - state = !!gpio_get_value(led_dat->gpio) ^ led_dat->active_low; + state = !!gpio_get_value_cansleep(led_dat->gpio) ^ led_dat->active_low; else state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; -- 2.39.2