2020-11-17 09:31:03

by Kaixu Xia

[permalink] [raw]
Subject: [PATCH] can: mcp251xfd: remove useless code in mcp251xfd_chip_softreset

From: Kaixu Xia <[email protected]>

It would directly return if the variable err equals to 0 or other errors.
Only when the err equals to -ETIMEDOUT it can reach the 'if (err)'
statement, so the 'if (err)' and last 'return -ETIMEDOUT' statements are
useless. Romove them.

Reported-by: Tosk Robot <[email protected]>
Signed-off-by: Kaixu Xia <[email protected]>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 9c215f7c5f81..ceae18270c01 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -644,10 +644,7 @@ static int mcp251xfd_chip_softreset(const struct mcp251xfd_priv *priv)
return 0;
}

- if (err)
- return err;
-
- return -ETIMEDOUT;
+ return err;
}

static int mcp251xfd_chip_clock_init(const struct mcp251xfd_priv *priv)
--
2.20.0


2020-11-17 10:10:26

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH] can: mcp251xfd: remove useless code in mcp251xfd_chip_softreset

On Tue, Nov 17, 2020 at 05:29:12PM +0800, [email protected] wrote:
> From: Kaixu Xia <[email protected]>
>
> It would directly return if the variable err equals to 0 or other errors.
> Only when the err equals to -ETIMEDOUT it can reach the 'if (err)'
> statement, so the 'if (err)' and last 'return -ETIMEDOUT' statements are
> useless. Romove them.
>
> Reported-by: Tosk Robot <[email protected]>
> Signed-off-by: Kaixu Xia <[email protected]>

Applied to linux-can-next/testing.

Tnx,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


Attachments:
(No filename) (803.00 B)
signature.asc (499.00 B)
Download all attachments