From nobody Thu Sep 11 01:28:17 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FA72335BC4 for ; Wed, 10 Sep 2025 16:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757521017; cv=none; b=r1Q0Zlnh0cOyLmGI/Q5/K/a2Ot1ajGqMKw8w1QtHRuA3rwi72qGi2wtjTiennfMVb5r18sxgAAC376XdIoy/AzSdFI9fgGqJ3ZwrUXYQr4cCv6vuBpYTZWsIbIs1HO+fASFbPb0b9PCHN1UeCz5zZhLPy8p+VgOccvfLlqyugS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757521017; c=relaxed/simple; bh=4nq8DRBsVSBsAblqH/EyOXPCcAMalYSbOuE50hkeaK4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hs229lNivUFYmJL2IVIfZJRLa0gTwlJHdD+gfOiRbxv0Uz8MFvVFVPWf4CdtjPOhzf7gMFfKHu0KinUBluF15ZRRxulNOAEHZHLzbsZlPEab0r1aM8CIlAbjEJkymoPtfa3hoC7J1jIAm6jWiBqzjhv79Yck9Nq02jmdJTdOJio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=qPmH3VJY; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="qPmH3VJY" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id D7B5A4E40BB5; Wed, 10 Sep 2025 16:16:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C6713606D4; Wed, 10 Sep 2025 16:16:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3B1E6102F28EA; Wed, 10 Sep 2025 18:16:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1757521007; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=LXdNFB9s1KI4qT/Zy8uuZBXtEbtV6EJNZuxTcSFMG8U=; b=qPmH3VJYltK62LYVdoa2NjIMGklmTfGDAvEDUum//CZyZ8bTHTC3KiWqJjZJWhdDrmRPoq aLvu/EbyObDesJOfz7pjes1Bz2y0pKs6ujaPSAbIz0fd3p2rBjGwZ8oPw16jKzBK1cFtZC kMK3I35Jwr5pH3hE2lemyiFiHIGkqfkxAe8fhOkhn3w8wajf9M5hm12WIWrE5T7Y5O6IWA Ak9q8WsHFWaidb5Soh7sQIkHby0EhjVYRbx7ljuEvZIC7Ste0FQEcq59l1btlZCFY5X738 66AaroBfnZhOmoxhouXmV56wm7X2+SQQaHtEyX1+2m5e2UvYpGC0x9d/3htMgA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 10 Sep 2025 18:15:34 +0200 Subject: [PATCH net v5 5/5] net: macb: avoid dealing with endianness in macb_set_hwaddr() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250910-macb-fixes-v5-5-f413a3601ce4@bootlin.com> References: <20250910-macb-fixes-v5-0-f413a3601ce4@bootlin.com> In-Reply-To: <20250910-macb-fixes-v5-0-f413a3601ce4@bootlin.com> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nicolas Ferre , Claudiu Beznea , Geert Uytterhoeven , Harini Katakam , Richard Cochran , Russell King Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= , Sean Anderson X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 bp->dev->dev_addr is of type `unsigned char *`. Casting it to a u32 pointer and dereferencing implies dealing manually with endianness, which is error-prone. Replace by calls to get_unaligned_le32|le16() helpers. This was found using sparse: =E2=9F=A9 make C=3D2 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] ... Reviewed-by: Sean Anderson Signed-off-by: Th=C3=A9o Lebrun --- drivers/net/ethernet/cadence/macb_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index fc082a7a5a313be3d58a008533c3815cb1b1639a..c16d60048185b4cb473ddfcf463= 3fa2f6dea20cc 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -271,12 +271,10 @@ static bool hw_is_gem(void __iomem *addr, bool native= _io) =20 static void macb_set_hwaddr(struct macb *bp) { - u32 bottom; - u16 top; + u32 bottom =3D get_unaligned_le32(bp->dev->dev_addr); + u16 top =3D get_unaligned_le16(bp->dev->dev_addr + 4); =20 - bottom =3D cpu_to_le32(*((u32 *)bp->dev->dev_addr)); macb_or_gem_writel(bp, SA1B, bottom); - top =3D cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4))); macb_or_gem_writel(bp, SA1T, top); =20 if (gem_has_ptp(bp)) { --=20 2.51.0