From: Jiri Pirko <j...@mellanox.com>

Since devlink knows the info needed to generate the physical port name
in a generic way for all devlink users, use the helper to do the job.

Signed-off-by: Jiri Pirko <j...@mellanox.com>
---
 net/dsa/slave.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 18561af7a8f1..8d71dd672e52 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -19,6 +19,7 @@
 #include <net/rtnetlink.h>
 #include <net/pkt_cls.h>
 #include <net/tc_act/tc_mirred.h>
+#include <net/devlink.h>
 #include <linux/if_bridge.h>
 #include <linux/netpoll.h>
 #include <linux/ptp_classify.h>
@@ -727,10 +728,7 @@ static int dsa_slave_get_phys_port_name(struct net_device 
*dev,
 {
        struct dsa_port *dp = dsa_slave_to_port(dev);
 
-       if (snprintf(name, len, "p%d", dp->index) >= len)
-               return -EINVAL;
-
-       return 0;
+       return devlink_port_get_phys_port_name(&dp->devlink_port, name, len);
 }
 
 static struct dsa_mall_tc_entry *
-- 
2.14.3

Reply via email to