From: Bryan Wu <cooloney@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Richard Purdie <rpurdie@rpsys.net>,
kernel@pengutronix.de,
Linux LED Subsystem <linux-leds@vger.kernel.org>,
Alexandre Courbot <acourbot@nvidia.com>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] leds: lp8860: make use of devm_gpiod_get_optional
Date: Mon, 2 Mar 2015 14:32:42 -0800 [thread overview]
Message-ID: <CAK5ve-KLgao-7duD9eMJ4D9xpaJWnBot1hij83qgdr_gcExLEw@mail.gmail.com> (raw)
In-Reply-To: <1425245147-3521-1-git-send-email-u.kleine-koenig@pengutronix.de>
On Sun, Mar 1, 2015 at 1:25 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> 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.
>
Thanks, I merged this into my tree.
-Bryan
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/leds/leds-lp8860.c | 12 +++++++-----
> 1 file 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,
> }
> }
>
> - led->enable_gpio = devm_gpiod_get(&client->dev, "enable");
> - if (IS_ERR(led->enable_gpio))
> - led->enable_gpio = NULL;
> - else
> - gpiod_direction_output(led->enable_gpio, 0);
> + led->enable_gpio = devm_gpiod_get_optional(&client->dev,
> + "enable", GPIOD_OUT_LOW);
> + if (IS_ERR(led->enable_gpio)) {
> + ret = PTR_ERR(led->enable_gpio);
> + dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);
> + return ret;
> + }
>
> led->regulator = devm_regulator_get(&client->dev, "vled");
> if (IS_ERR(led->regulator))
> --
> 2.1.4
>
prev parent reply other threads:[~2015-03-02 22:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-01 21:25 [PATCH] leds: lp8860: make use of devm_gpiod_get_optional Uwe Kleine-König
2015-03-02 22:32 ` Bryan Wu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAK5ve-KLgao-7duD9eMJ4D9xpaJWnBot1hij83qgdr_gcExLEw@mail.gmail.com \
--to=cooloney@gmail.com \
--cc=acourbot@nvidia.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-leds@vger.kernel.org \
--cc=rpurdie@rpsys.net \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).