public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] V4L/DVB: pxa-camera: Unsigned dma_chans[] cannot be negative
@ 2008-09-10 16:12 roel kluin
  2008-09-11 11:30 ` Guennadi Liakhovetski
  0 siblings, 1 reply; 2+ messages in thread
From: roel kluin @ 2008-09-10 16:12 UTC (permalink / raw)
  To: mchehab, linux-kernel

Unsigned dma_chans[] cannot be negative

Note that also the third time dma_chans[0] < 0 was tested instead of dma_chans[2]

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index ead87dd..950a2d4 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -1078,7 +1078,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
 	struct pxa_camera_dev *pcdev;
 	struct resource *res;
 	void __iomem *base;
-	int irq;
+	int irq, retval;
 	int err = 0;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1144,31 +1144,34 @@ static int pxa_camera_probe(struct platform_device *pdev)
 	pcdev->dev = &pdev->dev;
 
 	/* request dma */
-	pcdev->dma_chans[0] = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
+	retval = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
 					      pxa_camera_dma_irq_y, pcdev);
-	if (pcdev->dma_chans[0] < 0) {
+	if (retval < 0) {
 		dev_err(pcdev->dev, "Can't request DMA for Y\n");
 		err = -ENOMEM;
 		goto exit_iounmap;
 	}
+	pcdev->dma_chans[0] = retval;
 	dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
 
-	pcdev->dma_chans[1] = pxa_request_dma("CI_U", DMA_PRIO_HIGH,
+	retval = pxa_request_dma("CI_U", DMA_PRIO_HIGH,
 					      pxa_camera_dma_irq_u, pcdev);
-	if (pcdev->dma_chans[1] < 0) {
+	if (retval < 0) {
 		dev_err(pcdev->dev, "Can't request DMA for U\n");
 		err = -ENOMEM;
 		goto exit_free_dma_y;
 	}
+	pcdev->dma_chans[1] = retval;
 	dev_dbg(pcdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]);
 
-	pcdev->dma_chans[2] = pxa_request_dma("CI_V", DMA_PRIO_HIGH,
+	retval = pxa_request_dma("CI_V", DMA_PRIO_HIGH,
 					      pxa_camera_dma_irq_v, pcdev);
-	if (pcdev->dma_chans[0] < 0) {
+	if (retval < 0) {
 		dev_err(pcdev->dev, "Can't request DMA for V\n");
 		err = -ENOMEM;
 		goto exit_free_dma_u;
 	}
+	pcdev->dma_chans[2] = retval;
 	dev_dbg(pcdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]);
 
 	DRCMR68 = pcdev->dma_chans[0] | DRCMR_MAPVLD;

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

* Re: [PATCH] V4L/DVB: pxa-camera: Unsigned dma_chans[] cannot be negative
  2008-09-10 16:12 [PATCH] V4L/DVB: pxa-camera: Unsigned dma_chans[] cannot be negative roel kluin
@ 2008-09-11 11:30 ` Guennadi Liakhovetski
  0 siblings, 0 replies; 2+ messages in thread
From: Guennadi Liakhovetski @ 2008-09-11 11:30 UTC (permalink / raw)
  To: roel kluin; +Cc: mchehab, linux-kernel

On Wed, 10 Sep 2008, roel kluin wrote:

> Unsigned dma_chans[] cannot be negative
> 
> Note that also the third time dma_chans[0] < 0 was tested instead of dma_chans[2]
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
> index ead87dd..950a2d4 100644
> --- a/drivers/media/video/pxa_camera.c
> +++ b/drivers/media/video/pxa_camera.c
> @@ -1078,7 +1078,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
>  	struct pxa_camera_dev *pcdev;
>  	struct resource *res;
>  	void __iomem *base;
> -	int irq;
> +	int irq, retval;
>  	int err = 0;

You don't need an extra variable here, please just use err.

>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1144,31 +1144,34 @@ static int pxa_camera_probe(struct platform_device *pdev)
>  	pcdev->dev = &pdev->dev;
>  
>  	/* request dma */
> -	pcdev->dma_chans[0] = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
> +	retval = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
>  					      pxa_camera_dma_irq_y, pcdev);

also, please align the second line to start behind the opening 
parenthesis:

-	pcdev->dma_chans[0] = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
- 					      pxa_camera_dma_irq_y, pcdev);
+	err = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
+			      pxa_camera_dma_irq_y, pcdev);

> -	if (pcdev->dma_chans[0] < 0) {
> +	if (retval < 0) {
>  		dev_err(pcdev->dev, "Can't request DMA for Y\n");
>  		err = -ENOMEM;

...and then remove this overwriting, anyway I don't think -ENOMEM is a 
very good return code here. Just return with what pxa_request_dma 
returned.

>  		goto exit_iounmap;
>  	}
> +	pcdev->dma_chans[0] = retval;
>  	dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
>  
> -	pcdev->dma_chans[1] = pxa_request_dma("CI_U", DMA_PRIO_HIGH,
> +	retval = pxa_request_dma("CI_U", DMA_PRIO_HIGH,
>  					      pxa_camera_dma_irq_u, pcdev);
> -	if (pcdev->dma_chans[1] < 0) {
> +	if (retval < 0) {
>  		dev_err(pcdev->dev, "Can't request DMA for U\n");
>  		err = -ENOMEM;
>  		goto exit_free_dma_y;
>  	}
> +	pcdev->dma_chans[1] = retval;
>  	dev_dbg(pcdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]);
>  
> -	pcdev->dma_chans[2] = pxa_request_dma("CI_V", DMA_PRIO_HIGH,
> +	retval = pxa_request_dma("CI_V", DMA_PRIO_HIGH,
>  					      pxa_camera_dma_irq_v, pcdev);
> -	if (pcdev->dma_chans[0] < 0) {
> +	if (retval < 0) {
>  		dev_err(pcdev->dev, "Can't request DMA for V\n");
>  		err = -ENOMEM;
>  		goto exit_free_dma_u;
>  	}
> +	pcdev->dma_chans[2] = retval;
>  	dev_dbg(pcdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]);
>  
>  	DRCMR68 = pcdev->dma_chans[0] | DRCMR_MAPVLD;

Otherwise looks good! Please, resubmit and I'll pass it on to v4l 
maintainer.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer

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

end of thread, other threads:[~2008-09-11 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-10 16:12 [PATCH] V4L/DVB: pxa-camera: Unsigned dma_chans[] cannot be negative roel kluin
2008-09-11 11:30 ` Guennadi Liakhovetski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox