/* Get a value from the fdt and format it to be set in the environment  */
static int fdt_value_env_set(const void *nodep, int len, const char *var)
/* Get a value from the fdt and format it to be set in the environment  */
static int fdt_value_env_set(const void *nodep, int len, const char *var)
{
	if (is_printable_string(nodep, len))
		env_set(var, (void *)nodep);
	else if (len == 4) {
		char buf[11];
		sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
		env_set(var, buf);
	} else if (len%4 == 0 && len <= 20) {
		char buf[41];
		int i;
		for (i = 0; i < len; i += sizeof(unsigned int))
			sprintf(buf + (i * 2), "%08x",
				*(unsigned int *)(nodep + i));
		env_set(var, buf);
	} else {
		printf("error: unprintable value\n");
		return 1;
	}
	return 0;
}