mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] state: cleanup uint8 support
@ 2015-06-15 13:29 Marc Kleine-Budde
  2015-06-15 13:29 ` [PATCH 1/3] state: Documentation: add newly implemented "uint8" types Marc Kleine-Budde
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-06-15 13:29 UTC (permalink / raw)
  To: barebox

Hello Sascha,

these are three cleanup patches for the uint8 support. Feel free to squash
into:

    2532f5dfbfe5 state: add support for uint8 variables

regards,
Marc


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] state: Documentation: add newly implemented "uint8" types.
  2015-06-15 13:29 [PATCH 0/3] state: cleanup uint8 support Marc Kleine-Budde
@ 2015-06-15 13:29 ` Marc Kleine-Budde
  2015-06-15 13:29 ` [PATCH 2/3] state: uint8: use %u as format string Marc Kleine-Budde
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-06-15 13:29 UTC (permalink / raw)
  To: barebox; +Cc: Jan Luebbe

Cc: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/devicetree/bindings/barebox/barebox,state.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst b/Documentation/devicetree/bindings/barebox/barebox,state.rst
index 7156084c9364..3405f703c990 100644
--- a/Documentation/devicetree/bindings/barebox/barebox,state.rst
+++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst
@@ -42,9 +42,9 @@ These are subnodes of a state node each describing a single
 variable. The node name may end with ``@<ADDRESS>``, but the suffix is
 sripped from the variable name.
 
-State variables have a type. Currenty supported types are: ``uint32``,
-``enum32`` and ``mac`` address. Fixed length strings are planned but
-not implemented. Variable length strings are not planned.
+State variables have a type. Currenty supported types are: ``uint8``,
+``uint32``, ``enum32`` and ``mac`` address. Fixed length strings are
+planned but not implemented. Variable length strings are not planned.
 
 Required properties:
 
@@ -52,8 +52,8 @@ Required properties:
   ``#size-cells = <1>``. Defines the ``offset`` and ``size`` of the
   variable in the ``raw`` backend. ``size`` must fit the node
   ``type``. Variables are not allowed to overlap.
-* ``type``: Should be ``uint32``, ``enum32`` or ``mac`` for the type
-  of the variable
+* ``type``: Should be ``uint8``, ``uint32``, ``enum32`` or ``mac`` for
+  the type of the variable
 * ``names``: For ``enum32`` values only, this specifies the values
   possible for ``enum32``.
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] state: uint8: use %u as format string
  2015-06-15 13:29 [PATCH 0/3] state: cleanup uint8 support Marc Kleine-Budde
  2015-06-15 13:29 ` [PATCH 1/3] state: Documentation: add newly implemented "uint8" types Marc Kleine-Budde
@ 2015-06-15 13:29 ` Marc Kleine-Budde
  2015-06-15 13:29 ` [PATCH 3/3] state: uint8: add range check for uint8 Marc Kleine-Budde
  2015-06-17  5:49 ` [PATCH 0/3] state: cleanup uint8 support Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-06-15 13:29 UTC (permalink / raw)
  To: barebox; +Cc: Jan Luebbe

Cc: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/state.c b/common/state.c
index 7076f5764d1f..e30f72660797 100644
--- a/common/state.c
+++ b/common/state.c
@@ -172,7 +172,7 @@ static struct state_variable *state_uint8_create(struct state *state,
 	su32 = xzalloc(sizeof(*su32));
 
 	param = dev_add_param_int(&state->dev, name, state_set_dirty,
-				  NULL, &su32->value, "%d", state);
+				  NULL, &su32->value, "%u", state);
 	if (IS_ERR(param)) {
 		free(su32);
 		return ERR_CAST(param);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] state: uint8: add range check for uint8
  2015-06-15 13:29 [PATCH 0/3] state: cleanup uint8 support Marc Kleine-Budde
  2015-06-15 13:29 ` [PATCH 1/3] state: Documentation: add newly implemented "uint8" types Marc Kleine-Budde
  2015-06-15 13:29 ` [PATCH 2/3] state: uint8: use %u as format string Marc Kleine-Budde
@ 2015-06-15 13:29 ` Marc Kleine-Budde
  2015-06-17  5:49 ` [PATCH 0/3] state: cleanup uint8 support Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-06-15 13:29 UTC (permalink / raw)
  To: barebox; +Cc: Jan Luebbe

Bail out, if the user tries to set a value > 255.

Cc: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/state.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/common/state.c b/common/state.c
index e30f72660797..8fa027a847b9 100644
--- a/common/state.c
+++ b/common/state.c
@@ -113,6 +113,7 @@ static int state_set_dirty(struct param_d *p, void *priv)
 struct state_uint32 {
 	struct state_variable var;
 	struct param_d *param;
+	struct state *state;
 	uint32_t value;
 	uint32_t value_default;
 };
@@ -163,6 +164,17 @@ static int state_uint32_import(struct state_variable *sv,
 	return 0;
 }
 
+static int state_uint8_set(struct param_d *p, void *priv)
+{
+	struct state_uint32 *su32 = priv;
+	struct state *state = su32->state;
+
+	if (su32->value > 255)
+		return -ERANGE;
+
+	return state_set_dirty(p, state);
+}
+
 static struct state_variable *state_uint8_create(struct state *state,
 		const char *name, struct device_node *node)
 {
@@ -171,8 +183,8 @@ static struct state_variable *state_uint8_create(struct state *state,
 
 	su32 = xzalloc(sizeof(*su32));
 
-	param = dev_add_param_int(&state->dev, name, state_set_dirty,
-				  NULL, &su32->value, "%u", state);
+	param = dev_add_param_int(&state->dev, name, state_uint8_set,
+				  NULL, &su32->value, "%u", su32);
 	if (IS_ERR(param)) {
 		free(su32);
 		return ERR_CAST(param);
@@ -185,6 +197,7 @@ static struct state_variable *state_uint8_create(struct state *state,
 #else
 	su32->var.raw = &su32->value + 3;
 #endif
+	su32->state = state;
 
 	return &su32->var;
 }
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] state: cleanup uint8 support
  2015-06-15 13:29 [PATCH 0/3] state: cleanup uint8 support Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2015-06-15 13:29 ` [PATCH 3/3] state: uint8: add range check for uint8 Marc Kleine-Budde
@ 2015-06-17  5:49 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2015-06-17  5:49 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On Mon, Jun 15, 2015 at 03:29:03PM +0200, Marc Kleine-Budde wrote:
> Hello Sascha,
> 
> these are three cleanup patches for the uint8 support. Feel free to squash
> into:
> 
>     2532f5dfbfe5 state: add support for uint8 variables

This is not possible because this patch is already in master. Applied
for -next.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-17  5:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 13:29 [PATCH 0/3] state: cleanup uint8 support Marc Kleine-Budde
2015-06-15 13:29 ` [PATCH 1/3] state: Documentation: add newly implemented "uint8" types Marc Kleine-Budde
2015-06-15 13:29 ` [PATCH 2/3] state: uint8: use %u as format string Marc Kleine-Budde
2015-06-15 13:29 ` [PATCH 3/3] state: uint8: add range check for uint8 Marc Kleine-Budde
2015-06-17  5:49 ` [PATCH 0/3] state: cleanup uint8 support Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox