diff mbox series

[net-next,RFC,05/12] dsa: use devlink helper to generate physical port name

Message ID 20180322105522.8186-6-jiri@resnulli.us
State RFC, archived
Delegated to: David Miller
Headers show
Series devlink: introduce port flavours and common phys_port_name generation | expand

Commit Message

Jiri Pirko March 22, 2018, 10:55 a.m. UTC
From: Jiri Pirko <jiri@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 <jiri@mellanox.com>
---
 net/dsa/slave.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

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 *