[03/10] bus/dpaa: fix management command init calling

Message ID 1618839289-33224-4-git-send-email-humin29@huawei.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers
Series fixes for clean code |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

humin (Q) April 19, 2021, 1:34 p.m. UTC
  'bm_mc_init' only return 0, but the function whicl calls int
check the negative ret, and this is redundant.

This patch fixed it by not checking the return value.

Fixes: f38f61e982f8 ("bus/dpaa: add BMAN hardware interfaces")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/bus/dpaa/base/qbman/bman.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Andrew Rybchenko April 20, 2021, 9:35 a.m. UTC | #1
On 4/19/21 4:34 PM, Min Hu (Connor) wrote:
> 'bm_mc_init' only return 0, but the function whicl calls int
> check the negative ret, and this is redundant.
> 
> This patch fixed it by not checking the return value.
> 
> Fixes: f38f61e982f8 ("bus/dpaa: add BMAN hardware interfaces")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>  drivers/bus/dpaa/base/qbman/bman.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bus/dpaa/base/qbman/bman.c b/drivers/bus/dpaa/base/qbman/bman.c
> index 8a62907..e1ba2a8 100644
> --- a/drivers/bus/dpaa/base/qbman/bman.c
> +++ b/drivers/bus/dpaa/base/qbman/bman.c
> @@ -70,10 +70,8 @@ struct bman_portal *bman_create_portal(struct bman_portal *portal,
>  		pr_err("Bman RCR initialisation failed\n");
>  		return NULL;
>  	}
> -	if (bm_mc_init(p)) {
> -		pr_err("Bman MC initialisation failed\n");
> -		goto fail_mc;
> -	}
> +	(void)bm_mc_init(p);
> +

As I understand compiler can do it for you and there is no
point to break the code in the case of future changes if
bm_mc_init() starts to return errors.

>  	portal->pools = kmalloc(2 * sizeof(*pools), GFP_KERNEL);
>  	if (!portal->pools)
>  		goto fail_pools;
>
  
humin (Q) April 20, 2021, 9:54 a.m. UTC | #2
在 2021/4/20 17:35, Andrew Rybchenko 写道:
> On 4/19/21 4:34 PM, Min Hu (Connor) wrote:
>> 'bm_mc_init' only return 0, but the function whicl calls int
>> check the negative ret, and this is redundant.
>>
>> This patch fixed it by not checking the return value.
>>
>> Fixes: f38f61e982f8 ("bus/dpaa: add BMAN hardware interfaces")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   drivers/bus/dpaa/base/qbman/bman.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/bus/dpaa/base/qbman/bman.c b/drivers/bus/dpaa/base/qbman/bman.c
>> index 8a62907..e1ba2a8 100644
>> --- a/drivers/bus/dpaa/base/qbman/bman.c
>> +++ b/drivers/bus/dpaa/base/qbman/bman.c
>> @@ -70,10 +70,8 @@ struct bman_portal *bman_create_portal(struct bman_portal *portal,
>>   		pr_err("Bman RCR initialisation failed\n");
>>   		return NULL;
>>   	}
>> -	if (bm_mc_init(p)) {
>> -		pr_err("Bman MC initialisation failed\n");
>> -		goto fail_mc;
>> -	}
>> +	(void)bm_mc_init(p);
>> +
> 
> As I understand compiler can do it for you and there is no
> point to break the code in the case of future changes if
> bm_mc_init() starts to return errors.
> 
Agreed, this patch can be abandoned.
>>   	portal->pools = kmalloc(2 * sizeof(*pools), GFP_KERNEL);
>>   	if (!portal->pools)
>>   		goto fail_pools;
>>
> 
> .
>
  

Patch

diff --git a/drivers/bus/dpaa/base/qbman/bman.c b/drivers/bus/dpaa/base/qbman/bman.c
index 8a62907..e1ba2a8 100644
--- a/drivers/bus/dpaa/base/qbman/bman.c
+++ b/drivers/bus/dpaa/base/qbman/bman.c
@@ -70,10 +70,8 @@  struct bman_portal *bman_create_portal(struct bman_portal *portal,
 		pr_err("Bman RCR initialisation failed\n");
 		return NULL;
 	}
-	if (bm_mc_init(p)) {
-		pr_err("Bman MC initialisation failed\n");
-		goto fail_mc;
-	}
+	(void)bm_mc_init(p);
+
 	portal->pools = kmalloc(2 * sizeof(*pools), GFP_KERNEL);
 	if (!portal->pools)
 		goto fail_pools;