Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1736263 > unrolled thread

[PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional

Started byKees Cook <keescook@chromium.org>
First post2017-09-21 01:40 +0200
Last post2017-09-21 12:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional Kees Cook <keescook@chromium.org> - 2017-09-21 01:40 +0200
    Re: [PATCH v2 26/31] staging/comedi/das16: Make timer initialization  unconditional Ian Abbott <abbotti@mev.co.uk> - 2017-09-21 12:40 +0200

#1736263 — [PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional

FromKees Cook <keescook@chromium.org>
Date2017-09-21 01:40 +0200
Subject[PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional
Message-ID<urWL2-1k7-51@gated-at.bofh.it>
With timer initialization made unconditional, there is no reason to
make del_timer_sync() calls conditionally, there by removing the test
of the .data field.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/staging/comedi/drivers/das16.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 5d157951f63f..2b2a446af3f5 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -934,6 +934,9 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
 {
 	struct das16_private_struct *devpriv = dev->private;
 
+	setup_timer(&devpriv->timer, das16_timer_interrupt,
+		    (unsigned long)dev);
+
 	/* only DMA channels 3 and 1 are valid */
 	if (!(dma_chan == 1 || dma_chan == 3))
 		return;
@@ -941,10 +944,6 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
 	/* DMA uses two buffers */
 	devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
 					   DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
-	if (devpriv->dma) {
-		setup_timer(&devpriv->timer, das16_timer_interrupt,
-			    (unsigned long)dev);
-	}
 }
 
 static void das16_free_dma(struct comedi_device *dev)
@@ -952,8 +951,7 @@ static void das16_free_dma(struct comedi_device *dev)
 	struct das16_private_struct *devpriv = dev->private;
 
 	if (devpriv) {
-		if (devpriv->timer.data)
-			del_timer_sync(&devpriv->timer);
+		del_timer_sync(&devpriv->timer);
 		comedi_isadma_free(devpriv->dma);
 	}
 }
-- 
2.7.4

[toc] | [next] | [standalone]


#1736526 — Re: [PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional

FromIan Abbott <abbotti@mev.co.uk>
Date2017-09-21 12:40 +0200
SubjectRe: [PATCH v2 26/31] staging/comedi/das16: Make timer initialization unconditional
Message-ID<us73I-86N-5@gated-at.bofh.it>
In reply to#1736263
On 21/09/17 00:27, Kees Cook wrote:
> With timer initialization made unconditional, there is no reason to
> make del_timer_sync() calls conditionally, there by removing the test
> of the .data field.
> 
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: devel@driverdev.osuosl.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>   drivers/staging/comedi/drivers/das16.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
> index 5d157951f63f..2b2a446af3f5 100644
> --- a/drivers/staging/comedi/drivers/das16.c
> +++ b/drivers/staging/comedi/drivers/das16.c
> @@ -934,6 +934,9 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
>   {
>   	struct das16_private_struct *devpriv = dev->private;
>   
> +	setup_timer(&devpriv->timer, das16_timer_interrupt,
> +		    (unsigned long)dev);
> +
>   	/* only DMA channels 3 and 1 are valid */
>   	if (!(dma_chan == 1 || dma_chan == 3))
>   		return;
> @@ -941,10 +944,6 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
>   	/* DMA uses two buffers */
>   	devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
>   					   DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
> -	if (devpriv->dma) {
> -		setup_timer(&devpriv->timer, das16_timer_interrupt,
> -			    (unsigned long)dev);
> -	}
>   }
>   
>   static void das16_free_dma(struct comedi_device *dev)
> @@ -952,8 +951,7 @@ static void das16_free_dma(struct comedi_device *dev)
>   	struct das16_private_struct *devpriv = dev->private;
>   
>   	if (devpriv) {
> -		if (devpriv->timer.data)
> -			del_timer_sync(&devpriv->timer);
> +		del_timer_sync(&devpriv->timer);
>   		comedi_isadma_free(devpriv->dma);
>   	}
>   }
> 

That's fine.

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web