[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5405BDC0.6060508@cogentembedded.com>
Date: Tue, 02 Sep 2014 16:53:20 +0400
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Hayes Wang <hayeswang@...ltek.com>, netdev@...r.kernel.org
CC: nic_swsd@...ltek.com, linux-kernel@...r.kernel.org,
linux-usb@...r.kernel.org
Subject: Re: [PATCH net-next 2/2] r8152: use eth_hw_addr_random
Hello.
On 9/2/2014 1:55 PM, Hayes Wang wrote:
> If the hw doesn't have a valid MAC address, give a random one and
> set it to the hw.
> Signed-off-by: Hayes Wang <hayeswang@...ltek.com>
> ---
> drivers/net/usb/r8152.c | 39 ++++++++++++++++++++++++---------------
> 1 file changed, 24 insertions(+), 15 deletions(-)
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index b5ff933..2bc1b8d 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -992,32 +992,41 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
> return 0;
> }
>
> -static inline void set_ethernet_addr(struct r8152 *tp)
> +static int set_ethernet_addr(struct r8152 *tp)
> {
> struct net_device *dev = tp->netdev;
> + struct sockaddr sa;
> int ret;
> - u8 node_id[8] = {0};
>
> if (tp->version == RTL_VER_01)
> - ret = pla_ocp_read(tp, PLA_IDR, sizeof(node_id), node_id);
> + ret = pla_ocp_read(tp, PLA_IDR, 8, sa.sa_data);
> else
> - ret = pla_ocp_read(tp, PLA_BACKUP, sizeof(node_id), node_id);
> + ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa.sa_data);
>
> if (ret < 0) {
> - netif_notice(tp, probe, dev, "inet addr fail\n");
> + netif_err(tp, probe, dev, "Get ether addr fail\n");
> + } else if (!is_valid_ether_addr(sa.sa_data)) {
> + netif_err(tp, probe, dev,
> + "Invalid ether addr %02x:%02x:%02x:%02x:%02x:%02x\n",
There's now "%pM" format specifier for printing a MAC address.
> + sa.sa_data[0], sa.sa_data[1], sa.sa_data[2],
> + sa.sa_data[3], sa.sa_data[4], sa.sa_data[5]);
> + eth_hw_addr_random(dev);
> + ether_addr_copy(sa.sa_data, dev->dev_addr);
> + ret = rtl8152_set_mac_address(dev, &sa);
> + netif_info(tp, probe, dev,
> + "Random ether addr %02x:%02x:%02x:%02x:%02x:%02x\n",
Likewise.
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists