Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3610253pxu; Tue, 8 Dec 2020 17:14:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlU+YyBC798Y4ZmNXrGTh8424QctaknW9EMFmeKeGHnGtwnTYHtXT+qf/XpTdi0j832z8e X-Received: by 2002:a50:fe0e:: with SMTP id f14mr607351edt.159.1607476478671; Tue, 08 Dec 2020 17:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607476478; cv=none; d=google.com; s=arc-20160816; b=BwjQfHcQOz/xzytTSgdoDQ9+LsldwwP6k0rjdfIrv5BujwakPKxV6sBTabcwhWIbje b38faBFEGaAOBTEGKmpMwogaTLK2W6Lyw5HHDYH0fF00H1wSf+20k963K9NHO0ADoJwA vSfR9fCpG/R/RPmceXR86KIJF8w/ic4q7R1le9ek3//cq3w4Ba9gImCCWKdW059WXHPd FjegvqV+Jbmp8hDH6yfkxXjJANhsZvPSo8F46iexr2DtXg4z1VCQJ3MEii2IE+MWEINH WOxGUQWmerQAGWNvD5A3/VodteYIoxcBDi/0qii3wAx99iJ0eOJ2hmQdGsXNjJLB/KjF GTzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date; bh=b6X+XggOiXweNQqzJWCT7Q+giI0MHPT1oheIWXC99QI=; b=qKS1fRMT6ASpuS24prGoTyYep9VpE0sMrpNldKObr3ZoeVf24bLtssN/i3w2GnBfZT Or9Mz1a8GoCHi6KNqp6DViXIvfG9f5sPr5dtTRv/R8/SHYiQ4mD13k7OHfRdiQbP9M9c T+1zYtUDeYL49/nafXZ3+tBvHUNjd1hcxB5vfoQMv3QG6sN5zX6qSAKLsFmyC2/7hggz GsJ3QZ7Y19Am9b6frSfadWL+smlGK+rLhGhBwbJF4+dU0MxXlDmliXelc3OR+cM1bvU6 2+6cMX/pFYMvE983gTMDc05R/BQIHVQHkrm0NM0Ge4HxNd3RHHaXgkY0gI0x0ZrMUBc8 a3tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si119851edr.468.2020.12.08.17.14.16; Tue, 08 Dec 2020 17:14:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728876AbgLHVAK convert rfc822-to-8bit (ORCPT + 99 others); Tue, 8 Dec 2020 16:00:10 -0500 Received: from aposti.net ([89.234.176.197]:42030 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728511AbgLHVAK (ORCPT ); Tue, 8 Dec 2020 16:00:10 -0500 Date: Tue, 08 Dec 2020 19:00:22 +0000 From: Paul Cercueil Subject: Re: [PATCH 1/2] if_enabled.h: Add IF_ENABLED_OR_ELSE() =?UTF-8?Q?and=0D=0A?= IF_ENABLED() macros To: Randy Dunlap Cc: Linus Walleij , Arnd Bergmann , od@zcrc.me, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: In-Reply-To: References: <20201208164821.2686082-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Randy, Le mar. 8 déc. 2020 à 9:39, Randy Dunlap a écrit : > On 12/8/20 8:48 AM, Paul Cercueil wrote: >> >> Signed-off-by: Paul Cercueil > > Hi Paul, > > Why not just add these 2 new macros to ? > > Maybe you don't want to add the other 2 headers there also? That means including in , which causes build failures: LD vmlinux SORTTAB vmlinux SYSMAP System.map AS arch/mips/boot/compressed/head.o CC arch/mips/boot/compressed/decompress.o CC arch/mips/boot/compressed/string.o CC arch/mips/boot/compressed/dummy.o OBJCOPY arch/mips/boot/compressed/vmlinux.bin HOSTCC arch/mips/boot/compressed/calc_vmlinuz_load_addr GZIP arch/mips/boot/compressed/vmlinux.bin.z In file included from ./include/linux/kcsan-checks.h:7, from ./include/asm-generic/rwonce.h:27, from ./arch/mips/include/generated/asm/rwonce.h:1, from ./include/linux/compiler.h:246, from ././include/linux/kconfig.h:8, from :32: /include/linux/compiler_attributes.h:64: warning: "__always_inline" redefined 64 | #define __always_inline inline __attribute__((__always_inline__)) | In file included from ./include/linux/stddef.h:5, from ./include/uapi/linux/posix_types.h:5, from ./include/uapi/linux/types.h:14, from ./include/linux/types.h:6, from ./include/linux/kasan-checks.h:5, from ./include/asm-generic/rwonce.h:26, from ./arch/mips/include/generated/asm/rwonce.h:1, from ./include/linux/compiler.h:246, from ././include/linux/kconfig.h:8, from :32: /include/uapi/linux/stddef.h:5: note: this is the location of the previous definition 5 | #define __always_inline inline | In file included from ./arch/mips/include/generated/asm/rwonce.h:1, from ./include/linux/compiler.h:246, from ././include/linux/kconfig.h:8, from :32: /include/asm-generic/rwonce.h:64:31: error: expected ‘;’ before ‘unsigned’ 64 | static __no_sanitize_or_inline | ^ | ; 65 | unsigned long __read_once_word_nocheck(const void *addr) | ~~~~~~~~ /include/asm-generic/rwonce.h:65:15: warning: no previous prototype for ‘__read_once_word_nocheck’ [-Wmissing-prototypes] 65 | unsigned long __read_once_word_nocheck(const void *addr) | ^~~~~~~~~~~~~~~~~~~~~~~~ /include/asm-generic/rwonce.h:82:28: error: expected ‘;’ before ‘unsigned’ 82 | static __no_kasan_or_inline | ^ | ; 83 | unsigned long read_word_at_a_time(const void *addr) | ~~~~~~~~ /include/asm-generic/rwonce.h:83:15: warning: no previous prototype for ‘read_word_at_a_time’ [-Wmissing-prototypes] 83 | unsigned long read_word_at_a_time(const void *addr) | ^~~~~~~~~~~~~~~~~~~ That's why I opted for a new header. Cheers, -Paul >> --- >> include/linux/if_enabled.h | 22 ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> create mode 100644 include/linux/if_enabled.h >> >> diff --git a/include/linux/if_enabled.h b/include/linux/if_enabled.h >> new file mode 100644 >> index 000000000000..8189d1402340 >> --- /dev/null >> +++ b/include/linux/if_enabled.h >> @@ -0,0 +1,22 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +#ifndef __LINUX_IF_ENABLED_H >> +#define __LINUX_IF_ENABLED_H >> + >> +#include >> +#include >> +#include >> + >> +/* >> + * IF_ENABLED_OR_ELSE(CONFIG_FOO, a, b) evaluates to (a) if >> CONFIG_FOO is set >> + * to 'y' or 'm', (b) otherwise. >> + */ >> +#define IF_ENABLED_OR_ELSE(option, a, b) \ >> + (BUILD_BUG_ON_ZERO(__same_type((a), (b))) || IS_ENABLED(option) ? >> (a) : (b)) >> + >> +/* >> + * IF_ENABLED(CONFIG_FOO, ptr) evaluates to (ptr) if CONFIG_FOO is >> set to 'y' >> + * or 'm', NULL otherwise. >> + */ >> +#define IF_ENABLED(option, ptr) IF_ENABLED_OR_ELSE(option, ptr, >> NULL) >> + >> +#endif /* __LINUX_IF_ENABLED_H */ >> > > > thanks. > -- > ~Randy >