ACK: [Xenial snapdragon][PATCH 1/1] UBUNTU: SAUCE: smsc75xx: read MAC address from file if it exists

Hui Wang hui.wang at canonical.com
Wed Jul 4 03:54:50 UTC 2018


Looks fine to me, this change is safe to other platforms which also use 
this driver since they don't have the file in that folder.

Acked-by: Hui Wang <hui.wang at canonical.com>


On 2018年06月28日 17:01, Wen-chien Jesse Sung wrote:
> BugLink: https://launchpad.net/bugs/1779035
>
> When trying to determine which MAC address to use, find if a valid one
> is available in the file first.
>
> Signed-off-by: Wen-chien Jesse Sung <jesse.sung at canonical.com>
> ---
>   drivers/net/usb/smsc75xx.c | 32 ++++++++++++++++++++++++++++++++
>   1 file changed, 32 insertions(+)
>
> diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
> index 7337e6c0e126..b4352d4f58b1 100644
> --- a/drivers/net/usb/smsc75xx.c
> +++ b/drivers/net/usb/smsc75xx.c
> @@ -29,6 +29,7 @@
>   #include <linux/crc32.h>
>   #include <linux/usb/usbnet.h>
>   #include <linux/slab.h>
> +#include <linux/firmware.h>
>   #include "smsc75xx.h"
>   
>   #define SMSC_CHIPNAME			"smsc75xx"
> @@ -759,8 +760,39 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
>   	return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
>   }
>   
> +#define MAC_BASENAME	"smsc75xx/ethmacaddr"
> +
> +static int smsc75xx_get_hw_mac(struct usbnet *dev)
> +{
> +	const struct firmware *fp = NULL;
> +	int ret;
> +	u8 tmp[32];
> +
> +	snprintf(tmp, sizeof(tmp), "%s-%s", MAC_BASENAME, dev->udev->devpath);
> +	ret = request_firmware(&fp, tmp, &dev->udev->dev);
> +	if (!ret) {
> +		memset(tmp, 0, sizeof(tmp));
> +		memcpy(tmp, fp->data, sizeof(tmp) - 1);
> +		sscanf(tmp, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
> +			&dev->net->dev_addr[0],
> +			&dev->net->dev_addr[1],
> +			&dev->net->dev_addr[2],
> +			&dev->net->dev_addr[3],
> +			&dev->net->dev_addr[4],
> +			&dev->net->dev_addr[5]);
> +
> +		release_firmware(fp);
> +	}
> +	return ret;
> +}
> +
>   static void smsc75xx_init_mac_address(struct usbnet *dev)
>   {
> +	if (!smsc75xx_get_hw_mac(dev) && is_valid_ether_addr(dev->net->dev_addr)) {
> +		netif_dbg(dev, ifup, dev->net, "MAC address read from file\n");
> +		return;
> +	}
> +
>   	/* try reading mac address from EEPROM */
>   	if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
>   			dev->net->dev_addr) == 0) {


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20180704/1ef6b1c5/attachment.html>


More information about the kernel-team mailing list