From: Lee Jones <lee.jones@linaro.org>
To: Jingoo Han <jg1.han@samsung.com>
Cc: "'Rickard Strandqvist'" <rickard_strandqvist@spectrumdigital.se>,
"'Bryan Wu'" <cooloney@gmail.com>,
"'Jean-Christophe Plagniol-Villard'" <plagnioj@jcrosoft.com>,
"'Tomi Valkeinen'" <tomi.valkeinen@ti.com>,
"'Linux Fbdev development list'" <linux-fbdev@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] video: backlight: jornada720_lcd.c: Cleaning up variable that is never used
Date: Thu, 10 Jul 2014 08:40:01 +0100 [thread overview]
Message-ID: <20140710074001.GP2635@lee--X1> (raw)
In-Reply-To: <003001cf9be6$b45cfcd0$1d16f670$%han@samsung.com>
On Thu, 10 Jul 2014, Jingoo Han wrote:
> On Thursday, July 10, 2014 7:08 AM, Rickard Strandqvist wrote:
> > 2014-07-09 18:30 GMT+02:00 Lee Jones <lee.jones@linaro.org>:
> > > On Mon, 07 Jul 2014, Rickard Strandqvist wrote:
> > >
> > >> Variable ar assigned a value that is never used.
> > >> I have also removed all the code that thereby serves no purpose,
> > >> and made same change to clarify the similarities in function.
> > >>
> > >> This was found using a static code analysis program called cppcheck
> > >>
> > >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> > >> ---
> > >> drivers/video/backlight/jornada720_lcd.c | 31 ++++++++++++++----------------
> > >> 1 file changed, 14 insertions(+), 17 deletions(-)
> > >>
> > >> diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c
> > >> index da3876c..d16abcf 100644
> > >> --- a/drivers/video/backlight/jornada720_lcd.c
> > >> +++ b/drivers/video/backlight/jornada720_lcd.c
> > >> @@ -36,44 +36,41 @@ static int jornada_lcd_get_power(struct lcd_device *ld)
> > >>
> > >> static int jornada_lcd_get_contrast(struct lcd_device *ld)
> > >> {
> > >> - int ret;
> > >> + int ret = -ETIMEDOUT;
> > >>
> > >> if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
> > >> return 0;
> > >>
> > >> jornada_ssp_start();
> > >>
> > >> - if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
> > >> + if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY)
> > >> dev_err(&ld->dev, "get contrast failed\n");
> > >> - jornada_ssp_end();
> > >> - return -ETIMEDOUT;
> > >> - } else {
> > >> + else
> > >> ret = jornada_ssp_byte(TXDUMMY);
> > >> - jornada_ssp_end();
> > >> - return ret;
> > >> - }
> > >> +
> > >> + jornada_ssp_end();
> > >> +
> > >> + return ret;
> > >> }
> > >>
> > >> static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> > >> {
> > >> - int ret;
> > >> + int ret = -ETIMEDOUT;
> > >>
> > >> jornada_ssp_start();
> > >>
> > >> /* start by sending our set contrast cmd to mcu */
> > >> - ret = jornada_ssp_byte(SETCONTRAST);
> > >> -
> > >> + if (jornada_ssp_byte(SETCONTRAST) != TXDUMMY)
> > >> + dev_err(&ld->dev, "set contrast failed\n");
> > >> /* push the new value */
> > >> - if (jornada_ssp_byte(value) != TXDUMMY) {
> > >> + else if (jornada_ssp_byte(value) != TXDUMMY)
> > >> dev_err(&ld->dev, "set contrast failed\n");
> > >> - jornada_ssp_end();
> > >> - return -ETIMEDOUT;
> > >> - }
> > >> + else /* if we get here we can assume everything went well */
> > >> + ret = 0;
> > >>
> > >> - /* if we get here we can assume everything went well */
> > >> jornada_ssp_end();
> > >>
> > >> - return 0;
> > >> + return ret;
> > >> }
> > >>
> > >> static int jornada_lcd_set_power(struct lcd_device *ld, int power)
> > >
> > > Counter suggestion.
> > >
> > > What do you think, I think this looks cleaner:
> > >
> > > static int jornada_lcd_get_contrast(struct lcd_device *ld)
> > > {
> > > int ret;
> > >
> > > if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
> > > return 0;
> > >
> > > jornada_ssp_start();
> > >
> > > if (jornada_ssp_byte(GETCONTRAST) == TXDUMMY) {
> > > ret = jornada_ssp_byte(TXDUMMY);
> > > goto success;
> > > }
> > >
> > > dev_err(&ld->dev, "failed to set contrast\n");
> > > ret = -ETIMEDOUT;
> > >
> > > success:
> > > jornada_ssp_end();
> > > return ret;
> > > }
> > >
> > > static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> > > {
> > > int ret = 0;
> > >
> > > jornada_ssp_start();
> > >
> > > /* start by sending our set contrast cmd to mcu */
> > > if (jornada_ssp_byte(SETCONTRAST) == TXDUMMY) {
> > > /* if successful, push the new value */
> > > if (jornada_ssp_byte(value) == TXDUMMY)
> > > goto success;
> > > }
> > >
> > > dev_err(&ld->dev, "failed to set contrast\n");
> > > ret = -ETIMEDOUT;
> > >
> > > success:
> > > jornada_ssp_end();
> > > return ret;
> > > }
> >
> >
> > Hi Lee!
> >
> > Yes, I agree!
> > Both are clean without so much repetition of code, which was what annoyd me.
> > But yours is clearer when things go good or bad, nice 1 ;)
>
> Hi Rickard Strandqvist,
>
> I would liked to prefer Lee Jones's code. It looks cleaner.
>
> >
> > I do not know what I can/may do, but I'll try. Remove what is not ok :-)
> >
> > Reviewed-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> > Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>
> I suggest the following.
>
> Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Acked-by: Jingoo Han <jg1.han@samsung.com>
> Cc: Bryan Wu <cooloney@gmail.com>
Very well, I will submit as a patch with Jingoo's Ack and Rickard's
Suggested-by and Reviewed-by. Is anyone able to test this patch?
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2014-07-10 7:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 20:01 [PATCH] video: backlight: jornada720_lcd.c: Cleaning up variable that is never used Rickard Strandqvist
2014-07-09 16:30 ` Lee Jones
2014-07-09 22:08 ` Rickard Strandqvist
2014-07-10 2:28 ` Jingoo Han
2014-07-10 7:40 ` Lee Jones [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-07-06 18:21 Rickard Strandqvist
2014-07-07 10:46 ` Lee Jones
2014-07-07 20:00 ` Rickard Strandqvist
2014-07-05 12:12 Rickard Strandqvist
2014-07-07 10:50 ` Lee Jones
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=20140710074001.GP2635@lee--X1 \
--to=lee.jones@linaro.org \
--cc=cooloney@gmail.com \
--cc=jg1.han@samsung.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=plagnioj@jcrosoft.com \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=tomi.valkeinen@ti.com \
/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