Re: [PATCH 1/2] net/smscx5xx: use the device tree for mac address

2016-02-03 Thread Lubomir Rintel
On Wed, 2016-02-03 at 16:23 +0100, Arnd Bergmann wrote:
> On Wednesday 03 February 2016 16:02:38 Lubomir Rintel wrote:
> > From: Arnd Bergmann 
> > 
> > This takes the MAC address for smsc75xx/smsc95xx USB network
> > devices
> > from a the device tree. This is required to get a usable persistent
> > address on the popular beagleboard, whose hardware designers
> > accidentally forgot that an ethernet device really requires an a
> > MAC address to be functional.
> > 
> > The smsc75xx and smsc95xx drivers are just two copies of the
> > same code, so better fix both.
> > 
> > Tested-by: Lubomir Rintel 
> > Signed-off-by: Arnd Bergmann 
> > 
> 
> I have no memory of writing this patch, where did you find it?

2011's discussion: https://lkml.org/lkml/2011/3/17/416
(Link also in the cover letter).

> The changelog sounds like I wrote it, so I assume it was me after
> all.
> 
> > +   address = of_get_property(dev->udev->dev.of_node,
> > + "local-mac-address", NULL);
> > +   if (address) {
> > +   memcpy(dev->net->dev_addr, address, ETH_ALEN);
> > +   return;
> > +   }
> 
> This should use of_get_mac_address(), not an open-coded property
> lookup. The function was probably added after I wrote the
> the original patch.

Okay. Will fix that up once I get feedback for the devicetree part.

>   Arnd

Thanks,
Lubo


Re: [PATCH 1/2] net/smscx5xx: use the device tree for mac address

2016-02-03 Thread Arnd Bergmann
On Wednesday 03 February 2016 16:02:38 Lubomir Rintel wrote:
> From: Arnd Bergmann 
> 
> This takes the MAC address for smsc75xx/smsc95xx USB network devices
> from a the device tree. This is required to get a usable persistent
> address on the popular beagleboard, whose hardware designers
> accidentally forgot that an ethernet device really requires an a
> MAC address to be functional.
> 
> The smsc75xx and smsc95xx drivers are just two copies of the
> same code, so better fix both.
> 
> Tested-by: Lubomir Rintel 
> Signed-off-by: Arnd Bergmann 
> 

I have no memory of writing this patch, where did you find it?

The changelog sounds like I wrote it, so I assume it was me after all.

> +   address = of_get_property(dev->udev->dev.of_node,
> + "local-mac-address", NULL);
> +   if (address) {
> +   memcpy(dev->net->dev_addr, address, ETH_ALEN);
> +   return;
> +   }

This should use of_get_mac_address(), not an open-coded property
lookup. The function was probably added after I wrote the
the original patch.

Arnd


[PATCH 1/2] net/smscx5xx: use the device tree for mac address

2016-02-03 Thread Lubomir Rintel
From: Arnd Bergmann 

This takes the MAC address for smsc75xx/smsc95xx USB network devices
from a the device tree. This is required to get a usable persistent
address on the popular beagleboard, whose hardware designers
accidentally forgot that an ethernet device really requires an a
MAC address to be functional.

The smsc75xx and smsc95xx drivers are just two copies of the
same code, so better fix both.

Tested-by: Lubomir Rintel 
Signed-off-by: Arnd Bergmann 
---
 drivers/net/usb/smsc75xx.c | 10 ++
 drivers/net/usb/smsc95xx.c | 10 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 30033db..b2e33e6 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "smsc75xx.h"
 
 #define SMSC_CHIPNAME  "smsc75xx"
@@ -761,6 +762,8 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct 
ifreq *rq, int cmd)
 
 static void smsc75xx_init_mac_address(struct usbnet *dev)
 {
+   const void *address;
+
/* try reading mac address from EEPROM */
if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
dev->net->dev_addr) == 0) {
@@ -772,6 +775,13 @@ static void smsc75xx_init_mac_address(struct usbnet *dev)
}
}
 
+   address = of_get_property(dev->udev->dev.of_node,
+ "local-mac-address", NULL);
+   if (address) {
+   memcpy(dev->net->dev_addr, address, ETH_ALEN);
+   return;
+   }
+
/* no eeprom, or eeprom values are invalid. generate random MAC */
eth_hw_addr_random(dev->net);
netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 66b3ab9..021b9ce 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "smsc95xx.h"
 
 #define SMSC_CHIPNAME  "smsc95xx"
@@ -765,6 +766,8 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct 
ifreq *rq, int cmd)
 
 static void smsc95xx_init_mac_address(struct usbnet *dev)
 {
+   const void *address;
+
/* try reading mac address from EEPROM */
if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
dev->net->dev_addr) == 0) {
@@ -775,6 +778,13 @@ static void smsc95xx_init_mac_address(struct usbnet *dev)
}
}
 
+   address = of_get_property(dev->udev->dev.of_node,
+ "local-mac-address", NULL);
+   if (address) {
+   memcpy(dev->net->dev_addr, address, ETH_ALEN);
+   return;
+   }
+
/* no eeprom, or eeprom values are invalid. generate random MAC */
eth_hw_addr_random(dev->net);
netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
-- 
2.5.0



Re: [PATCH 1/2] net/smscx5xx: use the device tree for mac address

2016-02-03 Thread Arnd Bergmann
On Wednesday 03 February 2016 16:02:38 Lubomir Rintel wrote:
> From: Arnd Bergmann 
> 
> This takes the MAC address for smsc75xx/smsc95xx USB network devices
> from a the device tree. This is required to get a usable persistent
> address on the popular beagleboard, whose hardware designers
> accidentally forgot that an ethernet device really requires an a
> MAC address to be functional.
> 
> The smsc75xx and smsc95xx drivers are just two copies of the
> same code, so better fix both.
> 
> Tested-by: Lubomir Rintel 
> Signed-off-by: Arnd Bergmann 
> 

I have no memory of writing this patch, where did you find it?

The changelog sounds like I wrote it, so I assume it was me after all.

> +   address = of_get_property(dev->udev->dev.of_node,
> + "local-mac-address", NULL);
> +   if (address) {
> +   memcpy(dev->net->dev_addr, address, ETH_ALEN);
> +   return;
> +   }

This should use of_get_mac_address(), not an open-coded property
lookup. The function was probably added after I wrote the
the original patch.

Arnd


[PATCH 1/2] net/smscx5xx: use the device tree for mac address

2016-02-03 Thread Lubomir Rintel
From: Arnd Bergmann 

This takes the MAC address for smsc75xx/smsc95xx USB network devices
from a the device tree. This is required to get a usable persistent
address on the popular beagleboard, whose hardware designers
accidentally forgot that an ethernet device really requires an a
MAC address to be functional.

The smsc75xx and smsc95xx drivers are just two copies of the
same code, so better fix both.

Tested-by: Lubomir Rintel 
Signed-off-by: Arnd Bergmann 
---
 drivers/net/usb/smsc75xx.c | 10 ++
 drivers/net/usb/smsc95xx.c | 10 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 30033db..b2e33e6 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "smsc75xx.h"
 
 #define SMSC_CHIPNAME  "smsc75xx"
@@ -761,6 +762,8 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct 
ifreq *rq, int cmd)
 
 static void smsc75xx_init_mac_address(struct usbnet *dev)
 {
+   const void *address;
+
/* try reading mac address from EEPROM */
if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
dev->net->dev_addr) == 0) {
@@ -772,6 +775,13 @@ static void smsc75xx_init_mac_address(struct usbnet *dev)
}
}
 
+   address = of_get_property(dev->udev->dev.of_node,
+ "local-mac-address", NULL);
+   if (address) {
+   memcpy(dev->net->dev_addr, address, ETH_ALEN);
+   return;
+   }
+
/* no eeprom, or eeprom values are invalid. generate random MAC */
eth_hw_addr_random(dev->net);
netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 66b3ab9..021b9ce 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "smsc95xx.h"
 
 #define SMSC_CHIPNAME  "smsc95xx"
@@ -765,6 +766,8 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct 
ifreq *rq, int cmd)
 
 static void smsc95xx_init_mac_address(struct usbnet *dev)
 {
+   const void *address;
+
/* try reading mac address from EEPROM */
if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
dev->net->dev_addr) == 0) {
@@ -775,6 +778,13 @@ static void smsc95xx_init_mac_address(struct usbnet *dev)
}
}
 
+   address = of_get_property(dev->udev->dev.of_node,
+ "local-mac-address", NULL);
+   if (address) {
+   memcpy(dev->net->dev_addr, address, ETH_ALEN);
+   return;
+   }
+
/* no eeprom, or eeprom values are invalid. generate random MAC */
eth_hw_addr_random(dev->net);
netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n");
-- 
2.5.0



Re: [PATCH 1/2] net/smscx5xx: use the device tree for mac address

2016-02-03 Thread Lubomir Rintel
On Wed, 2016-02-03 at 16:23 +0100, Arnd Bergmann wrote:
> On Wednesday 03 February 2016 16:02:38 Lubomir Rintel wrote:
> > From: Arnd Bergmann 
> > 
> > This takes the MAC address for smsc75xx/smsc95xx USB network
> > devices
> > from a the device tree. This is required to get a usable persistent
> > address on the popular beagleboard, whose hardware designers
> > accidentally forgot that an ethernet device really requires an a
> > MAC address to be functional.
> > 
> > The smsc75xx and smsc95xx drivers are just two copies of the
> > same code, so better fix both.
> > 
> > Tested-by: Lubomir Rintel 
> > Signed-off-by: Arnd Bergmann 
> > 
> 
> I have no memory of writing this patch, where did you find it?

2011's discussion: https://lkml.org/lkml/2011/3/17/416
(Link also in the cover letter).

> The changelog sounds like I wrote it, so I assume it was me after
> all.
> 
> > +   address = of_get_property(dev->udev->dev.of_node,
> > + "local-mac-address", NULL);
> > +   if (address) {
> > +   memcpy(dev->net->dev_addr, address, ETH_ALEN);
> > +   return;
> > +   }
> 
> This should use of_get_mac_address(), not an open-coded property
> lookup. The function was probably added after I wrote the
> the original patch.

Okay. Will fix that up once I get feedback for the devicetree part.

>   Arnd

Thanks,
Lubo