void set_working_fdt_addr(void *addr)
{
- char buf[17];
-
working_fdt = addr;
-
- sprintf(buf, "%lx", (unsigned long)addr);
- setenv("fdtaddr", buf);
+ setenv_addr("fdtaddr", addr);
}
/*
}
if (subcmd[0] == 's') {
/* get the num nodes at this level */
- char buf[11];
-
- sprintf(buf, "%d", curIndex + 1);
- setenv(var, buf);
+ setenv_ulong(var, curIndex + 1);
} else {
/* node index not found */
printf("libfdt node not found\n");
}
/**
- * Set an environment variable to an address in hex
+ * Set an environment variable to an value in hex
*
* @param varname Environmet variable to set
- * @param addr Value to set it to
+ * @param value Value to set it to
* @return 0 if ok, 1 on error
*/
-int setenv_addr(const char *varname, const void *addr)
+int setenv_hex(const char *varname, ulong value)
{
char str[17];
- sprintf(str, "%lx", (uintptr_t)addr);
+ sprintf(str, "%lx", value);
return setenv(varname, str);
}
int saveenv (void);
int setenv (const char *, const char *);
int setenv_ulong(const char *varname, ulong value);
-int setenv_addr(const char *varname, const void *addr);
+int setenv_hex(const char *varname, ulong value);
+/**
+ * setenv_addr - Set an environment variable to an address in hex
+ *
+ * @varname: Environmet variable to set
+ * @addr: Value to set it to
+ * @return 0 if ok, 1 on error
+ */
+static inline int setenv_addr(const char *varname, const void *addr)
+{
+ return setenv_hex(varname, (ulong)addr);
+}
+
#ifdef CONFIG_ARM
# include <asm/mach-types.h>
# include <asm/setup.h>