Skip to contentSkip to conversation

staging: comedi: drivers: replace init_timer by setup_timer

PATCH Superseded Aya Mahfouz 2 participants 3 messages Feb 18, 2015 Staging

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: comedi: drivers: replace init_timer by setup_timer

This patch replaces init_timer and 2 step initialization of function and data by setup_timer to make the code more concise using the following coccinelle script:

@@
expression ds, e1, e2;
@@

-init_timer (&ds);
+setup_timer (&ds, e1, e2);
...
-ds.function = e1;
...
-ds.data = e2;

---
v2: changed commit message and picked Julia'a ack

 drivers/staging/comedi/drivers/comedi_test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers/comedi_test.c +2 -3
index e56525a..fbc4342 100644
@@ -420,9 +420,8 @@ static int waveform_attach(struct comedi_device *dev,
 	for (i = 0; i < s->n_chan; i++)
 		devpriv->ao_loopbacks[i] = s->maxdata / 2;
 
-	init_timer(&devpriv->timer);
-	devpriv->timer.function = waveform_ai_interrupt;
-	devpriv->timer.data = (unsigned long)dev;
+	setup_timer(&devpriv->timer, waveform_ai_interrupt,
+		    (unsigned long)dev);
 
 	dev_info(dev->class_dev,
 		 "%s: %i microvolt, %li microsecond waveform attached\n",
Signature · 1 line
1.9.3
#1 lore raw
Quoted 16 lines · Aya Mahfouz

This patch replaces init_timer and 2 step initialization of function and data by setup_timer to make the code more concise using the following coccinelle script:

@@
expression ds, e1, e2;
@@

(quoted diff) +1 -3
-init_timer (&ds);
+setup_timer (&ds, e1, e2);
...
-ds.function = e1;
...
-ds.data = e2;
Quoted 4 lines

---
v2: changed commit message and picked Julia'a ack

Looks good to me - the only minor issue is the commit message. I would make it say:

"
This patch replaces init_timer and 2 step initialization of function and data by setup_timer to make the code more concise.

The issue was discovered using the following coccinelle script:
"

Cheers,
Jes

Quoted 20 lines
 drivers/staging/comedi/drivers/comedi_test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers/comedi_test.c +2 -3
index e56525a..fbc4342 100644
@@ -420,9 +420,8 @@ static int waveform_attach(struct comedi_device *dev,
 	for (i = 0; i < s->n_chan; i++)
 		devpriv->ao_loopbacks[i] = s->maxdata / 2;
 
-	init_timer(&devpriv->timer);
-	devpriv->timer.function = waveform_ai_interrupt;
-	devpriv->timer.data = (unsigned long)dev;
+	setup_timer(&devpriv->timer, waveform_ai_interrupt,
+		    (unsigned long)dev);
 
 	dev_info(dev->class_dev,
 		 "%s: %i microvolt, %li microsecond waveform attached\n",
#2 lore raw
Quoted 29 lines · Jes Sorensen
Quoted 16 lines · Aya Mahfouz

This patch replaces init_timer and 2 step initialization of function and data by setup_timer to make the code more concise using the following coccinelle script:

@@
expression ds, e1, e2;
@@

(quoted diff) +1 -3
-init_timer (&ds);
+setup_timer (&ds, e1, e2);
...
-ds.function = e1;
...
-ds.data = e2;
Quoted 4 lines

---
v2: changed commit message and picked Julia'a ack

Looks good to me - the only minor issue is the commit message. I would make it say:

"
This patch replaces init_timer and 2 step initialization of function and data by setup_timer to make the code more concise.

Quoted 6 lines

The issue was discovered using the following coccinelle script:
"

Cheers,
Jes

Thanks will do!

Kind Regards,
Aya Saif El-yazal Mahfouz

Quoted 21 lines
Quoted 20 lines
 drivers/staging/comedi/drivers/comedi_test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers/comedi_test.c +2 -3
index e56525a..fbc4342 100644
@@ -420,9 +420,8 @@ static int waveform_attach(struct comedi_device *dev,
 	for (i = 0; i < s->n_chan; i++)
 		devpriv->ao_loopbacks[i] = s->maxdata / 2;
 
-	init_timer(&devpriv->timer);
-	devpriv->timer.function = waveform_ai_interrupt;
-	devpriv->timer.data = (unsigned long)dev;
+	setup_timer(&devpriv->timer, waveform_ai_interrupt,
+		    (unsigned long)dev);
 
 	dev_info(dev->class_dev,
 		 "%s: %i microvolt, %li microsecond waveform attached\n",