devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] of: add optional naming of interfaces
@ 2016-12-07 13:12 Volodymyr Bendiuga
       [not found] ` <1481116349-20678-1-git-send-email-volodymyr.bendiuga-qeDNsGSBLoYwFerOooGFRg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Volodymyr Bendiuga @ 2016-12-07 13:12 UTC (permalink / raw)
  To: robh+dt, mark.rutland, f.fainelli, frowand.list, netdev,
	devicetree, volodymyr.bendiuga
  Cc: Jonas Johansson, Mattias Walström

From: Jonas Johansson <jonas.johansson@westermo.se>

Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Jonas Johansson <jonas.johansson@westermo.se>
---
 Documentation/devicetree/bindings/net/ethernet.txt |  1 +
 drivers/of/of_net.c                                | 19 +++++++++++++++++++
 include/linux/of_net.h                             |  1 +
 3 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index 0515095..fcfe6a3 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -6,6 +6,7 @@ The following properties are common to the Ethernet controllers:
   the boot program; should be used in cases where the MAC address assigned to
   the device by the boot program is different from the "local-mac-address"
   property;
+- linux,interface-name, optional name of the interface.
 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
   the maximum frame size (there's contradiction in ePAPR).
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..ebff92d 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -80,3 +80,22 @@ const void *of_get_mac_address(struct device_node *np)
 	return of_get_mac_addr(np, "address");
 }
 EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * of_get_interface_name - Get interface name for given device_node
+ * @np:	Pointer to the given device_node
+ *
+ * The function gets the interface-name specified for np. It returns
+ * the name on success, NULL if not specified or on error.
+ */
+const char *of_get_interface_name(struct device_node *np)
+{
+	struct property *pp;
+
+	pp = of_find_property(np, "linux,interface-name", NULL);
+	if (pp && pp->length < IFNAMSIZ)
+		return pp->value;
+
+	return NULL;
+}
+EXPORT_SYMBOL(of_get_interface_name);
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 9cd72aa..bcbc6cb 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -14,6 +14,7 @@ struct net_device;
 extern int of_get_phy_mode(struct device_node *np);
 extern const void *of_get_mac_address(struct device_node *np);
 extern struct net_device *of_find_net_device_by_node(struct device_node *np);
+extern const char *of_get_interface_name(struct device_node *np);
 #else
 static inline int of_get_phy_mode(struct device_node *np)
 {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-07 17:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-07 13:12 [PATCH net-next] of: add optional naming of interfaces Volodymyr Bendiuga
     [not found] ` <1481116349-20678-1-git-send-email-volodymyr.bendiuga-qeDNsGSBLoYwFerOooGFRg@public.gmane.org>
2016-12-07 17:49   ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).