* [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid
@ 2012-11-21 10:22 Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1353493362-30418-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-11-22 7:35 ` [PATCH 1/1 v2] " Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 2 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-21 10:22 UTC (permalink / raw)
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: Jean-Christophe PLAGNIOL-VILLARD,
linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
drivers/net/usb/asix_devices.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 33ab824..7ebec5b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -225,7 +225,13 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
ret);
goto out;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+
+ if (is_valid_ether_addr(buf)) {
+ memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+ } else {
+ netdev_info(dev->net, "invalid hw address, using random\n");
+ eth_hw_addr_random(dev->net);
+ }
/* Initialize MII structure */
dev->mii.dev = dev->net;
@@ -423,7 +429,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+
+ if (is_valid_ether_addr(buf)) {
+ memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+ } else {
+ netdev_info(dev->net, "invalid hw address, using random\n");
+ eth_hw_addr_random(dev->net);
+ }
/* Initialize MII structure */
dev->mii.dev = dev->net;
@@ -777,7 +789,13 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+
+ if (is_valid_ether_addr(buf)) {
+ memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+ } else {
+ netdev_info(dev->net, "invalid hw address, using random\n");
+ eth_hw_addr_random(dev->net);
+ }
/* Initialize MII structure */
dev->mii.dev = dev->net;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1353493362-30418-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>]
* Re: [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid
[not found] ` <1353493362-30418-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
@ 2012-11-21 20:16 ` Sergei Shtylyov
2012-11-22 8:55 ` Bjørn Mork
0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2012-11-21 20:16 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
Hello.
On 11/21/2012 01:22 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
> Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---
> drivers/net/usb/asix_devices.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
> diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
> index 33ab824..7ebec5b 100644
> --- a/drivers/net/usb/asix_devices.c
> +++ b/drivers/net/usb/asix_devices.c
> @@ -225,7 +225,13 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
> ret);
> goto out;
> }
> - memcpy(dev->net->dev_addr, buf, ETH_ALEN);
> +
> + if (is_valid_ether_addr(buf)) {
> + memcpy(dev->net->dev_addr, buf, ETH_ALEN);
> + } else {
> + netdev_info(dev->net, "invalid hw address, using random\n");
> + eth_hw_addr_random(dev->net);
> + }
>
> /* Initialize MII structure */
> dev->mii.dev = dev->net;
> @@ -423,7 +429,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
> netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
> return ret;
> }
> - memcpy(dev->net->dev_addr, buf, ETH_ALEN);
> +
> + if (is_valid_ether_addr(buf)) {
> + memcpy(dev->net->dev_addr, buf, ETH_ALEN);
> + } else {
> + netdev_info(dev->net, "invalid hw address, using random\n");
> + eth_hw_addr_random(dev->net);
> + }
>
> /* Initialize MII structure */
> dev->mii.dev = dev->net;
> @@ -777,7 +789,13 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
> netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
> return ret;
> }
> - memcpy(dev->net->dev_addr, buf, ETH_ALEN);
> +
> + if (is_valid_ether_addr(buf)) {
> + memcpy(dev->net->dev_addr, buf, ETH_ALEN);
> + } else {
> + netdev_info(dev->net, "invalid hw address, using random\n");
> + eth_hw_addr_random(dev->net);
> + }
>
> /* Initialize MII structure */
> dev->mii.dev = dev->net;
Repeated thrice, this asks to be put into subroutine...
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid
2012-11-21 20:16 ` Sergei Shtylyov
@ 2012-11-22 8:55 ` Bjørn Mork
0 siblings, 0 replies; 5+ messages in thread
From: Bjørn Mork @ 2012-11-22 8:55 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD
Cc: netdev, linux-usb, linux-arm-kernel, Sergei Shtylyov
Sergei Shtylyov <sshtylyov@mvista.com> writes:
> On 11/21/2012 01:22 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
>
>> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
>> Cc: linux-usb@vger.kernel.org
>> Cc: netdev@vger.kernel.org
>> ---
>> drivers/net/usb/asix_devices.c | 24 +++++++++++++++++++++---
>> 1 file changed, 21 insertions(+), 3 deletions(-)
>
>> diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
>> index 33ab824..7ebec5b 100644
>> --- a/drivers/net/usb/asix_devices.c
>> +++ b/drivers/net/usb/asix_devices.c
>> @@ -225,7 +225,13 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
>> ret);
>> goto out;
>> }
>> - memcpy(dev->net->dev_addr, buf, ETH_ALEN);
>> +
>> + if (is_valid_ether_addr(buf)) {
>> + memcpy(dev->net->dev_addr, buf, ETH_ALEN);
>> + } else {
>> + netdev_info(dev->net, "invalid hw address, using random\n");
>> + eth_hw_addr_random(dev->net);
>> + }
>>
>> /* Initialize MII structure */
>> dev->mii.dev = dev->net;
[..]
>
> Repeated thrice, this asks to be put into subroutine...
Yes. Looking at the driver, this probably goes for most of the three
_bind() functions. There is a lot of common code there.
But more important wrt the eth_hw_addr_random() change: Does this
actually work with real devices? The driver implements a
asix_set_mac_address() which writes the address back to the device when
you change it. I assume there is a reason for doing that. Why don't
you do it here?
Bjørn
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1 v2] asix: use ramdom hw addr if the one read is not valid
2012-11-21 10:22 [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1353493362-30418-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
@ 2012-11-22 7:35 ` Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1353569717-1260-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
1 sibling, 1 reply; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-22 7:35 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: netdev, linux-usb, Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: linux-usb@vger.kernel.org
Cc: netdev@vger.kernel.org
---
v2:
introduce asix_set_netdev_dev_addr
Best Regards,
J.
drivers/net/usb/asix_devices.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 33ab824..7a6e758 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -64,6 +64,16 @@ static void asix_status(struct usbnet *dev, struct urb *urb)
}
}
+static void asix_set_netdev_dev_addr(struct usbnet *dev, u8 *addr)
+{
+ if (is_valid_ether_addr(addr)) {
+ memcpy(dev->net->dev_addr, addr, ETH_ALEN);
+ } else {
+ netdev_info(dev->net, "invalid hw address, using random\n");
+ eth_hw_addr_random(dev->net);
+ }
+}
+
/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
static u32 asix_get_phyid(struct usbnet *dev)
{
@@ -225,7 +235,8 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
ret);
goto out;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+
+ asix_set_netdev_dev_addr(dev, buf);
/* Initialize MII structure */
dev->mii.dev = dev->net;
@@ -423,7 +434,8 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+
+ asix_set_netdev_dev_addr(dev, buf);
/* Initialize MII structure */
dev->mii.dev = dev->net;
@@ -777,7 +789,8 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+
+ asix_set_netdev_dev_addr(dev, buf);
/* Initialize MII structure */
dev->mii.dev = dev->net;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-23 19:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-21 10:22 [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1353493362-30418-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-11-21 20:16 ` Sergei Shtylyov
2012-11-22 8:55 ` Bjørn Mork
2012-11-22 7:35 ` [PATCH 1/1 v2] " Jean-Christophe PLAGNIOL-VILLARD
[not found] ` <1353569717-1260-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
2012-11-23 19:30 ` David Miller
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).