2020-05-06 09:21:39

by Zou Wei

[permalink] [raw]
Subject: [PATCH -next] dmaengine: ti: k3-udma: Use PTR_ERR_OR_ZERO() to simplify code

Fixes coccicheck warnings:

drivers/dma/ti/k3-udma.c:1294:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/dma/ti/k3-udma.c:1311:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/dma/ti/k3-udma.c:1376:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Samuel Zou <[email protected]>
---
drivers/dma/ti/k3-udma.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 0a04174..f5775ca 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -1291,10 +1291,8 @@ static int udma_get_tchan(struct udma_chan *uc)
}

uc->tchan = __udma_reserve_tchan(ud, uc->config.channel_tpl, -1);
- if (IS_ERR(uc->tchan))
- return PTR_ERR(uc->tchan);

- return 0;
+ return PTR_ERR_OR_ZERO(uc->tchan);
}

static int udma_get_rchan(struct udma_chan *uc)
@@ -1308,10 +1306,8 @@ static int udma_get_rchan(struct udma_chan *uc)
}

uc->rchan = __udma_reserve_rchan(ud, uc->config.channel_tpl, -1);
- if (IS_ERR(uc->rchan))
- return PTR_ERR(uc->rchan);

- return 0;
+ return PTR_ERR_OR_ZERO(uc->rchan);
}

static int udma_get_chan_pair(struct udma_chan *uc)
@@ -1373,10 +1369,8 @@ static int udma_get_rflow(struct udma_chan *uc, int flow_id)
}

uc->rflow = __udma_get_rflow(ud, flow_id);
- if (IS_ERR(uc->rflow))
- return PTR_ERR(uc->rflow);

- return 0;
+ return PTR_ERR_OR_ZERO(uc->rflow);
}

static void udma_put_rchan(struct udma_chan *uc)
--
2.6.2


2020-05-13 14:54:20

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH -next] dmaengine: ti: k3-udma: Use PTR_ERR_OR_ZERO() to simplify code

On 06-05-20, 17:25, Samuel Zou wrote:
> Fixes coccicheck warnings:
>
> drivers/dma/ti/k3-udma.c:1294:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> drivers/dma/ti/k3-udma.c:1311:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> drivers/dma/ti/k3-udma.c:1376:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Applied, thanks

--
~Vinod

2020-05-14 08:35:18

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH -next] dmaengine: ti: k3-udma: Use PTR_ERR_OR_ZERO() to simplify code

Hi Samuel,

On 06/05/2020 12.25, Samuel Zou wrote:
> Fixes coccicheck warnings:
>
> drivers/dma/ti/k3-udma.c:1294:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> drivers/dma/ti/k3-udma.c:1311:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> drivers/dma/ti/k3-udma.c:1376:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Thanks for the patch, I have missed it as I was not in CC for it.
scripts/get_maintainer.pl would have tipped for a wider recipient list..

> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Samuel Zou <[email protected]>
> ---
> drivers/dma/ti/k3-udma.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 0a04174..f5775ca 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -1291,10 +1291,8 @@ static int udma_get_tchan(struct udma_chan *uc)
> }
>
> uc->tchan = __udma_reserve_tchan(ud, uc->config.channel_tpl, -1);
> - if (IS_ERR(uc->tchan))
> - return PTR_ERR(uc->tchan);
>
> - return 0;
> + return PTR_ERR_OR_ZERO(uc->tchan);
> }
>
> static int udma_get_rchan(struct udma_chan *uc)
> @@ -1308,10 +1306,8 @@ static int udma_get_rchan(struct udma_chan *uc)
> }
>
> uc->rchan = __udma_reserve_rchan(ud, uc->config.channel_tpl, -1);
> - if (IS_ERR(uc->rchan))
> - return PTR_ERR(uc->rchan);
>
> - return 0;
> + return PTR_ERR_OR_ZERO(uc->rchan);
> }
>
> static int udma_get_chan_pair(struct udma_chan *uc)
> @@ -1373,10 +1369,8 @@ static int udma_get_rflow(struct udma_chan *uc, int flow_id)
> }
>
> uc->rflow = __udma_get_rflow(ud, flow_id);
> - if (IS_ERR(uc->rflow))
> - return PTR_ERR(uc->rflow);
>
> - return 0;
> + return PTR_ERR_OR_ZERO(uc->rflow);
> }
>
> static void udma_put_rchan(struct udma_chan *uc)
>

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


Attachments:
pEpkey.asc (1.74 kB)

2020-05-14 09:11:35

by Zou Wei

[permalink] [raw]
Subject: Re: [PATCH -next] dmaengine: ti: k3-udma: Use PTR_ERR_OR_ZERO() to simplify code

Hi Peter,

I'm sorry for my mistake.
Thanks for your comments and suggestions.

On 2020/5/14 16:33, Peter Ujfalusi wrote:
> Hi Samuel,
>
> On 06/05/2020 12.25, Samuel Zou wrote:
>> Fixes coccicheck warnings:
>>
>> drivers/dma/ti/k3-udma.c:1294:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>> drivers/dma/ti/k3-udma.c:1311:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>> drivers/dma/ti/k3-udma.c:1376:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
> Thanks for the patch, I have missed it as I was not in CC for it.
> scripts/get_maintainer.pl would have tipped for a wider recipient list..
>
>> Reported-by: Hulk Robot <[email protected]>
>> Signed-off-by: Samuel Zou <[email protected]>
>> ---
>> drivers/dma/ti/k3-udma.c | 12 +++---------
>> 1 file changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
>> index 0a04174..f5775ca 100644
>> --- a/drivers/dma/ti/k3-udma.c
>> +++ b/drivers/dma/ti/k3-udma.c
>> @@ -1291,10 +1291,8 @@ static int udma_get_tchan(struct udma_chan *uc)
>> }
>>
>> uc->tchan = __udma_reserve_tchan(ud, uc->config.channel_tpl, -1);
>> - if (IS_ERR(uc->tchan))
>> - return PTR_ERR(uc->tchan);
>>
>> - return 0;
>> + return PTR_ERR_OR_ZERO(uc->tchan);
>> }
>>
>> static int udma_get_rchan(struct udma_chan *uc)
>> @@ -1308,10 +1306,8 @@ static int udma_get_rchan(struct udma_chan *uc)
>> }
>>
>> uc->rchan = __udma_reserve_rchan(ud, uc->config.channel_tpl, -1);
>> - if (IS_ERR(uc->rchan))
>> - return PTR_ERR(uc->rchan);
>>
>> - return 0;
>> + return PTR_ERR_OR_ZERO(uc->rchan);
>> }
>>
>> static int udma_get_chan_pair(struct udma_chan *uc)
>> @@ -1373,10 +1369,8 @@ static int udma_get_rflow(struct udma_chan *uc, int flow_id)
>> }
>>
>> uc->rflow = __udma_get_rflow(ud, flow_id);
>> - if (IS_ERR(uc->rflow))
>> - return PTR_ERR(uc->rflow);
>>
>> - return 0;
>> + return PTR_ERR_OR_ZERO(uc->rflow);
>> }
>>
>> static void udma_put_rchan(struct udma_chan *uc)
>>
>
> - Péter
>
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>