From: gnomes@lxorguk.ukuu.org.uk (One Thousand Gnomes)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] watchdog: bcm281xx: Watchdog Driver
Date: Tue, 12 Nov 2013 23:39:11 +0000 [thread overview]
Message-ID: <20131112233911.16eba130@alan.etchedpixels.co.uk> (raw)
In-Reply-To: <1383943488-6537-2-git-send-email-markus.mayer@linaro.org>
> +static int bcm_kona_wdt_set_resolution_reg(struct bcm_kona_wdt *wdt)
> +{
> + uint32_t val;
> + int timeout;
> + unsigned long flags;
> + int ret = 0;
> +
> + if (wdt->resolution > SECWDOG_MAX_RES)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wdt->lock, flags);
> +
> + val = secure_register_read(wdt->base + SECWDOG_CTRL_REG, &timeout);
> + if (!timeout) {
> + val &= ~SECWDOG_RES_MASK;
> + val |= wdt->resolution << SECWDOG_CLKS_SHIFT;
> + writel_relaxed(val, wdt->base + SECWDOG_CTRL_REG);
> + } else {
> + ret = -EAGAIN;
This is I think the wrong choice of return. If the register fails to read
then presumably the device is b*ggered ? In which case return something
like -EIO and log something nasty.
EAGAIN has fairly specific semantics around signals and/or specific
requests for an I/O operation not to wait.
> + spin_lock_irqsave(&wdt->lock, flags);
> +
> + val = secure_register_read(wdt->base + SECWDOG_CTRL_REG, &timeout);
> + if (!timeout) {
> + val &= ~SECWDOG_COUNT_MASK;
> + val |= SECS_TO_TICKS(wdog->timeout, wdt);
> + writel_relaxed(val, wdt->base + SECWDOG_CTRL_REG);
> + } else {
> + ret = -EAGAIN;
> + }
> +
> + spin_unlock_irqrestore(&wdt->lock, flags);
As an aside you could fold most of these functions into one single helper
method that read CTRL_REG, did the and and or and wrote the result back
rather than repeating yourself. But hey if you like typing...
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
What if there is no resource present ?
> + dev_info(dev, "Broadcom Kona Watchdog Timer");
The module load succeeded - the user knows it loaded from that. Likewise
the unload spewage is unwanted and the kernel would just drown in such
messages if we didn't keep them in check. If you need the for debug then
mark them dev_dbg but otherwise bin them.
Alan
next prev parent reply other threads:[~2013-11-12 23:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 20:44 [PATCH 0/2] watchdog: bcm281xx: Watchdog Driver Markus Mayer
2013-11-08 20:44 ` [PATCH 1/2] " Markus Mayer
2013-11-11 17:34 ` Guenter Roeck
2013-11-12 22:17 ` Markus Mayer
2013-11-13 4:00 ` Guenter Roeck
2013-11-12 23:39 ` One Thousand Gnomes [this message]
2013-11-13 0:08 ` Markus Mayer
2013-11-08 20:44 ` [PATCH 2/2] ARM: bcm281xx: watchdog configuration Markus Mayer
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=20131112233911.16eba130@alan.etchedpixels.co.uk \
--to=gnomes@lxorguk.ukuu.org.uk \
--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).