Subject: [PATCH] dm9601: warn on invalid mac address

From: Wu Fengguang <[email-masked]>
Date: Tue, 6 Jan 2009 17:10:50 +0800

Add warnings on invalid mac address to help disclose/debug problems.

Signed-off-by: Wu Fengguang <[email-masked]>
---
 drivers/net/usb/dm9601.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- linux-2.6.orig/drivers/net/usb/dm9601.c
+++ linux-2.6/drivers/net/usb/dm9601.c
@@ -401,8 +401,12 @@ static int dm9601_set_mac_address(struct
 	struct sockaddr *addr = p;
 	struct usbnet *dev = netdev_priv(net);
 
-	if (!is_valid_ether_addr(addr->sa_data))
+	if (!is_valid_ether_addr(addr->sa_data)) {
+		DECLARE_MAC_BUF(mac_buf);
+		print_mac(mac_buf, addr->sa_data);
+		dev_warn(&net->dev, "not setting invalid mac address %s\n", mac_buf);
 		return -EINVAL;
+	}
 
 	memcpy(net->dev_addr, addr->sa_data, net->addr_len);
 	dm_write_async(dev, DM_PHY_ADDR, net->addr_len, net->dev_addr);
@@ -449,6 +453,12 @@ static int dm9601_bind(struct usbnet *de
 	 */
 	if (is_valid_ether_addr(mac))
 		memcpy(dev->net->dev_addr, mac, ETH_ALEN);
+	else {
+		DECLARE_MAC_BUF(mac_buf);
+		print_mac(mac_buf, mac);
+		devdbg(dev, "EEPROM reported mac address %s is invalid,"
+				" use the randomly generated one.", mac_buf);
+	}
 
 	/* power up phy */
 	dm_write_reg(dev, DM_GPR_CTRL, 1);