aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-03-01 16:25:47 -0500
committerBryan Wu <cooloney@gmail.com>2015-03-02 16:29:33 -0500
commiteb2294c3432fb6366ec12b56a3b2a12cf4242b69 (patch)
treea7469f2814b60525e58088990fa4329fc31b7812
parent0cd1b0c3adaac2f9e8b5d2e739bf63a42fbf7ff2 (diff)
leds: lp8860: make use of devm_gpiod_get_optional
The probe function open coded a bad variant of devm_gpiod_get_optional using devm_gpiod_get and just ignoring all errors. In contrast to that devm_gpiod_get_optional returns NULL if there was no corresponding gpio specified in the device tree (or ACPI table) and fails if there is an error (or GPIOLIB is not enabled). Moreover since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output which allows some simplification. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r--drivers/leds/leds-lp8860.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c
index 840e93f3ab3e..f2a29c256d32 100644
--- a/drivers/leds/leds-lp8860.c
+++ b/drivers/leds/leds-lp8860.c
@@ -391,11 +391,13 @@ static int lp8860_probe(struct i2c_client *client,
391 } 391 }
392 } 392 }
393 393
394 led->enable_gpio = devm_gpiod_get(&client->dev, "enable"); 394 led->enable_gpio = devm_gpiod_get_optional(&client->dev,
395 if (IS_ERR(led->enable_gpio)) 395 "enable", GPIOD_OUT_LOW);
396 led->enable_gpio = NULL; 396 if (IS_ERR(led->enable_gpio)) {
397 else 397 ret = PTR_ERR(led->enable_gpio);
398 gpiod_direction_output(led->enable_gpio, 0); 398 dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);
399 return ret;
400 }
399 401
400 led->regulator = devm_regulator_get(&client->dev, "vled"); 402 led->regulator = devm_regulator_get(&client->dev, "vled");
401 if (IS_ERR(led->regulator)) 403 if (IS_ERR(led->regulator))