mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2024-11-25 06:26:15 +00:00
8c405cdccc
The patches were generated from the RPi repo with the following command: git format-patch v6.6.34..rpi-6.1.y Some patches needed rebasing and, as usual, the applied and reverted, wireless drivers, Github workflows, READMEs and defconfigs patches were removed. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
73 lines
2.2 KiB
Diff
73 lines
2.2 KiB
Diff
From 51c5d2bb01d3a0cff31d00686f35ed8f33039f78 Mon Sep 17 00:00:00 2001
|
|
From: popcornmix <popcornmix@gmail.com>
|
|
Date: Tue, 26 Mar 2013 17:26:38 +0000
|
|
Subject: [PATCH 1131/1135] Allow mac address to be set in smsc95xx
|
|
|
|
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
|
|
|
SQUASH: smsc95xx: Use dev_mod_addr to set MAC addr
|
|
|
|
Since adeef3e32146 ("net: constify netdev->dev_addr") it has been
|
|
illegal to write to the dev_addr MAC address field. Later commits
|
|
have added explicit checks that it hasn't been modified by nefarious
|
|
means. The dev_addr_mod helper function is the accepted way to change
|
|
the dev_addr field, so use it.
|
|
|
|
Squash with 96c1def63ee1 ("Allow mac address to be set in smsc95xx").
|
|
|
|
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|
---
|
|
drivers/net/usb/smsc95xx.c | 27 +++++++++++++++++++++++++++
|
|
1 file changed, 27 insertions(+)
|
|
|
|
--- a/drivers/net/usb/smsc95xx.c
|
|
+++ b/drivers/net/usb/smsc95xx.c
|
|
@@ -83,6 +83,10 @@ static int packetsize = 2560;
|
|
module_param(packetsize, int, 0644);
|
|
MODULE_PARM_DESC(packetsize, "Override the RX URB packet size");
|
|
|
|
+static char *macaddr = ":";
|
|
+module_param(macaddr, charp, 0);
|
|
+MODULE_PARM_DESC(macaddr, "MAC address");
|
|
+
|
|
static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
|
|
u32 *data)
|
|
{
|
|
@@ -805,6 +809,21 @@ static int smsc95xx_ioctl(struct net_dev
|
|
return phy_mii_ioctl(netdev->phydev, rq, cmd);
|
|
}
|
|
|
|
+/* Check the macaddr module parameter for a MAC address */
|
|
+static int smsc95xx_macaddr_param(struct usbnet *dev, struct net_device *nd)
|
|
+{
|
|
+ u8 mtbl[ETH_ALEN];
|
|
+
|
|
+ if (mac_pton(macaddr, mtbl)) {
|
|
+ netif_dbg(dev, ifup, dev->net,
|
|
+ "Overriding MAC address with: %pM\n", mtbl);
|
|
+ dev_addr_mod(nd, 0, mtbl, ETH_ALEN);
|
|
+ return 0;
|
|
+ } else {
|
|
+ return -EINVAL;
|
|
+ }
|
|
+}
|
|
+
|
|
static void smsc95xx_init_mac_address(struct usbnet *dev)
|
|
{
|
|
u8 addr[ETH_ALEN];
|
|
@@ -827,6 +846,14 @@ static void smsc95xx_init_mac_address(st
|
|
return;
|
|
}
|
|
}
|
|
+
|
|
+ /* Check module parameters */
|
|
+ if (smsc95xx_macaddr_param(dev, dev->net) == 0) {
|
|
+ if (is_valid_ether_addr(dev->net->dev_addr)) {
|
|
+ netif_dbg(dev, ifup, dev->net, "MAC address read from module parameter\n");
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
|
|
/* no useful static MAC address found. generate a random one */
|
|
eth_hw_addr_random(dev->net);
|