diff mbox

dmaengine: sprd: fix an NULL vs IS_ERR() bug

Message ID 20180516084807.GA23043@mwanda (mailing list archive)
State Accepted
Headers show

Commit Message

Dan Carpenter May 16, 2018, 8:48 a.m. UTC
We recently cleaned this code up but we need to update the error
handling as well.  The devm_ioremap_resource() returns error pointers on
error, never NULL.

Fixes: e7f063ae1a31 ("dmaengine: sprd: Use devm_ioremap_resource() to map memory")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

(Exiting) Baolin Wang May 16, 2018, 8:56 a.m. UTC | #1
Hi Dan,

On 16 May 2018 at 16:48, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We recently cleaned this code up but we need to update the error
> handling as well.  The devm_ioremap_resource() returns error pointers on
> error, never NULL.
>
> Fixes: e7f063ae1a31 ("dmaengine: sprd: Use devm_ioremap_resource() to map memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks.
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>

>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index e715d07aa632..36df3b096bbc 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -808,8 +808,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
>
>         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         sdev->glb_base = devm_ioremap_resource(&pdev->dev, res);
> -       if (!sdev->glb_base)
> -               return -ENOMEM;
> +       if (IS_ERR(sdev->glb_base))
> +               return PTR_ERR(sdev->glb_base);
>
>         dma_cap_set(DMA_MEMCPY, sdev->dma_dev.cap_mask);
>         sdev->total_chns = chn_count;
Vinod Koul May 17, 2018, 4:31 a.m. UTC | #2
On 16-05-18, 11:48, Dan Carpenter wrote:
> We recently cleaned this code up but we need to update the error
> handling as well.  The devm_ioremap_resource() returns error pointers on
> error, never NULL.

Applied, thanks
diff mbox

Patch

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index e715d07aa632..36df3b096bbc 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -808,8 +808,8 @@  static int sprd_dma_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	sdev->glb_base = devm_ioremap_resource(&pdev->dev, res);
-	if (!sdev->glb_base)
-		return -ENOMEM;
+	if (IS_ERR(sdev->glb_base))
+		return PTR_ERR(sdev->glb_base);
 
 	dma_cap_set(DMA_MEMCPY, sdev->dma_dev.cap_mask);
 	sdev->total_chns = chn_count;