summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-05-05 11:31:35 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-05-05 11:31:35 +0200
commit8e91536a000c1738e354827d6f72965fa1444985 (patch)
treecb48104fa7a635e82d2b8b8eed6af6fe671756f2 /common
parent30cce0c7414498317a43b2020dc1737b007acf98 (diff)
parent0071bacb4c7cab21c9fab8540f5aa9922a270a85 (diff)
downloadbarebox-8e91536a000c1738e354827d6f72965fa1444985.tar.gz
barebox-8e91536a000c1738e354827d6f72965fa1444985.tar.xz
Merge branch 'for-next/parameter-types'
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.c52
-rw-r--r--common/console_common.c6
-rw-r--r--common/globalvar.c42
-rw-r--r--common/partitions/dos.c2
-rw-r--r--common/password.c2
-rw-r--r--common/reset_source.c2
-rw-r--r--common/state/state_variables.c4
10 files changed, 51 insertions, 67 deletions
diff --git a/common/boot.c b/common/boot.c
index cef3d5e514..a2d27d1593 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 455f290fa2..f6d99d130b 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 81625d9157..92cfeb6c32 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.c b/common/console.c
index 74fb684b2c..f4c799fa54 100644
--- a/common/console.c
+++ b/common/console.c
@@ -94,7 +94,7 @@ int console_close(struct console_device *cdev)
int console_set_active(struct console_device *cdev, unsigned flag)
{
- int ret, i;
+ int ret;
if (!cdev->getc)
flag &= ~CONSOLE_STDIN;
@@ -119,18 +119,6 @@ int console_set_active(struct console_device *cdev, unsigned flag)
cdev->f_active = flag;
- if (IS_ENABLED(CONFIG_PARAMETER)) {
- i = 0;
-
- if (flag & CONSOLE_STDIN)
- cdev->active[i++] = 'i';
- if (flag & CONSOLE_STDOUT)
- cdev->active[i++] = 'o';
- if (flag & CONSOLE_STDERR)
- cdev->active[i++] = 'e';
- cdev->active[i] = 0;
- }
-
if (initialized < CONSOLE_INIT_FULL) {
char ch;
initialized = CONSOLE_INIT_FULL;
@@ -150,30 +138,39 @@ unsigned console_get_active(struct console_device *cdev)
return cdev->f_active;
}
-static int console_active_set(struct device_d *dev, struct param_d *param,
- const char *val)
+static int console_active_set(struct param_d *param, void *priv)
{
- struct console_device *cdev = to_console_dev(dev);
+ struct console_device *cdev = priv;
unsigned int flag = 0;
+ int ret;
- if (val) {
- if (strchr(val, 'i'))
+ if (cdev->active_string) {
+ if (strchr(cdev->active_string, 'i'))
flag |= CONSOLE_STDIN;
- if (strchr(val, 'o'))
+ if (strchr(cdev->active_string, 'o'))
flag |= CONSOLE_STDOUT;
- if (strchr(val, 'e'))
+ if (strchr(cdev->active_string, 'e'))
flag |= CONSOLE_STDERR;
}
- return console_set_active(cdev, flag);
+ ret = console_set_active(cdev, flag);
+ if (ret)
+ return ret;
+
+ return 0;
}
-static const char *console_active_get(struct device_d *dev,
- struct param_d *param)
+static int console_active_get(struct param_d *param, void *priv)
{
- struct console_device *cdev = to_console_dev(dev);
+ struct console_device *cdev = priv;
+ unsigned int flag = cdev->f_active;
- return cdev->active;
+ free(cdev->active_string);
+ cdev->active_string = basprintf("%s%s%s",
+ flag & CONSOLE_STDIN ? "i" : "",
+ flag & CONSOLE_STDOUT ? "o" : "",
+ flag & CONSOLE_STDERR ? "e" : "");
+ return 0;
}
int console_set_baudrate(struct console_device *cdev, unsigned baudrate)
@@ -331,7 +328,7 @@ int console_register(struct console_device *newcdev)
if (ret)
return ret;
newcdev->baudrate_param = newcdev->baudrate = CONFIG_BAUDRATE;
- dev_add_param_int(dev, "baudrate", console_baudrate_set,
+ dev_add_param_uint32(dev, "baudrate", console_baudrate_set,
NULL, &newcdev->baudrate_param, "%u", newcdev);
}
@@ -340,7 +337,8 @@ int console_register(struct console_device *newcdev)
newcdev->open_count = 0;
- dev_add_param(dev, "active", console_active_set, console_active_get, 0);
+ dev_add_param_string(dev, "active", console_active_set, console_active_get,
+ &newcdev->active_string, newcdev);
if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) {
if (list_empty(&console_list))
diff --git a/common/console_common.c b/common/console_common.c
index d051458de4..b36b3ff083 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 ff52c9d47f..1385559fd7 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -166,7 +166,7 @@ static int nvvar_device_dispatch(const char *name, struct device_d **dev,
return 1;
}
-static int nv_set(struct device_d *dev, struct param_d *p, const char *val)
+static int nv_set(struct param_d *p, const char *val)
{
struct param_d *g;
int ret;
@@ -187,16 +187,16 @@ static int nv_set(struct device_d *dev, struct param_d *p, const char *val)
return 0;
}
-static const char *nv_param_get(struct device_d *dev, struct param_d *p)
+static const char *nv_param_get(struct param_d *p)
{
return p->value ? p->value : "";
}
-static int nv_param_set(struct device_d *dev, struct param_d *p, const char *val)
+static int nv_param_set(struct param_d *p, const char *val)
{
int ret;
- ret = nv_set(dev, p, val);
+ ret = nv_set(p, val);
if (ret)
return ret;
@@ -219,7 +219,7 @@ static int __nvvar_add(const char *name, const char *value)
}
if (value)
- return nv_set(&nv_device, p, value);
+ return nv_set(p, value);
value = dev_get_param(&global_device, name);
if (value) {
@@ -373,7 +373,7 @@ void globalvar_set_match(const char *match, const char *val)
}
}
-static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const char *val)
+static int globalvar_simple_set(struct param_d *p, const char *val)
{
struct device_d *rdev;
const char *pname = NULL;
@@ -391,7 +391,7 @@ static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const c
}
/* Pass to the generic function we have overwritten */
- return dev_param_set_generic(dev, p, val);
+ return dev_param_set_generic(p, val);
}
static void globalvar_nv_sync(const char *name)
@@ -430,7 +430,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;
@@ -445,28 +445,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);
@@ -528,7 +514,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/partitions/dos.c b/common/partitions/dos.c
index 5f08e253ee..91b5399079 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -251,7 +251,7 @@ static void dos_partition(void *buf, struct block_device *blk,
* signature and pp is a zero-filled hex representation of the 1-based
* partition number.
*/
- dev_add_param_int(blk->dev, "nt_signature",
+ dev_add_param_uint32(blk->dev, "nt_signature",
dos_set_disk_signature, dos_get_disk_signature,
&dsp->signature, "%08x", dsp);
}
diff --git a/common/password.c b/common/password.c
index 74d328f4b2..5e6bfc53e7 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 06e2ca85f5..e18bf6db68 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;
diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index 5b8e6284d9..56bcd9590a 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -108,7 +108,7 @@ static struct state_variable *state_uint8_create(struct state *state,
su32 = xzalloc(sizeof(*su32));
- param = dev_add_param_int(&state->dev, name, state_uint8_set,
+ param = dev_add_param_uint32(&state->dev, name, state_uint8_set,
NULL, &su32->value, "%u", &su32->var);
if (IS_ERR(param)) {
free(su32);
@@ -136,7 +136,7 @@ static struct state_variable *state_uint32_create(struct state *state,
su32 = xzalloc(sizeof(*su32));
- param = dev_add_param_int(&state->dev, name, state_set_dirty,
+ param = dev_add_param_uint32(&state->dev, name, state_set_dirty,
NULL, &su32->value, "%u", &su32->var);
if (IS_ERR(param)) {
free(su32);