Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Kyle Roeschley <kyle.roeschley@ni.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kyle Roeschley and committed by
David S. Miller
457937bd 695bce8f

+3 -14
+2 -13
drivers/net/phy/phy_led_triggers.c
··· 67 67 EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed); 68 68 69 69 static void phy_led_trigger_format_name(struct phy_device *phy, char *buf, 70 - size_t size, char *suffix) 70 + size_t size, const char *suffix) 71 71 { 72 72 snprintf(buf, size, PHY_ID_FMT ":%s", 73 73 phy->mdio.bus->id, phy->mdio.addr, suffix); ··· 77 77 struct phy_led_trigger *plt, 78 78 unsigned int speed) 79 79 { 80 - char name_suffix[PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE]; 81 - 82 80 plt->speed = speed; 83 - 84 - if (speed < SPEED_1000) 85 - snprintf(name_suffix, sizeof(name_suffix), "%dMbps", speed); 86 - else if (speed == SPEED_2500) 87 - snprintf(name_suffix, sizeof(name_suffix), "2.5Gbps"); 88 - else 89 - snprintf(name_suffix, sizeof(name_suffix), "%dGbps", 90 - DIV_ROUND_CLOSEST(speed, 1000)); 91 - 92 81 phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), 93 - name_suffix); 82 + phy_speed_to_str(speed)); 94 83 plt->trigger.name = plt->name; 95 84 96 85 return led_trigger_register(&plt->trigger);
+1 -1
include/linux/phy_led_triggers.h
··· 20 20 #include <linux/leds.h> 21 21 #include <linux/phy.h> 22 22 23 - #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10 23 + #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11 24 24 25 25 #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ 26 26 FIELD_SIZEOF(struct mdio_device, addr)+\