From patchwork Mon May 22 07:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1260807vqo; Mon, 22 May 2023 00:14:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TMXZLYzV3IQ71MIVoiOpnsOxQ2HUGM6ItKjc4g8J73wPDTDbX3DWcybQBdX0rDwlWXXHK X-Received: by 2002:a17:90a:70cf:b0:253:266a:3b00 with SMTP id a15-20020a17090a70cf00b00253266a3b00mr9362298pjm.37.1684739677108; Mon, 22 May 2023 00:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684739677; cv=none; d=google.com; s=arc-20160816; b=QyayuBGLHS9id3nsXzNFNjQ0ALQRJtm4dRZZgDd7h+AeFOgpFLEYorqMCQqrsQ/mtw 5iIzGb5XZTdDzJTiUdxzS1S01XMGmuVkZy+Lv5gR7vpYeZtJiAYn/8uauvflG+4kO4Az e8lMeKPWDmJOkZ9BiztnXM7IWmFq74VDlOFBVS72AW530fP6JGVAsdCHGWe8cKwEyEc2 l6tBnvamS73oDA7gj1BdQLT6TV0yn7JKHvupJzrZe1MhW1E0h6otaM9no+7+aN7j6X+2 uch68ibVAPpWBagchkdQrE59NNd3UxgZbjhfLaZppcH+8ci2yYRy0I2h8ErPwQ5vCS6w fHCg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a63ab04000000b00535f192eac7si405742pgf.211.2023.05.22.00.14.21; Mon, 22 May 2023 00:14:37 -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 S232332AbjEVHCO (ORCPT + 99 others); Mon, 22 May 2023 03:02:14 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766577591345801451?= X-GMAIL-MSGID: =?utf-8?q?1766577591345801451?= 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))