Add code to explicitly check for success of of_device_enable_path()
when selecting which media is expected to contain barebox environment.

Signed-off-by: Andrey Smirnov <andrew.smir...@gmail.com>
---
 arch/arm/boards/phytec-phyflex-imx6/board.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boards/phytec-phyflex-imx6/board.c 
b/arch/arm/boards/phytec-phyflex-imx6/board.c
index 7ac7928..c731faf 100644
--- a/arch/arm/boards/phytec-phyflex-imx6/board.c
+++ b/arch/arm/boards/phytec-phyflex-imx6/board.c
@@ -65,6 +65,9 @@ static void phyflex_err006282_workaround(void)
 
 static int phytec_pfla02_init(void)
 {
+       int ret;
+       char *environment_path;
+
        if (!of_machine_is_compatible("phytec,imx6q-pfla02") &&
                        !of_machine_is_compatible("phytec,imx6dl-pfla02") &&
                        !of_machine_is_compatible("phytec,imx6s-pfla02"))
@@ -76,17 +79,22 @@ static int phytec_pfla02_init(void)
 
        switch (bootsource_get()) {
        case BOOTSOURCE_MMC:
-               of_device_enable_path("/chosen/environment-sd");
+               environment_path = "/chosen/environment-sd";
                break;
        case BOOTSOURCE_NAND:
-               of_device_enable_path("/chosen/environment-nand");
+               environment_path = "/chosen/environment-nand";
                break;
        default:
        case BOOTSOURCE_SPI:
-               of_device_enable_path("/chosen/environment-spinor");
+               environment_path = "/chosen/environment-spinor";
                break;
        }
 
+       ret = of_device_enable_path(environment_path);
+       if (ret < 0)
+               pr_warn("Failed to enable environment partition '%s' (%d)\n",
+                       environment_path, ret);
+
        return 0;
 }
 device_initcall(phytec_pfla02_init);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to