Skip to content

Commit ff198cd

Browse files
maciejsszmigierodavem330
authored andcommitted
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: Maciej S. Szmigiero <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fffcefe commit ff198cd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/net/phy/phy_led_triggers.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@ static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy,
2727
return NULL;
2828
}
2929

30+
static void phy_led_trigger_no_link(struct phy_device *phy)
31+
{
32+
if (phy->last_triggered) {
33+
led_trigger_event(&phy->last_triggered->trigger, LED_OFF);
34+
phy->last_triggered = NULL;
35+
}
36+
}
37+
3038
void phy_led_trigger_change_speed(struct phy_device *phy)
3139
{
3240
struct phy_led_trigger *plt;
3341

3442
if (!phy->link)
35-
goto out_change_speed;
43+
return phy_led_trigger_no_link(phy);
3644

3745
if (phy->speed == 0)
3846
return;
@@ -42,22 +50,14 @@ void phy_led_trigger_change_speed(struct phy_device *phy)
4250
netdev_alert(phy->attached_dev,
4351
"No phy led trigger registered for speed(%d)\n",
4452
phy->speed);
45-
goto out_change_speed;
53+
return phy_led_trigger_no_link(phy);
4654
}
4755

4856
if (plt != phy->last_triggered) {
4957
led_trigger_event(&phy->last_triggered->trigger, LED_OFF);
5058
led_trigger_event(&plt->trigger, LED_FULL);
5159
phy->last_triggered = plt;
5260
}
53-
return;
54-
55-
out_change_speed:
56-
if (phy->last_triggered) {
57-
led_trigger_event(&phy->last_triggered->trigger,
58-
LED_OFF);
59-
phy->last_triggered = NULL;
60-
}
6161
}
6262
EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed);
6363

0 commit comments

Comments
 (0)