netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sh_eth: simplify sh_eth_check_reset()
@ 2018-02-18 15:21 Sergei Shtylyov
  2018-02-19  8:39 ` Geert Uytterhoeven
  2018-02-19 16:34 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2018-02-18 15:21 UTC (permalink / raw)
  To: netdev@vger.kernel.org; +Cc: linux-renesas-soc

The *while* loop in this function  can be turned into a normal *for* loop.
And getting rid  of the  single return point saves us a few more LoCs...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
The patch is against DaveM's 'net-next.git' repo.

 drivers/net/ethernet/renesas/sh_eth.c |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -962,20 +962,16 @@ static void sh_eth_set_default_cpu_data(
 
 static int sh_eth_check_reset(struct net_device *ndev)
 {
-	int ret = 0;
-	int cnt = 100;
+	int cnt;
 
-	while (cnt > 0) {
+	for (cnt = 100; cnt > 0; cnt--) {
 		if (!(sh_eth_read(ndev, EDMR) & EDMR_SRST_GETHER))
-			break;
+			return 0;
 		mdelay(1);
-		cnt--;
 	}
-	if (cnt <= 0) {
-		netdev_err(ndev, "Device reset failed\n");
-		ret = -ETIMEDOUT;
-	}
-	return ret;
+
+	netdev_err(ndev, "Device reset failed\n");
+	return -ETIMEDOUT;
 }
 
 static int sh_eth_reset(struct net_device *ndev)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sh_eth: simplify sh_eth_check_reset()
  2018-02-18 15:21 [PATCH] sh_eth: simplify sh_eth_check_reset() Sergei Shtylyov
@ 2018-02-19  8:39 ` Geert Uytterhoeven
  2018-02-19 16:34 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2018-02-19  8:39 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: netdev@vger.kernel.org, Linux-Renesas

On Sun, Feb 18, 2018 at 4:21 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> The *while* loop in this function  can be turned into a normal *for* loop.
> And getting rid  of the  single return point saves us a few more LoCs...
>
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sh_eth: simplify sh_eth_check_reset()
  2018-02-18 15:21 [PATCH] sh_eth: simplify sh_eth_check_reset() Sergei Shtylyov
  2018-02-19  8:39 ` Geert Uytterhoeven
@ 2018-02-19 16:34 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-02-19 16:34 UTC (permalink / raw)
  To: sergei.shtylyov; +Cc: netdev, linux-renesas-soc

From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Sun, 18 Feb 2018 18:21:05 +0300

> The *while* loop in this function  can be turned into a normal *for* loop.
> And getting rid  of the  single return point saves us a few more LoCs...
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

Applied to net-next, thanks Sergei.

> The patch is against DaveM's 'net-next.git' repo.

It is actually easier for you (and me) if you just indicate this in
your Subject like "[PATCH net-next]" in the future.

Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-19 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-18 15:21 [PATCH] sh_eth: simplify sh_eth_check_reset() Sergei Shtylyov
2018-02-19  8:39 ` Geert Uytterhoeven
2018-02-19 16:34 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).