summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Ölmann <u.oelmann@pengutronix.de>2019-09-30 09:26:09 +0200
committerRoland Hieber <rhi@pengutronix.de>2019-10-11 16:49:39 +0200
commit20fb10ce5d55676754c1df9c0c8bed34c9aa9aeb (patch)
tree692f03e87d4ecbedcb64afd1620a57e407a8b560
parent2dbca4c3284b283b9d191a423a127b0d9402a55d (diff)
downloaddt-utils-20fb10ce5d55676754c1df9c0c8bed34c9aa9aeb.tar.gz
dt-utils-20fb10ce5d55676754c1df9c0c8bed34c9aa9aeb.tar.xz
state: backend_storage: harmonize code with barebox
This ports the following barebox commit: | commit f3895311ef49171b58b5ea1f06942408c8685a1e | Author: Lucas Stach <l.stach@pengutronix.de> | Date: Fri Jul 22 15:00:19 2016 +0200 | | state: only build circular backend if MTD is enabled | | The circular backend depends on MTD symbols and is only useful | if MTD is present. Exclude it from the build if MTD is not enabled. | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
-rw-r--r--configure.ac2
-rw-r--r--src/barebox-state/backend_storage.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 04c2226..3033262 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,8 @@ AS_IF([test "x${enable_state_backward_compatibility}" = "xyes"], [
AC_DEFINE(CONFIG_STATE_BACKWARD_COMPATIBLE, [0])
])
+AC_DEFINE(CONFIG_MTD, [1], [Statically define to be enabled to harmonize barebox' & dt-utils' code base.])
+
AC_CHECK_FUNCS([__secure_getenv secure_getenv])
my_CFLAGS="-Wall \
diff --git a/src/barebox-state/backend_storage.c b/src/barebox-state/backend_storage.c
index 3879a8d..509427f 100644
--- a/src/barebox-state/backend_storage.c
+++ b/src/barebox-state/backend_storage.c
@@ -369,7 +369,7 @@ int state_storage_init(struct state *state, const char *path,
const char *storagetype)
{
struct state_backend_storage *storage = &state->storage;
- int ret;
+ int ret = -ENODEV;
struct mtd_info_user meminfo;
INIT_LIST_HEAD(&storage->buckets);
@@ -380,7 +380,9 @@ int state_storage_init(struct state *state, const char *path,
storage->max_size = max_size;
storage->path = xstrdup(path);
- ret = mtd_get_meminfo(path, &meminfo);
+ if (IS_ENABLED(CONFIG_MTD))
+ ret = mtd_get_meminfo(path, &meminfo);
+
if (!ret && !(meminfo.flags & MTD_NO_ERASE)) {
bool circular;
if (!storagetype || !strcmp(storagetype, "circular")) {