2020-09-15 03:06:06

by Liu Shixin

[permalink] [raw]
Subject: [PATCH -next] staging: greybus: simplify the return expression of gb_svc_add()

Simplify the return expression.

Signed-off-by: Liu Shixin <[email protected]>
---
drivers/greybus/svc.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
index ce7740ef449b..dca251172cd2 100644
--- a/drivers/greybus/svc.c
+++ b/drivers/greybus/svc.c
@@ -1345,18 +1345,12 @@ struct gb_svc *gb_svc_create(struct gb_host_device *hd)

int gb_svc_add(struct gb_svc *svc)
{
- int ret;
-
/*
* The SVC protocol is currently driven by the SVC, so the SVC device
* is added from the connection request handler when enough
* information has been received.
*/
- ret = gb_connection_enable(svc->connection);
- if (ret)
- return ret;
-
- return 0;
+ return gb_connection_enable(svc->connection);
}

static void gb_svc_remove_modules(struct gb_svc *svc)
--
2.25.1


2020-09-15 09:40:33

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH -next] staging: greybus: simplify the return expression of gb_svc_add()

On Tue, Sep 15, 2020 at 11:26:30AM +0800, Liu Shixin wrote:
> Simplify the return expression.
>
> Signed-off-by: Liu Shixin <[email protected]>
> ---
> drivers/greybus/svc.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
> index ce7740ef449b..dca251172cd2 100644
> --- a/drivers/greybus/svc.c
> +++ b/drivers/greybus/svc.c
> @@ -1345,18 +1345,12 @@ struct gb_svc *gb_svc_create(struct gb_host_device *hd)
>
> int gb_svc_add(struct gb_svc *svc)
> {
> - int ret;
> -
> /*
> * The SVC protocol is currently driven by the SVC, so the SVC device
> * is added from the connection request handler when enough
> * information has been received.
> */
> - ret = gb_connection_enable(svc->connection);
> - if (ret)
> - return ret;
> -
> - return 0;
> + return gb_connection_enable(svc->connection);

There no need for this change. This code was written with an explicit
success path on purpose.

Also, this driver doesn't live in staging anymore as your patch prefix
suggests.

> }
>
> static void gb_svc_remove_modules(struct gb_svc *svc)

Johan