mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] magicvar: Use __UNIQUE_ID to generate name
@ 2020-10-01  8:07 Sascha Hauer
  2020-10-01  8:07 ` [PATCH 2/3] magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVAR Sascha Hauer
  2020-10-01  8:07 ` [PATCH 3/3] magicvar: retire BAREBOX_MAGICVAR_NAMED Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-10-01  8:07 UTC (permalink / raw)
  To: Barebox List

BAREBOX_MAGICVAR_NAME only exists to generate a unique identifier. We can
generate that using __UNIQUE_ID. With this we can convert users from
BAREBOX_MAGICVAR_NAME to the simpler BAREBOX_MAGICVAR macro.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/magicvar.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/magicvar.h b/include/magicvar.h
index 9fb89a84cc..bad9b0dee5 100644
--- a/include/magicvar.h
+++ b/include/magicvar.h
@@ -19,16 +19,18 @@ extern struct magicvar __barebox_magicvar_end;
 #endif
 
 #ifdef CONFIG_CMD_MAGICVAR
-#define BAREBOX_MAGICVAR_NAMED(_name, _varname, _description)			\
-extern const struct magicvar __barebox_magicvar_##_name;	\
-const struct magicvar __barebox_magicvar_##_name		\
+#define __BAREBOX_MAGICVAR_NAMED(_name, _varname, _description)			\
+static const struct magicvar _name							\
         __attribute__ ((unused,section (".barebox_magicvar_" __stringify(_name)))) = {	\
         .name	= #_varname,					\
 	.description = MAGICVAR_DESCRIPTION(_description),	\
 };
 
+#define BAREBOX_MAGICVAR_NAMED(_name, _varname, _description)			\
+	__BAREBOX_MAGICVAR_NAMED(__barebox_magicvar_##_name, _varname, _description)
+
 #define BAREBOX_MAGICVAR(_name, _description)			\
-	BAREBOX_MAGICVAR_NAMED(_name, _name, _description)
+	__BAREBOX_MAGICVAR_NAMED(__UNIQUE_ID(magicvar), _name, _description)
 #else
 #define BAREBOX_MAGICVAR_NAMED(_name, _varname, _description)
 #define BAREBOX_MAGICVAR(_name, _description)
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-01  8:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  8:07 [PATCH 1/3] magicvar: Use __UNIQUE_ID to generate name Sascha Hauer
2020-10-01  8:07 ` [PATCH 2/3] magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVAR Sascha Hauer
2020-10-01  8:07 ` [PATCH 3/3] magicvar: retire BAREBOX_MAGICVAR_NAMED Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox