Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8681997rwr; Thu, 11 May 2023 05:02:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76nChmHBo5Bn33h1l2LDBltb5pISSlE/TCrnplvPGWNKI7teLEtGT68O4a30PcNCAoj3Xy X-Received: by 2002:a05:6a20:9f4d:b0:f2:6fc6:9ca3 with SMTP id ml13-20020a056a209f4d00b000f26fc69ca3mr20743662pzb.43.1683806528852; Thu, 11 May 2023 05:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683806528; cv=none; d=google.com; s=arc-20160816; b=g9XWqWudH/R5eCK8n3mHfJ+zbMCANvIGbDbh3gj/T0nVDMuTEV7xsxi1Qv6b9S9cuj RdsgJLAZGmpxQWGdtCDiUWIzGgAiQni9sEMA4odCM52dR/xq/geG9Q6lPnbjNp8FBIsN rPa3cYa4LWb6/ozyeyAaas2zKtVE30nmQWjeYC3YuBzqO55Iousz2FvCzZ0AphDlRunJ HuXixsrLmGWY6wXN4pJAlJhKuujJh8zXv/ReH5NXDwmiHtryAB+iS2JI6dKRUgw1KyCI rrKCC5b4/ju5657PYqdD0lfcKOsQZt3k/NI/UqBWZGbYNsedrB6HxHwqigHUCla+rp6W S2kQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020aa79a46000000b006478fe28452si5248433pfj.27.2023.05.11.05.01.54; Thu, 11 May 2023 05:02:08 -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 S238064AbjEKMBA (ORCPT + 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 ); 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 ; Thu, 11 May 2023 04:59:57 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f22908a082so6545673e87.1 for ; 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 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 , Vineet Gupta , Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Greg Ungerer 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 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: 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..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)) -- 2.34.1