From: Ian Abbott <abbotti@mev.co.uk>
To: linux-watchdog@vger.kernel.org
Cc: Wim Van Sebroeck <wim@iguana.be>,
linux-kernel@vger.kernel.org, Ian Abbott <abbotti@mev.co.uk>
Subject: [PATCH 1/5] watchdog: dw_wdt: prepare for more atomic bits
Date: Fri, 26 Jun 2015 14:21:09 +0100 [thread overview]
Message-ID: <1435324873-18318-2-git-send-email-abbotti@mev.co.uk> (raw)
In-Reply-To: <1435324873-18318-1-git-send-email-abbotti@mev.co.uk>
Bit 0 of `dw_wdt.in_use` is tested and set atomically to indicate that
the watchdog has been opened exclusively. The other bits are unused.
Some parts of the code also treat the whole of the `in_use` member as a
boolean value.
In preparation for making use of the unused bits, rename the `in_use`
member to `state`, define a new macro `DW_WDT_IN_USE` to identify bit 0
as the "in-use" bit, and replace conditional tests on the whole of
`in_use` with single-bit tests on the appropriate bit of `state`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
drivers/watchdog/dw_wdt.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 6ea0634..249ef09 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -59,10 +59,13 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
#define WDT_TIMEOUT (HZ / 2)
+/* dw_wdt.state bit numbers */
+#define DW_WDT_IN_USE 0
+
static struct {
void __iomem *regs;
struct clk *clk;
- unsigned long in_use;
+ unsigned long state;
unsigned long next_heartbeat;
struct timer_list timer;
int expect_close;
@@ -160,7 +163,7 @@ static int dw_wdt_restart_handle(struct notifier_block *this,
static void dw_wdt_ping(unsigned long data)
{
if (time_before(jiffies, dw_wdt.next_heartbeat) ||
- (!nowayout && !dw_wdt.in_use)) {
+ (!nowayout && !test_bit(DW_WDT_IN_USE, &dw_wdt.state))) {
dw_wdt_keepalive();
mod_timer(&dw_wdt.timer, jiffies + WDT_TIMEOUT);
} else
@@ -169,7 +172,7 @@ static void dw_wdt_ping(unsigned long data)
static int dw_wdt_open(struct inode *inode, struct file *filp)
{
- if (test_and_set_bit(0, &dw_wdt.in_use))
+ if (test_and_set_bit(DW_WDT_IN_USE, &dw_wdt.state))
return -EBUSY;
/* Make sure we don't get unloaded. */
@@ -273,7 +276,7 @@ static long dw_wdt_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
static int dw_wdt_release(struct inode *inode, struct file *filp)
{
- clear_bit(0, &dw_wdt.in_use);
+ clear_bit(DW_WDT_IN_USE, &dw_wdt.state);
if (!dw_wdt.expect_close) {
del_timer(&dw_wdt.timer);
--
2.1.4
next prev parent reply other threads:[~2015-06-26 13:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 13:21 [PATCH 0/5] watchdog: dw_wdt: allow only one probe + various fixes Ian Abbott
2015-06-26 13:21 ` Ian Abbott [this message]
2015-06-26 13:21 ` [PATCH 2/5] watchdog: dw_wdt: reject additional device probes Ian Abbott
2015-06-26 13:21 ` [PATCH 3/5] watchdog: dw_wdt: only unregister restart handler if registered Ian Abbott
2015-06-26 13:21 ` [PATCH 4/5] watchdog: dw_wdt: unqueue timer on device removal Ian Abbott
2015-06-26 13:21 ` [PATCH 5/5] watchdog: dw_wdt: unqueue timer synchronously on unexpected close Ian Abbott
2015-06-26 13:54 ` [PATCH 0/5] watchdog: dw_wdt: allow only one probe + various fixes Guenter Roeck
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=1435324873-18318-2-git-send-email-abbotti@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--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
all inboxes | Powered by JetHome®