diff options
author | Ulrich Ölmann <u.oelmann@pengutronix.de> | 2019-09-30 09:26:11 +0200 |
---|---|---|
committer | Roland Hieber <rhi@pengutronix.de> | 2019-10-11 16:49:39 +0200 |
commit | 1aeb1e4fdff012e7382599df5ea59de9383228d5 (patch) | |
tree | 7e8c48438532389532f185da7e41fade5f482260 | |
parent | e267c877e2eebeec1591b182d047afc5ff5d452f (diff) | |
download | dt-utils-1aeb1e4fdff012e7382599df5ea59de9383228d5.tar.gz dt-utils-1aeb1e4fdff012e7382599df5ea59de9383228d5.tar.xz |
state: harmonize code with barebox
This ports the following barebox commit:
| commit cdbeddf62b7a01f09f00e0fe94430789f4b0b05e
| Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
| Date: Wed Sep 11 21:27:38 2019 +0200
|
| state: provide dummy implementations for some functions when STATE is
| disabled
|
| This allows to simplify some callers as can be seen from the
| phytec-som-am335x/board.c change. (The check for state != NULL could be
| dropped already before.)
|
| Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/state.h | 36 |
2 files changed, 38 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 3033262..c2486af 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,8 @@ AS_IF([test "x${enable_state_backward_compatibility}" = "xyes"], [ AC_DEFINE(CONFIG_MTD, [1], [Statically define to be enabled to harmonize barebox' & dt-utils' code base.]) +AC_DEFINE(CONFIG_STATE, [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/state.h b/src/state.h index a49155e..d98b781 100644 --- a/src/state.h +++ b/src/state.h @@ -5,6 +5,7 @@ struct state; +#if IS_ENABLED(CONFIG_STATE) struct state *state_new_from_node(struct device_node *node, bool readonly); void state_release(struct state *state); @@ -19,4 +20,39 @@ void state_info(void); int state_read_mac(struct state *state, const char *name, u8 *buf); +#else /* #if IS_ENABLED(CONFIG_STATE) */ + +static inline struct state *state_new_from_node(struct device_node *node, + bool readonly) +{ + return ERR_PTR(-ENOSYS); +} + +static inline struct state *state_by_name(const char *name) +{ + return NULL; +} + +static inline struct state *state_by_node(const struct device_node *node) +{ + return NULL; +}; + +static inline int state_load(struct state *state) +{ + return -ENOSYS; +} + +static inline int state_save(struct state *state) +{ + return -ENOSYS; +} + +static inline int state_read_mac(struct state *state, const char *name, u8 *buf) +{ + return -ENOSYS; +} + +#endif /* #if IS_ENABLED(CONFIG_STATE) / #else */ + #endif /* __STATE_H */ |