diff options
author | Jan Luebbe <jluebbe@debian.org> | 2015-05-30 15:11:45 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-06-03 10:20:55 +0200 |
commit | 2532f5dfbfe5bb995020e542f698c1c1d1e5f213 (patch) | |
tree | 6fba931620f77cd8830d04c9b883f760850103b8 /common | |
parent | d0d929927c5e61531385e0c51fea9dc9440d35ad (diff) | |
download | barebox-2532f5dfbfe5bb995020e542f698c1c1d1e5f213.tar.gz barebox-2532f5dfbfe5bb995020e542f698c1c1d1e5f213.tar.xz |
state: add support for uint8 variables
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/state.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/common/state.c b/common/state.c index 0be0efe898..7076f5764d 100644 --- a/common/state.c +++ b/common/state.c @@ -61,6 +61,7 @@ struct state_backend { enum state_variable_type { STATE_TYPE_INVALID = 0, STATE_TYPE_ENUM, + STATE_TYPE_U8, STATE_TYPE_U32, STATE_TYPE_MAC, }; @@ -162,6 +163,32 @@ static int state_uint32_import(struct state_variable *sv, return 0; } +static struct state_variable *state_uint8_create(struct state *state, + const char *name, struct device_node *node) +{ + struct state_uint32 *su32; + struct param_d *param; + + su32 = xzalloc(sizeof(*su32)); + + param = dev_add_param_int(&state->dev, name, state_set_dirty, + NULL, &su32->value, "%d", state); + if (IS_ERR(param)) { + free(su32); + return ERR_CAST(param); + } + + su32->param = param; + su32->var.size = sizeof(uint8_t); +#ifdef __LITTLE_ENDIAN + su32->var.raw = &su32->value; +#else + su32->var.raw = &su32->value + 3; +#endif + + return &su32->var; +} + static struct state_variable *state_uint32_create(struct state *state, const char *name, struct device_node *node) { @@ -372,6 +399,12 @@ out: static struct variable_type types[] = { { + .type = STATE_TYPE_U8, + .type_name = "uint8", + .export = state_uint32_export, + .import = state_uint32_import, + .create = state_uint8_create, + }, { .type = STATE_TYPE_U32, .type_name = "uint32", .export = state_uint32_export, |