aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/property.c45
1 files changed, 1 insertions, 44 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 71520454c038..149de311a10e 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -180,31 +180,6 @@ static int pset_prop_read_string_array(struct property_set *pset,
180 return array_len; 180 return array_len;
181} 181}
182 182
183static int pset_prop_read_string(struct property_set *pset,
184 const char *propname, const char **strings)
185{
186 const struct property_entry *prop;
187 const char * const *pointer;
188
189 prop = pset_prop_get(pset, propname);
190 if (!prop)
191 return -EINVAL;
192 if (!prop->is_string)
193 return -EILSEQ;
194 if (prop->is_array) {
195 pointer = prop->pointer.str;
196 if (!pointer)
197 return -ENODATA;
198 } else {
199 pointer = &prop->value.str;
200 if (*pointer && strnlen(*pointer, prop->length) >= prop->length)
201 return -EILSEQ;
202 }
203
204 *strings = *pointer;
205 return 0;
206}
207
208struct fwnode_handle *dev_fwnode(struct device *dev) 183struct fwnode_handle *dev_fwnode(struct device *dev)
209{ 184{
210 return IS_ENABLED(CONFIG_OF) && dev->of_node ? 185 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
@@ -582,19 +557,6 @@ static int __fwnode_property_read_string_array(struct fwnode_handle *fwnode,
582 return -ENXIO; 557 return -ENXIO;
583} 558}
584 559
585static int __fwnode_property_read_string(struct fwnode_handle *fwnode,
586 const char *propname, const char **val)
587{
588 if (is_of_node(fwnode))
589 return of_property_read_string(to_of_node(fwnode), propname, val);
590 else if (is_acpi_node(fwnode))
591 return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING,
592 val, 1);
593 else if (is_pset_node(fwnode))
594 return pset_prop_read_string(to_pset_node(fwnode), propname, val);
595 return -ENXIO;
596}
597
598/** 560/**
599 * fwnode_property_read_string_array - return string array property of a node 561 * fwnode_property_read_string_array - return string array property of a node
600 * @fwnode: Firmware node to get the property of 562 * @fwnode: Firmware node to get the property of
@@ -646,13 +608,8 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
646int fwnode_property_read_string(struct fwnode_handle *fwnode, 608int fwnode_property_read_string(struct fwnode_handle *fwnode,
647 const char *propname, const char **val) 609 const char *propname, const char **val)
648{ 610{
649 int ret; 611 int ret = fwnode_property_read_string_array(fwnode, propname, val, 1);
650 612
651 ret = __fwnode_property_read_string(fwnode, propname, val);
652 if (ret == -EINVAL && !IS_ERR_OR_NULL(fwnode) &&
653 !IS_ERR_OR_NULL(fwnode->secondary))
654 ret = __fwnode_property_read_string(fwnode->secondary,
655 propname, val);
656 return ret < 0 ? ret : 0; 613 return ret < 0 ? ret : 0;
657} 614}
658EXPORT_SYMBOL_GPL(fwnode_property_read_string); 615EXPORT_SYMBOL_GPL(fwnode_property_read_string);