# Re: \[PATCH 2/2\] of: net: fix of\_get\_mac\_addr\_nvmem() for PCI and DSA nodes

- From: Andrew Lunn \<andrew@lunn.ch\>
- Date: 2021-04-05 21:34:44 
- List: netdev
- Page: https://ratatoskr.run/netdev/2021/04/11200658
- Thread: https://ratatoskr.run/netdev/2021/04/6327232/t.md

```text
Hi Michael

> -static int of_get_mac_addr_nvmem(struct device_node *np, u8 addr)
> +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 *mac;
> +	size_t len;
>  	int ret;
>  
> -	if (!pdev)
> -		return -ENODEV;
> +	/* Try lookup by device first, there might be a nvmem_cell_lookup
> +	 * associated with a given device.
> +	 */
> +	if (pdev) {
> +		ret = nvmem_get_mac_address(&pdev->dev, addr);
> +		put_device(&pdev->dev);
> +		return ret;
> +	}

Can you think of any odd corner case where nvmem_get_mac_address()
would fail, but of_nvmem_cell_get(np, "mac-address") would work?

      Andrew
```
