mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] state: fixup: only export default value during fixup if set
@ 2015-06-25 12:47 Marc Kleine-Budde
  2015-06-25 12:47 ` [PATCH 2/3] fixup! state: add support for fixed length strings Marc Kleine-Budde
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2015-06-25 12:47 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/state.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/common/state.c b/common/state.c
index 377507bb482a..688c85cf0e7d 100644
--- a/common/state.c
+++ b/common/state.c
@@ -143,13 +143,16 @@ static int state_uint32_export(struct state_variable *var,
 	struct state_uint32 *su32 = to_state_uint32(var);
 	int ret;
 
-	if (su32->value_default || conv == STATE_CONVERT_FIXUP) {
+	if (su32->value_default) {
 		ret = of_property_write_u32(node, "default",
 					    su32->value_default);
-		if (ret || conv == STATE_CONVERT_FIXUP)
+		if (ret)
 			return ret;
 	}
 
+	if (conv == STATE_CONVERT_FIXUP)
+		return 0;
+
 	return of_property_write_u32(node, "value", su32->value);
 }
 
@@ -249,13 +252,16 @@ static int state_enum32_export(struct state_variable *var,
 	int ret, i, len;
 	char *prop, *str;
 
-	if (enum32->value_default || conv == STATE_CONVERT_FIXUP) {
+	if (enum32->value_default) {
 		ret = of_property_write_u32(node, "default",
 					    enum32->value_default);
-		if (ret || conv == STATE_CONVERT_FIXUP)
+		if (ret)
 			return ret;
 	}
 
+	if (conv == STATE_CONVERT_FIXUP)
+		return 0;
+
 	ret = of_property_write_u32(node, "value", enum32->value);
 	if (ret)
 		return ret;
@@ -364,10 +370,15 @@ static int state_mac_export(struct state_variable *var,
 	struct state_mac *mac = to_state_mac(var);
 	int ret;
 
-	ret = of_property_write_u8_array(node, "default", mac->value_default,
-					 ARRAY_SIZE(mac->value_default));
-	if (ret || conv == STATE_CONVERT_FIXUP)
-		return ret;
+	if (!is_zero_ether_addr(mac->value_default)) {
+		ret = of_property_write_u8_array(node, "default", mac->value_default,
+						 ARRAY_SIZE(mac->value_default));
+		if (ret)
+			return ret;
+	}
+
+	if (conv == STATE_CONVERT_FIXUP)
+		return 0;
 
 	return of_property_write_u8_array(node, "value", mac->value,
 					  ARRAY_SIZE(mac->value));
-- 
2.1.4


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

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

* [PATCH 2/3] fixup! state: add support for fixed length strings
  2015-06-25 12:47 [PATCH 1/3] state: fixup: only export default value during fixup if set Marc Kleine-Budde
@ 2015-06-25 12:47 ` Marc Kleine-Budde
  2015-06-25 12:47 ` [PATCH 3/3] " Marc Kleine-Budde
  2015-06-26  9:27 ` [PATCH 1/3] state: fixup: only export default value during fixup if set Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2015-06-25 12:47 UTC (permalink / raw)
  To: barebox

From: Ulrich Ölmann <u.oelmann@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/devicetree/bindings/barebox/barebox,state.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst b/Documentation/devicetree/bindings/barebox/barebox,state.rst
index 6ded161e618d..4c5b06db47f6 100644
--- a/Documentation/devicetree/bindings/barebox/barebox,state.rst
+++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst
@@ -87,7 +87,7 @@ Variable Types
 
 * ``uint8``:
 * ``uint32``:
-* ``enum32``: The ``default`` value it is an integer representing an
+* ``enum32``: The ``default`` value is an integer representing an
   offset into the names array.
 * ``mac``:
 * ``string``: The length of the string excluding the trailing 0 is
-- 
2.1.4


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

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

* [PATCH 3/3] fixup! state: add support for fixed length strings
  2015-06-25 12:47 [PATCH 1/3] state: fixup: only export default value during fixup if set Marc Kleine-Budde
  2015-06-25 12:47 ` [PATCH 2/3] fixup! state: add support for fixed length strings Marc Kleine-Budde
@ 2015-06-25 12:47 ` Marc Kleine-Budde
  2015-06-26  9:27 ` [PATCH 1/3] state: fixup: only export default value during fixup if set Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2015-06-25 12:47 UTC (permalink / raw)
  To: barebox

Only export default value if set. This may cause an NULL pointer deref.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/state.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/state.c b/common/state.c
index 688c85cf0e7d..124332022662 100644
--- a/common/state.c
+++ b/common/state.c
@@ -445,14 +445,17 @@ static int state_string_export(struct state_variable *var,
 	struct state_string *string = to_state_string(var);
 	int ret = 0;
 
-	if (string->value_default || conv == STATE_CONVERT_FIXUP) {
+	if (string->value_default) {
 		ret = of_set_property(node, "default", string->value_default,
 				      strlen(string->value_default) + 1, 1);
 
-		if (ret || conv == STATE_CONVERT_FIXUP)
+		if (ret)
 			return ret;
 	}
 
+	if (conv == STATE_CONVERT_FIXUP)
+		return 0;
+
 	if (string->value)
 		ret = of_set_property(node, "value", string->value,
 				      strlen(string->value) + 1, 1);
-- 
2.1.4


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

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

* Re: [PATCH 1/3] state: fixup: only export default value during fixup if set
  2015-06-25 12:47 [PATCH 1/3] state: fixup: only export default value during fixup if set Marc Kleine-Budde
  2015-06-25 12:47 ` [PATCH 2/3] fixup! state: add support for fixed length strings Marc Kleine-Budde
  2015-06-25 12:47 ` [PATCH 3/3] " Marc Kleine-Budde
@ 2015-06-26  9:27 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2015-06-26  9:27 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On Thu, Jun 25, 2015 at 02:47:09PM +0200, Marc Kleine-Budde wrote:
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  common/state.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)

Applied, thanks

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] 4+ messages in thread

end of thread, other threads:[~2015-06-26  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 12:47 [PATCH 1/3] state: fixup: only export default value during fixup if set Marc Kleine-Budde
2015-06-25 12:47 ` [PATCH 2/3] fixup! state: add support for fixed length strings Marc Kleine-Budde
2015-06-25 12:47 ` [PATCH 3/3] " Marc Kleine-Budde
2015-06-26  9:27 ` [PATCH 1/3] state: fixup: only export default value during fixup if set Sascha Hauer

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