diff options
author | Ulrich Ölmann <u.oelmann@pengutronix.de> | 2019-02-08 08:15:23 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-02-11 09:12:36 +0100 |
commit | 04657b6af779bcf7ac06f36ffa0707f216a88b45 (patch) | |
tree | 681b7db6edf2ae0b7425e0ab7a204d10c614ecb6 /common/state | |
parent | ed86bd67ef9bda914c99c6ee939de836eff1dc10 (diff) | |
download | barebox-04657b6af779bcf7ac06f36ffa0707f216a88b45.tar.gz barebox-04657b6af779bcf7ac06f36ffa0707f216a88b45.tar.xz |
common: state: harmonize code with dt-utils
Other than in barebox the offset and size of a state's backend device do not
necessarily equal zero in Linux userspace (EEPROMs & block devices), so barebox'
and dt-utils' state code differ here.
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state')
-rw-r--r-- | common/state/state.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/state/state.c b/common/state/state.c index d3e048b990..3f5d43ecbf 100644 --- a/common/state/state.c +++ b/common/state/state.c @@ -596,6 +596,8 @@ struct state *state_new_from_node(struct device_node *node, bool readonly) const char *alias; uint32_t stridesize; struct device_node *partition_node; + off_t offset = 0; + size_t size = 0; alias = of_alias_get(node); if (!alias) { @@ -614,7 +616,11 @@ struct state *state_new_from_node(struct device_node *node, bool readonly) goto out_release_state; } +#ifdef __BAREBOX__ ret = of_find_path_by_node(partition_node, &state->backend_path, 0); +#else + ret = of_get_devicepath(partition_node, &state->backend_path, &offset, &size); +#endif if (ret) { if (ret != -EPROBE_DEFER) dev_err(&state->dev, "state failed to parse path to backend: %s\n", @@ -645,8 +651,8 @@ struct state *state_new_from_node(struct device_node *node, bool readonly) if (ret) goto out_release_state; - ret = state_storage_init(state, state->backend_path, 0, - 0, stridesize, storage_type); + ret = state_storage_init(state, state->backend_path, offset, + size, stridesize, storage_type); if (ret) goto out_release_state; |