From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 3/5] fbdev: omap2: panel-dpi: drop assignment to local variable
Date: Wed, 16 Dec 2015 17:29:17 +0000 [thread overview]
Message-ID: <56719F6D.3060800@ti.com> (raw)
In-Reply-To: <1449753107-11410-3-git-send-email-uwe@kleine-koenig.org>
[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]
On 10/12/15 15:11, Uwe Kleine-König wrote:
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>
> The variable gpio is only used to store the return value of
> devm_gpiod_get_optional just to assign it to a member of the driver
> data.
>
> Get rid of this local variable and assign to driver data directly.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/video/fbdev/omap2/displays-new/panel-dpi.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
> index e780fd4f8b46..1216341a0d19 100644
> --- a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
> +++ b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
> @@ -205,13 +205,11 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
> int r;
> struct display_timing timing;
> struct videomode vm;
> - struct gpio_desc *gpio;
>
> - gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW);
> - if (IS_ERR(gpio))
> - return PTR_ERR(gpio);
> -
> - ddata->enable_gpio = gpio;
> + ddata->enable_gpio = devm_gpiod_get_optional(&pdev->dev,
> + "enable", GPIOD_OUT_LOW);
> + if (IS_ERR(ddata->enable_gpio))
> + return PTR_ERR(ddata->enable_gpio);
>
> ddata->backlight_gpio = -ENOENT;
I usually try to avoid writing bad values to fields. Here
ddata->enable_gpio may get an error ptr. It probably doesn't matter as
we bail out right away, but still. If devm_gpiod_get_optional's return
value would be NULL or valid gpio_desc*, then it'd be fine.
And the code is shorter (more readable) when using just "gpio" instead
of "ddata->enable_gpio".
So I'll leave this one out.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-12-16 17:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 13:11 [PATCH 3/5] fbdev: omap2: panel-dpi: drop assignment to local variable Uwe Kleine-König
2015-12-16 17:29 ` Tomi Valkeinen [this message]
2015-12-20 10:31 ` Uwe Kleine-König
2015-12-22 8:56 ` Tomi Valkeinen
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=56719F6D.3060800@ti.com \
--to=tomi.valkeinen@ti.com \
--cc=linux-fbdev@vger.kernel.org \
/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).