summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-04-06 13:59:29 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-04-11 08:33:48 +0200
commit1b4a05c9263ae26083526acfabdea1ef96531a1d (patch)
treee41d654539e018930f0d012c1ee12415eead4117 /common
parentc5d95eb4c72a2639c10d01a801df00b4c34db315 (diff)
downloadbarebox-1b4a05c9263ae26083526acfabdea1ef96531a1d.tar.gz
barebox-1b4a05c9263ae26083526acfabdea1ef96531a1d.tar.xz
globalvar: make globalvar functions more consistent
Similar to the device parameter functions also make the globalvar functions more consistent. This also adds support for readonly globalvars and changes several existing globalvars which should really be readonly to readonly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/boot.c2
-rw-r--r--common/bootchooser.c4
-rw-r--r--common/bootm.c2
-rw-r--r--common/console_common.c6
-rw-r--r--common/globalvar.c28
-rw-r--r--common/password.c2
-rw-r--r--common/reset_source.c2
7 files changed, 16 insertions, 30 deletions
diff --git a/common/boot.c b/common/boot.c
index cef3d5e51..a2d27d159 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_int("boot.watchdog_timeout",
+ return globalvar_add_simple_uint32("boot.watchdog_timeout",
&boot_watchdog_timeout, "%u");
}
late_initcall(init_boot_watchdog_timeout);
diff --git a/common/bootchooser.c b/common/bootchooser.c
index 455f290fa..f6d99d130 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_int("bootchooser.default_attempts", &global_default_attempts, "%u");
- globalvar_add_simple_int("bootchooser.default_priority", &global_default_priority, "%u");
+ 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_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 81625d915..92cfeb6c3 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_int("bootm.verbose", &bootm_verbosity, "%u");
+ globalvar_add_simple_uint32("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 d051458de..b36b3ff08 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_int("log_max_messages",
- &barebox_log_max_messages, "%d");
+ globalvar_add_simple_uint32("log_max_messages",
+ &barebox_log_max_messages, "%u");
- return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d");
+ return globalvar_add_simple_uint32("loglevel", &barebox_loglevel, "%u");
}
device_initcall(loglevel_init);
diff --git a/common/globalvar.c b/common/globalvar.c
index 32ca6a24d..2f65ca805 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,28 +439,14 @@ int globalvar_add_simple_string(const char *name, char **value)
return 0;
}
-int globalvar_add_simple_int(const char *name, int *value,
- const char *format)
+int __globalvar_add_simple_int(const char *name, void *value,
+ enum param_type type,
+ const char *format)
{
struct param_d *p;
- 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);
+ p = __dev_add_param_int(&global_device, name, NULL, NULL,
+ value, type, format, NULL);
if (IS_ERR(p))
return PTR_ERR(p);
@@ -522,7 +508,7 @@ static int globalvar_init(void)
if (IS_ENABLED(CONFIG_NVVAR))
register_device(&nv_device);
- globalvar_add_simple("version", UTS_RELEASE);
+ globalvar_add_simple_string_fixed("version", UTS_RELEASE);
return 0;
}
diff --git a/common/password.c b/common/password.c
index 74d328f4b..5e6bfc53e 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_int("login.timeout", &login_timeout, "%d");
+ globalvar_add_simple_uint32("login.timeout", &login_timeout, "%u");
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 06e2ca85f..e18bf6db6 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("system.reset", (unsigned int *)&reset_source,
+ globalvar_add_simple_enum_ro("system.reset", (unsigned int *)&reset_source,
reset_src_names, ARRAY_SIZE(reset_src_names));
return 0;