netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Klauser <tklauser@distanz.ch>
To: Chris Metcalf <cmetcalf@tilera.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH v2 2/2] net: tile: Use helpers from linux/etherdevice.h to check/set MAC
Date: Fri, 30 May 2014 09:47:17 +0200	[thread overview]
Message-ID: <1401436037-4993-1-git-send-email-tklauser@distanz.ch> (raw)
In-Reply-To: <1401192245-26260-1-git-send-email-tklauser@distanz.ch>

Use is_zero_ether_addr() to check for the MAC address being all zeros instead of
open coding the check.

Also use ether_addr_copy() instead of a manual memcpy() to set the
netdev->dev_addr.

Furthermore, get rid of a redundant assignment of netdev->addr_len. This is
already set by ether_setup() which is called in tile_net_setup().

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>

---
v2: only check for zero address

 drivers/net/ethernet/tile/tilegx.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 0db40de..14389f8 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -2192,7 +2192,6 @@ static void tile_net_dev_init(const char *name, const uint8_t *mac)
 {
 	int ret;
 	int i;
-	int nz_addr = 0;
 	struct net_device *dev;
 	struct tile_net_priv *priv;
 
@@ -2222,15 +2221,10 @@ static void tile_net_dev_init(const char *name, const uint8_t *mac)
 	 * be done before the device is opened.  If the MAC is all zeroes,
 	 * we use a random address, since we're probably on the simulator.
 	 */
-	for (i = 0; i < 6; i++)
-		nz_addr |= mac[i];
-
-	if (nz_addr) {
-		memcpy(dev->dev_addr, mac, ETH_ALEN);
-		dev->addr_len = 6;
-	} else {
+	if (!is_zero_ether_addr(mac))
+		ether_addr_copy(dev->dev_addr, mac);
+	else
 		eth_hw_addr_random(dev);
-	}
 
 	/* Register the network device. */
 	ret = register_netdev(dev);
-- 
1.7.9.5

  parent reply	other threads:[~2014-05-30  7:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-27 12:04 [PATCH 2/2] net: tilegx: Use helpers from linux/etherdevice.h to check/set MAC Tobias Klauser
2014-05-28 19:43 ` Chris Metcalf
2014-05-30  7:14   ` Tobias Klauser
2014-05-30  7:47 ` Tobias Klauser [this message]
2014-05-31  0:06   ` [PATCH v2 2/2] net: tile: " 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=1401436037-4993-1-git-send-email-tklauser@distanz.ch \
    --to=tklauser@distanz.ch \
    --cc=cmetcalf@tilera.com \
    --cc=netdev@vger.kernel.org \
    /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).