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 34DE7286BC; Tue, 16 Jan 2024 01:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rPRr+9my" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA412C433F1; Tue, 16 Jan 2024 01:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705367256; bh=Xoyym8SbFaFTJhnzUgEkGRcabuTho3/U89WhI3ZWbn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rPRr+9myOnyJwAV+rO9TY4gRQ+TEONiltNqNyHgHAoAXIIfiMMx8LyTWk0nTTCiI+ 0GOitjaJNgJcY4f2utaFVDsBUs0OgGxPn4IUg0f32o4XbdpBM/QqjjX483dty+I82R RHnT1ztcWSWaOZ36+gpqDk1jFjBLdqJLusD07tBHvwv27DAREhmB5K44m/vaudNbnA ZQ9OcXqII+qo5Fq7CDnFfLT0s6hKcOWac87HJskj6Mw+LRttEiKLp5ZlpcbGr36pAY WBzqb9ZLqCLSvV9gVDLzAOVVXAV9biIB3S/3FseHvfUn7qPJTWlWH1il8lb9km7gnQ 6PG08nDvLvaKQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Walleij , Brian Cain , Arnd Bergmann , Sasha Levin , shorne@gmail.com, rppt@kernel.org, linux-hexagon@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 02/11] Hexagon: Make pfn accessors statics inlines Date: Mon, 15 Jan 2024 20:07:02 -0500 Message-ID: <20240116010729.219219-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116010729.219219-1-sashal@kernel.org> References: <20240116010729.219219-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-hexagon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.147 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 7cbf719c578e..2d8c681c3469 100644 --- a/arch/hexagon/include/asm/page.h +++ b/arch/hexagon/include/asm/page.h @@ -78,6 +78,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. @@ -126,8 +129,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