* [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
* Re: [PATCH net-next] of: add optional naming of interfaces
[not found] ` <1481116349-20678-1-git-send-email-volodymyr.bendiuga-qeDNsGSBLoYwFerOooGFRg@public.gmane.org>
@ 2016-12-07 17:49 ` Florian Fainelli
0 siblings, 0 replies; 2+ messages in thread
From: Florian Fainelli @ 2016-12-07 17:49 UTC (permalink / raw)
To: Volodymyr Bendiuga, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
mark.rutland-5wv7dgnIgG8, frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
volodymyr.bendiuga-Re5JQEeQqe8AvxtiuMwx3w
Cc: Jonas Johansson, Mattias Walström
On 12/07/2016 05:12 AM, Volodymyr Bendiuga wrote:
> From: Jonas Johansson <jonas.johansson-qeDNsGSBLoYwFerOooGFRg@public.gmane.org>
>
> Signed-off-by: Mattias Walström <lazzer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Jonas Johansson <jonas.johansson-qeDNsGSBLoYwFerOooGFRg@public.gmane.org>
This does not belong to the Device Tree, there should be plenty of
information in user-space to make an educated device rename. I
definitively understand that some drivers (e.g: dsa) do actually get
their interface name from Device Tree directly (label property), but
this is probably the one and only case where this may be tolerated.
Besides, if you submit such a change, you would want to also provide a
consumer of that API to illustrate how this is used.
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [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).