linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] net: phy: leds: Refactor "no link" handler into a separate function
@ 2017-11-01 23:48 Maciej S. Szmigiero
  2017-11-08  1:25 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej S. Szmigiero @ 2017-11-01 23:48 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli; +Cc: netdev, linux-kernel

Currently, phy_led_trigger_change_speed() is handling a "no link" condition
like it was some kind of an error (using "goto" to a code at the function
end).

However, having no link at PHY is an ordinary operational state, so let's
handle it in an appropriately named separate function so it is more obvious
what the code is doing.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
---
 drivers/net/phy/phy_led_triggers.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c
index 94ca42e630bb..c736f29b3b2a 100644
--- a/drivers/net/phy/phy_led_triggers.c
+++ b/drivers/net/phy/phy_led_triggers.c
@@ -27,12 +27,20 @@ static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy,
 	return NULL;
 }
 
+static void phy_led_trigger_no_link(struct phy_device *phy)
+{
+	if (phy->last_triggered) {
+		led_trigger_event(&phy->last_triggered->trigger, LED_OFF);
+		phy->last_triggered = NULL;
+	}
+}
+
 void phy_led_trigger_change_speed(struct phy_device *phy)
 {
 	struct phy_led_trigger *plt;
 
 	if (!phy->link)
-		goto out_change_speed;
+		return phy_led_trigger_no_link(phy);
 
 	if (phy->speed == 0)
 		return;
@@ -42,7 +50,7 @@ void phy_led_trigger_change_speed(struct phy_device *phy)
 		netdev_alert(phy->attached_dev,
 			     "No phy led trigger registered for speed(%d)\n",
 			     phy->speed);
-		goto out_change_speed;
+		return phy_led_trigger_no_link(phy);
 	}
 
 	if (plt != phy->last_triggered) {
@@ -50,14 +58,6 @@ void phy_led_trigger_change_speed(struct phy_device *phy)
 		led_trigger_event(&plt->trigger, LED_FULL);
 		phy->last_triggered = plt;
 	}
-	return;
-
-out_change_speed:
-	if (phy->last_triggered) {
-		led_trigger_event(&phy->last_triggered->trigger,
-				  LED_OFF);
-		phy->last_triggered = NULL;
-	}
 }
 EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed);
 

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

* Re: [PATCH v3 1/2] net: phy: leds: Refactor "no link" handler into a separate function
  2017-11-01 23:48 [PATCH v3 1/2] net: phy: leds: Refactor "no link" handler into a separate function Maciej S. Szmigiero
@ 2017-11-08  1:25 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-11-08  1:25 UTC (permalink / raw)
  To: mail; +Cc: andrew, f.fainelli, netdev, linux-kernel

From: "Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
Date: Thu, 2 Nov 2017 00:48:45 +0100

> Currently, phy_led_trigger_change_speed() is handling a "no link" condition
> like it was some kind of an error (using "goto" to a code at the function
> end).
> 
> However, having no link at PHY is an ordinary operational state, so let's
> handle it in an appropriately named separate function so it is more obvious
> what the code is doing.
> 
> Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>

Applied.

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

end of thread, other threads:[~2017-11-08  1:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 23:48 [PATCH v3 1/2] net: phy: leds: Refactor "no link" handler into a separate function Maciej S. Szmigiero
2017-11-08  1:25 ` 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).