mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
leds: leds-gpio: use gpio_request_one
Using gpio_request_one can make the code simpler because it can set the direction and initial value in one shot. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
This commit is contained in:
parent
14ce82e536
commit
a99d76f9eb
@ -106,10 +106,6 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpio_request(template->gpio, template->name);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
led_dat->cdev.name = template->name;
|
led_dat->cdev.name = template->name;
|
||||||
led_dat->cdev.default_trigger = template->default_trigger;
|
led_dat->cdev.default_trigger = template->default_trigger;
|
||||||
led_dat->gpio = template->gpio;
|
led_dat->gpio = template->gpio;
|
||||||
@ -129,10 +125,12 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
|
|||||||
if (!template->retain_state_suspended)
|
if (!template->retain_state_suspended)
|
||||||
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
|
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
|
||||||
|
|
||||||
ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state);
|
ret = gpio_request_one(template->gpio,
|
||||||
|
GPIOF_DIR_OUT | (led_dat->active_low ^ state),
|
||||||
|
template->name);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
return ret;
|
||||||
|
|
||||||
INIT_WORK(&led_dat->work, gpio_led_work);
|
INIT_WORK(&led_dat->work, gpio_led_work);
|
||||||
|
|
||||||
ret = led_classdev_register(parent, &led_dat->cdev);
|
ret = led_classdev_register(parent, &led_dat->cdev);
|
||||||
|
Loading…
Reference in New Issue
Block a user