From: sshtylyov@mvista.com (Sergei Shtylyov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid
Date: Wed, 21 Nov 2012 23:16:40 +0300 [thread overview]
Message-ID: <50AD36A8.6000702@mvista.com> (raw)
In-Reply-To: <1353493362-30418-1-git-send-email-plagnioj@jcrosoft.com>
Hello.
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 at vger.kernel.org
> Cc: netdev at 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;
> @@ -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
WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sshtylyov-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
To: Jean-Christophe PLAGNIOL-VILLARD
<plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid
Date: Wed, 21 Nov 2012 23:16:40 +0300 [thread overview]
Message-ID: <50AD36A8.6000702@mvista.com> (raw)
In-Reply-To: <1353493362-30418-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org>
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
next prev parent reply other threads:[~2012-11-21 20:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 10:22 [PATCH 1/1] asix: use ramdom hw addr if the one read is not valid Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 10:22 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 20:16 ` Sergei Shtylyov [this message]
2012-11-21 20:16 ` Sergei Shtylyov
2012-11-22 8:55 ` Bjørn Mork
2012-11-22 8:55 ` Bjørn Mork
2012-11-22 7:35 ` [PATCH 1/1 v2] " Jean-Christophe PLAGNIOL-VILLARD
2012-11-22 7:35 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-23 19:30 ` David Miller
2012-11-23 19:30 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50AD36A8.6000702@mvista.com \
--to=sshtylyov@mvista.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.