mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] state: fixup: only export default value during fixup if set
Date: Thu, 25 Jun 2015 14:47:09 +0200	[thread overview]
Message-ID: <1435236431-11021-1-git-send-email-mkl@pengutronix.de> (raw)

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

             reply	other threads:[~2015-06-25 12:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 12:47 Marc Kleine-Budde [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435236431-11021-1-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox