From: Andrew Lunn <andrew@lunn.ch>
To: thesven73@gmail.com
Cc: svendev@arcx.com, siva.kallam@broadcom.com,
prashant@broadcom.com, mchan@broadcom.com, davem@davemloft.net,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
arnd@arndb.de
Subject: Re: [PATCH v1] tg3: optionally get mac address from devicetree
Date: Tue, 13 Nov 2018 22:09:13 +0100 [thread overview]
Message-ID: <20181113210913.GD9828@lunn.ch> (raw)
In-Reply-To: <20181113161508.7427-1-TheSven73@googlemail.com>
> +static int tg3_of_get_macaddr(struct tg3 *tp)
> {
> - struct net_device *dev = tp->dev;
> - struct pci_dev *pdev = tp->pdev;
> - struct device_node *dp = pci_device_to_OF_node(pdev);
> - const unsigned char *addr;
> - int len;
> + struct device_node *np = pci_device_to_OF_node(tp->pdev);
> + const void *mac;
>
> - addr = of_get_property(dp, "local-mac-address", &len);
> - if (addr && len == ETH_ALEN) {
> - memcpy(dev->dev_addr, addr, ETH_ALEN);
> - return 0;
> - }
> - return -ENODEV;
> + if (!np)
> + return -ENODEV;
> + mac = of_get_mac_address(np);
> + if (!mac || !is_valid_ether_addr(mac))
> + return -EINVAL;
Hi Sven
If i'm reading of_get_mac_address() correctly, there is no need to
call is_valid_ether_addr() afterwards. It does it already.
Andrew
next prev parent reply other threads:[~2018-11-13 21:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 16:15 [PATCH v1] tg3: optionally get mac address from devicetree thesven73
2018-11-13 21:09 ` Andrew Lunn [this message]
2018-11-17 3:37 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181113210913.GD9828@lunn.ch \
--to=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=prashant@broadcom.com \
--cc=siva.kallam@broadcom.com \
--cc=svendev@arcx.com \
--cc=thesven73@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).