[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <34647b2e-3d9d-42db-9851-34ad8621af02@linux.dev>
Date: Tue, 1 Jul 2025 12:44:55 -0400
From: Sean Anderson <sean.anderson@...ux.dev>
To: Théo Lebrun <theo.lebrun@...tlin.com>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Claudiu Beznea <claudiu.beznea@...on.dev>,
Paul Walmsley <paul.walmsley@...ive.com>, Palmer Dabbelt
<palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Alexandre Ghiti <alex@...ti.fr>, Samuel Holland <samuel.holland@...ive.com>,
Richard Cochran <richardcochran@...il.com>,
Russell King <linux@...linux.org.uk>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Vladimir Kondratiev <vladimir.kondratiev@...ileye.com>,
Gregory CLEMENT <gregory.clement@...tlin.com>,
Cyrille Pitchen <cyrille.pitchen@...el.com>,
Harini Katakam <harini.katakam@...inx.com>,
Rafal Ozieblo <rafalo@...ence.com>,
Haavard Skinnemoen <hskinnemoen@...el.com>, Jeff Garzik <jeff@...zik.org>
Cc: netdev@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
linux-mips@...r.kernel.org, Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Tawfik Bayouk <tawfik.bayouk@...ileye.com>
Subject: Re: [PATCH net-next v2 13/18] net: macb: avoid double endianness swap
in macb_set_hwaddr()
On 6/27/25 05:08, Théo Lebrun wrote:
> writel() does a CPU->LE conversion. Drop manual cpu_to_le*() calls.
>
> On little-endian system:
> - cpu_to_le32() is a no-op (LE->LE),
> - writel() is a no-op (LE->LE),
> - dev_addr will therefore not be swapped and written as-is.
>
> On big-endian system:
> - cpu_to_le32() is a swap (BE->LE),
> - writel() is a swap (BE->LE),
> - dev_addr will therefore be swapped twice and written as a BE value.
>
> This was found using sparse:
> ⟩ make C=2 drivers/net/ethernet/cadence/macb_main.o
> warning: incorrect type in assignment (different base types)
> expected unsigned int [usertype] bottom
> got restricted __le32 [usertype]
> warning: incorrect type in assignment (different base types)
> expected unsigned short [usertype] top
> got restricted __le16 [usertype]
> ...
>
> Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver")
> Signed-off-by: Théo Lebrun <theo.lebrun@...tlin.com>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 578e72c7727d4f578478ff2b3d0a6316327271b1..34223dad2d01ae4bcefc0823c868a67f59435638 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -265,9 +265,9 @@ static void macb_set_hwaddr(struct macb *bp)
> u32 bottom;
> u16 top;
>
> - bottom = cpu_to_le32(*((u32 *)bp->dev->dev_addr));
> + bottom = *((u32 *)bp->dev->dev_addr);
> macb_or_gem_writel(bp, SA1B, bottom);
> - top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
> + top = *((u16 *)(bp->dev->dev_addr + 4));> macb_or_gem_writel(bp, SA1T, top);
>
> if (gem_has_ptp(bp)) {
>
Reviewed-by: Sean Anderson <sean.anderson@...ux.dev>
Powered by blists - more mailing lists