Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of: net: export of_get_mac_address_nvmem()

Export

of_get_mac_addr_nvmem()

and rename it to

of_get_mac_address_nvmem()

in order to fit the convention followed by the existing exported helpers
of the same kind.

This way, OF compatible drivers using eg. fwnode_get_mac_address() can
do a direct call to it instead of calling of_get_mac_address() just for
the nvmem step, avoiding to repeat an expensive DT lookup which has
already been done once.

Eventually, fwnode_get_mac_address() should probably be updated to
perform the nvmem lookup directly, but as of today, nvmem cells seem not
to be supported by ACPI yet which would defeat this kind of extension.

Suggested-by: Marcin Wojtas <mw@semihalf.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Miquel Raynal and committed by
Paolo Abeni
4c47867b 39d10386

+9 -2
+6
include/linux/of_net.h
··· 14 14 struct net_device; 15 15 extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface); 16 16 extern int of_get_mac_address(struct device_node *np, u8 *mac); 17 + extern int of_get_mac_address_nvmem(struct device_node *np, u8 *mac); 17 18 int of_get_ethdev_address(struct device_node *np, struct net_device *dev); 18 19 extern struct net_device *of_find_net_device_by_node(struct device_node *np); 19 20 #else ··· 25 24 } 26 25 27 26 static inline int of_get_mac_address(struct device_node *np, u8 *mac) 27 + { 28 + return -ENODEV; 29 + } 30 + 31 + static inline int of_get_mac_address_nvmem(struct device_node *np, u8 *mac) 28 32 { 29 33 return -ENODEV; 30 34 }
+3 -2
net/core/of_net.c
··· 57 57 return -ENODEV; 58 58 } 59 59 60 - static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr) 60 + int of_get_mac_address_nvmem(struct device_node *np, u8 *addr) 61 61 { 62 62 struct platform_device *pdev = of_find_device_by_node(np); 63 63 struct nvmem_cell *cell; ··· 94 94 95 95 return 0; 96 96 } 97 + EXPORT_SYMBOL(of_get_mac_address_nvmem); 97 98 98 99 /** 99 100 * of_get_mac_address() ··· 141 140 if (!ret) 142 141 return 0; 143 142 144 - return of_get_mac_addr_nvmem(np, addr); 143 + return of_get_mac_address_nvmem(np, addr); 145 144 } 146 145 EXPORT_SYMBOL(of_get_mac_address); 147 146