From: damien.riegel@savoirfairelinux.com (Damien Riegel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/5] watchdog: ts4800: add driver for TS-4800 watchdog
Date: Mon, 23 Nov 2015 21:55:45 -0500 [thread overview]
Message-ID: <20151124025544.GA5743@localhost> (raw)
In-Reply-To: <5653CC2F.8080608@roeck-us.net>
On Mon, Nov 23, 2015 at 06:32:15PM -0800, Guenter Roeck wrote:
> Hi Damien,
>
> On 11/23/2015 07:17 AM, Damien Riegel wrote:
> >This watchdog is instantiated in a FPGA that is memory mapped. It is
> >made of only one register, called the feed register. Writing to this
> >register will re-arm the watchdog for a given time (and enable it if it
> >was disable). It can be disabled by writing a special value into it.
> >
> >It is part of a syscon block, and the watchdog register offset in this
> >block varies from board to board. This offset is passed in the syscon
> >property after the phandle to the syscon node.
> >
> >Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> >---
>
> [ ... ]
>
> >+
> >+static int ts4800_wdt_set_timeout(struct watchdog_device *wdd,
> >+ unsigned int timeout)
> >+{
> >+ struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
> >+ int i;
> >+
> >+ for (i = 0; i <= MAX_TIMEOUT_INDEX; i++) {
> >+ if (ts4800_wdt_map[i].timeout >= timeout)
> >+ break;
> >+ }
>
> If the loop does not break, i will have a value of MAX_TIMEOUT_INDEX + 1,
> or 2, pointing after the end of the table. That should never happen,
> but still ...
That should never happen, but indeed it's not very elegant. I will
change that.
>
> I preferred the earlier version, where you had an extra function.
As I have to set both wdd->timeout and wdt->feed_val, I found it easier
and shorter to iterate directly in the set_timeout function.
> Only my suggestion was to have that function return MAX_TIMEOUT_INDEX
> instead of an error. Alternatively, the check above needs to be
> "i < MAX_TIMEOUT_INDEX".
That would be a strange stop condition. Would this construct be ok for
you:
for (i = 0; i < ARRAY_SIZE(ts4800_wdt_map; i++) {
if (ts4800_wdt_map[i].timeout >= timeout)
break;
}
if (i >= ARRAY_SIZE(ts4800_wdt_map)
i = MAX_TIMEOUT_INDEX;
Thanks,
Damien
next prev parent reply other threads:[~2015-11-24 2:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 15:17 [PATCH v4 0/5] Add board support for TS-4800 Damien Riegel
2015-11-23 15:17 ` [PATCH v4 1/5] of: add vendor prefix for Technologic Systems Damien Riegel
2015-11-23 15:17 ` [PATCH v4 2/5] mfd: syscon: add a DT property to set value width Damien Riegel
2015-11-23 15:19 ` Arnd Bergmann
2015-11-24 8:20 ` Lee Jones
2015-11-24 16:24 ` Damien Riegel
2015-11-24 17:22 ` Lee Jones
2015-11-24 17:23 ` Lee Jones
2015-11-23 15:17 ` [PATCH v4 3/5] watchdog: ts4800: add driver for TS-4800 watchdog Damien Riegel
2015-11-24 2:32 ` Guenter Roeck
2015-11-24 2:55 ` Damien Riegel [this message]
2015-11-23 15:17 ` [PATCH v4 4/5] ARM: imx_v6_v7_defconfig: add " Damien Riegel
2015-11-23 15:17 ` [PATCH v4 5/5] ARM: dts: TS-4800: add basic device tree Damien Riegel
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=20151124025544.GA5743@localhost \
--to=damien.riegel@savoirfairelinux.com \
--cc=linux-arm-kernel@lists.infradead.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).