diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/state.c | 65 |
1 files changed, 2 insertions, 63 deletions
diff --git a/drivers/misc/state.c b/drivers/misc/state.c index 73356b45a0..b9eb1b7bb2 100644 --- a/drivers/misc/state.c +++ b/drivers/misc/state.c @@ -24,75 +24,14 @@ static int state_probe(struct device_d *dev) { struct device_node *np = dev->device_node; - struct device_node *partition_node; struct state *state; - const char *alias; - const char *backend_type = NULL; - int len, ret; - const char *of_path; - char *path; + bool readonly = false; - if (!np) - return -EINVAL; - - alias = of_alias_get(np); - if (!alias) - alias = np->name; - - state = state_new_from_node(alias, np); + state = state_new_from_node(np, NULL, 0, 0, readonly); if (IS_ERR(state)) return PTR_ERR(state); - of_path = of_get_property(np, "backend", &len); - if (!of_path) { - ret = -ENODEV; - goto out_release; - } - - /* guess if of_path is a path, not a phandle */ - if (of_path[0] == '/' && len > 1) { - ret = of_find_path(np, "backend", &path, 0); - } else { - - partition_node = of_parse_phandle(np, "backend", 0); - if (!partition_node) - return -EINVAL; - - of_path = partition_node->full_name; - ret = of_find_path_by_node(partition_node, &path, 0); - } - - if (ret == -ENODEV) - ret = -EPROBE_DEFER; - if (ret) - goto out_release; - - ret = of_property_read_string(np, "backend-type", &backend_type); - if (ret) { - goto out_free; - } else if (!strcmp(backend_type, "raw")) { - ret = state_backend_raw_file(state, of_path, path, 0, 0); - } else if (!strcmp(backend_type, "dtb")) { - ret = state_backend_dtb_file(state, of_path, path); - } else { - dev_warn(dev, "invalid backend type: %s\n", backend_type); - ret = -ENODEV; - goto out_free; - } - - if (ret) - goto out_free; - - dev_info(dev, "backend: %s, path: %s, of_path: %s\n", backend_type, path, of_path); - free(path); - return 0; - - out_free: - free(path); - out_release: - state_release(state); - return ret; } static __maybe_unused struct of_device_id state_ids[] = { |