0147-Updated-smsc95xx-driver-to-check-for-a-valid-MAC-add.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 0f77e8585ca73daddcc386ec45c9e5d5649de0fa Mon Sep 17 00:00:00 2001
  2. From: Craig Roberts <cjr@craigroberts.net>
  3. Date: Tue, 16 Feb 2016 10:03:42 +0000
  4. Subject: [PATCH] Updated smsc95xx driver to check for a valid MAC address in
  5. eeprom before using smsc95xx.macaddr parameter passed on command line.
  6. The built-in RPi adaptor will still get a MAC address based on the parameter passed on the command line as the RPi hardware does not have an eeprom,
  7. however usb->ethernet adaptors using the same driver should have an eeprom with MAC address as part of their hardware and therefore will use this
  8. meaning they don't end up with the same MAC address as the built-in RPi adaptor.
  9. ---
  10. drivers/net/usb/smsc95xx.c | 10 +++++-----
  11. 1 file changed, 5 insertions(+), 5 deletions(-)
  12. --- a/drivers/net/usb/smsc95xx.c
  13. +++ b/drivers/net/usb/smsc95xx.c
  14. @@ -820,10 +820,6 @@ static int smsc95xx_is_macaddr_param(str
  15. static void smsc95xx_init_mac_address(struct usbnet *dev)
  16. {
  17. - /* Check module parameters */
  18. - if (smsc95xx_is_macaddr_param(dev, dev->net->dev_addr))
  19. - return;
  20. -
  21. /* try reading mac address from EEPROM */
  22. if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
  23. dev->net->dev_addr) == 0) {
  24. @@ -834,7 +830,11 @@ static void smsc95xx_init_mac_address(st
  25. }
  26. }
  27. - /* no eeprom, or eeprom values are invalid. generate random MAC */
  28. + /* Check module parameters */
  29. + if (smsc95xx_is_macaddr_param(dev, dev->net->dev_addr))
  30. + return;
  31. +
  32. + /* no eeprom, or eeprom values are invalid, and no module parameter specified to set MAC. Generate random MAC */
  33. eth_hw_addr_random(dev->net);
  34. netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
  35. }