From patchwork Fri Jan 18 16:00:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Murray X-Patchwork-Id: 10770757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F24FA6C5 for ; Fri, 18 Jan 2019 16:01:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E10242EAA0 for ; Fri, 18 Jan 2019 16:01:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D579A2F31B; Fri, 18 Jan 2019 16:01:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 58C462F36D for ; Fri, 18 Jan 2019 16:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gGF5W685pMMYuxBrfKlM+d4owd88EL2NZHhePXjAA/s=; b=i1BO8Wm4g0hlgKUnCyAQBFhXmW YLtfNHEaq/HAMDDJpkDxErTYNJrgOG9D+PmnrpnrRRrNpoGc6uWvixK6NByZ6BE2Dm4SMqNnEUDnm 1cCV+uJxhv5dZMipybku20uqGxPVXjptylBlC1xFJHpM37KJ27emsT22yl2ylbWkSgiX9hGd+Po4r WaFFFNLTkGziSPGW5lh7fvIzqM5Ml+ckemaNOksfXZSjhSB96LQSpi0Z6sYRJgCXvgQQrulZoxHdv JtWBXV2dsVD6M3nrdSks+dA+dUdYoLuT4GuDmD87h3BeF0ej0d7O0m6ruFYFK1MD4qtJY0d7yjNQY vUS36IBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gkWaO-0006bF-6Z; Fri, 18 Jan 2019 16:01:36 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gkWZW-0006PV-Gg for linux-arm-kernel@lists.infradead.org; Fri, 18 Jan 2019 16:00:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E4F41596; Fri, 18 Jan 2019 08:00:42 -0800 (PST) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AACE33F557; Fri, 18 Jan 2019 08:00:39 -0800 (PST) From: Andrew Murray To: Masahiro Yamada , Arnd Bergmann , Kees Cook , Andrew Morton Subject: [PATCH 1/3] kconfig.h: abstract empty functions with STUB_UNLESS macro Date: Fri, 18 Jan 2019 16:00:28 +0000 Message-Id: <1547827230-55132-2-git-send-email-andrew.murray@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> References: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190118_080042_555172_4F9DB94C X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rjw@rjwysocki.net, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Steven Price , Grant Likely , Dave P Martin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP A common pattern found in header files is a function declaration dependent on a CONFIG_ option being enabled, followed by an empty function for when that option isn't enabled. This can often take up a lot of space and impact code readability. Let's introduce the following STUB_UNLESS macro: STUB_UNLESS(CONFIG_FOO, [body], prototype) This evaluates to 'prototype' prepended with 'extern' if CONFIG_FOO is set to 'y'. Otherwise it will evaluate to 'prototype' prepended with 'static inline' followed by an empty function body. Where optional argument 'body' then 'body' will be used as the function body, intended to allow for simple return statements. Signed-off-by: Andrew Murray Reviewed-by: Steven Price --- include/linux/kconfig.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index cc8fa10..216a27f 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -12,6 +12,7 @@ #define __ARG_PLACEHOLDER_1 0, #define __take_second_arg(__ignored, val, ...) val +#define __take_fourth_arg(__ignored, __ignored2, __ignored3, val, ...) val /* * The use of "&&" / "||" is limited in certain expressions. @@ -70,4 +71,34 @@ */ #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) + + +/* + * Allow for __stub to be overloaded by making the second argument optional + */ +#define __stub_overload(...) __take_fourth_arg(__VA_ARGS__, \ + __stub_body, __stub_void)(__VA_ARGS__) +#define __stub_body(option, body, ptype) __stub(option, body, ptype) +#define __stub_void(option, ptype) __stub(option, , ptype) + +/* + * Using the same trick as __defined we use the config option to conditionally + * expand to an extern function declaration or a static stub function. + */ +#define __stub(option, body, ptype) ___stub( \ + __ARG_PLACEHOLDER_##option, body, ptype) +#define ___stub(arg1_or_junk, body, ptype) __take_second_arg( \ + arg1_or_junk __extern_ptype(ptype), __static_ptype(body, ptype)) +#define __static_ptype(body, ptype) static inline ptype { body; } +#define __extern_ptype(ptype) extern ptype + +/* + * STUB_UNLESS(CONFIG_FOO, [body], prototype) evaluates to 'prototype' prepended + * with 'extern' if CONFIG_FOO is set to 'y'. Otherwise it will evaluate to + * 'prototype' prepended with 'static inline' followed by an empty function + * body. Where optional argument 'body' is present then 'body' will be used + * as the function body, intended to allow for simple return statements. + */ +#define STUB_UNLESS(...) __stub_overload(__VA_ARGS__) + #endif /* __LINUX_KCONFIG_H */ From patchwork Fri Jan 18 16:00:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Murray X-Patchwork-Id: 10770759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 954006C5 for ; Fri, 18 Jan 2019 16:01:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81B562EA4C for ; Fri, 18 Jan 2019 16:01:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75E722F319; Fri, 18 Jan 2019 16:01:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1259D2F318 for ; Fri, 18 Jan 2019 16:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=inzLQQgaWCdfNNVKeWAGleaLtDxnNgMYwOq7ghP5gio=; b=umUcTr1K/litaJSHS9SabNnl0d KjHIvPvrpgX+J7Pd4S2FboRkdPmCeTrXAchkt18QZcSLh6Uaj6UO+NgWdzjfkTHWA9nnSe5mVcOPl CAWhorszrLyu9nyAO9IV1f75QOQpIyxfEUsA2iHOHDG+M7/5hHBJdfNh75hW61Dw/qqiZVzQpyxUs vdWEHRl7KMPBA9P1pT7gBcYsoZPrQfDhaqStdi0k4rQITQP838/k1AeZFSDQUUIXY3wuGderztPTE b5vcM4O7dku18iS/vtBM6uGc7E9v8S0ANc0fLE4PpssBLjMZXpkMA7kPMm2gLjfm+yWNBejaDmAt/ WfGzFCmw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gkWaa-0006qE-Kl; Fri, 18 Jan 2019 16:01:48 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gkWZZ-0006Pu-54 for linux-arm-kernel@lists.infradead.org; Fri, 18 Jan 2019 16:00:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C4FBEEBD; Fri, 18 Jan 2019 08:00:44 -0800 (PST) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6766A3F557; Fri, 18 Jan 2019 08:00:42 -0800 (PST) From: Andrew Murray To: Masahiro Yamada , Arnd Bergmann , Kees Cook , Andrew Morton Subject: [PATCH 2/3] cpufreq: update headers to use STUB_UNLESS macro Date: Fri, 18 Jan 2019 16:00:29 +0000 Message-Id: <1547827230-55132-3-git-send-email-andrew.murray@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> References: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190118_080045_195888_49AC22D2 X-CRM114-Status: GOOD ( 10.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rjw@rjwysocki.net, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Steven Price , Grant Likely , Dave P Martin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use the STUB_UNLESS macro to simplify function declaration. Signed-off-by: Andrew Murray Reviewed-by: Steven Price --- include/linux/cpufreq.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index c86d6d8..2c53cae 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -159,21 +159,12 @@ struct cpufreq_policy { #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ -#ifdef CONFIG_CPU_FREQ -struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu); -struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); -void cpufreq_cpu_put(struct cpufreq_policy *policy); -#else -static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu) -{ - return NULL; -} -static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) -{ - return NULL; -} -static inline void cpufreq_cpu_put(struct cpufreq_policy *policy) { } -#endif +STUB_UNLESS(CONFIG_CPU_FREQ, return NULL, +struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)); +STUB_UNLESS(CONFIG_CPU_FREQ, return NULL, +struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)); +STUB_UNLESS(CONFIG_CPU_FREQ, +void cpufreq_cpu_put(struct cpufreq_policy *policy)); static inline bool policy_is_shared(struct cpufreq_policy *policy) { From patchwork Fri Jan 18 16:00:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Murray X-Patchwork-Id: 10770761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 831976C5 for ; Fri, 18 Jan 2019 16:02:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CAE02E9AB for ; Fri, 18 Jan 2019 16:02:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A8262F42F; Fri, 18 Jan 2019 16:02:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 530492E9AB for ; Fri, 18 Jan 2019 16:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=76miWvJSxxzMGbwfEHaDjbY+4k/DGw4a0lnw34MLoTU=; b=gtwdC0f/rivOKfbt9wsYU8vnAV 0FkndpBYLMS3LORVfQQwgUck1g9jbfoTmWEnHXFttin44IFSr43ocaKWRKh7aPNK9n/d97/vGkPK6 wcNDvMYwWASq9tYuSFmBf1O7QS01CrJNpnNFxghS8gvcOsrtsjBwc1d1TpyvW+XJ189F5O8lx2tt8 FCyTw/hrDXuaNVO5KpAsOsQO4jAKcoTJTIe1n78L5X+0Tc4EaycvfKYNOuEp5khec4oeaRFpfK5Cx jWeXj9dVdAX/gJBu4zyYKedXHt/WZIGa+Nm/VYWy7/4dyeJYijJiJM4NdPeA/A80aAONK3Ncja45x 6isV03KQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gkWat-0007Ef-Oq; Fri, 18 Jan 2019 16:02:07 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gkWZc-0006QK-1M for linux-arm-kernel@lists.infradead.org; Fri, 18 Jan 2019 16:00:51 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A00D71596; Fri, 18 Jan 2019 08:00:47 -0800 (PST) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 19C333F557; Fri, 18 Jan 2019 08:00:44 -0800 (PST) From: Andrew Murray To: Masahiro Yamada , Arnd Bergmann , Kees Cook , Andrew Morton Subject: [PATCH 3/3] arm64: update headers to use STUB_UNLESS macro Date: Fri, 18 Jan 2019 16:00:30 +0000 Message-Id: <1547827230-55132-4-git-send-email-andrew.murray@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> References: <1547827230-55132-1-git-send-email-andrew.murray@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190118_080048_090238_21415527 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rjw@rjwysocki.net, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Steven Price , Grant Likely , Dave P Martin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use the STUB_UNLESS macro to simplify function declaration. Signed-off-by: Andrew Murray --- arch/arm64/include/asm/acpi.h | 38 +++++++++------------- arch/arm64/include/asm/alternative.h | 6 +--- arch/arm64/include/asm/cpufeature.h | 6 +--- arch/arm64/include/asm/cpuidle.h | 18 +++-------- arch/arm64/include/asm/debug-monitors.h | 10 ++---- arch/arm64/include/asm/fpsimd.h | 57 +++++++++++++-------------------- arch/arm64/include/asm/hw_breakpoint.h | 16 +++------ arch/arm64/include/asm/kasan.h | 9 ++---- arch/arm64/include/asm/numa.h | 19 ++++------- arch/arm64/include/asm/ptdump.h | 13 +++----- arch/arm64/include/asm/signal32.h | 29 +++++------------ 11 files changed, 73 insertions(+), 148 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 2def77e..81836ff 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -109,22 +109,17 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) } static inline void arch_fix_phys_package_id(int num, u32 slot) { } -void __init acpi_init_cpus(void); - -#else -static inline void acpi_init_cpus(void) { } #endif /* CONFIG_ACPI */ -#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL -bool acpi_parking_protocol_valid(int cpu); +STUB_UNLESS(CONFIG_ACPI, +void __init acpi_init_cpus(void)); + +STUB_UNLESS(CONFIG_ARM64_ACPI_PARKING_PROTOCOL, return false, +bool acpi_parking_protocol_valid(int cpu)); + +STUB_UNLESS(CONFIG_ARM64_ACPI_PARKING_PROTOCOL, void __init -acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor); -#else -static inline bool acpi_parking_protocol_valid(int cpu) { return false; } -static inline void -acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) -{} -#endif +acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)); static inline const char *acpi_get_enable_method(int cpu) { @@ -152,15 +147,14 @@ static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) } #endif /* CONFIG_ACPI_APEI */ -#ifdef CONFIG_ACPI_NUMA -int arm64_acpi_numa_init(void); -int acpi_numa_get_nid(unsigned int cpu); -void acpi_map_cpus_to_nodes(void); -#else -static inline int arm64_acpi_numa_init(void) { return -ENOSYS; } -static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } -static inline void acpi_map_cpus_to_nodes(void) { } -#endif /* CONFIG_ACPI_NUMA */ +STUB_UNLESS(CONFIG_ACPI_NUMA, return -ENOSYS, +int arm64_acpi_numa_init(void)); + +STUB_UNLESS(CONFIG_ACPI_NUMA, return NUMA_NO_NODE, +int acpi_numa_get_nid(unsigned int cpu)); + +STUB_UNLESS(CONFIG_ACPI_NUMA, +void acpi_map_cpus_to_nodes(void)); #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h index 4b650ec..3dfbc15 100644 --- a/arch/arm64/include/asm/alternative.h +++ b/arch/arm64/include/asm/alternative.h @@ -29,11 +29,7 @@ typedef void (*alternative_cb_t)(struct alt_instr *alt, void __init apply_alternatives_all(void); -#ifdef CONFIG_MODULES -void apply_alternatives_module(void *start, size_t length); -#else -static inline void apply_alternatives_module(void *start, size_t length) { } -#endif +STUB_UNLESS(CONFIG_MODULES, void apply_alternatives_module(void *start, size_t length)); #define ALTINSTR_ENTRY(feature,cb) \ " .word 661b - .\n" /* label */ \ diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index dfcfba7..27edb5e 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -628,11 +628,7 @@ static inline int arm64_get_ssbd_state(void) #endif } -#ifdef CONFIG_ARM64_SSBD -void arm64_set_ssbd_mitigation(bool state); -#else -static inline void arm64_set_ssbd_mitigation(bool state) {} -#endif +STUB_UNLESS(CONFIG_ARM64_SSBD, void arm64_set_ssbd_mitigation(bool state)); extern int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt); diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h index 3c5ddb4..fecde4f 100644 --- a/arch/arm64/include/asm/cpuidle.h +++ b/arch/arm64/include/asm/cpuidle.h @@ -4,18 +4,10 @@ #include -#ifdef CONFIG_CPU_IDLE -extern int arm_cpuidle_init(unsigned int cpu); -extern int arm_cpuidle_suspend(int index); -#else -static inline int arm_cpuidle_init(unsigned int cpu) -{ - return -EOPNOTSUPP; -} +STUB_UNLESS(CONFIG_CPU_IDLE, return -EOPNOTSUPP, +int arm_cpuidle_init(unsigned int cpu)); + +STUB_UNLESS(CONFIG_CPU_IDLE, return -EOPNOTSUPP, +int arm_cpuidle_suspend(int index)); -static inline int arm_cpuidle_suspend(int index) -{ - return -EOPNOTSUPP; -} -#endif #endif diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h index a44cf52..8b91d8e 100644 --- a/arch/arm64/include/asm/debug-monitors.h +++ b/arch/arm64/include/asm/debug-monitors.h @@ -124,14 +124,8 @@ void kernel_enable_single_step(struct pt_regs *regs); void kernel_disable_single_step(void); int kernel_active_single_step(void); -#ifdef CONFIG_HAVE_HW_BREAKPOINT -int reinstall_suspended_bps(struct pt_regs *regs); -#else -static inline int reinstall_suspended_bps(struct pt_regs *regs) -{ - return -ENODEV; -} -#endif +STUB_UNLESS(CONFIG_HAVE_HW_BREAKPOINT, return -ENODEV, +int reinstall_suspended_bps(struct pt_regs *regs)); int aarch32_break_handler(struct pt_regs *regs); diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index dd1ad39..f247eb1 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -92,17 +92,10 @@ extern int __ro_after_init sve_max_vl; extern size_t sve_state_size(struct task_struct const *task); -extern void sve_alloc(struct task_struct *task); -extern void fpsimd_release_task(struct task_struct *task); -extern void fpsimd_sync_to_sve(struct task_struct *task); -extern void sve_sync_to_fpsimd(struct task_struct *task); -extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task); extern int sve_set_vector_length(struct task_struct *task, unsigned long vl, unsigned long flags); -extern int sve_set_current_vl(unsigned long arg); -extern int sve_get_current_vl(void); static inline void sve_user_disable(void) { @@ -113,43 +106,37 @@ static inline void sve_user_enable(void) { sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN); } - -/* - * Probing and setup functions. - * Calls to these functions must be serialised with one another. - */ -extern void __init sve_init_vq_map(void); -extern void sve_update_vq_map(void); -extern int sve_verify_vq_map(void); -extern void __init sve_setup(void); +extern void fpsimd_sync_to_sve(struct task_struct *task); #else /* ! CONFIG_ARM64_SVE */ -static inline void sve_alloc(struct task_struct *task) { } -static inline void fpsimd_release_task(struct task_struct *task) { } -static inline void sve_sync_to_fpsimd(struct task_struct *task) { } -static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { } - -static inline int sve_set_current_vl(unsigned long arg) -{ - return -EINVAL; -} - -static inline int sve_get_current_vl(void) -{ - return -EINVAL; -} - static inline void sve_user_disable(void) { BUILD_BUG(); } static inline void sve_user_enable(void) { BUILD_BUG(); } -static inline void sve_init_vq_map(void) { } -static inline void sve_update_vq_map(void) { } -static inline int sve_verify_vq_map(void) { return 0; } -static inline void sve_setup(void) { } #endif /* ! CONFIG_ARM64_SVE */ +STUB_UNLESS(CONFIG_ARM64_SVE, return -EINVAL, +int sve_set_current_vl(unsigned long arg)); + +STUB_UNLESS(CONFIG_ARM64_SVE, return -EINVAL, +int sve_get_current_vl(void)); + +STUB_UNLESS(CONFIG_ARM64_SVE, void sve_alloc(struct task_struct *task)); +STUB_UNLESS(CONFIG_ARM64_SVE, void fpsimd_release_task(struct task_struct *task)); +STUB_UNLESS(CONFIG_ARM64_SVE, void sve_sync_to_fpsimd(struct task_struct *task)); +STUB_UNLESS(CONFIG_ARM64_SVE, void sve_sync_from_fpsimd_zeropad(struct task_struct *task)); + +/* + * Probing and setup functions. + * Calls to these functions must be serialised with one another. + */ +STUB_UNLESS(CONFIG_ARM64_SVE, void __init sve_init_vq_map(void)); +STUB_UNLESS(CONFIG_ARM64_SVE, void sve_update_vq_map(void)); +STUB_UNLESS(CONFIG_ARM64_SVE, return 0, int sve_verify_vq_map(void)); +STUB_UNLESS(CONFIG_ARM64_SVE, void __init sve_setup(void)); + + /* For use by EFI runtime services calls only */ extern void __efi_fpsimd_begin(void); extern void __efi_fpsimd_end(void); diff --git a/arch/arm64/include/asm/hw_breakpoint.h b/arch/arm64/include/asm/hw_breakpoint.h index 6a53e59..ba451fc 100644 --- a/arch/arm64/include/asm/hw_breakpoint.h +++ b/arch/arm64/include/asm/hw_breakpoint.h @@ -137,17 +137,11 @@ extern void arch_uninstall_hw_breakpoint(struct perf_event *bp); extern void hw_breakpoint_pmu_read(struct perf_event *bp); extern int hw_breakpoint_slots(int type); -#ifdef CONFIG_HAVE_HW_BREAKPOINT -extern void hw_breakpoint_thread_switch(struct task_struct *next); -extern void ptrace_hw_copy_thread(struct task_struct *task); -#else -static inline void hw_breakpoint_thread_switch(struct task_struct *next) -{ -} -static inline void ptrace_hw_copy_thread(struct task_struct *task) -{ -} -#endif +STUB_UNLESS(CONFIG_HAVE_HW_BREAKPOINT, +void hw_breakpoint_thread_switch(struct task_struct *next)); + +STUB_UNLESS(CONFIG_HAVE_HW_BREAKPOINT, +void ptrace_hw_copy_thread(struct task_struct *task)); /* Determine number of BRP registers available. */ static inline int get_num_brps(void) diff --git a/arch/arm64/include/asm/kasan.h b/arch/arm64/include/asm/kasan.h index b52aacd..e67d1a3 100644 --- a/arch/arm64/include/asm/kasan.h +++ b/arch/arm64/include/asm/kasan.h @@ -36,14 +36,11 @@ #define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \ (64 - KASAN_SHADOW_SCALE_SHIFT))) -void kasan_init(void); -void kasan_copy_shadow(pgd_t *pgdir); asmlinkage void kasan_early_init(void); - -#else -static inline void kasan_init(void) { } -static inline void kasan_copy_shadow(pgd_t *pgdir) { } #endif +STUB_UNLESS(CONFIG_KASAN, void kasan_init(void)); +STUB_UNLESS(CONFIG_KASAN, void kasan_copy_shadow(pgd_t *pgdir)); + #endif #endif diff --git a/arch/arm64/include/asm/numa.h b/arch/arm64/include/asm/numa.h index 626ad01..700a4a9 100644 --- a/arch/arm64/include/asm/numa.h +++ b/arch/arm64/include/asm/numa.h @@ -29,23 +29,16 @@ static inline const struct cpumask *cpumask_of_node(int node) } #endif -void __init arm64_numa_init(void); int __init numa_add_memblk(int nodeid, u64 start, u64 end); void __init numa_set_distance(int from, int to, int distance); void __init numa_free_distance(void); -void __init early_map_cpu_to_node(unsigned int cpu, int nid); -void numa_store_cpu_info(unsigned int cpu); -void numa_add_cpu(unsigned int cpu); -void numa_remove_cpu(unsigned int cpu); - -#else /* CONFIG_NUMA */ - -static inline void numa_store_cpu_info(unsigned int cpu) { } -static inline void numa_add_cpu(unsigned int cpu) { } -static inline void numa_remove_cpu(unsigned int cpu) { } -static inline void arm64_numa_init(void) { } -static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { } #endif /* CONFIG_NUMA */ +STUB_UNLESS(CONFIG_NUMA, void __init arm64_numa_init(void)); +STUB_UNLESS(CONFIG_NUMA, void __init early_map_cpu_to_node(unsigned int cpu, int nid)); +STUB_UNLESS(CONFIG_NUMA, void numa_store_cpu_info(unsigned int cpu)); +STUB_UNLESS(CONFIG_NUMA, void numa_add_cpu(unsigned int cpu)); +STUB_UNLESS(CONFIG_NUMA, void numa_remove_cpu(unsigned int cpu)); + #endif /* __ASM_NUMA_H */ diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h index 6afd847..8d27672 100644 --- a/arch/arm64/include/asm/ptdump.h +++ b/arch/arm64/include/asm/ptdump.h @@ -33,15 +33,10 @@ struct ptdump_info { }; void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info); -#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS -int ptdump_debugfs_register(struct ptdump_info *info, const char *name); -#else -static inline int ptdump_debugfs_register(struct ptdump_info *info, - const char *name) -{ - return 0; -} -#endif + +STUB_UNLESS(CONFIG_ARM64_PTDUMP_DEBUGFS, return 0, +int ptdump_debugfs_register(struct ptdump_info *info, const char *name)); + void ptdump_check_wx(void); #endif /* CONFIG_ARM64_PTDUMP_CORE */ diff --git a/arch/arm64/include/asm/signal32.h b/arch/arm64/include/asm/signal32.h index 81abea0..9dc06bd 100644 --- a/arch/arm64/include/asm/signal32.h +++ b/arch/arm64/include/asm/signal32.h @@ -21,30 +21,17 @@ #include #define AARCH32_KERN_SIGRET_CODE_OFFSET 0x500 +#endif /* CONFIG_COMPAT */ +STUB_UNLESS(CONFIG_COMPAT, return -ENOSYS, int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set, - struct pt_regs *regs); -int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, - struct pt_regs *regs); - -void compat_setup_restart_syscall(struct pt_regs *regs); -#else + struct pt_regs *regs)); -static inline int compat_setup_frame(int usid, struct ksignal *ksig, - sigset_t *set, struct pt_regs *regs) -{ - return -ENOSYS; -} - -static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, - struct pt_regs *regs) -{ - return -ENOSYS; -} +STUB_UNLESS(CONFIG_COMPAT, return -ENOSYS, +int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, + struct pt_regs *regs)); -static inline void compat_setup_restart_syscall(struct pt_regs *regs) -{ -} -#endif /* CONFIG_COMPAT */ +STUB_UNLESS(CONFIG_COMPAT, +void compat_setup_restart_syscall(struct pt_regs *regs)); #endif /* __KERNEL__ */ #endif /* __ASM_SIGNAL32_H */