+static int uniphier_set_fdt_file(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ const char *compat;
+ char dtb_name[256];
+ int buf_len = sizeof(dtb_name);
+
+ if (env_get("fdtfile"))
+ return 0; /* do nothing if it is already set */
+
+ compat = fdt_stringlist_get(gd->fdt_blob, 0, "compatible", 0, NULL);
+ if (!compat)
+ return -EINVAL;
+
+ /* rip off the vendor prefix "socionext," */
+ compat = strchr(compat, ',');
+ if (!compat)
+ return -EINVAL;
+ compat++;
+
+ strncpy(dtb_name, compat, buf_len);
+ buf_len -= strlen(compat);
+
+ strncat(dtb_name, ".dtb", buf_len);
+
+ return env_set("fdtfile", dtb_name);
+}
+