From: Christoph Hellwig <hch@lst.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Mark Gross <mark.gross@intel.com>, Tejun Heo <tj@kernel.org>,
linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 8/9] tlclk: switch switchover_timer to a modern timer
Date: Tue, 16 May 2017 13:48:11 +0200 [thread overview]
Message-ID: <20170516114812.10660-9-hch@lst.de> (raw)
In-Reply-To: <20170516114812.10660-1-hch@lst.de>
And remove a superflous double-initialization.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/char/tlclk.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 572a51704e67..7144016da82c 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -184,10 +184,14 @@ static unsigned int telclk_interrupt;
static int int_events; /* Event that generate a interrupt */
static int got_event; /* if events processing have been done */
-static void switchover_timeout(unsigned long data);
-static struct timer_list switchover_timer =
- TIMER_INITIALIZER(switchover_timeout , 0, 0);
-static unsigned long tlclk_timer_data;
+static void switchover_timeout(struct timer_list *timer);
+
+static struct switchover_timer {
+ struct timer_list timer;
+ unsigned long data;
+} switchover_timer = {
+ .timer = INIT_TIMER(switchover_timeout, 0, TIMER_DEFERRABLE),
+};
static struct tlclk_alarms *alarm_events;
@@ -805,8 +809,6 @@ static int __init tlclk_init(void)
goto out3;
}
- init_timer(&switchover_timer);
-
ret = misc_register(&tlclk_miscdev);
if (ret < 0) {
printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret);
@@ -850,25 +852,26 @@ static void __exit tlclk_cleanup(void)
unregister_chrdev(tlclk_major, "telco_clock");
release_region(TLCLK_BASE, 8);
- del_timer_sync(&switchover_timer);
+ del_timer_sync(&switchover_timer.timer);
kfree(alarm_events);
}
-static void switchover_timeout(unsigned long data)
+static void switchover_timeout(struct timer_list *timer)
{
- unsigned long flags = *(unsigned long *) data;
+ struct switchover_timer *s =
+ container_of(timer, struct switchover_timer, timer);
- if ((flags & 1)) {
- if ((inb(TLCLK_REG1) & 0x08) != (flags & 0x08))
+ if ((s->data & 1)) {
+ if ((inb(TLCLK_REG1) & 0x08) != (s->data & 0x08))
alarm_events->switchover_primary++;
} else {
- if ((inb(TLCLK_REG1) & 0x08) != (flags & 0x08))
+ if ((inb(TLCLK_REG1) & 0x08) != (s->data & 0x08))
alarm_events->switchover_secondary++;
}
/* Alarm processing is done, wake up read task */
- del_timer(&switchover_timer);
+ del_timer(&switchover_timer.timer);
got_event = 1;
wake_up(&wq);
}
@@ -920,10 +923,9 @@ static irqreturn_t tlclk_interrupt(int irq, void *dev_id)
alarm_events->pll_holdover++;
/* TIMEOUT in ~10ms */
- switchover_timer.expires = jiffies + msecs_to_jiffies(10);
- tlclk_timer_data = inb(TLCLK_REG1);
- switchover_timer.data = (unsigned long) &tlclk_timer_data;
- mod_timer(&switchover_timer, switchover_timer.expires);
+ switchover_timer.data = inb(TLCLK_REG1);
+ mod_timer(&switchover_timer.timer,
+ jiffies + msecs_to_jiffies(10));
} else {
got_event = 1;
wake_up(&wq);
--
2.11.0
next prev parent reply other threads:[~2017-05-16 11:48 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 11:48 RFC: better timer interface Christoph Hellwig
2017-05-16 11:48 ` [PATCH 1/9] timers: remove the fn and data arguments to call_timer_fn Christoph Hellwig
2017-05-16 11:48 ` [PATCH 2/9] timers: provide a "modern" variant of timers Christoph Hellwig
2017-05-16 19:29 ` Randy Dunlap
2017-05-16 20:03 ` Arnd Bergmann
2017-05-18 8:24 ` Christoph Hellwig
2017-05-18 8:41 ` Christoph Hellwig
2017-05-18 8:57 ` Arnd Bergmann
2017-05-21 7:00 ` Christoph Hellwig
2017-05-21 12:29 ` Arnd Bergmann
2017-05-21 17:57 ` Thomas Gleixner
2017-05-21 18:23 ` Al Viro
2017-05-19 10:48 ` David Laight
2017-05-21 6:57 ` 'Christoph Hellwig'
2017-05-16 11:48 ` [PATCH 3/9] kthread: remove unused macros Christoph Hellwig
2017-05-17 12:09 ` Petr Mladek
2017-05-18 8:22 ` Christoph Hellwig
2017-05-16 11:48 ` [PATCH 4/9] workqueue: switch to modern timers Christoph Hellwig
2017-05-16 11:48 ` [PATCH 5/9] powerpc/numa: switch topology_timer to modern timer Christoph Hellwig
2017-05-16 11:48 ` [PATCH 6/9] s390: switch topology_timer to a " Christoph Hellwig
2017-05-16 11:48 ` [PATCH 7/9] s390: switch lgr timer " Christoph Hellwig
2017-05-16 11:48 ` Christoph Hellwig [this message]
2017-05-16 11:48 ` [PATCH 9/9] timers: remove old timer initialization macros Christoph Hellwig
2017-05-16 19:43 ` Arnd Bergmann
2017-05-18 8:25 ` Christoph Hellwig
2017-05-16 15:45 ` RFC: better timer interface Arnd Bergmann
2017-05-16 15:51 ` Christoph Hellwig
2017-05-16 20:26 ` Arnd Bergmann
2017-05-18 8:27 ` Christoph Hellwig
2017-05-21 17:13 ` Thomas Gleixner
2017-05-21 18:14 ` Thomas Gleixner
2017-05-22 11:26 ` Arnd Bergmann
2017-05-22 19:24 ` Thomas Gleixner
2017-05-23 11:36 ` David Laight
2017-05-23 11:58 ` Thomas Gleixner
2017-05-23 12:51 ` David Laight
2017-05-23 13:02 ` Thomas Gleixner
2017-05-22 13:32 ` Arnd Bergmann
2017-05-22 19:14 ` Thomas Gleixner
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=20170516114812.10660-9-hch@lst.de \
--to=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.gross@intel.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.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).