[PATCH v3 13/13] software node: remove separate handling of references

From: Dmitry Torokhov
Date: Mon Sep 09 2019 - 04:16:25 EST


Now that all users of references have moved to reference properties,
we can remove separate handling of references.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/base/swnode.c | 44 +++++++++++++++-------------------------
include/linux/property.h | 14 -------------
2 files changed, 16 insertions(+), 42 deletions(-)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 4aaad0c7b1eb..8085b39e23b4 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -452,8 +452,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
struct fwnode_reference_args *args)
{
struct swnode *swnode = to_swnode(fwnode);
- const struct software_node_reference *ref;
- const struct software_node_ref_args *ref_args;
+ const struct software_node_ref_args *ref;
const struct property_entry *prop;
struct fwnode_handle *refnode;
int i;
@@ -462,36 +461,25 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
return -ENOENT;

prop = property_entry_get(swnode->node->properties, propname);
- if (prop) {
- if (prop->type != DEV_PROP_REF)
- return -EINVAL;
-
- /*
- * We expect that references are never stored inline, even
- * single ones, as they are too big.
- */
- if (prop->is_inline)
- return -EINVAL;
-
- if (index * sizeof(*ref_args) >= prop->length)
- return -ENOENT;
+ if (!prop)
+ return -ENOENT;

- ref_args = &prop->pointer.ref[index];
- } else {
- if (!swnode->node->references)
- return -ENOENT;
+ if (prop->type != DEV_PROP_REF)
+ return -EINVAL;

- for (ref = swnode->node->references; ref->name; ref++)
- if (!strcmp(ref->name, propname))
- break;
+ /*
+ * We expect that references are never stored inline, even
+ * single ones, as they are too big.
+ */
+ if (prop->is_inline)
+ return -EINVAL;

- if (!ref->name || index > (ref->nrefs - 1))
- return -ENOENT;
+ if (index * sizeof(*ref) >= prop->length)
+ return -ENOENT;

- ref_args = &ref->refs[index];
- }
+ ref = &prop->pointer.ref[index];

- refnode = software_node_fwnode(ref_args->node);
+ refnode = software_node_fwnode(ref->node);
if (!refnode)
return -ENOENT;

@@ -510,7 +498,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
args->nargs = nargs;

for (i = 0; i < nargs; i++)
- args->args[i] = ref_args->args[i];
+ args->args[i] = ref->args[i];

return 0;
}
diff --git a/include/linux/property.h b/include/linux/property.h
index c9234fc43917..67cd38936c1e 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -419,30 +419,16 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
/* -------------------------------------------------------------------------- */
/* Software fwnode support - when HW description is incomplete or missing */

-/**
- * struct software_node_reference - Named software node reference property
- * @name: Name of the property
- * @nrefs: Number of elements in @refs array
- * @refs: Array of references with optional arguments
- */
-struct software_node_reference {
- const char *name;
- unsigned int nrefs;
- const struct software_node_ref_args *refs;
-};
-
/**
* struct software_node - Software node description
* @name: Name of the software node
* @parent: Parent of the software node
* @properties: Array of device properties
- * @references: Array of software node reference properties
*/
struct software_node {
const char *name;
const struct software_node *parent;
const struct property_entry *properties;
- const struct software_node_reference *references;
};

bool is_software_node(const struct fwnode_handle *fwnode);
--
2.23.0.187.g17f5b7556c-goog