diff options
Diffstat (limited to 'common/state.c')
-rw-r--r-- | common/state.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/common/state.c b/common/state.c index ec72dbd9a0..d1fa47ffa3 100644 --- a/common/state.c +++ b/common/state.c @@ -66,6 +66,7 @@ enum state_variable_type { STATE_TYPE_ENUM, STATE_TYPE_U8, STATE_TYPE_U32, + STATE_TYPE_S32, STATE_TYPE_MAC, STATE_TYPE_STRING, }; @@ -209,8 +210,8 @@ static struct state_variable *state_uint8_create(struct state *state, return &su32->var; } -static struct state_variable *state_uint32_create(struct state *state, - const char *name, struct device_node *node) +static struct state_variable *state_int32_create(struct state *state, + const char *name, struct device_node *node, const char *format) { struct state_uint32 *su32; struct param_d *param; @@ -218,7 +219,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, - NULL, &su32->value, "%u", state); + NULL, &su32->value, format, state); if (IS_ERR(param)) { free(su32); return ERR_CAST(param); @@ -231,6 +232,18 @@ static struct state_variable *state_uint32_create(struct state *state, return &su32->var; } +static struct state_variable *state_uint32_create(struct state *state, + const char *name, struct device_node *node) +{ + return state_int32_create(state, name, node, "%u"); +} + +static struct state_variable *state_sint32_create(struct state *state, + const char *name, struct device_node *node) +{ + return state_int32_create(state, name, node, "%d"); +} + /* * enum32 */ @@ -605,6 +618,12 @@ static struct variable_type types[] = { .export = state_string_export, .import = state_string_import, .create = state_string_create, + }, { + .type = STATE_TYPE_S32, + .type_name = "int32", + .export = state_uint32_export, + .import = state_uint32_import, + .create = state_sint32_create, }, }; |