From patchwork Thu May 11 11:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 92497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4318289vqo; Thu, 11 May 2023 05:10:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XYob2Hj4JMjh2z14dD7fasz4Gm0NU83F3zga7l/IpJ491rLnqk8TqjSTlbKZtmY2ptfI3 X-Received: by 2002:a17:902:ea0c:b0:1a6:4a64:4d27 with SMTP id s12-20020a170902ea0c00b001a64a644d27mr28780782plg.40.1683807021143; Thu, 11 May 2023 05:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683807021; cv=none; d=google.com; s=arc-20160816; b=GI8kt1THUx4fhHVbX3HvqKmxKDrZANOe+7LTmsZcQAFkF6lRDtATNW3p4t50lm0AxC S/RnXKAKvaD500jz6H4k9gFO24bobBERkNUFRKCQC2zGzfHGl0GyNfpEdTKQKeK03W/Q Sco8xcZ1EqMH/ddIxCXI2Ck/7sOuyJi+HrpX6ho3cwX2DkOzC6YZSxj1ih2W/uZApMuV T3OtoSFzaxOICVd+zBZyEfwMHBvKcwj0fAaz03is6XmokjEJjWinRZX9WqhaJ/EQRe2+ 9DrL08Feqml130kCK6l36AZS/N6gED5TOr7FpsQg03GejGxDzanUfxd3Zz5TqHOCjl0f uQrw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a170902779000b001ac82e60516si6047881pll.323.2023.05.11.05.10.05; Thu, 11 May 2023 05:10:21 -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 S238006AbjEKMB0 (ORCPT + 99 others); Thu, 11 May 2023 08:01:26 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765599630922373164?= X-GMAIL-MSGID: =?utf-8?q?1765599630922373164?= 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))