All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default
@ 2011-12-22 18:59 Grant Erickson
  2012-01-05 15:59 ` Wolfgang Denk
  0 siblings, 1 reply; 6+ messages in thread
From: Grant Erickson @ 2011-12-22 18:59 UTC (permalink / raw)
  To: u-boot

This patch allows the U-Boot user space companion utility, fw_setenv,
to overwrite the 'ethaddr' key/value pair if the current value is set
to a per-board-configured default.

This change allows 'fw_setenv' to match the behavior of 'setenv' /
'env set' on the U-Boot command line.

Signed-off-by: Grant Erickson <marathon96@gmail.com>
---
 tools/env/fw_env.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 996682e..2185be9 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -45,6 +45,8 @@
 
 #include "fw_env.h"
 
+#include <config.h>
+
 #define WHITESPACE(c) ((c == '\t') || (c == ' '))
 
 #define min(x, y) ({				\
@@ -390,15 +392,23 @@ int fw_env_write(char *name, char *value)
 	 * Delete any existing definition
 	 */
 	if (oldval) {
+#ifndef CONFIG_ENV_OVERWRITE
+
 		/*
 		 * Ethernet Address and serial# can be set only once
 		 */
-		if ((strcmp (name, "ethaddr") == 0) ||
-			(strcmp (name, "serial#") == 0)) {
+		if (
+		    (strcmp(name, "serial#") == 0) ||
+		    ((strcmp(name, "ethaddr") == 0)
+#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
+		    && (strcmp(oldval, MK_STR(CONFIG_ETHADDR)) != 0)
+#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
+		   ) ) {
 			fprintf (stderr, "Can't overwrite \"%s\"\n", name);
 			errno = EROFS;
 			return -1;
 		}
+#endif /* CONFIG_ENV_OVERWRITE */
 
 		if (*++nxt == '\0') {
 			*env = '\0';
-- 
1.7.7.3

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

end of thread, other threads:[~2012-01-23 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-22 18:59 [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default Grant Erickson
2012-01-05 15:59 ` Wolfgang Denk
2012-01-23 12:23   ` Andreas Bießmann
2012-01-23 13:30     ` [U-Boot] Toradex Colibri, PXA-270 (ARM) Daniel Mack
2012-01-23 14:28       ` Wolfgang Denk
2012-01-23 20:40     ` [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default Mike Frysinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.