Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8696367rwr; Thu, 11 May 2023 05:11:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6sTocwIN1GO5c68tkhYHulg97DEQtNyMxQVkTVEJmH05vUdDMY9VdDi63pmm5aQegFxpv8 X-Received: by 2002:a17:902:e748:b0:1a9:a478:66c5 with SMTP id p8-20020a170902e74800b001a9a47866c5mr28128048plf.63.1683807075501; Thu, 11 May 2023 05:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683807075; cv=none; d=google.com; s=arc-20160816; b=bma06trdcBH0aeYdwOis6GXbcoZUj/TlhfMvpzmE50+oGawglWDeChMEcnwQf2RoE7 k3X66aFPYZck26XsxQ7lb7oU1TC1G1oQgxYQ0n9gv/+BxguU2Lqh+RYoWWsLd+6di+bh 5/goTHbxsz9aItHBdZbNErySqZ5nXZBvojzEbHCHtb98b0uad3aUyUIhaIln8i+ARKGF XI6MhIPvm02jO9cD+EGlgLjgv2dJEYRWwPra2ucJP60u+CxwsCM8sJHapL5mkBLTj4lZ N87xgjVqQ+xbE1QOiAQJb130SBqBsiEsXEYsOu2FIDYFZIT3We43VtzLXv9dkNTBYtFV mqDg== 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=vHjA668SX6CTsxzYO8Z8nc4Ecy//EJfwtQFWj2t6kqU=; b=WHGraSQz4/d2cYkGFkCc0tErzURmFxkc5L4z8mcTkhrrfYHbMV+bGckjZK2LPqKX1t E8RCMNPSXvNgNbqz3BQWicjwH7iAVwVE2reyyzUVLk3rdbg1+m4op2FBO+cdS3Oo49xn 4bbxxl89VeHefzhQW2p5sdIEHzLHaEGRu/nNp6wboX4Q1uKrHiK2lZ1uubjzzPe5dMWo j7p3Af46Rl5A0sy6KYzdJPmMP5FG89TTcqmpQZnCPIFmiq4GTF4p613OGy9Ifo85qzFI xgVy35g1Y3eQyRVUqjeB+ATg1cYStFK5Nbtrxx7TDjkQnV9tWkHI8aMaUNTmX7QXfRA8 CDMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kbc555pc; 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 13-20020a170902c20d00b001ac53744492si6378551pll.2.2023.05.11.05.10.57; Thu, 11 May 2023 05:11:15 -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=Kbc555pc; 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 S237998AbjEKMBZ (ORCPT + 99 others); Thu, 11 May 2023 08:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238008AbjEKMA1 (ORCPT ); Thu, 11 May 2023 08:00:27 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E446A266 for ; Thu, 11 May 2023 05:00:01 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4eed764a10cso9484225e87.0 for ; Thu, 11 May 2023 05:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683806399; x=1686398399; 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=vHjA668SX6CTsxzYO8Z8nc4Ecy//EJfwtQFWj2t6kqU=; b=Kbc555pcdKJLogrS9D2fpTuZbCLYtRRslUUmtE3xLf7EzdNZYf1OzcE9wV1Z90iGk3 NIk4MKV6b+X0k2N3VL5lQ56i9UXtaetINfk3JT4UgzFD7yBuaWIOfZWXEKT5PzupCvP/ bamqIQqMgGCRriAPRj2xemXl7nSVYfhgFkSm0NP8XdgPgFP+JDpOUwXIwzQsFylS4IVi tfsy8c7iyORHTNygYljmk4DBR7XlBqGcbH84OblELC60Ek8nQDNUr7Skn4YvyNLuLFxu E+aTQ0Z1NbLg7cPj3DH6p8fVNfeCCf6YY3IJLOUYGk/XToeDr9UU3eGzOCWV1mI1abGA My9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683806399; x=1686398399; 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=vHjA668SX6CTsxzYO8Z8nc4Ecy//EJfwtQFWj2t6kqU=; b=D/ZeSvSBQFeZkJ78puo/I8sJvfCoj06+KPZl3MTG+e0RX6Q21LRCsK4tCPK752/UCU IJH1MCh+Uwl6Or9K1F5T3DhOyB3YFdNn375h9f/2hnaYrBHArGQTYh2Wvz70kelWE5lz MIhwBwdYrZ3bkBi63Jz4kzrL417BrUc6omcaA9HrPvB8dXMxxWSfEc5WPgiALGuh7Jd6 3i+9JE6Fv2xMmb3rvOI23nJN16i+1MTjkUF0/0oHRivgjDxD2qD90dWK0wnWV3rKYsnh pl7znFr+GFWWPj4bzHeX/Ko9or6h2G8+x1Y5ftSTYK6w62wi+UoSSGQ9nnTbSmTphDK3 e/bg== X-Gm-Message-State: AC+VfDz0FVQ259KV5pJB7RQzqaV5SghIkLfZGxn0KxDp0G2OYPuT/SXq ON8FM5Feh67ox8HfS2ujHgDnXw== X-Received: by 2002:ac2:4e51:0:b0:4ee:e10f:8e5d with SMTP id f17-20020ac24e51000000b004eee10f8e5dmr2439363lfr.4.1683806398938; Thu, 11 May 2023 04:59:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 04:59:58 -0700 (PDT) From: Linus Walleij Date: Thu, 11 May 2023 13:59:29 +0200 Subject: [PATCH 12/12] m68k/mm: 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-12-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, 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..40bcc6aa33da 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..f1daf466a57b 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)) -- 2.34.1