Commit 043d2be2 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jakub Kicinski

net: phy: leds: Deduplicate link LED trigger registration

Refactor phy_led_trigger_register() and deduplicate its functionality
when registering LED trigger for link.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20201027182146.21355-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent be1c7eae
...@@ -66,11 +66,11 @@ static void phy_led_trigger_format_name(struct phy_device *phy, char *buf, ...@@ -66,11 +66,11 @@ static void phy_led_trigger_format_name(struct phy_device *phy, char *buf,
static int phy_led_trigger_register(struct phy_device *phy, static int phy_led_trigger_register(struct phy_device *phy,
struct phy_led_trigger *plt, struct phy_led_trigger *plt,
unsigned int speed) unsigned int speed,
const char *suffix)
{ {
plt->speed = speed; plt->speed = speed;
phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), suffix);
phy_speed_to_str(speed));
plt->trigger.name = plt->name; plt->trigger.name = plt->name;
return led_trigger_register(&plt->trigger); return led_trigger_register(&plt->trigger);
...@@ -99,12 +99,7 @@ int phy_led_triggers_register(struct phy_device *phy) ...@@ -99,12 +99,7 @@ int phy_led_triggers_register(struct phy_device *phy)
goto out_clear; goto out_clear;
} }
phy_led_trigger_format_name(phy, phy->led_link_trigger->name, err = phy_led_trigger_register(phy, phy->led_link_trigger, 0, "link");
sizeof(phy->led_link_trigger->name),
"link");
phy->led_link_trigger->trigger.name = phy->led_link_trigger->name;
err = led_trigger_register(&phy->led_link_trigger->trigger);
if (err) if (err)
goto out_free_link; goto out_free_link;
...@@ -119,7 +114,8 @@ int phy_led_triggers_register(struct phy_device *phy) ...@@ -119,7 +114,8 @@ int phy_led_triggers_register(struct phy_device *phy)
for (i = 0; i < phy->phy_num_led_triggers; i++) { for (i = 0; i < phy->phy_num_led_triggers; i++) {
err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i],
speeds[i]); speeds[i],
phy_speed_to_str(speeds[i]));
if (err) if (err)
goto out_unreg; goto out_unreg;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment