Commit 457937bd authored by Kyle Roeschley's avatar Kyle Roeschley Committed by David S. Miller

net: phy: leds: Don't make our own link speed names

The phy core provides a handy phy_speed_to_str() helper, so use that
instead of doing our own formatting of the different known link speeds.
To do this, increase PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE to 11 so we can fit
'Unsupported' if necessary.
Signed-off-by: default avatarKyle Roeschley <kyle.roeschley@ni.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 695bce8f
...@@ -67,7 +67,7 @@ void phy_led_trigger_change_speed(struct phy_device *phy) ...@@ -67,7 +67,7 @@ void phy_led_trigger_change_speed(struct phy_device *phy)
EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed); EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed);
static void phy_led_trigger_format_name(struct phy_device *phy, char *buf, static void phy_led_trigger_format_name(struct phy_device *phy, char *buf,
size_t size, char *suffix) size_t size, const char *suffix)
{ {
snprintf(buf, size, PHY_ID_FMT ":%s", snprintf(buf, size, PHY_ID_FMT ":%s",
phy->mdio.bus->id, phy->mdio.addr, suffix); phy->mdio.bus->id, phy->mdio.addr, suffix);
...@@ -77,20 +77,9 @@ static int phy_led_trigger_register(struct phy_device *phy, ...@@ -77,20 +77,9 @@ 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)
{ {
char name_suffix[PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE];
plt->speed = speed; plt->speed = speed;
if (speed < SPEED_1000)
snprintf(name_suffix, sizeof(name_suffix), "%dMbps", speed);
else if (speed == SPEED_2500)
snprintf(name_suffix, sizeof(name_suffix), "2.5Gbps");
else
snprintf(name_suffix, sizeof(name_suffix), "%dGbps",
DIV_ROUND_CLOSEST(speed, 1000));
phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name),
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);
......
...@@ -20,7 +20,7 @@ struct phy_device; ...@@ -20,7 +20,7 @@ struct phy_device;
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/phy.h> #include <linux/phy.h>
#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10 #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11
#define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \
FIELD_SIZEOF(struct mdio_device, addr)+\ FIELD_SIZEOF(struct mdio_device, addr)+\
......
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