Message ID | 20230503-virt-to-pfn-v6-4-rc1-v1-9-6c4698dcf9c8@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4319107vqo; Thu, 11 May 2023 05:11:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wvllQgkgl4+z22bMvvSdBkH36AoYnGal1Gh54NOzgrr67+LoI1S+HELuL53cp/ZyYWNFN X-Received: by 2002:a17:903:2cb:b0:1ac:73e9:de5 with SMTP id s11-20020a17090302cb00b001ac73e90de5mr17285330plk.46.1683807081592; Thu, 11 May 2023 05:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683807081; cv=none; d=google.com; s=arc-20160816; b=QksH7Udkubg1N+OqhwaVct3pk1wPrRlHNhOafWmU4Ao566wCgHPul3Aqpt9kdB/qOc jr8mPs1vM/zO33/bjF1JUn2/Cn6cqc2S4B3jnfBpt9njle+paKIyoVgfs9dC01tmcOKP jPuB4w474kfpDwThq6/kYf8h8o6g/E/Q6j5z5TnI1snLyjJ9YBM9dZcPB1VOdQuy893A giKR1bx1X4J+3PnGoEvbHJF8ASQhYNHSuQTgfdV6riHK8xidilEbG7YwAtutzPn4XbNv etlJdxNjYvsskZUswwmEuWuxIX67xYeX4v1D1wsT8DfsMeOA8li6iFEVGqYHX/MN1eYq A10Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ldVw9wlzEkzEKLn5PMVleGqWnYMQxC7MlxWwEOwXVk4=; b=NjrLtwvchUOEY6dRtRVdE+2aXf3kmBWdarDzDIZm6Izb1AlM+sYsb2jEtsenykQQwQ jL3e8NwUHMl5vQt71zzC4JU/ZE0Z3wHZN0SiaasNxZtjM9J+T7Z/M2CSRI7yhnCLOAi2 P8Xb/RQje9P3370mx32LCc1b8YgBM5HMQ8Il6cC2yaU+22Kj3JhTYnx2Vau1SmrrsbAF ftDK2yHyb6ABpZ6SlZamEcS8Ngaytjc4/ad5ktHX9SWYG/97K3v9mpnUZ93gp6l2DfuX yBnLeaH7nV3ouWfRrH5LEgUmV2EtWRT60ew965Ene9IznPrEl/nxYJ136kWR6VWmZpUD XsEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sersNdtz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc12-20020a17090325cc00b001ac741db80asi4408271plb.236.2023.05.11.05.11.05; Thu, 11 May 2023 05:11:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sersNdtz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237984AbjEKMBA (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Thu, 11 May 2023 08:01:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237977AbjEKMAX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 11 May 2023 08:00:23 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6820EAD3A for <linux-kernel@vger.kernel.org>; Thu, 11 May 2023 04:59:57 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f22908a082so6545673e87.1 for <linux-kernel@vger.kernel.org>; Thu, 11 May 2023 04:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683806395; x=1686398395; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ldVw9wlzEkzEKLn5PMVleGqWnYMQxC7MlxWwEOwXVk4=; b=sersNdtzW5iLzGVupNMmSJvBYmwrZ//xZBxoOUDkXI1JTW4CI6ctj4FhudGratDn9k cRnkGze5UhsFvb3lR7Z7ykzxMMc0MSELwIy7erx+30m7guaXslAKu512vsaLide2fBN8 bzO6LMr/4P01YQk5JchLInzlvvtZaYnfs9CHAIEYLUvt9rNDqzoX36kf+ZRPAeMUF63R CCLsu72Nt/qnplWuj/eGGivCt82mEPHLpvvAQfOpT7G7x9ZKs78aN4p4kFH/Q3ORHnfo F+xP25avZTDsQROtfUVMJN8MesmV4EWv4hDtLKEn2U2w6S7bTHItXBK0WvgvggA3JEzW 4KRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683806395; x=1686398395; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ldVw9wlzEkzEKLn5PMVleGqWnYMQxC7MlxWwEOwXVk4=; b=VVpo9oegWEdzAGQzk+Bp+bkuYc10GSGQAvj8kW+OpGeEbZI+/cuLN4bmjm+D8ayzJL EbMNUQbIAT6XFggSbUkX7D4FRCf3REquZzwDg6J48ZfB0zi79g9mM10IP97x1/tYRyyf xNmmEOsvbFAwHxszwoinELiz1WZgsfgXDqyZcvfSZnvohSdRAIjHjvhj74uDtaumbKkJ bcqGHDWdEgOWPYO2OyUhO9+ydBkdYB2YZN2IEEmzcke6Qm6RQigtbA3CJWoUnYcQUIHE d1L8go8o454EaObwLl+9ff3iuCCNBv5EkbLFoOhsNIPkVv/kuZAL24gNOUeKoj5jLRMO 549g== X-Gm-Message-State: AC+VfDzm0WGHHUZkebMz5TjiIAi7OHYpW3gt58uvB5KnofSqAOfiaIBm npMHQ2WhagvBZ4hOusYSHyiVTg== X-Received: by 2002:ac2:5339:0:b0:4ef:f725:ae2f with SMTP id f25-20020ac25339000000b004eff725ae2fmr3438930lfh.37.1683806395538; Thu, 11 May 2023 04:59:55 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id f16-20020ac25090000000b004cb23904bd9sm1100841lfm.144.2023.05.11.04.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 04:59:55 -0700 (PDT) From: Linus Walleij <linus.walleij@linaro.org> Date: Thu, 11 May 2023 13:59:26 +0200 Subject: [PATCH 09/12] asm-generic/page.h: Make pfn accessors static inlines MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230503-virt-to-pfn-v6-4-rc1-v1-9-6c4698dcf9c8@linaro.org> References: <20230503-virt-to-pfn-v6-4-rc1-v1-0-6c4698dcf9c8@linaro.org> In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v1-0-6c4698dcf9c8@linaro.org> To: Geert Uytterhoeven <geert@linux-m68k.org>, Vineet Gupta <vgupta@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Russell King <linux@armlinux.org.uk>, Greg Ungerer <gerg@linux-m68k.org> Cc: linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-snps-arc@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org> X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765599694547255829?= X-GMAIL-MSGID: =?utf-8?q?1765599694547255829?= |
Series |
arch: Make virt_to_pfn into a static inline
|
|
Commit Message
Linus Walleij
May 11, 2023, 11:59 a.m. UTC
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 we do the same change for pfn_to_virt.
Immediately define virt_to_pfn and pfn_to_virt to the static
inline after the static inline since this style of defining
functions is used for the generic helpers.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
include/asm-generic/page.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h index c0be2edeb484..e8ef12bb858c 100644 --- a/include/asm-generic/page.h +++ b/include/asm-generic/page.h @@ -74,8 +74,16 @@ extern unsigned long memory_end; #define __va(x) ((void *)((unsigned long) (x))) #define __pa(x) ((unsigned long) (x)) -#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; +} +#define virt_to_pfn virt_to_pfn +static inline void * pfn_to_virt(unsigned long pfn) +{ + return __va(pfn) << PAGE_SHIFT; +} +#define pfn_to_virt pfn_to_virt #define virt_to_page(addr) pfn_to_page(virt_to_pfn(addr)) #define page_to_virt(page) pfn_to_virt(page_to_pfn(page))