mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: i4l: pcbit: drv: use setup_timer() and mod_timer().
@ 2016-05-11 13:54 Muhammad Falak R Wani
  2016-05-11 13:55 ` [PATCH 2/3] staging: i4l: pcbit: edss1: " Muhammad Falak R Wani
  2016-05-11 13:55 ` [PATCH 3/3] staging: i4l: pcbit: layer2: " Muhammad Falak R Wani
  0 siblings, 2 replies; 3+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-11 13:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Karsten Keil, Arnd Bergmann, devel, linux-kernel

Use setup_timer() instead of init_timer(), being the preferred/standard
way to set a timer up.

Also, quoting the mod_timer() function comment:
-> mod_timer() is a more efficient way to update the expire field of an
   active timer (if the timer is inactive it will be activated).

Use setup_timer and mod_timer to setup and arm a timer, to make the code
cleaner and easier to read.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
 drivers/staging/i4l/pcbit/drv.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/i4l/pcbit/drv.c b/drivers/staging/i4l/pcbit/drv.c
index c5270e2..d417df5 100644
--- a/drivers/staging/i4l/pcbit/drv.c
+++ b/drivers/staging/i4l/pcbit/drv.c
@@ -359,11 +359,9 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb)
 		 */
 #ifdef BLOCK_TIMER
 		if (chan->block_timer.function == NULL) {
-			init_timer(&chan->block_timer);
-			chan->block_timer.function =  &pcbit_block_timer;
-			chan->block_timer.data = (long) chan;
-			chan->block_timer.expires = jiffies + 1 * HZ;
-			add_timer(&chan->block_timer);
+			setup_timer(&chan->block_timer, &pcbit_block_timer,
+				    (long)chan);
+			mod_timer(&chan->block_timer, jiffies + 1 * HZ);
 		}
 #endif
 		return 0;
@@ -804,11 +802,7 @@ static int set_protocol_running(struct pcbit_dev *dev)
 {
 	isdn_ctrl ctl;
 
-	init_timer(&dev->set_running_timer);
-
-	dev->set_running_timer.function = &set_running_timeout;
-	dev->set_running_timer.data = (ulong) dev;
-	dev->set_running_timer.expires = jiffies + SET_RUN_TIMEOUT;
+	setup_timer(&dev->set_running_timer, &set_running_timeout, (ulong)dev);
 
 	/* kick it */
 
@@ -817,7 +811,7 @@ static int set_protocol_running(struct pcbit_dev *dev)
 	writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)),
 	       dev->sh_mem + BANK4);
 
-	add_timer(&dev->set_running_timer);
+	mod_timer(&dev->set_running_timer, jiffies + SET_RUN_TIMEOUT);
 
 	wait_event(dev->set_running_wq, dev->l2_state == L2_RUNNING ||
 					dev->l2_state == L2_DOWN);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] staging: i4l: pcbit: edss1: use setup_timer() and mod_timer().
  2016-05-11 13:54 [PATCH 1/3] staging: i4l: pcbit: drv: use setup_timer() and mod_timer() Muhammad Falak R Wani
@ 2016-05-11 13:55 ` Muhammad Falak R Wani
  2016-05-11 13:55 ` [PATCH 3/3] staging: i4l: pcbit: layer2: " Muhammad Falak R Wani
  1 sibling, 0 replies; 3+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-11 13:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Karsten Keil, Arnd Bergmann, devel, linux-kernel

Use setup_timer() instead of init_timer(), being the preferred/standard
way to set a timer up.

Also, quoting the mod_timer() function comment:
-> mod_timer() is a more efficient way to update the expire field of an
   active timer (if the timer is inactive it will be activated).

Use setup_timer and mod_timer to setup and arm a timer, to make the code
cleaner and easier to read.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
 drivers/staging/i4l/pcbit/edss1.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/i4l/pcbit/edss1.c b/drivers/staging/i4l/pcbit/edss1.c
index e72c164..6d291d5 100644
--- a/drivers/staging/i4l/pcbit/edss1.c
+++ b/drivers/staging/i4l/pcbit/edss1.c
@@ -298,11 +298,8 @@ void pcbit_fsm_event(struct pcbit_dev *dev, struct pcbit_chan *chan,
 			break;
 
 	if (tentry->init != 0xff) {
-		init_timer(&chan->fsm_timer);
-		chan->fsm_timer.function = &pcbit_fsm_timer;
-		chan->fsm_timer.data = (ulong) chan;
-		chan->fsm_timer.expires = jiffies + tentry->timeout * HZ;
-		add_timer(&chan->fsm_timer);
+		setup_timer(&chan->fsm_timer, &pcbit_fsm_timer, (ulong)chan);
+		mod_timer(&chan->fsm_timer, jiffies + tentry->timeout * HZ);
 	}
 
 	spin_unlock_irqrestore(&dev->lock, flags);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] staging: i4l: pcbit: layer2: use setup_timer() and mod_timer().
  2016-05-11 13:54 [PATCH 1/3] staging: i4l: pcbit: drv: use setup_timer() and mod_timer() Muhammad Falak R Wani
  2016-05-11 13:55 ` [PATCH 2/3] staging: i4l: pcbit: edss1: " Muhammad Falak R Wani
@ 2016-05-11 13:55 ` Muhammad Falak R Wani
  1 sibling, 0 replies; 3+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-11 13:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Karsten Keil, Arnd Bergmann, devel, linux-kernel

Use setup_timer() instead of init_timer(), being the preferred/standard
way to set a timer up.

Also, quoting the mod_timer() function comment:
-> mod_timer() is a more efficient way to update the expire field of an
   active timer (if the timer is inactive it will be activated).

Use setup_timer and mod_timer to setup and arm a timer, to make the code
cleaner and easier to read.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
 drivers/staging/i4l/pcbit/layer2.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/i4l/pcbit/layer2.c b/drivers/staging/i4l/pcbit/layer2.c
index 46e1240..a136c72 100644
--- a/drivers/staging/i4l/pcbit/layer2.c
+++ b/drivers/staging/i4l/pcbit/layer2.c
@@ -645,11 +645,9 @@ pcbit_l2_error(struct pcbit_dev *dev)
 
 		dev->l2_state = L2_DOWN;
 
-		init_timer(&dev->error_recover_timer);
-		dev->error_recover_timer.function = &pcbit_l2_err_recover;
-		dev->error_recover_timer.data = (ulong) dev;
-		dev->error_recover_timer.expires = jiffies + ERRTIME;
-		add_timer(&dev->error_recover_timer);
+		setup_timer(&dev->error_recover_timer, &pcbit_l2_err_recover,
+			    (ulong)dev);
+		mod_timer(&dev->error_recover_timer, jiffies + ERRTIME);
 	}
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-11 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 13:54 [PATCH 1/3] staging: i4l: pcbit: drv: use setup_timer() and mod_timer() Muhammad Falak R Wani
2016-05-11 13:55 ` [PATCH 2/3] staging: i4l: pcbit: edss1: " Muhammad Falak R Wani
2016-05-11 13:55 ` [PATCH 3/3] staging: i4l: pcbit: layer2: " Muhammad Falak R Wani

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®