diff mbox

dma: ti-dma-crossbar: Fix checking return value of devm_ioremap_resource

Message ID 1436537599.10674.1.camel@ingics.com (mailing list archive)
State Accepted
Headers show

Commit Message

Axel Lin July 10, 2015, 2:13 p.m. UTC
devm_ioremap_resource returns ERR_PTR on failure.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/dma/ti-dma-crossbar.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Vinod Koul Aug. 5, 2015, 3:20 a.m. UTC | #1
On Fri, Jul 10, 2015 at 10:13:19PM +0800, Axel Lin wrote:
> devm_ioremap_resource returns ERR_PTR on failure.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/dma/ti-dma-crossbar.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
> index 24f5ca2..5e261d1 100644
> --- a/drivers/dma/ti-dma-crossbar.c
> +++ b/drivers/dma/ti-dma-crossbar.c
> @@ -139,12 +139,9 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
>  		xbar->safe_val = (u16)safe_val;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res)
> -		return -ENODEV;
and why remove this check?

and is is not documented why you removed this
Axel Lin Aug. 5, 2015, 3:22 a.m. UTC | #2
2015-08-05 11:20 GMT+08:00 Vinod Koul <vinod.koul@intel.com>:
> On Fri, Jul 10, 2015 at 10:13:19PM +0800, Axel Lin wrote:
>> devm_ioremap_resource returns ERR_PTR on failure.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>>  drivers/dma/ti-dma-crossbar.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
>> index 24f5ca2..5e261d1 100644
>> --- a/drivers/dma/ti-dma-crossbar.c
>> +++ b/drivers/dma/ti-dma-crossbar.c
>> @@ -139,12 +139,9 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
>>               xbar->safe_val = (u16)safe_val;
>>
>>       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -     if (!res)
>> -             return -ENODEV;
> and why remove this check?
>
> and is is not documented why you removed this

The checking is done in devm_ioremap_resource(), that is the usually way
to use devm_ioremap_resource().
I think it's very common in kernel code, so I didn't document it in commit log.

So should I send v2 to update the commit?
--
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
Vinod Koul Aug. 5, 2015, 5:07 a.m. UTC | #3
On Wed, Aug 05, 2015 at 11:22:32AM +0800, Axel Lin wrote:
> 2015-08-05 11:20 GMT+08:00 Vinod Koul <vinod.koul@intel.com>:
> > On Fri, Jul 10, 2015 at 10:13:19PM +0800, Axel Lin wrote:
> >> devm_ioremap_resource returns ERR_PTR on failure.
> >>
> >> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> >> ---
> >>  drivers/dma/ti-dma-crossbar.c | 7 ++-----
> >>  1 file changed, 2 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
> >> index 24f5ca2..5e261d1 100644
> >> --- a/drivers/dma/ti-dma-crossbar.c
> >> +++ b/drivers/dma/ti-dma-crossbar.c
> >> @@ -139,12 +139,9 @@ static int ti_dma_xbar_probe(struct platform_device *pdev)
> >>               xbar->safe_val = (u16)safe_val;
> >>
> >>       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> -     if (!res)
> >> -             return -ENODEV;
> > and why remove this check?
> >
> > and is is not documented why you removed this
> 
> The checking is done in devm_ioremap_resource(), that is the usually way
> to use devm_ioremap_resource().
> I think it's very common in kernel code, so I didn't document it in commit log.

Yes devm_ioremap_resource() does check for this, so this is fine. I will
apply this with Peter's ack
diff mbox

Patch

diff --git a/drivers/dma/ti-dma-crossbar.c b/drivers/dma/ti-dma-crossbar.c
index 24f5ca2..5e261d1 100644
--- a/drivers/dma/ti-dma-crossbar.c
+++ b/drivers/dma/ti-dma-crossbar.c
@@ -139,12 +139,9 @@  static int ti_dma_xbar_probe(struct platform_device *pdev)
 		xbar->safe_val = (u16)safe_val;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
-
 	iomem = devm_ioremap_resource(&pdev->dev, res);
-	if (!iomem)
-		return -ENOMEM;
+	if (IS_ERR(iomem))
+		return PTR_ERR(iomem);
 
 	xbar->iomem = iomem;