/* @fdt: ptr to device tree @nodeoffset: node to update @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, FDT_STATUS_FAIL, FDT_STATUS_FAIL_ERROR_CODE @error_code: optional, only used if status is FDT_STATUS_FAIL_ERROR_CODE  */
int fdt_set_node_status(void *fdt, int nodeoffset, enum fdt_status status, unsigned int error_code)
/* @fdt: ptr to device tree @nodeoffset: node to update @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, FDT_STATUS_FAIL, FDT_STATUS_FAIL_ERROR_CODE @error_code: optional, only used if status is FDT_STATUS_FAIL_ERROR_CODE  */
int fdt_set_node_status(void *fdt, int nodeoffset, enum fdt_status status, unsigned int error_code)
{
	char buf[16];
	int ret = 0;
	if (nodeoffset < 0)
		return nodeoffset;
	switch (status) {
	case FDT_STATUS_OKAY:
		ret = fdt_setprop_string(fdt, nodeoffset, "status", "okay");
		break;
	case FDT_STATUS_DISABLED:
		ret = fdt_setprop_string(fdt, nodeoffset, "status", "disabled");
		break;
	case FDT_STATUS_FAIL:
		ret = fdt_setprop_string(fdt, nodeoffset, "status", "fail");
		break;
	case FDT_STATUS_FAIL_ERROR_CODE:
		sprintf(buf, "fail-%d", error_code);
		ret = fdt_setprop_string(fdt, nodeoffset, "status", buf);
		break;
	default:
		printf("Invalid fdt status: %x\n", status);
		ret = -1;
		break;
	}
	return ret;
}