leds: leds-ns2: 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
507d967bc1
commit
31c3dc7488
1 changed files with 7 additions and 14 deletions
|
@ -191,25 +191,18 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
|
||||||
int ret;
|
int ret;
|
||||||
enum ns2_led_modes mode;
|
enum ns2_led_modes mode;
|
||||||
|
|
||||||
ret = gpio_request(template->cmd, template->name);
|
ret = gpio_request_one(template->cmd,
|
||||||
if (ret == 0) {
|
GPIOF_DIR_OUT | gpio_get_value(template->cmd),
|
||||||
ret = gpio_direction_output(template->cmd,
|
template->name);
|
||||||
gpio_get_value(template->cmd));
|
|
||||||
if (ret)
|
|
||||||
gpio_free(template->cmd);
|
|
||||||
}
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "%s: failed to setup command GPIO\n",
|
dev_err(&pdev->dev, "%s: failed to setup command GPIO\n",
|
||||||
template->name);
|
template->name);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpio_request(template->slow, template->name);
|
ret = gpio_request_one(template->slow,
|
||||||
if (ret == 0) {
|
GPIOF_DIR_OUT | gpio_get_value(template->slow),
|
||||||
ret = gpio_direction_output(template->slow,
|
template->name);
|
||||||
gpio_get_value(template->slow));
|
|
||||||
if (ret)
|
|
||||||
gpio_free(template->slow);
|
|
||||||
}
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n",
|
dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n",
|
||||||
template->name);
|
template->name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue