Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2557627rwd; Mon, 22 May 2023 00:11:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43PdiWREUiCwhJ3Pum+uIMCsRby1z3IWvX6a4s2oimQK3eRKMzsXDFECTtjNyO5tmune5A X-Received: by 2002:a05:6a20:4408:b0:101:8cad:6db9 with SMTP id ce8-20020a056a20440800b001018cad6db9mr11135693pzb.47.1684739514454; Mon, 22 May 2023 00:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684739514; cv=none; d=google.com; s=arc-20160816; b=LqfgZM1IBhF0r1bgtT6LymprhsUHQIzYgtmrEvwVx2isrnRkZwAQtznxisOtE39CHY xSF8i2Q86L2/twhxkmb1rxhv97P2UxCfW7CA6a5VklLef46iZTY09BKA597VQCsyi+k3 UnAtT6hMrn4siT6K0Mj11ekdv0Cnelit83CvNMRkSzuW3QvSEu2zuiAKxhnkJxCPw8QD 95yazii+uf7ptcMofQoFQWI+L4eBv5JEOFPOIC58R08R6OCzl2EAAeBn7zPRa22ob+hX 11E0/vF8lgRKWao5TXz+QVy491ht1RNtTfjDkq7DWSb7aZ+nTYI0uQQYTYke31HK1Bzv 0pNQ== 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=AONfAAZMrnsFVzGnn4T7AsxCflbiCmylFoMW0ZmEwzYaXSAoxfSVPhr3/9BFj25o0T 9+ZFith/GWOSEHafAWGKYRdtlHxzgVSGKQ8k4lGFhbSQjEQlPj/GyZbN8mP6SaLzPhLv BLwiHq3F0NPF665BIChOnWaGPfd13KOtcGXsVsYSy8oXoFOa2NmttJLfcPrYmsP7vX7S seqTRu64C3zO2y2FNK4q6X7ZNgImR19W+SQP7X4f6uVLdDdPbvJl1EaYAvemfA/3nbze myNpgbjYHTbkGhMESW/tvPwRw/hDMUkSTW/0O/HZy0h+GtFigXc07qQQrRB8XkzyDezX hU7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EgeeaYxH; 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 f20-20020a63f114000000b00534780446d9si4119079pgi.640.2023.05.22.00.11.40; Mon, 22 May 2023 00:11:54 -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=EgeeaYxH; 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 S232329AbjEVHCN (ORCPT + 99 others); Mon, 22 May 2023 03:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbjEVHBF (ORCPT ); Mon, 22 May 2023 03:01:05 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A881E107 for ; Mon, 22 May 2023 00:00:50 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2af20198f20so41911611fa.0 for ; Mon, 22 May 2023 00:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684738848; x=1687330848; 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=EgeeaYxHiw9wjOAGc/5G+LN0c3KUHNjvlMLN8uS8AnOgASES7fyW/rsQOHqr9DJIm4 Q8pNdnQ8gVkoZSj/+upHrsi/tavYgOTyzBUdlAtcr2Kh9ffmMPH4gQgxiD9jwMMKDMI+ CuKr2WQEU8br9TaFssSRKesDxf+IahbGC5Zx0cbDL1B32MIMmQqJEpul0X/k5OkwgL/p biyoDSbwAxtoAdQjplEuS+uPbUVkhGZwVNA6jM4DVWvLhyshkUq3uEnshyu8D9Pr1j1Y dtZh4qZurb2FlkyA/lCRl9W6OQ/h4jDhIaJlJh3cxPH3CVc6wzd8qQhjtgUMnfkuf6pl /E1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684738848; x=1687330848; 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=TFqO43hd96uQ7TSKeT/xhXeahhu/eh2tXOYB8vrHxFJ23p70sg1X6O7TcSCnaBYoy9 Pf49oHI+6tYIM6lRinxz49hSXbIMz3gzsJ0yUzseVMeOZt/Vhn4Up45NZuAZuwFUim80 V11mItSUIE8ijS8QY9fJDdgW4goSKRNMQp62M+U9bGsHBitmvTrGK9wbEmMkfLnHKsM8 IgU0LYo2PsyCoU9W0CYZH4wXZi9fk8lU8pWoJ77xkVvO4OWSTpcsJnm4Q154UXuEn+pd jHgnr9zH+Xg06NlVz7W1dMZsFtu0AvFyjGLwz5HLKHEK+ZXVnEawlrZ4kKMKyV0KGhYC Vykg== X-Gm-Message-State: AC+VfDzhQcyRVgQ6y28v7dhwK/FStbpANu73xPfotLVDmRXmLO+k36bW MEKHjK/YLKrbkiuWt24bxPWoZQ== X-Received: by 2002:a2e:9588:0:b0:2ad:aa42:8c0b with SMTP id w8-20020a2e9588000000b002adaa428c0bmr3570722ljh.35.1684738848500; Mon, 22 May 2023 00:00:48 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id q4-20020a2e8744000000b002adb98fdf81sm1010187ljj.7.2023.05.22.00.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 00:00:48 -0700 (PDT) From: Linus Walleij Date: Mon, 22 May 2023 09:00:44 +0200 Subject: [PATCH v2 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-v2-9-0948d38bddab@linaro.org> References: <20230503-virt-to-pfn-v6-4-rc1-v2-0-0948d38bddab@linaro.org> In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v2-0-0948d38bddab@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, 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..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