Skip to content

Commit 4c47867

Browse files
miquelraynalPaolo Abeni
authored andcommitted
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>
1 parent 39d1038 commit 4c47867

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/linux/of_net.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
struct net_device;
1515
extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface);
1616
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);
1718
int of_get_ethdev_address(struct device_node *np, struct net_device *dev);
1819
extern struct net_device *of_find_net_device_by_node(struct device_node *np);
1920
#else
@@ -28,6 +29,11 @@ static inline int of_get_mac_address(struct device_node *np, u8 *mac)
2829
return -ENODEV;
2930
}
3031

32+
static inline int of_get_mac_address_nvmem(struct device_node *np, u8 *mac)
33+
{
34+
return -ENODEV;
35+
}
36+
3137
static inline int of_get_ethdev_address(struct device_node *np, struct net_device *dev)
3238
{
3339
return -ENODEV;

net/core/of_net.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int of_get_mac_addr(struct device_node *np, const char *name, u8 *addr)
5757
return -ENODEV;
5858
}
5959

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)
6161
{
6262
struct platform_device *pdev = of_find_device_by_node(np);
6363
struct nvmem_cell *cell;
@@ -94,6 +94,7 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
9494

9595
return 0;
9696
}
97+
EXPORT_SYMBOL(of_get_mac_address_nvmem);
9798

9899
/**
99100
* of_get_mac_address()
@@ -140,7 +141,7 @@ int of_get_mac_address(struct device_node *np, u8 *addr)
140141
if (!ret)
141142
return 0;
142143

143-
return of_get_mac_addr_nvmem(np, addr);
144+
return of_get_mac_address_nvmem(np, addr);
144145
}
145146
EXPORT_SYMBOL(of_get_mac_address);
146147

0 commit comments

Comments
 (0)