diff mbox series

[net-next,1/6] ethernet: netsec: use eth_hw_addr_set()

Message ID 20211019150011.1355755-2-kuba@kernel.org (mailing list archive)
State Accepted
Commit 414c6a3c84d7f0633d2b37de061b35387c951304
Delegated to: Netdev Maintainers
Headers show
Series ethernet: manual netdev->dev_addr conversions (part 3) | expand

Checks

Context Check Description
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Jakub Kicinski Oct. 19, 2021, 3 p.m. UTC
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Read the address into an array on the stack, then call
eth_hw_addr_set().

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jaswinder.singh@linaro.org
CC: ilias.apalodimas@linaro.org
---
 drivers/net/ethernet/socionext/netsec.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Ilias Apalodimas Oct. 20, 2021, 7:20 a.m. UTC | #1
Hi Jakub,

On Tue, 19 Oct 2021 at 18:00, Jakub Kicinski <kuba@kernel.org> wrote:
>
> Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
> of VLANs...") introduced a rbtree for faster Ethernet address look
> up. To maintain netdev->dev_addr in this tree we need to make all
> the writes to it got through appropriate helpers.
>
> Read the address into an array on the stack, then call
> eth_hw_addr_set().
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: jaswinder.singh@linaro.org
> CC: ilias.apalodimas@linaro.org
> ---
>  drivers/net/ethernet/socionext/netsec.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> index baa9f5d1c549..de7d8bf2c226 100644
> --- a/drivers/net/ethernet/socionext/netsec.c
> +++ b/drivers/net/ethernet/socionext/netsec.c
> @@ -2037,13 +2037,15 @@ static int netsec_probe(struct platform_device *pdev)
>         if (ret && priv->eeprom_base) {
>                 void __iomem *macp = priv->eeprom_base +
>                                         NETSEC_EEPROM_MAC_ADDRESS;
> -
> -               ndev->dev_addr[0] = readb(macp + 3);
> -               ndev->dev_addr[1] = readb(macp + 2);
> -               ndev->dev_addr[2] = readb(macp + 1);
> -               ndev->dev_addr[3] = readb(macp + 0);
> -               ndev->dev_addr[4] = readb(macp + 7);
> -               ndev->dev_addr[5] = readb(macp + 6);
> +               u8 addr[ETH_ALEN];
> +
> +               addr[0] = readb(macp + 3);
> +               addr[1] = readb(macp + 2);
> +               addr[2] = readb(macp + 1);
> +               addr[3] = readb(macp + 0);
> +               addr[4] = readb(macp + 7);
> +               addr[5] = readb(macp + 6);
> +               eth_hw_addr_set(ndev, addr);
>         }
>
>         if (!is_valid_ether_addr(ndev->dev_addr)) {
> --
> 2.31.1
>

Thanks!

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index baa9f5d1c549..de7d8bf2c226 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -2037,13 +2037,15 @@  static int netsec_probe(struct platform_device *pdev)
 	if (ret && priv->eeprom_base) {
 		void __iomem *macp = priv->eeprom_base +
 					NETSEC_EEPROM_MAC_ADDRESS;
-
-		ndev->dev_addr[0] = readb(macp + 3);
-		ndev->dev_addr[1] = readb(macp + 2);
-		ndev->dev_addr[2] = readb(macp + 1);
-		ndev->dev_addr[3] = readb(macp + 0);
-		ndev->dev_addr[4] = readb(macp + 7);
-		ndev->dev_addr[5] = readb(macp + 6);
+		u8 addr[ETH_ALEN];
+
+		addr[0] = readb(macp + 3);
+		addr[1] = readb(macp + 2);
+		addr[2] = readb(macp + 1);
+		addr[3] = readb(macp + 0);
+		addr[4] = readb(macp + 7);
+		addr[5] = readb(macp + 6);
+		eth_hw_addr_set(ndev, addr);
 	}
 
 	if (!is_valid_ether_addr(ndev->dev_addr)) {