From patchwork Tue May 23 14:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 98018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2188320vqo; Tue, 23 May 2023 07:33:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fqcgeP0JTqW2hGxNw0PTybfxXrgJpxN2PHfi3mRwXALGnkI/QyZe0S91Fke9G9CmvAoRZ X-Received: by 2002:a05:6a20:3caa:b0:101:65a2:e06b with SMTP id b42-20020a056a203caa00b0010165a2e06bmr15693262pzj.20.1684852396267; Tue, 23 May 2023 07:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684852396; cv=none; d=google.com; s=arc-20160816; b=W2Q0YI045eze6vn72pWwbndyD0N5jED5HIleB3Knom43gH78BDomm1OfIxc9s0Vz2X zw45zzBUsIMZ4+Zf5Ra4CIf4y5GiYRoE7B3Wl9n9MlWxBklAzzkrhsqOsrZUsBz8ZIkL OTtjDbeCkXViwNRfvbkcJn7lPcv7GYrS6gDqN2NDFGH++Fv7z4LMWilhZY1nZtsLW1Ej lciUUX6nQ4EcxEmspi6bKt26aZA/cDw45OaLiaDKc9F/0799KdcmqlFteFnOpH0pjfGI EhE7IoiYWWx+ZXd3zjk26EbUAQ0+jPEKVlGdh/CTmQIc12rDhbPfvgTLbC8/oYp5QdQs wB+A== 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=UDtU5Jqmt1rhTrWGvrFpFNAhujSWuurCg4wxa03/anU=; b=E+b8NL3nGj5ubOAx2OCEmUfvMc3Wh+Nsxd2aPMKL2Giyu9sKG90eenS+ffihs7/zIy hhs76/c87hqEmZ8IVVX5J2aNzBstt56DSSaTEJvyRU6ymHL4+COdrw8pr284717DA6X7 gEUk4mBfodWx70Af4fTeKg5srfSQcvJXjnE06ITA08wX54d14XpRch93lT/xogBv8a4x yIO876qrrQ9PTD4U6TQG3Yj26qdlIKzuUN/m59rSBkkoKogx0Fu/0qvCQm5DU1ZAuoyF v8/mHb7WE/uNcwJU922HAP3TYQQYyTH35AKWWexIXw0EiKxI0U8l4/L7MUQo/l5lXUs2 hgew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HpmD5IFX; 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 p5-20020a637f45000000b0053076a4da8esi1841323pgn.761.2023.05.23.07.33.02; Tue, 23 May 2023 07:33:16 -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=HpmD5IFX; 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 S237187AbjEWOIS (ORCPT + 99 others); Tue, 23 May 2023 10:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237159AbjEWOHN (ORCPT ); Tue, 23 May 2023 10:07:13 -0400 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2CEBE43 for ; Tue, 23 May 2023 07:06:55 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-4f122ff663eso8056433e87.2 for ; Tue, 23 May 2023 07:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684850754; x=1687442754; 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=UDtU5Jqmt1rhTrWGvrFpFNAhujSWuurCg4wxa03/anU=; b=HpmD5IFXXBYh79hB/QdHKbKxuFRZSDMi4b5OZGTylI/XbzqUU0nz4W2BvN6yvKss7I K1cwCwlsNLZKWtwDIbEgnBIwLeSRk9MusgogzqpLIGkeV6I3IpHf5ZImCV1dO7TmBmQd Jxo5lBjORGSyxFQpYfuSMr3vb6XHB27JbLUYvAKRm5hN6Vx2cqGdrc5nBtxembJzIGb+ XkA5TOH4FTAGjGGX8LhKx2vDYw5pSIfYWUjWXmA8zVjBOfrxf/vDnuKaKLU2/n/3jNel W+4yMbxUSUGgrAJBjS8Un11ko0kSEr5ibGVEHRlBzUWYgh4gIdzzchv9ZLkOCYx4CEzT 1cyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684850754; x=1687442754; 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=UDtU5Jqmt1rhTrWGvrFpFNAhujSWuurCg4wxa03/anU=; b=c1IiiWxTLO8Cmh6n/gRL0U9btfTBlyPYjaQA5eSU4/nPYlj3lSGbiu5k8GHqCFHms9 O5COTINfeq6ZyBl6AMolZPZOpGs+Ap3w1is3rZv6Jgn4YCrbtuw252xJ6L0ZSiG5zAHL 3v2Hgn2gphKk4MJKoC93G6SWA2hOMREgAUqXlNH5OQzb0iYvQAN0CIZw/iEENHdUTvYm hSw3hKBJymHmVeIw9EYoSOl5KYpT2N9aMI8G5HSO8+RccDVFJ5SKG6xx1Cr/4u/JdsZP /KFEEWX51V9i2I/MkmMsccvWMdrgOGArVmSnK6M4lxEpxhXtWQqXigLJeeOgjRcOnB2W +xOQ== X-Gm-Message-State: AC+VfDy/d6nNboQHm2JfDJODRQP4cL5yKI76JcZ5hrtIVqTttrikO6jV xKhgcVA/pYKfM+epunwc+lFvlg== X-Received: by 2002:ac2:51a9:0:b0:4f3:b9bc:9d68 with SMTP id f9-20020ac251a9000000b004f3b9bc9d68mr2955818lfk.18.1684850754250; Tue, 23 May 2023 07:05:54 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id h28-20020ac2597c000000b004e9bf853c27sm1346562lfp.70.2023.05.23.07.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 07:05:53 -0700 (PDT) From: Linus Walleij Date: Tue, 23 May 2023 16:05:33 +0200 Subject: [PATCH v3 09/12] asm-generic/page.h: Make pfn accessors static inlines MIME-Version: 1.0 Message-Id: <20230503-virt-to-pfn-v6-4-rc1-v3-9-a16c19c03583@linaro.org> References: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org> In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org> To: Andrew Morton , Geert Uytterhoeven , Vineet Gupta , Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Greg Ungerer Cc: linux-mm@vger.kernel.org, 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, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Linus Walleij 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766695786218945224?= X-GMAIL-MSGID: =?utf-8?q?1766695786218945224?= 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 --- 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..9773582fd96e 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))