[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <82ea17c0-826b-7dae-8709-da721c4d0d6c@gmail.com>
Date: Fri, 16 Apr 2021 12:21:20 +0300
From: Sergei Shtylyov <sergei.shtylyov@...il.com>
To: Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Rob Herring <robh+dt@...nel.org>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mips@...r.kernel.org
Subject: Re: [PATCH v4 net-next 07/10] net: korina: Add support for device
tree
Hello!
On 16.04.2021 11:47, Thomas Bogendoerfer wrote:
> If there is no mac address passed via platform data try to get it via > device tree and fall back to a random mac address, if all fail.
>
> Signed-off-by: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
> ---
> drivers/net/ethernet/korina.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
> index d6dbbdd43d7c..cd078a5c679b 100644
> --- a/drivers/net/ethernet/korina.c
> +++ b/drivers/net/ethernet/korina.c
> @@ -43,6 +43,8 @@
> #include <linux/ioport.h>
> #include <linux/iopoll.h>
> #include <linux/in.h>
> +#include <linux/of_device.h>
> +#include <linux/of_net.h>
> #include <linux/slab.h>
> #include <linux/string.h>
> #include <linux/delay.h>
> @@ -1068,7 +1070,12 @@ static int korina_probe(struct platform_device *pdev)
> SET_NETDEV_DEV(dev, &pdev->dev);
> lp = netdev_priv(dev);
>
> - memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
> + if (mac_addr) {
> + ether_addr_copy(dev->dev_addr, mac_addr);
> + } else {
> + if (of_get_mac_address(pdev->dev.of_node, dev->dev_addr))
*else* *if* here, and no need for {} then? :-)
> + eth_hw_addr_random(dev);
> + }
>
> lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx");
> lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx");
[...]
MBR, Sergei
Powered by blists - more mailing lists