Skip to content

Commit

Permalink
Revert "of: net: support NVMEM cells with MAC in text format"
Browse files Browse the repository at this point in the history
This reverts commit 9ed319e.

We can already post process a nvmem cell value in a particular driver.
Instead of having yet another place to convert the values, the post
processing hook of the nvmem provider should be used in this case.

Signed-off-by: Michael Walle <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mwalle authored and davem330 committed Jan 12, 2022
1 parent edcb501 commit 3486eb7
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions net/core/of_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
{
struct platform_device *pdev = of_find_device_by_node(np);
struct nvmem_cell *cell;
const void *buf;
const void *mac;
size_t len;
int ret;

Expand All @@ -78,32 +78,21 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
if (IS_ERR(cell))
return PTR_ERR(cell);

buf = nvmem_cell_read(cell, &len);
mac = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);

if (IS_ERR(buf))
return PTR_ERR(buf);

ret = 0;
if (len == ETH_ALEN) {
if (is_valid_ether_addr(buf))
memcpy(addr, buf, ETH_ALEN);
else
ret = -EINVAL;
} else if (len == 3 * ETH_ALEN - 1) {
u8 mac[ETH_ALEN];

if (mac_pton(buf, mac))
memcpy(addr, mac, ETH_ALEN);
else
ret = -EINVAL;
} else {
ret = -EINVAL;
if (IS_ERR(mac))
return PTR_ERR(mac);

if (len != ETH_ALEN || !is_valid_ether_addr(mac)) {
kfree(mac);
return -EINVAL;
}

kfree(buf);
memcpy(addr, mac, ETH_ALEN);
kfree(mac);

return ret;
return 0;
}

/**
Expand Down

0 comments on commit 3486eb7

Please sign in to comment.