[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-backports
Subject:    [PATCH 17/18] header: fix of_get_mac_address()
From:       Hauke Mehrtens <hauke () hauke-m ! de>
Date:       2019-07-01 21:49:13
Message-ID: 20190701214914.8066-19-hauke () hauke-m ! de
[Download RAW message or body]

The behavior of of_get_mac_address() changed in kernel 5.2, it now
returns an error code and not NULL in case of an error.

This was changed in upstream kernel commit d01f449c008a
("of_net: add NVMEM support to of_get_mac_address")

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/of_net.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/backport/backport-include/linux/of_net.h b/backport/backport-include/linux/of_net.h
index 7f4b688f..18becf5c 100644
--- a/backport/backport-include/linux/of_net.h
+++ b/backport/backport-include/linux/of_net.h
@@ -12,4 +12,20 @@ static inline const void *of_get_mac_address(struct device_node *np)
 #endif
 #endif
 
+/* The behavior of of_get_mac_address() changed in kernel 5.2, it now
+ * returns an error code and not NULL in case of an error.
+ */
+#if LINUX_VERSION_IS_LESS(5,2,0)
+static inline const void *backport_of_get_mac_address(struct device_node *np)
+{
+	const void *mac = of_get_mac_address(np);
+
+	if (!mac)
+		return ERR_PTR(-ENODEV);
+
+	return mac;
+}
+#define of_get_mac_address LINUX_BACKPORT(of_get_mac_address)
+#endif /* < 5.2 */
+
 #endif /* _BP_OF_NET_H */
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic