Skip to content

Commit 81906c3

Browse files
aby0gregkh
authored andcommitted
Staging: comedi: Use function setup_timer for combining initialization
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6946edd commit 81906c3

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

drivers/staging/comedi/drivers/das16.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,9 +935,8 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
935935
devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
936936
DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
937937
if (devpriv->dma) {
938-
init_timer(&devpriv->timer);
939-
devpriv->timer.function = das16_timer_interrupt;
940-
devpriv->timer.data = (unsigned long)dev;
938+
setup_timer(&devpriv->timer, das16_timer_interrupt,
939+
(unsigned long)dev);
941940
}
942941
}
943942

drivers/staging/comedi/drivers/jr3_pci.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,6 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
706706
if (!devpriv)
707707
return -ENOMEM;
708708

709-
init_timer(&devpriv->timer);
710-
711709
ret = comedi_pci_enable(dev);
712710
if (ret)
713711
return ret;
@@ -775,8 +773,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
775773
spriv->next_time_max = jiffies + msecs_to_jiffies(2000);
776774
}
777775

778-
devpriv->timer.data = (unsigned long)dev;
779-
devpriv->timer.function = jr3_pci_poll_dev;
776+
setup_timer(&devpriv->timer, jr3_pci_poll_dev, (unsigned long)dev);
780777
devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
781778
add_timer(&devpriv->timer);
782779

0 commit comments

Comments
 (0)