Skip to contentSkip to conversation

net: constify netdev->dev_addr - x86 changes

PATCH Applied Jakub Kicinski 3 participants 7 messages Nov 18, 2021 – Nov 19, 2021

Subsystems (6)

v1 of 2 Applied 4/4 Latest is v2 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover net: constify netdev->dev_addr - x86 changes

Resending these so they can get merged while I battle random cross builds.

Jakub Kicinski (4):
net: ax88796c: don't write to netdev->dev_addr directly
mlxsw: constify address in mlxsw_sp_port_dev_addr_set
wilc1000: copy address before calling wilc_set_mac_address
ipw2200: constify address in ipw_send_adapter_address

 drivers/net/ethernet/asix/ax88796c_main.c      | 18 ++++++++++--------
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c |  2 +-
 drivers/net/wireless/intel/ipw2x00/ipw2200.c   |  2 +-
 .../net/wireless/microchip/wilc1000/netdev.c   |  6 +++---
 4 files changed, 15 insertions(+), 13 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/4 net: ax88796c: don't write to netdev->dev_addr directly

The future is here, convert the new driver as we are about to make netdev->dev_addr const.

---
 drivers/net/ethernet/asix/ax88796c_main.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/net/ethernet/asix/ax88796c_main.c +10 -8
index e230d8d0ff73..e7a9f9863258 100644
@@ -144,12 +144,13 @@ static void ax88796c_set_mac_addr(struct net_device *ndev)
 static void ax88796c_load_mac_addr(struct net_device *ndev)
 {
 	struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
+	u8 addr[ETH_ALEN];
 	u16 temp;
 
 	lockdep_assert_held(&ax_local->spi_lock);
 
 	/* Try the device tree first */
-	if (!eth_platform_get_mac_address(&ax_local->spi->dev, ndev->dev_addr) &&
+	if (!platform_get_ethdev_address(&ax_local->spi->dev, ndev) &&
 	    is_valid_ether_addr(ndev->dev_addr)) {
 		if (netif_msg_probe(ax_local))
 			dev_info(&ax_local->spi->dev,
@@ -159,18 +160,19 @@ static void ax88796c_load_mac_addr(struct net_device *ndev)
 
 	/* Read the MAC address from AX88796C */
 	temp = AX_READ(&ax_local->ax_spi, P3_MACASR0);
-	ndev->dev_addr[5] = (u8)temp;
-	ndev->dev_addr[4] = (u8)(temp >> 8);
+	addr[5] = (u8)temp;
+	addr[4] = (u8)(temp >> 8);
 
 	temp = AX_READ(&ax_local->ax_spi, P3_MACASR1);
-	ndev->dev_addr[3] = (u8)temp;
-	ndev->dev_addr[2] = (u8)(temp >> 8);
+	addr[3] = (u8)temp;
+	addr[2] = (u8)(temp >> 8);
 
 	temp = AX_READ(&ax_local->ax_spi, P3_MACASR2);
-	ndev->dev_addr[1] = (u8)temp;
-	ndev->dev_addr[0] = (u8)(temp >> 8);
+	addr[1] = (u8)temp;
+	addr[0] = (u8)(temp >> 8);
 
-	if (is_valid_ether_addr(ndev->dev_addr)) {
+	if (is_valid_ether_addr(addr)) {
+		eth_hw_addr_set(ndev, addr);
 		if (netif_msg_probe(ax_local))
 			dev_info(&ax_local->spi->dev,
 				 "MAC address read from ASIX chip\n");
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH 2/4 mlxsw: constify address in mlxsw_sp_port_dev_addr_set

In reply to Jakub Kicinski

Argument comes from netdev->dev_addr directly, it needs a const.

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -1
index 5925db386b1b..4ce07f9905f6 100644
@@ -303,7 +303,7 @@ int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
 }
 
 static int mlxsw_sp_port_dev_addr_set(struct mlxsw_sp_port *mlxsw_sp_port,
-				      unsigned char *addr)
+				      const unsigned char *addr)
 {
 	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 	char ppad_pl[MLXSW_REG_PPAD_LEN];
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 3/4 wilc1000: copy address before calling wilc_set_mac_address

In reply to Jakub Kicinski

wilc_set_mac_address() calls IO routines which don't guarantee the pointer won't be written to. Make a copy.

---
CC: [email protected]
CC: [email protected]

---
 drivers/net/wireless/microchip/wilc1000/netdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/microchip/wilc1000/netdev.c +3 -3
index 690572e01a2a..4712cd7dff9f 100644
@@ -574,6 +574,7 @@ static int wilc_mac_open(struct net_device *ndev)
 	struct wilc *wl = vif->wilc;
 	int ret = 0;
 	struct mgmt_frame_regs mgmt_regs = {};
+	u8 addr[ETH_ALEN] __aligned(2);
 
 	if (!wl || !wl->dev) {
 		netdev_err(ndev, "device not ready\n");
@@ -596,10 +597,9 @@ static int wilc_mac_open(struct net_device *ndev)
 				vif->idx);
 
 	if (is_valid_ether_addr(ndev->dev_addr)) {
-		wilc_set_mac_address(vif, ndev->dev_addr);
+		ether_addr_copy(addr, ndev->dev_addr);
+		wilc_set_mac_address(vif, addr);
 	} else {
-		u8 addr[ETH_ALEN];
-
 		wilc_get_mac_address(vif, addr);
 		eth_hw_addr_set(ndev, addr);
 	}
Signature · 1 line
2.31.1
author maintainer
#4 lore raw

PATCH 4/4 ipw2200: constify address in ipw_send_adapter_address

In reply to Jakub Kicinski

Add const to the address param of ipw_send_adapter_address() all the functions down the chain have already been changed.

Not sure how I lost this in the rebase.

---
CC: [email protected]

---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/ipw2x00/ipw2200.c +1 -1
index 23037bfc9e4c..5727c7c00a28 100644
@@ -2303,7 +2303,7 @@ static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len)
 				ssid);
 }
 
-static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac)
+static int ipw_send_adapter_address(struct ipw_priv *priv, const u8 * mac)
 {
 	if (!priv || !mac) {
 		IPW_ERROR("Invalid args\n");
Signature · 1 line
2.31.1
maintainer Acked-by on v1 4/4
#5 lore raw

Re: [PATCH net-next 4/4] ipw2200: constify address in ipw_send_adapter_address

Quoted 6 lines · Jakub Kicinski

Add const to the address param of ipw_send_adapter_address() all the functions down the chain have already been changed.

Not sure how I lost this in the rebase.

Quoted 8 lines

---
CC: [email protected]

---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
drivers/net/wireless/intel/ipw2x00/ipw2200.c +1 -2
index 23037bfc9e4c..5727c7c00a28 100644
@@ -2303,7 +2303,7 @@ static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len)
                                ssid);
 }
 
-static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac)
+static int ipw_send_adapter_address(struct ipw_priv *priv, const u8 * mac)
 {
        if (!priv || !mac) {
                IPW_ERROR("Invalid args\n");
--

2.31.1

#6 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 9 lines · On Thu, 18 Nov 2021 06:27:16 -0800 you wrote:

Resending these so they can get merged while I battle random cross builds.

Jakub Kicinski (4):
net: ax88796c: don't write to netdev->dev_addr directly
mlxsw: constify address in mlxsw_sp_port_dev_addr_set
wilc1000: copy address before calling wilc_set_mac_address
ipw2200: constify address in ipw_send_adapter_address

[...]

Here is the summary with links:
- [net-next,1/4] net: ax88796c: don't write to netdev->dev_addr directly

    https://git.kernel.org/netdev/net-next/c/e291422c8f00
  - [net-next,2/4] mlxsw: constify address in mlxsw_sp_port_dev_addr_set
    https://git.kernel.org/netdev/net-next/c/54612b4a8bc7
  - [net-next,3/4] wilc1000: copy address before calling wilc_set_mac_address
    https://git.kernel.org/netdev/net-next/c/b09d58025e3c
  - [net-next,4/4] ipw2200: constify address in ipw_send_adapter_address
    https://git.kernel.org/netdev/net-next/c/a608e6794b08

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html