Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4389759rwd; Tue, 23 May 2023 07:09:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58Uc7JAiiPIHaHcByWpnsRovYenVqe6cj7HFtnJPb2B6oGWkVRKeGpN/Z8fefL6rGkL9UV X-Received: by 2002:a17:90a:af89:b0:255:c061:9e5b with SMTP id w9-20020a17090aaf8900b00255c0619e5bmr765757pjq.37.1684850986129; Tue, 23 May 2023 07:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850986; cv=none; d=google.com; s=arc-20160816; b=aZe2W7q+tJZcLcOHcjtAkHJYsqcXzUrqam/KZ9KU0RWPMU/lKmFoL3JA2TSEWLX/bZ TRLC8qGbI1Jzl/S4UPT4nt7w9put59UPLhc0dygkefU1XB3ScghlXrJ5aEuJmgIKvqNQ aV44UIslJJShZobmYFSZaPzfbFV4k6Eiv99A81DjymaRMGWkWLGuQeeKtBrt0+S0U5c/ 0Iyj2Am8dCP/1+IZdNr3e1v7xuI0PHKrs6P73wV0I/UC8ZnUNpFYnwi6pED1W9vdPLuv +piqgo5Uo6xrTBQxdFP0+Ltv8/SrTth+tNUxNTRUqklCXQzoccTuSWHQc7jcL6ajfzyx e2lQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a17090abf1300b0024df86690a6si8455474pjs.135.2023.05.23.07.09.29; Tue, 23 May 2023 07:09:46 -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 S237184AbjEWOIS (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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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)) -- 2.34.1