aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2021-10-09 18:31:58 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2021-10-18 23:01:19 +0200
commit35cf9be2759027850c22af2b68ef08001349f223 (patch)
tree7e593a57774241bb6bef15f225f9f2877e4f6975
parentaf58b27b1b1ab1133c0fec4d817cd6360ebe280e (diff)
downloadbackports-35cf9be2759027850c22af2b68ef08001349f223.tar.gz
headers: Adapt signature of of_get_mac_address()
The function signature of of_get_mac_address() changed in kernel 5.13. This code converts calls using the new signature to the old API. The return value changed in kernel 5.2, which is still taken care of. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--backport/backport-include/linux/of_net.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/backport/backport-include/linux/of_net.h b/backport/backport-include/linux/of_net.h
index 866aec57..9b9276f1 100644
--- a/backport/backport-include/linux/of_net.h
+++ b/backport/backport-include/linux/of_net.h
@@ -2,19 +2,23 @@
#define _BP_OF_NET_H
#include_next <linux/of_net.h>
#include <linux/version.h>
+#include <linux/etherdevice.h>
/* 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)
+#if LINUX_VERSION_IS_LESS(5,13,0)
+static inline int backport_of_get_mac_address(struct device_node *np, u8 *mac_out)
{
const void *mac = of_get_mac_address(np);
if (!mac)
- return ERR_PTR(-ENODEV);
-
- return mac;
+ return -ENODEV;
+ if (IS_ERR(mac))
+ return PTR_ERR(mac);
+ ether_addr_copy(mac_out, mac);
+
+ return 0;
}
#define of_get_mac_address LINUX_BACKPORT(of_get_mac_address)
#endif /* < 5.2 */