Skip to content

Commit

Permalink
state: remove unused arguments from state_new_from_node()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
saschahauer committed Feb 22, 2018
1 parent 359966d commit a66a8d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 32 deletions.
2 changes: 1 addition & 1 deletion common/efi/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
44 changes: 16 additions & 28 deletions common/state/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,24 +567,18 @@ 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;
const char *backend_type;
const char *storage_type = NULL;
const char *alias;
uint32_t stridesize;
struct device_node *partition_node;

alias = of_alias_get(node);
if (!alias) {
Expand All @@ -596,26 +590,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) {
Expand All @@ -635,8 +623,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;

Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions include/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a66a8d7

Please sign in to comment.