74 lines
1.8 KiB
Diff
74 lines
1.8 KiB
Diff
|
From cada2ed0b4ca0d467621fa90de304421e17b4869 Mon Sep 17 00:00:00 2001
|
||
|
From: Jan Luebbe <jluebbe@debian.org>
|
||
|
Date: Sat, 30 May 2015 19:52:55 +0200
|
||
|
Subject: [PATCH 2/3] barebox-state: add support for uint8 variables
|
||
|
|
||
|
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
|
||
|
---
|
||
|
src/barebox-state.c | 35 +++++++++++++++++++++++++++++++++++
|
||
|
1 file changed, 35 insertions(+)
|
||
|
|
||
|
diff --git a/src/barebox-state.c b/src/barebox-state.c
|
||
|
index 57305c4..f56275f 100644
|
||
|
--- a/src/barebox-state.c
|
||
|
+++ b/src/barebox-state.c
|
||
|
@@ -81,6 +81,7 @@ struct state_backend {
|
||
|
enum state_variable_type {
|
||
|
STATE_TYPE_INVALID = 0,
|
||
|
STATE_TYPE_ENUM,
|
||
|
+ STATE_TYPE_U8,
|
||
|
STATE_TYPE_U32,
|
||
|
STATE_TYPE_MAC,
|
||
|
};
|
||
|
@@ -185,6 +186,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, "%u", 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)
|
||
|
{
|
||
|
@@ -395,6 +422,14 @@ 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,
|
||
|
+ .set = state_uint32_set,
|
||
|
+ .get = state_uint32_get,
|
||
|
+ }, {
|
||
|
.type = STATE_TYPE_U32,
|
||
|
.type_name = "uint32",
|
||
|
.export = state_uint32_export,
|
||
|
--
|
||
|
2.1.4
|
||
|
|