summaryrefslogtreecommitdiffstats
path: root/common/state/state_variables.c
diff options
context:
space:
mode:
authorDaniel Schultz <d.schultz@phytec.de>2017-11-03 11:48:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-11-07 07:47:10 +0100
commit7126dffd0be98a0f4c80bc13bc7df601526f056f (patch)
tree80f373b9739241385653ba0dfa0b233c19a9a5fd /common/state/state_variables.c
parentb4f9903a3c6b5bcbb4f64a0e34a4fbc858a770e1 (diff)
downloadbarebox-7126dffd0be98a0f4c80bc13bc7df601526f056f.tar.gz
barebox-7126dffd0be98a0f4c80bc13bc7df601526f056f.tar.xz
common: state: Add variable_type to state_variable
Add a pointer in state_variable to the corresponding variable_type array element. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state/state_variables.c')
-rw-r--r--common/state/state_variables.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index 56bcd9590a..688467d8cd 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -101,7 +101,8 @@ static int state_uint8_set(struct param_d *p, void *priv)
static struct state_variable *state_uint8_create(struct state *state,
const char *name,
- struct device_node *node)
+ struct device_node *node,
+ const struct variable_type *vtype)
{
struct state_uint32 *su32;
struct param_d *param;
@@ -116,6 +117,7 @@ static struct state_variable *state_uint8_create(struct state *state,
}
su32->param = param;
+ su32->var.type = vtype;
su32->var.size = sizeof(uint8_t);
#ifdef __LITTLE_ENDIAN
su32->var.raw = &su32->value;
@@ -129,7 +131,8 @@ static struct state_variable *state_uint8_create(struct state *state,
static struct state_variable *state_uint32_create(struct state *state,
const char *name,
- struct device_node *node)
+ struct device_node *node,
+ const struct variable_type *vtype)
{
struct state_uint32 *su32;
struct param_d *param;
@@ -144,6 +147,7 @@ static struct state_variable *state_uint32_create(struct state *state,
}
su32->param = param;
+ su32->var.type = vtype;
su32->var.size = sizeof(uint32_t);
su32->var.raw = &su32->value;
su32->var.state = state;
@@ -218,7 +222,8 @@ static int state_enum32_import(struct state_variable *sv,
static struct state_variable *state_enum32_create(struct state *state,
const char *name,
- struct device_node *node)
+ struct device_node *node,
+ const struct variable_type *vtype)
{
struct state_enum32 *enum32;
int ret, i, num_names;
@@ -234,6 +239,7 @@ static struct state_variable *state_enum32_create(struct state *state,
enum32->names = xzalloc(sizeof(char *) * num_names);
enum32->num_names = num_names;
+ enum32->var.type = vtype;
enum32->var.size = sizeof(uint32_t);
enum32->var.raw = &enum32->value;
enum32->var.state = state;
@@ -300,13 +306,15 @@ static int state_mac_import(struct state_variable *sv, struct device_node *node)
static struct state_variable *state_mac_create(struct state *state,
const char *name,
- struct device_node *node)
+ struct device_node *node,
+ const struct variable_type *vtype)
{
struct state_mac *mac;
int ret;
mac = xzalloc(sizeof(*mac));
+ mac->var.type = vtype;
mac->var.size = ARRAY_SIZE(mac->value);
mac->var.raw = mac->value;
mac->var.state = state;
@@ -402,7 +410,8 @@ static int state_string_get(struct param_d *p, void *priv)
static struct state_variable *state_string_create(struct state *state,
const char *name,
- struct device_node *node)
+ struct device_node *node,
+ const struct variable_type *vtype)
{
struct state_string *string;
uint32_t start_size[2];
@@ -420,6 +429,7 @@ static struct state_variable *state_string_create(struct state *state,
return ERR_PTR(-EILSEQ);
string = xzalloc(sizeof(*string) + start_size[1]);
+ string->var.type = vtype;
string->var.size = start_size[1];
string->var.raw = &string->raw;
string->var.state = state;