提交 ff198cdb 编写于 作者: M Maciej S. Szmigiero 提交者: David S. Miller

net: phy: leds: Refactor "no link" handler into a separate function

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: NMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 fffcefe9
...@@ -27,12 +27,20 @@ static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy, ...@@ -27,12 +27,20 @@ static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy,
return NULL; 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) void phy_led_trigger_change_speed(struct phy_device *phy)
{ {
struct phy_led_trigger *plt; struct phy_led_trigger *plt;
if (!phy->link) if (!phy->link)
goto out_change_speed; return phy_led_trigger_no_link(phy);
if (phy->speed == 0) if (phy->speed == 0)
return; return;
...@@ -42,7 +50,7 @@ void phy_led_trigger_change_speed(struct phy_device *phy) ...@@ -42,7 +50,7 @@ void phy_led_trigger_change_speed(struct phy_device *phy)
netdev_alert(phy->attached_dev, netdev_alert(phy->attached_dev,
"No phy led trigger registered for speed(%d)\n", "No phy led trigger registered for speed(%d)\n",
phy->speed); phy->speed);
goto out_change_speed; return phy_led_trigger_no_link(phy);
} }
if (plt != phy->last_triggered) { if (plt != phy->last_triggered) {
...@@ -50,14 +58,6 @@ void phy_led_trigger_change_speed(struct phy_device *phy) ...@@ -50,14 +58,6 @@ void phy_led_trigger_change_speed(struct phy_device *phy)
led_trigger_event(&plt->trigger, LED_FULL); led_trigger_event(&plt->trigger, LED_FULL);
phy->last_triggered = plt; 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); EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册