From: "Oskar Schirmer" <oskar@scara.com>
To: "Wolfram Sang" <w.sang@pengutronix.de>
Cc: "Oskar Schirmer" <oskar@scara.com>,
wim@iguana.be, s.hauer@pengutronix.de,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: make imx2_wdt report boot status correctly
Date: 16 Feb 2012 14:17:07 +0000 [thread overview]
Message-ID: <20120216141707.GA8647@curry> (raw)
In-Reply-To: <20120216133510.GA2541@pengutronix.de>
Hi Wolfram,
On Thu, Feb 16, 2012 at 14:35:10 +0100, Wolfram Sang wrote:
> besides this minor thing (which may be just personal taste)...
>
> > + case WDIOC_GETBOOTSTATUS:
> > + val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
> > + new_value = 0;
> > + if (val & IMX2_WDT_WRSR_TOUT)
> > + new_value = WDIOF_CARDRESET;
>
> I'd go for this to save some lines:
> new_value = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
A good alternative for sure.
Seen from the perspective of code compactness ("save some lines"),
one could try to be consequent here, and save the "val" variable
altogether, ending up with some "new_value = __raw_readw ... & ... ? ... : 0;"
But eventually there might be code readability issues, so it's
a good idea to keep the balance.
An argument for the original, longer version might be it is easier
to extend, when more flags need to be handled, like
"else if (val & ...) new_value = ...", while nested conditional
expressions would most likely become quite complex soon.
Actually, my personal taste doesn't show a preference for
one version or the other, so I'm ok with Your proposal, too.
Oskar
next prev parent reply other threads:[~2012-02-16 14:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 12:17 [PATCH] watchdog: make imx2_wdt report boot status correctly Oskar Schirmer
2012-02-16 13:35 ` Wolfram Sang
2012-02-16 14:17 ` Oskar Schirmer [this message]
2012-02-16 14:23 ` Wolfram Sang
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=20120216141707.GA8647@curry \
--to=oskar@scara.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=w.sang@pengutronix.de \
--cc=wim@iguana.be \
/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