mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 6/8] Revert "globalvar: make globalvar functions more consistent"
Date: Wed, 14 Jun 2017 09:26:39 +0200	[thread overview]
Message-ID: <20170614072641.29942-7-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170614072641.29942-1-s.hauer@pengutronix.de>

This reverts commit 1b4a05c9263ae26083526acfabdea1ef96531a1d.
---
 arch/arm/boards/beaglebone/board.c               |   2 +-
 arch/arm/boards/crystalfontz-cfa10036/hwdetect.c |   2 +-
 arch/arm/boards/phytec-som-imx6/board.c          |   2 +-
 arch/arm/boards/vscom-baltos/board.c             |   7 +-
 arch/ppc/boards/pcm030/eeprom.c                  |   4 +-
 common/boot.c                                    |   2 +-
 common/bootchooser.c                             |   4 +-
 common/bootm.c                                   |   2 +-
 common/console_common.c                          |   6 +-
 common/globalvar.c                               |  28 ++++--
 common/password.c                                |   2 +-
 common/reset_source.c                            |   2 +-
 drivers/mtd/peb.c                                |   6 +-
 include/globalvar.h                              | 109 +++--------------------
 14 files changed, 55 insertions(+), 123 deletions(-)

diff --git a/arch/arm/boards/beaglebone/board.c b/arch/arm/boards/beaglebone/board.c
index 18a9a10a86..5717c45020 100644
--- a/arch/arm/boards/beaglebone/board.c
+++ b/arch/arm/boards/beaglebone/board.c
@@ -87,7 +87,7 @@ static int beaglebone_devices_init(void)
 
 	defaultenv_append_directory(defaultenv_beaglebone);
 
-	globalvar_add_simple_string_fixed("board.variant", black ? "boneblack" : "bone");
+	globalvar_add_simple("board.variant", black ? "boneblack" : "bone");
 
 	printf("detected 'BeagleBone %s'\n", black ? "Black" : "White");
 
diff --git a/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c b/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c
index d0907c11f0..c94cb355e2 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c
+++ b/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c
@@ -105,7 +105,7 @@ void cfa10036_detect_hw(void)
 		return;
 	}
 
-	globalvar_add_simple_string_fixed("board.variant", board_name);
+	globalvar_add_simple("board.variant", board_name);
 
 	pr_info("Booting on a CFA10036 with %s\n", board_name);
 }
diff --git a/arch/arm/boards/phytec-som-imx6/board.c b/arch/arm/boards/phytec-som-imx6/board.c
index 31b2761024..ed9453bdda 100644
--- a/arch/arm/boards/phytec-som-imx6/board.c
+++ b/arch/arm/boards/phytec-som-imx6/board.c
@@ -152,7 +152,7 @@ static int physom_imx6_devices_init(void)
 		phyflex_err006282_workaround();
 
 		pfla02_module_revision = get_module_rev();
-		globalvar_add_simple_uint32_fixed("board.revision", pfla02_module_revision, "%u");
+		globalvar_add_simple_int("board.revision", &pfla02_module_revision, "%u");
 		pr_info("Module Revision: %u\n", pfla02_module_revision);
 
 		barebox_set_hostname("phyFLEX-i.MX6");
diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c
index 1a4dc30936..39f40a6061 100644
--- a/arch/arm/boards/vscom-baltos/board.c
+++ b/arch/arm/boards/vscom-baltos/board.c
@@ -64,7 +64,7 @@ static int baltos_read_eeprom(void)
 {
 	struct bsp_vs_hwparam hw_param;
 	size_t size;
-	char *buf;
+	char *buf, var_buf[32];
 	int rc;
 	unsigned char mac_addr[6];
 
@@ -107,7 +107,8 @@ static int baltos_read_eeprom(void)
 		hw_param.SystemId = 0;
 	}
 
-	globalvar_add_simple_uint32_fixed("board.id", hw_param.SystemId, "%u");
+	sprintf(var_buf, "%d", hw_param.SystemId);
+	globalvar_add_simple("board.id", var_buf);
 
 	/* enable mPCIe slot */
 	gpio_direction_output(100, 1);
@@ -130,7 +131,7 @@ static int baltos_devices_init(void)
 	if (!of_machine_is_compatible("vscom,onrisc"))
 		return 0;
 
-	globalvar_add_simple_string_fixed("board.variant", "baltos");
+	globalvar_add_simple("board.variant", "baltos");
 
 	if (bootsource_get() == BOOTSOURCE_MMC)
 		omap_set_bootmmc_devname("mmc0");
diff --git a/arch/ppc/boards/pcm030/eeprom.c b/arch/ppc/boards/pcm030/eeprom.c
index 34bce85b94..aa00f361cd 100644
--- a/arch/ppc/boards/pcm030/eeprom.c
+++ b/arch/ppc/boards/pcm030/eeprom.c
@@ -53,7 +53,7 @@ static void pcm030_read_factory_data(const struct pcm030_eeprom *buf)
 			continue;
 		board = xstrndup(&buf->product[u], l);
 		u += l + 1;
-		globalvar_add_simple_string_fixed("model.type", board);
+		globalvar_add_simple("model.type", board);
 		free(board);
 	}
 
@@ -62,7 +62,7 @@ static void pcm030_read_factory_data(const struct pcm030_eeprom *buf)
 			continue;
 		serial = xstrndup(&buf->product[u], l);
 		u += l + 1;
-		globalvar_add_simple_string_fixed("model.serial", serial);
+		globalvar_add_simple("model.serial", serial);
 		free(serial);
 	}
 
diff --git a/common/boot.c b/common/boot.c
index a2d27d1593..cef3d5e514 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -123,7 +123,7 @@ void boot_set_watchdog_timeout(unsigned int timeout)
 
 static int init_boot_watchdog_timeout(void)
 {
-	return globalvar_add_simple_uint32("boot.watchdog_timeout",
+	return globalvar_add_simple_int("boot.watchdog_timeout",
 			&boot_watchdog_timeout, "%u");
 }
 late_initcall(init_boot_watchdog_timeout);
diff --git a/common/bootchooser.c b/common/bootchooser.c
index f6d99d130b..455f290fa2 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -907,8 +907,8 @@ static int bootchooser_init(void)
 	globalvar_add_simple_bool("bootchooser.retry", &retry);
 	globalvar_add_simple_string("bootchooser.targets", &available_targets);
 	globalvar_add_simple_string("bootchooser.state_prefix", &state_prefix);
-	globalvar_add_simple_uint32("bootchooser.default_attempts", &global_default_attempts, "%u");
-	globalvar_add_simple_uint32("bootchooser.default_priority", &global_default_priority, "%u");
+	globalvar_add_simple_int("bootchooser.default_attempts", &global_default_attempts, "%u");
+	globalvar_add_simple_int("bootchooser.default_priority", &global_default_priority, "%u");
 	globalvar_add_simple_bitmask("bootchooser.reset_attempts", &reset_attempts,
 				  reset_attempts_names, ARRAY_SIZE(reset_attempts_names));
 	globalvar_add_simple_bitmask("bootchooser.reset_priorities", &reset_priorities,
diff --git a/common/bootm.c b/common/bootm.c
index 92cfeb6c32..81625d9157 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -668,7 +668,7 @@ static int bootm_init(void)
 	if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES))
 		bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
 
-	globalvar_add_simple_uint32("bootm.verbose", &bootm_verbosity, "%u");
+	globalvar_add_simple_int("bootm.verbose", &bootm_verbosity, "%u");
 
 	globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode,
 				  bootm_verify_names, ARRAY_SIZE(bootm_verify_names));
diff --git a/common/console_common.c b/common/console_common.c
index b36b3ff083..d051458de4 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -148,10 +148,10 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...)
 static int loglevel_init(void)
 {
 	if (IS_ENABLED(CONFIG_LOGBUF))
-		globalvar_add_simple_uint32("log_max_messages",
-				&barebox_log_max_messages, "%u");
+		globalvar_add_simple_int("log_max_messages",
+				&barebox_log_max_messages, "%d");
 
-	return globalvar_add_simple_uint32("loglevel", &barebox_loglevel, "%u");
+	return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d");
 }
 device_initcall(loglevel_init);
 
diff --git a/common/globalvar.c b/common/globalvar.c
index 2f65ca805f..32ca6a24db 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -424,7 +424,7 @@ int globalvar_add_simple(const char *name, const char *value)
 	return 0;
 }
 
-int __globalvar_add_simple_string(const char *name, char **value)
+int globalvar_add_simple_string(const char *name, char **value)
 {
 	struct param_d *p;
 
@@ -439,14 +439,28 @@ int __globalvar_add_simple_string(const char *name, char **value)
 	return 0;
 }
 
-int __globalvar_add_simple_int(const char *name, void *value,
-				      enum param_type type,
-				      const char *format)
+int globalvar_add_simple_int(const char *name, int *value,
+			     const char *format)
 {
 	struct param_d *p;
 
-	p = __dev_add_param_int(&global_device, name, NULL, NULL,
-		value, type, format, NULL);
+	p = dev_add_param_int(&global_device, name, NULL, NULL,
+		value, format, NULL);
+
+	if (IS_ERR(p))
+		return PTR_ERR(p);
+
+	globalvar_nv_sync(name);
+
+	return 0;
+}
+
+int globalvar_add_simple_bool(const char *name, int *value)
+{
+	struct param_d *p;
+
+	p = dev_add_param_bool(&global_device, name, NULL, NULL,
+		value, NULL);
 
 	if (IS_ERR(p))
 		return PTR_ERR(p);
@@ -508,7 +522,7 @@ static int globalvar_init(void)
 	if (IS_ENABLED(CONFIG_NVVAR))
 		register_device(&nv_device);
 
-	globalvar_add_simple_string_fixed("version", UTS_RELEASE);
+	globalvar_add_simple("version", UTS_RELEASE);
 
 	return 0;
 }
diff --git a/common/password.c b/common/password.c
index 5e6bfc53e7..74d328f4b2 100644
--- a/common/password.c
+++ b/common/password.c
@@ -443,7 +443,7 @@ static int login_global_init(void)
 {
 	login_fail_command = xstrdup("boot");
 
-	globalvar_add_simple_uint32("login.timeout", &login_timeout, "%u");
+	globalvar_add_simple_int("login.timeout", &login_timeout, "%d");
 	globalvar_add_simple_string("login.fail_command", &login_fail_command);
 
 	return 0;
diff --git a/common/reset_source.c b/common/reset_source.c
index e18bf6db68..06e2ca85f5 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -54,7 +54,7 @@ EXPORT_SYMBOL(reset_source_set_priority);
 
 static int reset_source_init(void)
 {
-	globalvar_add_simple_enum_ro("system.reset", (unsigned int *)&reset_source,
+	globalvar_add_simple_enum("system.reset", (unsigned int *)&reset_source,
 			reset_src_names, ARRAY_SIZE(reset_src_names));
 
 	return 0;
diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c
index 0e64fe1671..c35b63f2fd 100644
--- a/drivers/mtd/peb.c
+++ b/drivers/mtd/peb.c
@@ -76,11 +76,11 @@ static int mtd_peb_emulate_erase_failure(void)
 #ifdef CONFIG_MTD_PEB_DEBUG
 static int mtd_peb_debug_init(void)
 {
-	globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_bitflip",
+	globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_bitflip",
 				 &__mtd_peb_emulate_bitflip, "%u");
-	globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_write_failure",
+	globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_write_failure",
 				 &__mtd_peb_emulate_write_failure, "%u");
-	globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_erase_failures",
+	globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_erase_failures",
 				 &__mtd_peb_emulate_erase_failures, "%u");
 	globalvar_add_simple_bool("mtd_peb.mtd_peb_chk_io",
 				 &__mtd_peb_chk_io);
diff --git a/include/globalvar.h b/include/globalvar.h
index aea43b193d..df43f1fe66 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -15,9 +15,10 @@ void globalvar_remove(const char *name);
 char *globalvar_get_match(const char *match, const char *separator);
 void globalvar_set_match(const char *match, const char *val);
 
-int __globalvar_add_simple_string(const char *name, char **value);
-int __globalvar_add_simple_int(const char *name, void *value,
-			       enum param_type type, const char *format);
+int globalvar_add_simple_string(const char *name, char **value);
+int globalvar_add_simple_int(const char *name, int *value,
+			     const char *format);
+int globalvar_add_simple_bool(const char *name, int *value);
 int globalvar_add_simple_enum(const char *name,	int *value,
 			      const char * const *names, int max);
 int globalvar_add_simple_bitmask(const char *name, unsigned long *value,
@@ -38,13 +39,19 @@ static inline int globalvar_add_simple(const char *name, const char *value)
 	return 0;
 }
 
-static inline int __globalvar_add_simple_int(const char *name, void *value,
-			       enum param_type type, const char *format)
+static inline int globalvar_add_simple_string(const char *name, char **value)
 {
 	return 0;
 }
 
-static inline int __globalvar_add_simple_string(const char *name, char **value)
+static inline int globalvar_add_simple_int(const char *name,
+		int *value, const char *format)
+{
+	return 0;
+}
+
+static inline int globalvar_add_simple_bool(const char *name,
+		int *value)
 {
 	return 0;
 }
@@ -108,96 +115,6 @@ static inline void dev_param_init_from_nv(struct device_d *dev, const char *name
 
 #endif
 
-#define DECLARE_GLOBALVAR_INT(intname, inttype, paramtype) \
-	static inline int globalvar_add_simple_##intname(const char *name,	\
-						      inttype *value,		\
-						      const char *format)	\
-	{									\
-		return __globalvar_add_simple_int(name, value,			\
-						  paramtype,			\
-						  format);			\
-	}
-
-DECLARE_GLOBALVAR_INT(uint32, uint32_t, PARAM_TYPE_UINT32)
-DECLARE_GLOBALVAR_INT(int32, int32_t, PARAM_TYPE_INT32)
-DECLARE_GLOBALVAR_INT(uint64, uint64_t, PARAM_TYPE_UINT64)
-DECLARE_GLOBALVAR_INT(int64, int64_t, PARAM_TYPE_INT64)
-
-static inline int globalvar_add_simple_bool(const char *name, uint32_t *value)
-{
-	return __globalvar_add_simple_int(name, value, PARAM_TYPE_BOOL, "%u");
-}
-
-static inline int globalvar_add_simple_string(const char *name, char **value)
-{
-	return __globalvar_add_simple_string(name, value);
-}
-
-#define DECLARE_GLOBALVAR_INT_RO(intname, inttype, paramtype) \
-	static inline int globalvar_add_simple_##intname##_ro(const char *name,	\
-						      inttype *value,		\
-						      const char *format)	\
-	{									\
-		return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,\
-							   param_set_readonly,	\
-							   NULL, value,		\
-							   paramtype,		\
-							   format, NULL));	\
-	}
-
-DECLARE_GLOBALVAR_INT_RO(uint32, uint32_t, PARAM_TYPE_UINT32)
-DECLARE_GLOBALVAR_INT_RO(int32, int32_t, PARAM_TYPE_INT32)
-DECLARE_GLOBALVAR_INT_RO(uint64, uint64_t, PARAM_TYPE_UINT64)
-DECLARE_GLOBALVAR_INT_RO(int64, int64_t, PARAM_TYPE_INT64)
-
-static inline int globalvar_add_simple_bool_ro(const char *name, uint32_t *value)
-{
-	return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,
-						   param_set_readonly, NULL,
-						   value, PARAM_TYPE_BOOL, "%u",
-						   NULL));
-}
-
-static inline int globalvar_add_simple_string_ro(const char *name, char **value)
-{
-	return __globalvar_add_simple_string(name, value);
-}
-
-#define DECLARE_GLOBALVAR_INT_FIXED(intname, inttype, paramtype) \
-	static inline int globalvar_add_simple_##intname##_fixed(const char *name,	\
-								 inttype value,		\
-								 const char *format)	\
-	{										\
-		return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,	\
-							   ERR_PTR(-EROFS), NULL,	\
-							   &value, paramtype,		\
-							   format, NULL));		\
-	}
-
-DECLARE_GLOBALVAR_INT_FIXED(uint32, uint32_t, PARAM_TYPE_UINT32)
-DECLARE_GLOBALVAR_INT_FIXED(int32, int32_t, PARAM_TYPE_INT32)
-DECLARE_GLOBALVAR_INT_FIXED(uint64, uint64_t, PARAM_TYPE_UINT64)
-DECLARE_GLOBALVAR_INT_FIXED(int64, int64_t, PARAM_TYPE_INT64)
-
-static inline int globalvar_add_simple_bool_fixed(const char *name, uint32_t value)
-{
-	return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, ERR_PTR(-EROFS),
-						   NULL, &value, PARAM_TYPE_BOOL, "%u",
-						   NULL));
-}
-
-static inline int globalvar_add_simple_string_fixed(const char *name, char *value)
-{
-	return PTR_ERR_OR_ZERO(dev_add_param_string_fixed(&global_device, name, value));
-}
-
-static inline int globalvar_add_simple_enum_ro(const char *name, int *value,
-					       const char * const *names, int max)
-{
-	return PTR_ERR_OR_ZERO(dev_add_param_enum_ro(&global_device, name, value, names,
-						     max));
-}
-
 void nv_var_set_clean(void);
 int nvvar_save(void);
 int nv_global_complete(struct string_list *sl, char *instr);
-- 
2.11.0


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

  parent reply	other threads:[~2017-06-14  7:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14  7:26 revert nvvar changes Sascha Hauer
2017-06-14  7:26 ` [PATCH 1/8] Revert "globalvar: Fix value of new globalvar when nvvar exists" Sascha Hauer
2017-06-14  7:26 ` [PATCH 2/8] Revert "nv: Fix setting of nv.dev.<devname>.<param> variables" Sascha Hauer
2017-06-14  7:26 ` [PATCH 3/8] Revert "globalvar: make nv_device static" Sascha Hauer
2017-06-14  7:26 ` [PATCH 4/8] Revert "globalvar: don't use nv_device if CONFIG_NVVAR is disabled" Sascha Hauer
2017-06-14  7:26 ` [PATCH 5/8] Revert "param: remove unnecessary device_d * argument" Sascha Hauer
2017-06-14  7:26 ` Sascha Hauer [this message]
2017-06-14  7:26 ` [PATCH 7/8] Revert "globalvar: remove code for unqualified globalvars" Sascha Hauer
2017-06-14  7:26 ` [PATCH 8/8] Revert "nv: Do not create globalvars from nvvars" Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170614072641.29942-7-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox