summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-01-23 13:58:49 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-01-27 09:27:02 +0100
commit25cee7ec176693c40d80c1614e1244624e803a85 (patch)
treef3a4c680270487d3d21b68aa30cca2e0a0c17f89
parentdac65f99e8bf1fbe2e15fa96ef901623bb49dc89 (diff)
downloadbarebox-25cee7ec176693c40d80c1614e1244624e803a85.tar.gz
environment: Use accessor functions for default environment path
default_environment_path only exists when CONFIG_ENV_HANDLING is enabled. Boards would have to #ifdef this if they wanted to use default_environment_path. Use accessor functions instead which can be ifdeffed on a single place. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/gk802/board.c4
-rw-r--r--arch/arm/boards/raspberry-pi/rpi.c2
-rw-r--r--arch/arm/boards/tqma6x/board.c2
-rw-r--r--arch/arm/mach-omap/omap_generic.c2
-rw-r--r--arch/arm/mach-socfpga/generic.c2
-rw-r--r--commands/loadenv.c2
-rw-r--r--commands/saveenv.c2
-rw-r--r--common/environment.c14
-rw-r--r--common/startup.c1
-rw-r--r--drivers/of/barebox.c2
-rw-r--r--include/envfs.h14
11 files changed, 36 insertions, 11 deletions
diff --git a/arch/arm/boards/gk802/board.c b/arch/arm/boards/gk802/board.c
index a4be03f..facb923 100644
--- a/arch/arm/boards/gk802/board.c
+++ b/arch/arm/boards/gk802/board.c
@@ -53,13 +53,13 @@ static int gk802_env_init(void)
bootsource_name = "mmc2";
barebox_name = "mmc2.barebox";
default_environment_name = "mmc2.bareboxenv";
- default_environment_path = "/dev/mmc2.bareboxenv";
+ default_environment_path_set("/dev/mmc2.bareboxenv");
break;
case 3:
bootsource_name = "mmc3";
barebox_name = "mmc3.barebox";
default_environment_name = "mmc3.bareboxenv";
- default_environment_path = "/dev/mmc3.bareboxenv";
+ default_environment_path_set("/dev/mmc3.bareboxenv");
break;
default:
return 0;
diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
index d2f27a8..0997124 100644
--- a/arch/arm/boards/raspberry-pi/rpi.c
+++ b/arch/arm/boards/raspberry-pi/rpi.c
@@ -132,7 +132,7 @@ static int rpi_env_init(void)
return 0;
}
- default_environment_path = "/boot/barebox.env";
+ default_environment_path_set("/boot/barebox.env");
return 0;
}
diff --git a/arch/arm/boards/tqma6x/board.c b/arch/arm/boards/tqma6x/board.c
index a870bf2..30ebf34 100644
--- a/arch/arm/boards/tqma6x/board.c
+++ b/arch/arm/boards/tqma6x/board.c
@@ -129,7 +129,7 @@ static int tqma6x_env_init(void)
device_detect_by_name("mmc2");
- default_environment_path = "/dev/mmc2.boot1";
+ default_environment_path_set("/dev/mmc2.boot1");
return 0;
}
diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c
index 3d302f3..bedb4d8 100644
--- a/arch/arm/mach-omap/omap_generic.c
+++ b/arch/arm/mach-omap/omap_generic.c
@@ -142,7 +142,7 @@ static int omap_env_init(void)
return 0;
}
- default_environment_path = "/boot/barebox.env";
+ default_environment_path_set("/boot/barebox.env");
return 0;
}
diff --git a/arch/arm/mach-socfpga/generic.c b/arch/arm/mach-socfpga/generic.c
index c166369..0d958d2 100644
--- a/arch/arm/mach-socfpga/generic.c
+++ b/arch/arm/mach-socfpga/generic.c
@@ -103,7 +103,7 @@ static int socfpga_env_init(void)
goto out_free;
}
- default_environment_path = "/boot/barebox.env";
+ default_environment_path_set("/boot/barebox.env");
out_free:
free(partname);
diff --git a/commands/loadenv.c b/commands/loadenv.c
index df0df27..bad8894 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -53,7 +53,7 @@ static int do_loadenv(int argc, char *argv[])
dirname = argv[optind + 1];
if (argc - optind < 1)
- filename = default_environment_path;
+ filename = default_environment_path_get();
else
filename = argv[optind];
diff --git a/commands/saveenv.c b/commands/saveenv.c
index 7f371a8..8ead98d 100644
--- a/commands/saveenv.c
+++ b/commands/saveenv.c
@@ -38,7 +38,7 @@ static int do_saveenv(int argc, char *argv[])
else
dirname = argv[2];
if (argc < 2)
- filename = default_environment_path;
+ filename = default_environment_path_get();
else
filename = argv[1];
diff --git a/common/environment.c b/common/environment.c
index 2448777..3f6f4b3 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -48,7 +48,19 @@ struct action_data {
};
#define PAD4(x) ((x + 3) & ~3)
-char *default_environment_path = "/dev/env0";
+#ifdef __BAREBOX__
+static char *default_environment_path = "/dev/env0";
+
+void default_environment_path_set(char *path)
+{
+ default_environment_path = path;
+}
+
+char *default_environment_path_get(void)
+{
+ return default_environment_path;
+}
+#endif
static int file_size_action(const char *filename, struct stat *statbuf,
void *userdata, int depth)
diff --git a/common/startup.c b/common/startup.c
index 74c7735..e8b9ea0 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -121,6 +121,7 @@ void __noreturn start_barebox(void)
if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
int ret;
+ char *default_environment_path = default_environment_path_get();
ret = envfs_load(default_environment_path, "/env", 0);
diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
index 8977158..44ec820 100644
--- a/drivers/of/barebox.c
+++ b/drivers/of/barebox.c
@@ -59,7 +59,7 @@ static int environment_probe(struct device_d *dev)
dev_info(dev, "setting default environment path to %s\n", path);
- default_environment_path = path;
+ default_environment_path_set(path);
return 0;
}
diff --git a/include/envfs.h b/include/envfs.h
index e9372b3..e847e4c 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -94,7 +94,19 @@ int envfs_load(char *filename, char *dirname, unsigned flags);
int envfs_save(char *filename, char *dirname);
/* defaults to /dev/env0 */
-extern char *default_environment_path;
+#ifdef CONFIG_ENV_HANDLING
+void default_environment_path_set(char *path);
+char *default_environment_path_get(void);
+#else
+static inline void default_environment_path_set(char *path)
+{
+}
+
+static inline char *default_environment_path_get(void)
+{
+ return NULL;
+}
+#endif
int envfs_register_partition(const char *devname, unsigned int partnr);