From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 651DA41C8F; Tue, 16 Jan 2024 01:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RfQawvA7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 374C2C43609; Tue, 16 Jan 2024 01:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705367325; bh=Rk1uqynb+AnJ48RW0IpXMM1fACNtVtSc83i3nlFTGpg=; h=From:To:Cc:Subject:Date:From; b=RfQawvA71eTRH/EYJ0hoqL6qr5XSW09V/7aKcgmYhElH/Gn95uWkXkm6FQZdgSV1p DipYGLRxiI5jNiVLqU8gc/MFYTMsHtjqqzWIwPuN6SjUd34h1s7atERtDv2few9e0b vKMMCJUm6Uy0plYfg37bcPyEcTs1xzGsGzKkuUB9adb8xbvg7jHCtoN7b5zdporlEc eD6bnyrAMYGbOFKDZ/VLbERNtbXdSCeBwCIgqeKONQwUT8bnXuAtPb4KAD+ozYp26O rGMmFkCTS1Zla6EsLBc998DQrr89Up1ybF0c/YPoBxhJkGAXA+XA2ewR4XZsVXqWXZ T4NxVegZ9QwyQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Walleij , Brian Cain , Arnd Bergmann , Sasha Levin , chenhuacai@kernel.org, mpe@ellerman.id.au, shorne@gmail.com, rppt@kernel.org, linux-hexagon@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 1/8] Hexagon: Make pfn accessors statics inlines Date: Mon, 15 Jan 2024 20:08:31 -0500 Message-ID: <20240116010842.219925-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 4.19.305 Content-Transfer-Encoding: 8bit From: Linus Walleij [ Upstream commit d6e81532b10d8deb2bc30f7b44f09534876893e3 ] Making virt_to_pfn() a static inline taking a strongly typed (const void *) makes the contract of a passing a pointer of that type to the function explicit and exposes any misuse of the macro virt_to_pfn() acting polymorphic and accepting many types such as (void *), (unitptr_t) or (unsigned long) as arguments without warnings. For symmetry do the same with pfn_to_virt(). For compiletime resolution of __pa() we need PAGE_OFFSET which was not available to __pa() and resolved by the preprocessor wherever __pa() was used. Fix this by explicitly including where required, following the pattern of the architectures page.h file. Acked-by: Brian Cain Signed-off-by: Linus Walleij Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin --- arch/hexagon/include/asm/page.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h index 93f5669b4aa1..a12ba19e6460 100644 --- a/arch/hexagon/include/asm/page.h +++ b/arch/hexagon/include/asm/page.h @@ -91,6 +91,9 @@ typedef struct page *pgtable_t; #define __pgd(x) ((pgd_t) { (x) }) #define __pgprot(x) ((pgprot_t) { (x) }) +/* Needed for PAGE_OFFSET used in the macro right below */ +#include + /* * We need a __pa and a __va routine for kernel space. * MIPS says they're only used during mem_init. @@ -140,8 +143,16 @@ static inline void clear_page(void *page) */ #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) -#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) -#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) +static inline unsigned long virt_to_pfn(const void *kaddr) +{ + return __pa(kaddr) >> PAGE_SHIFT; +} + +static inline void *pfn_to_virt(unsigned long pfn) +{ + return (void *)((unsigned long)__va(pfn) << PAGE_SHIFT); +} + #define page_to_virt(page) __va(page_to_phys(page)) -- 2.43.0