From patchwork Mon May 22 07:00:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 97091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1255954vqo; Mon, 22 May 2023 00:03:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5EogDypHhO8CzOhecBVvCRrLiTN4WwJ+I7tpLnHcOXuWgEFDq4pV3Y/K98HfayU1RCMfPN X-Received: by 2002:a05:6a20:12d1:b0:10b:cf0a:f82a with SMTP id v17-20020a056a2012d100b0010bcf0af82amr1462411pzg.45.1684739033118; Mon, 22 May 2023 00:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684739033; cv=none; d=google.com; s=arc-20160816; b=gGZuruP9iBGmiLY47HhUPyQNDepe8qJpW5NqZ0Ce+2LEJacTqZu68mT9elMnjavBmL EkdbCWr9E+5qAUWlIgYTz5gMRFSdmVd+yizA3DmXD7W8XrtXqduZ2eiwZ05h8IpVGDpi 2OPoAo9gx2VkrvdJQxpvh2SQn95krFmb3Wo1eQLMZVACRAB6Qc23lEuPq12pjj3tBMdt WDdEoehEf7RgW36VZU+e/E5Nvng1aelrDCzV1u8FVnsLbi3cYzcJQmhyE4ZFsYNojieC 4mBe03z2Kg4KwoepcfpNYp3dpA+Q7FLRKDrGdJN5CEgAKmakTVtkSaNw2HrRoyREKCj4 81pQ== 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=XXvb5TDUzvESWFR9QC/PoBRtJqf1+F8aU7D/u9pREy0=; b=KlCYhdCXKxd3StHoANs0M1VN8f5ksfInvcX32T52UujWtTXj2ykzyeCufka3WntA9L 3nKKWvi+e4UiF33a975pPVvRtdVAE38DtujvbV5ePY1z4kDax32WAIcBkAoJtzMwQb9C Y5fdxSb0ZGIJ2PkFbtq9Ey/8v0eSi2gNP64UeqPSxB/kN6VJRJrQfD/iBv7w2ShIhUbR 0fzWArgkRsLkJ8QLqH3jGc71giyIgfpkzTRVFduCnPhnXKHOret/8c54T+67Xg6XkGnz AL77vPafqAqKyJ4wsuPj2YA2AUC5cC7F3f8Ycu0W2COYQmjLqLaRa2z7N/1ZaoO58RRz T2Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OtttQP9k; 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 i7-20020a633c47000000b00534839d5ee5si791867pgn.98.2023.05.22.00.03.38; Mon, 22 May 2023 00:03:53 -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=OtttQP9k; 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 S232365AbjEVHCf (ORCPT + 99 others); Mon, 22 May 2023 03:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232214AbjEVHBb (ORCPT ); Mon, 22 May 2023 03:01:31 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A84ED110 for ; Mon, 22 May 2023 00:00:52 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2af1a7d2f6aso48824341fa.1 for ; Mon, 22 May 2023 00:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684738852; x=1687330852; 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=XXvb5TDUzvESWFR9QC/PoBRtJqf1+F8aU7D/u9pREy0=; b=OtttQP9k8xlpdHUIJVQBj8OckJ52gXzjAKfZrO75yaomv2Kiy+b4fjJvIwaykOdpkr usJaUK3rXE5surL3MPXnlE1TEJwwCby96MhbkYqN1mF6zVB6zp2XsGhjdCbv4XVJE6/s T4ni/jV8YaVyRAd6JB8iNtxkvmPyKAInGhO77viNGA33qHHTOTMSjoPo6kYmfoiQK12j iDtwhnWm7qBIe6BJff5uUa9Mw7T989YyEmwWpkc6B/+u6Lc+aAkLc1d4kRY6SMY63VU7 hmiPvpMUPJTmQnqUoOO6sf1NrZ+OQ4se37lsy0EYUsaGwaOuyi19yVC4YL6wRFmh7WLu cHJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684738852; x=1687330852; 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=XXvb5TDUzvESWFR9QC/PoBRtJqf1+F8aU7D/u9pREy0=; b=EIJmkm5Yk4pS7CFgncZ+kuzQeGAI7GUNaNUI8y9MuZKPn6JGVfxU4bguImY/ekc1ah nHa1Tn+mR3sMrjO1d/V0JZ1Eh1FvTb18qAabJx0yQL6J2B3nJnZtvp0c5cheNY3YZrvU uRFYEyjVGI3WYs3wK6T4RR0gtFX1fooIe7/YQqeXk6PBEKENmLb+rKH7GywisBd79ffF t/tCqygpfBxOxmhTrWR5P+xBHJzZD/XRaI+TMJPCcNaPl7vz16L8sD/RrPQgslLVZWe3 1wcUj0Ed+EtQH45pzY9VvYkiR+N5VQ73g17Hngzn6l36oy+vlEBxciTz6BUulS4AeRI+ 4I7w== X-Gm-Message-State: AC+VfDxOj9oSlabI+RswXbifI2/y3yGa6Ha0DMGv/gxlvZGF1JhddETJ vNQTqR9RSYSjCemS3/XYw5/nqQ== X-Received: by 2002:a2e:9f42:0:b0:2af:19dd:ecda with SMTP id v2-20020a2e9f42000000b002af19ddecdamr3543683ljk.45.1684738851937; Mon, 22 May 2023 00:00:51 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 00:00:51 -0700 (PDT) From: Linus Walleij Date: Mon, 22 May 2023 09:00:47 +0200 Subject: [PATCH v2 12/12] m68k/mm: Make pfn accessors static inlines MIME-Version: 1.0 Message-Id: <20230503-virt-to-pfn-v6-4-rc1-v2-12-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?1766576916888050232?= X-GMAIL-MSGID: =?utf-8?q?1766576916888050232?= 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, do the same with pfn_to_virt(). Signed-off-by: Linus Walleij --- arch/m68k/include/asm/page_mm.h | 11 +++++++++-- arch/m68k/include/asm/page_no.h | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h index 3903db2e8da7..363aa0f9ba8a 100644 --- a/arch/m68k/include/asm/page_mm.h +++ b/arch/m68k/include/asm/page_mm.h @@ -121,8 +121,15 @@ static inline void *__va(unsigned long x) * TODO: implement (fast) pfn<->pgdat_idx conversion functions, this makes lots * of the shifts unnecessary. */ -#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; +} + +static inline void *pfn_to_virt(unsigned long pfn) +{ + return __va(pfn << PAGE_SHIFT); +} extern int m68k_virt_to_node_shift; diff --git a/arch/m68k/include/asm/page_no.h b/arch/m68k/include/asm/page_no.h index 060e4c0e7605..af3a10973233 100644 --- a/arch/m68k/include/asm/page_no.h +++ b/arch/m68k/include/asm/page_no.h @@ -19,8 +19,15 @@ extern unsigned long memory_end; #define __pa(vaddr) ((unsigned long)(vaddr)) #define __va(paddr) ((void *)((unsigned long)(paddr))) -#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; +} + +static inline void *pfn_to_virt(unsigned long pfn) +{ + return __va(pfn << PAGE_SHIFT); +} #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) #define page_to_virt(page) __va(((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET))