[PATCH] usb:smsc: preserve MAC address when resetting device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Initialize MAC address only once, when device opened first time
to avoid generation random addresses when failed to read one from ROM.

Some hardware hasn't hw address in ROM, e.g. Pandaboard  (http://pandaboard.org),
so every time device is up, its address is regenerated again.
It makeis impossible to set custom hw address and also makes DHCP servers and switches crazy.

Signed-off-by: Sergiy Kibrik <sakib@xxxxxxx>
---
 drivers/net/usb/smsc75xx.c |    6 +++++-
 drivers/net/usb/smsc95xx.c |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 753ee6e..a45dfa2 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -77,6 +77,7 @@ struct usb_context {
 };
 
 static int turbo_mode = true;
+static int first_reset = true;
 module_param(turbo_mode, bool, 0644);
 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
 
@@ -836,7 +837,10 @@ static int smsc75xx_reset(struct usbnet *dev)
 
 	netif_dbg(dev, ifup, dev->net, "PHY reset complete");
 
-	smsc75xx_init_mac_address(dev);
+	if (first_reset){
+		smsc75xx_init_mac_address(dev);
+		first_reset = false;
+	}
 
 	ret = smsc75xx_set_mac_address(dev);
 	check_warn_return(ret, "Failed to set mac address");
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index bc86f4b..83008c1 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -59,6 +59,7 @@ struct usb_context {
 	struct usbnet *dev;
 };
 
+static int first_reset = true;
 static int turbo_mode = true;
 module_param(turbo_mode, bool, 0644);
 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
@@ -1045,7 +1046,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	pdata->use_tx_csum = DEFAULT_TX_CSUM_ENABLE;
 	pdata->use_rx_csum = DEFAULT_RX_CSUM_ENABLE;
 
-	smsc95xx_init_mac_address(dev);
+	if (first_reset){
+		smsc95xx_init_mac_address(dev);
+		first_reset = false;
+	}
 
 	/* Init all registers */
 	ret = smsc95xx_reset(dev);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux