* [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1
@ 2023-05-23 9:40 Ahmad Fatoum
2023-05-23 9:40 ` [PATCH 2/2] block: efi: " Ahmad Fatoum
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2023-05-23 9:40 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The code uses __is_defined, which only works for undefined macros and
defined ones with a value. This is different than the debugging prints
that accept empty defined DEBUG, so add a commented out #define DEBUG 1
to alert those seeking to debug the code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/efi/payload/iomem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/common/efi/payload/iomem.c b/common/efi/payload/iomem.c
index 6b92ca993aa7..550d832668ed 100644
--- a/common/efi/payload/iomem.c
+++ b/common/efi/payload/iomem.c
@@ -3,6 +3,7 @@
#define pr_fmt(fmt) "efi-iomem: " fmt
+// #define DEBUG 1
#include <common.h>
#include <init.h>
#include <efi.h>
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] block: efi: add commented out #define DEBUG 1
2023-05-23 9:40 [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1 Ahmad Fatoum
@ 2023-05-23 9:40 ` Ahmad Fatoum
2023-05-30 12:31 ` [PATCH 1/2] efi: payload: iomem: " Sascha Hauer
2023-05-30 12:38 ` Sascha Hauer
2 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2023-05-23 9:40 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The code uses __is_defined, which only works for undefined macros and
defined ones with a value. This is different than the debugging prints
that accept empty defined DEBUG, so add a commented out #define DEBUG 1
to alert those seeking to debug the code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/block/efi-block-io.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index eb4981e86298..668eac9d75f0 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
+
+// #define DEBUG 1
#include <common.h>
#include <driver.h>
#include <init.h>
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1
2023-05-23 9:40 [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1 Ahmad Fatoum
2023-05-23 9:40 ` [PATCH 2/2] block: efi: " Ahmad Fatoum
@ 2023-05-30 12:31 ` Sascha Hauer
2023-05-30 12:38 ` Sascha Hauer
2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-05-30 12:31 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Masahiro Yamada
On Tue, May 23, 2023 at 11:40:34AM +0200, Ahmad Fatoum wrote:
> The code uses __is_defined, which only works for undefined macros and
> defined ones with a value. This is different than the debugging prints
> that accept empty defined DEBUG, so add a commented out #define DEBUG 1
> to alert those seeking to debug the code.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> common/efi/payload/iomem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/common/efi/payload/iomem.c b/common/efi/payload/iomem.c
> index 6b92ca993aa7..550d832668ed 100644
> --- a/common/efi/payload/iomem.c
> +++ b/common/efi/payload/iomem.c
> @@ -3,6 +3,7 @@
>
> #define pr_fmt(fmt) "efi-iomem: " fmt
>
> +// #define DEBUG 1
I don't like this very much.
Generally being able to do this is really appealing:
if (__is_defined(DEBUG))
...
Indeed this is so appealing that others may copy this. Having to
remember then that there's a subtle difference between __is_defined() and
#ifdef is not so nice though.
We could add
#define __ARG_PLACEHOLDER_ 0,
to include/linux/kconfig.h. With this __is_defined() and #ifdef should
do the same thing. It would even better to add this to the Linux
upstream version of this file. I am not sure though if that has any
unwanted side effects. Masahiro, do you have an opinion about this?
Another option would be to add this somewhere:
#ifdef DEBUG
#undef DEBUG
#define DEBUG 1
#endif
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1
2023-05-23 9:40 [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1 Ahmad Fatoum
2023-05-23 9:40 ` [PATCH 2/2] block: efi: " Ahmad Fatoum
2023-05-30 12:31 ` [PATCH 1/2] efi: payload: iomem: " Sascha Hauer
@ 2023-05-30 12:38 ` Sascha Hauer
2023-05-30 15:38 ` Masahiro Yamada
2 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2023-05-30 12:38 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Masahiro Yamada
Picked some outdated address from Masahiro, so once again:
On Tue, May 23, 2023 at 11:40:34AM +0200, Ahmad Fatoum wrote:
> The code uses __is_defined, which only works for undefined macros and
> defined ones with a value. This is different than the debugging prints
> that accept empty defined DEBUG, so add a commented out #define DEBUG 1
> to alert those seeking to debug the code.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> common/efi/payload/iomem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/common/efi/payload/iomem.c b/common/efi/payload/iomem.c
> index 6b92ca993aa7..550d832668ed 100644
> --- a/common/efi/payload/iomem.c
> +++ b/common/efi/payload/iomem.c
> @@ -3,6 +3,7 @@
>
> #define pr_fmt(fmt) "efi-iomem: " fmt
>
> +// #define DEBUG 1
I don't like this very much.
Generally being able to do this is really appealing:
if (__is_defined(DEBUG))
...
Indeed this is so appealing that others may copy this. Having to
remember then that there's a subtle difference between __is_defined() and
#ifdef is not so nice though.
We could add
#define __ARG_PLACEHOLDER_ 0,
to include/linux/kconfig.h. With this __is_defined() and #ifdef should
do the same thing. It would even better to add this to the Linux
upstream version of this file. I am not sure though if that has any
unwanted side effects. Masahiro, do you have an opinion about this?
Another option would be to add this somewhere:
#ifdef DEBUG
#undef DEBUG
#define DEBUG 1
#endif
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1
2023-05-30 12:38 ` Sascha Hauer
@ 2023-05-30 15:38 ` Masahiro Yamada
2023-05-31 7:27 ` Sascha Hauer
0 siblings, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2023-05-30 15:38 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Ahmad Fatoum, barebox
On Tue, May 30, 2023 at 9:38 PM Sascha Hauer <sha@pengutronix.de> wrote:
>
> Picked some outdated address from Masahiro, so once again:
The macro name is misleading - perhaps, it should have
been named as __is_defined_as_1().
I do not know if __is_defined() is future-proof.
IS_BUILTIN, IS_MODULE, etc. are official,
but __is_defined() is internal.
>
> On Tue, May 23, 2023 at 11:40:34AM +0200, Ahmad Fatoum wrote:
> > The code uses __is_defined, which only works for undefined macros and
> > defined ones with a value. This is different than the debugging prints
> > that accept empty defined DEBUG, so add a commented out #define DEBUG 1
> > to alert those seeking to debug the code.
> >
> > Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> > ---
> > common/efi/payload/iomem.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/common/efi/payload/iomem.c b/common/efi/payload/iomem.c
> > index 6b92ca993aa7..550d832668ed 100644
> > --- a/common/efi/payload/iomem.c
> > +++ b/common/efi/payload/iomem.c
> > @@ -3,6 +3,7 @@
> >
> > #define pr_fmt(fmt) "efi-iomem: " fmt
> >
> > +// #define DEBUG 1
>
> I don't like this very much.
>
> Generally being able to do this is really appealing:
>
> if (__is_defined(DEBUG))
> ...
>
> Indeed this is so appealing that others may copy this. Having to
> remember then that there's a subtle difference between __is_defined() and
> #ifdef is not so nice though.
>
> We could add
>
> #define __ARG_PLACEHOLDER_ 0,
>
> to include/linux/kconfig.h. With this __is_defined() and #ifdef should
> do the same thing. It would even better to add this to the Linux
> upstream version of this file. I am not sure though if that has any
> unwanted side effects. Masahiro, do you have an opinion about this?
>
> Another option would be to add this somewhere:
>
> #ifdef DEBUG
> #undef DEBUG
> #define DEBUG 1
> #endif
>
> Sascha
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1
2023-05-30 15:38 ` Masahiro Yamada
@ 2023-05-31 7:27 ` Sascha Hauer
0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-05-31 7:27 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Ahmad Fatoum, barebox
On Wed, May 31, 2023 at 12:38:20AM +0900, Masahiro Yamada wrote:
> On Tue, May 30, 2023 at 9:38 PM Sascha Hauer <sha@pengutronix.de> wrote:
> >
> > Picked some outdated address from Masahiro, so once again:
>
>
> The macro name is misleading - perhaps, it should have
> been named as __is_defined_as_1().
>
> I do not know if __is_defined() is future-proof.
> IS_BUILTIN, IS_MODULE, etc. are official,
> but __is_defined() is internal.
Yes, it looks like __is_defined() is meant to be used internally by
Kconfig, nevertheless it's getting more users in the kernel:
arch/arm64/include/asm/cpufeature.h:408: return __is_defined(__KVM_VHE_HYPERVISOR__);
arch/arm64/include/asm/cpufeature.h:414: return __is_defined(__KVM_NVHE_HYPERVISOR__);
arch/arm64/include/asm/kvm_nested.h:9: return (!__is_defined(__KVM_NVHE_HYPERVISOR__) &&
arch/powerpc/include/asm/vdso/timebase.h:54: if (__is_defined(__powerpc64__))
arch/s390/include/asm/nospec-branch.h:17: return __is_defined(CC_USING_EXPOLINE) && !nospec_disable;
arch/s390/kernel/nospec-branch.c:67: if (__is_defined(CC_USING_EXPOLINE))
arch/s390/kernel/nospec-branch.c:70: } else if (__is_defined(CC_USING_EXPOLINE)) {
drivers/crypto/sahara.c:356: if (!__is_defined(DEBUG))
drivers/crypto/sahara.c:408: if (!__is_defined(DEBUG))
drivers/crypto/sahara.c:429: if (!__is_defined(DEBUG))
drivers/usb/host/sl811-hcd.c:1290: if (__is_defined(VERBOSE) ||
include/linux/pgtable.h:1605:#define mm_p4d_folded(mm) __is_defined(__PAGETABLE_P4D_FOLDED)
include/linux/pgtable.h:1609:#define mm_pud_folded(mm) __is_defined(__PAGETABLE_PUD_FOLDED)
include/linux/pgtable.h:1613:#define mm_pmd_folded(mm) __is_defined(__PAGETABLE_PMD_FOLDED)
security/smack/smack_lsm.c:2911: if (__is_defined(SMACK_IPV6_SECMARK_LABELING))
Maybe we should move __is_defined() somewhere else so that it can
officially be used.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-05-31 7:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 9:40 [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1 Ahmad Fatoum
2023-05-23 9:40 ` [PATCH 2/2] block: efi: " Ahmad Fatoum
2023-05-30 12:31 ` [PATCH 1/2] efi: payload: iomem: " Sascha Hauer
2023-05-30 12:38 ` Sascha Hauer
2023-05-30 15:38 ` Masahiro Yamada
2023-05-31 7:27 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox