From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from imap5.colo.codethink.co.uk (imap5.colo.codethink.co.uk [78.40.148.171]) (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 C60C12D3225 for ; Mon, 22 Jun 2026 12:49:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.40.148.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782132551; cv=none; b=iYzQfFXImU6cNH1OzDjdNaylziVFAg15CSzVMKj8kUtxYepycvW8/mS+Scbs8TQj2IgIr6D4NLyb33OFFv3wK9/xss8Tg/4lY7Yfb9D3RC40FBpM2HSwxrZaUHTSWh+rM4Y91HeKAY7BTT00tC6efI1QonsHAT5Oinq/F5plV1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782132551; c=relaxed/simple; bh=1QQoOvTDQMz5nqaG3Xr8KylzuzbO2UrXYaKVHo1H1PE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=I04jSY5u21lC+rD2cbB1PedF6Znn+L3ve3xEDD8eQ+IYy4Nka00Wx5bUxLZ2cJ73t6Ozop8AEMGccIoEsbteJoRmEenuIQmI9wh77E8agAl6Re+h5BPe9rwh3GAYeIaGUyZt7OfEZAvkcxf1gI90y+R+zavjGx/VfPM9+bJrkG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codethink.co.uk; spf=pass smtp.mailfrom=codethink.com; dkim=pass (2048-bit key) header.d=codethink.co.uk header.i=@codethink.co.uk header.b=Ghq6+2Rk; arc=none smtp.client-ip=78.40.148.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codethink.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codethink.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codethink.co.uk header.i=@codethink.co.uk header.b="Ghq6+2Rk" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:In-Reply-To: References; bh=7yR4UwRenVx/bokq1CwTrcuvUKsoRWjzDh3Qz7Cl6f4=; b=Ghq6+2RkMMvYIH USWGhWqaPsKlYxlWJ2dDqgwnA/Naoz60u0TxRIeCDQCe74CJmEahL0lPFMTZxbht9lzrLeZesXd4D GOcs9FMqq0KGcr1FIbOQvg0NfNqf1+iKvvaJSHyQjluD5Va4w2Vt8xEob3ZEObUqGJq54Bj+bB3V3 51EzQ839Fb1vAm1cvldAC6u4PdsSXEeZztgW6D3nC6qqa9/PcdLLE4LNNfY6dLA763f6bZgGu2hqD hGNNySAhcWQry9Y39aSG2NVvm73QLFb4fl/KAMuYWppvXSgQq22c8bnpycH/5z2rJsNvV8g08xHj4 xCuNG2scG6mE6eA3NHHw==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1wbe5E-004sH2-E7; Mon, 22 Jun 2026 13:49:00 +0100 Received: from ben by rainbowdash with local (Exim 4.99.4) (envelope-from ) id 1wbe5D-00000001ap7-2ovc; Mon, 22 Jun 2026 13:48:59 +0100 From: Ben Dooks To: Andrew Morton , linux-kernel@vger.kernel.org Cc: Ben Dooks Subject: [PATCH] lib/iomem_copy: fix __iomem casts Date: Mon, 22 Jun 2026 13:48:57 +0100 Message-Id: <20260622124857.379868-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: srv_ts003@codethink.com The iomem_copy.c code discards __iomem address space when using the IS_ALIGNED() macro. It would make more sense to fix this in one place by aing a PTR_ALIGNED_LONG() macro and then doing the necessary casts there before invoking IS_ALIGNED(). As part of this, also force the pointer to an unsigned long as pointers are generally not signed, although there is no warning as yet on treating pointers as signed. lib/iomem_copy.c:27:26: warning: cast removes address space '__iomem' of expression lib/iomem_copy.c:27:26: warning: cast removes address space '__iomem' of expression lib/iomem_copy.c:64:26: warning: cast removes address space '__iomem' of expression lib/iomem_copy.c:64:26: warning: cast removes address space '__iomem' of expression lib/iomem_copy.c:106:26: warning: cast removes address space '__iomem' of expression lib/iomem_copy.c:106:26: warning: cast removes address space '__iomem' of expression Signed-off-by: Ben Dooks --- lib/iomem_copy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/iomem_copy.c b/lib/iomem_copy.c index dec7eaea60e0..a8cd2642e3ee 100644 --- a/lib/iomem_copy.c +++ b/lib/iomem_copy.c @@ -9,6 +9,8 @@ #include #include +#define PTR_ALIGNED_LONG(__ptr) IS_ALIGNED((__force unsigned long)__ptr, sizeof(long)) + #ifndef memset_io /** * memset_io() - Set a range of I/O memory to a constant value @@ -24,7 +26,7 @@ void memset_io(volatile void __iomem *addr, int val, size_t count) qc *= ~0UL / 0xff; - while (count && !IS_ALIGNED((long)addr, sizeof(long))) { + while (count && !PTR_ALIGNED_LONG(addr)) { __raw_writeb(val, addr); addr++; count--; @@ -61,7 +63,7 @@ EXPORT_SYMBOL(memset_io); */ void memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count) { - while (count && !IS_ALIGNED((long)src, sizeof(long))) { + while (count && !PTR_ALIGNED_LONG(src)) { *(u8 *)dst = __raw_readb(src); src++; dst++; @@ -103,7 +105,7 @@ EXPORT_SYMBOL(memcpy_fromio); */ void memcpy_toio(volatile void __iomem *dst, const void *src, size_t count) { - while (count && !IS_ALIGNED((long)dst, sizeof(long))) { + while (count && !PTR_ALIGNED_LONG(dst)) { __raw_writeb(*(u8 *)src, dst); src++; dst++; -- 2.37.2.352.g3c44437643