* [PATCH 1/2] state: remove unused arguments from state_new_from_node()
@ 2018-02-20 13:45 Sascha Hauer
2018-02-20 13:45 ` [PATCH 2/2] state: find backend node with its reproducible name Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2018-02-20 13:45 UTC (permalink / raw)
To: Barebox List
state_new_from_node() has arguments describing the backend path. These
are never used in barebox, the backend path is always derived from the
device nodes backend description. Remove these arguments.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/efi/efi.c | 2 +-
common/state/state.c | 44 ++++++++++++++++----------------------------
drivers/misc/state.c | 2 +-
include/state.h | 3 +--
4 files changed, 19 insertions(+), 32 deletions(-)
diff --git a/common/efi/efi.c b/common/efi/efi.c
index 561ce4c081..1f451a157e 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -441,7 +441,7 @@ static int efi_late_init(void)
np = of_find_node_by_alias(root, "state");
- state = state_new_from_node(np, NULL, 0, 0, false);
+ state = state_new_from_node(np, false);
if (IS_ERR(state))
return PTR_ERR(state);
diff --git a/common/state/state.c b/common/state/state.c
index 6399bd3736..fdf10991aa 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -557,17 +557,10 @@ void state_release(struct state *state)
/*
* state_new_from_node - create a new state instance from a device_node
*
- * @node The device_node describing the new state instance
- * @path Path to the backend device. If NULL the path is constructed
- * using the path in the backend property of the DT.
- * @offset Offset in the device path. May be 0 to start at the beginning.
- * @max_size Maximum size of the area used. This may be 0 to use the full
- * size.
* @readonly This is a read-only state. Note that with this option set,
* there are no repairs done.
*/
-struct state *state_new_from_node(struct device_node *node, char *path,
- off_t offset, size_t max_size, bool readonly)
+struct state *state_new_from_node(struct device_node *node, bool readonly)
{
struct state *state;
int ret = 0;
@@ -575,6 +568,7 @@ struct state *state_new_from_node(struct device_node *node, char *path,
const char *storage_type = NULL;
const char *alias;
uint32_t stridesize;
+ struct device_node *partition_node;
alias = of_alias_get(node);
if (!alias) {
@@ -586,26 +580,20 @@ struct state *state_new_from_node(struct device_node *node, char *path,
if (IS_ERR(state))
return state;
- if (!path) {
- struct device_node *partition_node;
-
- partition_node = of_parse_phandle(node, "backend", 0);
- if (!partition_node) {
- dev_err(&state->dev, "Cannot resolve \"backend\" phandle\n");
- ret = -EINVAL;
- goto out_release_state;
- }
-
- ret = of_find_path_by_node(partition_node, &path, 0);
- if (ret) {
- if (ret != -EPROBE_DEFER)
- dev_err(&state->dev, "state failed to parse path to backend: %s\n",
- strerror(-ret));
- goto out_release_state;
- }
+ partition_node = of_parse_phandle(node, "backend", 0);
+ if (!partition_node) {
+ dev_err(&state->dev, "Cannot resolve \"backend\" phandle\n");
+ ret = -EINVAL;
+ goto out_release_state;
}
- state->backend_path = xstrdup(path);
+ ret = of_find_path_by_node(partition_node, &state->backend_path, 0);
+ if (ret) {
+ if (ret != -EPROBE_DEFER)
+ dev_err(&state->dev, "state failed to parse path to backend: %s\n",
+ strerror(-ret));
+ goto out_release_state;
+ }
ret = of_property_read_string(node, "backend-type", &backend_type);
if (ret) {
@@ -625,8 +613,8 @@ struct state *state_new_from_node(struct device_node *node, char *path,
if (ret)
goto out_release_state;
- ret = state_storage_init(state, path, offset,
- max_size, stridesize, storage_type);
+ ret = state_storage_init(state, state->backend_path, 0,
+ 0, stridesize, storage_type);
if (ret)
goto out_release_state;
diff --git a/drivers/misc/state.c b/drivers/misc/state.c
index 98ed42e757..d7e385d0b5 100644
--- a/drivers/misc/state.c
+++ b/drivers/misc/state.c
@@ -28,7 +28,7 @@ static int state_probe(struct device_d *dev)
bool readonly = false;
int ret;
- state = state_new_from_node(np, NULL, 0, 0, readonly);
+ state = state_new_from_node(np, readonly);
if (IS_ERR(state)) {
int ret = PTR_ERR(state);
if (ret == -ENODEV)
diff --git a/include/state.h b/include/state.h
index f1882ae026..4e995a19ef 100644
--- a/include/state.h
+++ b/include/state.h
@@ -10,8 +10,7 @@ int state_backend_dtb_file(struct state *state, const char *of_path,
int state_backend_raw_file(struct state *state, const char *of_path,
const char *path, off_t offset, size_t size);
-struct state *state_new_from_node(struct device_node *node, char *path,
- off_t offset, size_t max_size, bool readonly);
+struct state *state_new_from_node(struct device_node *node, bool readonly);
void state_release(struct state *state);
struct state *state_by_name(const char *name);
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] state: find backend node with its reproducible name
2018-02-20 13:45 [PATCH 1/2] state: remove unused arguments from state_new_from_node() Sascha Hauer
@ 2018-02-20 13:45 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-02-20 13:45 UTC (permalink / raw)
To: Barebox List
When fixing up the kernels state nodes we depended on the full node path
of the input device tree. This does not work when the kernel device tree
has different names. This has happened lately when the i.MX6 device
trees got their leading zeroes removed from the node names.
Use of_find_node_by_reproducible_name() to find the node corresponding
to the storage backend node in the kernel device tree.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/state/state.c | 6 +++++-
common/state/state.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/common/state/state.c b/common/state/state.c
index fdf10991aa..2a91c6aa6a 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -470,7 +470,8 @@ static int of_state_fixup(struct device_node *root, void *ctx)
}
/* backend phandle */
- backend_node = of_find_node_by_devpath(root, state->backend_path);
+ backend_node = of_find_node_by_reproducible_name(root,
+ state->backend_reproducible_name);
if (!backend_node) {
ret = -ENODEV;
goto out;
@@ -550,6 +551,7 @@ void state_release(struct state *state)
state_storage_free(&state->storage);
state_format_free(state->format);
free(state->backend_path);
+ free(state->backend_reproducible_name);
free(state->of_path);
free(state);
}
@@ -595,6 +597,8 @@ struct state *state_new_from_node(struct device_node *node, bool readonly)
goto out_release_state;
}
+ state->backend_reproducible_name = of_get_reproducible_name(partition_node);
+
ret = of_property_read_string(node, "backend-type", &backend_type);
if (ret) {
dev_dbg(&state->dev, "Missing 'backend-type' property\n");
diff --git a/common/state/state.h b/common/state/state.h
index fcc6b9f5cd..cde6a34c23 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -113,6 +113,7 @@ struct state {
struct state_backend_format *format;
struct state_backend_storage storage;
char *backend_path;
+ char *backend_reproducible_name;
};
enum state_convert {
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-20 13:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 13:45 [PATCH 1/2] state: remove unused arguments from state_new_from_node() Sascha Hauer
2018-02-20 13:45 ` [PATCH 2/2] state: find backend node with its reproducible name Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox