Staging: comedi: Use function setup_timer for combining initialization
authorSomya Anand <somyaanand214@gmail.com>
Wed, 11 Mar 2015 11:32:13 +0000 (17:02 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 15 Mar 2015 17:41:15 +0000 (18:41 +0100)
The function setup_timer combines the initialization of a timer with the
initialization of the timer's function and data fields.

So, this patch combines the multiline code for timer initialization using the function
setup_timer. This issue is identified via coccinelle script.

@@
expression E1, E2, E3;
type T;
@@
- init_timer(&E1);
...
(
- E1.function = E2;
...
- E1.data = (T)E3;
+ setup_timer(&E1, E2, (T)E3);
|
- E1.data = (T)E3;
...
- E1.function = E2;
+ setup_timer(&E1, E2, (T)E3);
|
- E1.function = E2;
+ setup_timer(&E1, E2, 0);
)

Signed-off-by: Somya Anand <somyaanand214@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/jr3_pci.c

index be6277ae4abc2018220bdda2b40152b384639367..f66db97b9d4fc97ae0e21eb62d06c9a41f93adda 100644 (file)
@@ -935,9 +935,8 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
        devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
                                           DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
        if (devpriv->dma) {
-               init_timer(&devpriv->timer);
-               devpriv->timer.function = das16_timer_interrupt;
-               devpriv->timer.data = (unsigned long)dev;
+               setup_timer(&devpriv->timer, das16_timer_interrupt,
+                           (unsigned long)dev);
        }
 }
 
index 81fab2dfafa43b3b277ff22945d7623115d92fb4..282c37f759d849644f6b04f67e7c4071e398920e 100644 (file)
@@ -706,8 +706,6 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
        if (!devpriv)
                return -ENOMEM;
 
-       init_timer(&devpriv->timer);
-
        ret = comedi_pci_enable(dev);
        if (ret)
                return ret;
@@ -775,8 +773,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
                spriv->next_time_max = jiffies + msecs_to_jiffies(2000);
        }
 
-       devpriv->timer.data = (unsigned long)dev;
-       devpriv->timer.function = jr3_pci_poll_dev;
+       setup_timer(&devpriv->timer, jr3_pci_poll_dev, (unsigned long)dev);
        devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
        add_timer(&devpriv->timer);