summaryrefslogtreecommitdiffstats
path: root/src/barebox-state/state.h
diff options
context:
space:
mode:
authorUlrich Ölmann <u.oelmann@pengutronix.de>2018-12-18 14:57:49 +0100
committerRoland Hieber <rhi@pengutronix.de>2019-01-07 15:46:04 +0100
commit44122040c53042f68e93657450ef5e5ceaa48e4a (patch)
tree7cd36c899e9634f67e1012cf7fd6dcd4ea097d8e /src/barebox-state/state.h
parentd32a8de0e9d23db601f06676ff432e495ae1156e (diff)
downloaddt-utils-44122040c53042f68e93657450ef5e5ceaa48e4a.tar.gz
dt-utils-44122040c53042f68e93657450ef5e5ceaa48e4a.tar.xz
state: refactor variable type
This ports the following barebox commits and adjusts the handling of type information of state variables in barebox-state: | commit 7b3d284f4bad78d61e9f5d32ec5aa1efc19ce733 | Author: Sascha Hauer <s.hauer@pengutronix.de> | Date: Mon Apr 3 22:51:58 2017 +0200 | | state: remove unused variable type | | enum state_variable_type is never used. Remove it. | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> | commit 7126dffd0be98a0f4c80bc13bc7df601526f056f | Author: Daniel Schultz <d.schultz@phytec.de> | Date: Fri Nov 3 11:48:26 2017 +0100 | | 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> | commit dc74265d2ac074a18609d51bad1fdbd2bbcdd608 | Author: Daniel Schultz <d.schultz@phytec.de> | Date: Fri Nov 3 11:48:27 2017 +0100 | | common: state: Add variable type as enum | | The variable_type struct holds a name of its type. Checking the type of | a variable with this string needs much resources. | | This patch introduce a enum of the variable type for better type | checking. | | Signed-off-by: Daniel Schultz <d.schultz@phytec.de> | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> [rhi: fixed function parameter alignment in common/state/state_variables.c, and submitted those changes as patches for barebox: https://www.mail-archive.com/barebox@lists.infradead.org/msg29427.html https://www.mail-archive.com/barebox@lists.infradead.org/msg29462.html ] Signed-off-by: Roland Hieber <rhi@pengutronix.de>
Diffstat (limited to 'src/barebox-state/state.h')
-rw-r--r--src/barebox-state/state.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/barebox-state/state.h b/src/barebox-state/state.h
index ead8cc8..fcc6b9f 100644
--- a/src/barebox-state/state.h
+++ b/src/barebox-state/state.h
@@ -9,6 +9,14 @@ enum state_flags {
STATE_FLAG_NO_AUTHENTIFICATION = (1 << 0),
};
+enum state_variable_type {
+ STATE_VARIABLE_TYPE_UINT8,
+ STATE_VARIABLE_TYPE_UINT32,
+ STATE_VARIABLE_TYPE_ENUM32,
+ STATE_VARIABLE_TYPE_MAC,
+ STATE_VARIABLE_TYPE_STRING
+};
+
/**
* state_backend_storage_bucket - This class describes a single backend storage
* object copy
@@ -114,35 +122,27 @@ enum state_convert {
STATE_CONVERT_FIXUP,
};
-enum state_variable_type {
- STATE_TYPE_INVALID = 0,
- STATE_TYPE_ENUM,
- STATE_TYPE_U8,
- STATE_TYPE_U32,
- STATE_TYPE_MAC,
- STATE_TYPE_STRING,
-};
-
struct state_variable;
/* A variable type (uint32, enum32) */
struct variable_type {
- enum state_variable_type type;
const char *type_name;
+ enum state_variable_type type;
struct list_head list;
int (*export) (struct state_variable *, struct device_node *,
enum state_convert);
int (*import) (struct state_variable *, struct device_node *);
- struct state_variable *(*create) (struct state * state,
- const char *name,
- struct device_node *);
+ struct state_variable *(*create) (struct state *,
+ const char *,
+ struct device_node *,
+ const struct variable_type *);
};
/* instance of a single variable */
struct state_variable {
struct state *state;
- enum state_variable_type type;
struct list_head list;
+ const struct variable_type *type;
const char *name;
unsigned int start;
unsigned int size;