diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2017-03-28 15:26:22 +0300 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2017-11-27 14:12:20 +0800 |
commit | 37c23c6fcae82267f2a1d3a77a6e8a9568cf4474 (patch) | |
tree | 356f989a2a9ad5e9ab47b792a3fc7f0dc333106a /drivers/base | |
parent | 5f17e4a7306fdb5aa9dfcdb4dc2b8ea1fd9fd16d (diff) |
BACKPORT: device property: Read strings using string array reading functions
Always read strings using of_property_read_string_array() instead of
of_property_read_string(). This allows using a single operation struct
callback for accessing strings.
Same for pset_prop_read_string_array() and pset_prop_read_string().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit e48174779440c79ff5dd75f0e6b169d4e184262d)
Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
Brian L: conflicted on removing pset_prop_read_string() - favor
upstream and remove this function.
Conflicts:
drivers/base/property.c
BUG=b:64133998
TEST=media device topology shows subdevs registered successfully
TEST=no camera regression
Change-Id: I011469cb71a549bf8efc0cd2c89664af3d6c9ff1
Reviewed-on: https://chromium-review.googlesource.com/692691
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Hyungwoo Yang <hyungwoo.yang@intel.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/property.c | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index 33f9d37eae63..53ec35a0d4b9 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -175,31 +175,6 @@ static int pset_prop_read_string_array(struct property_set *pset, return array_len; } -static int pset_prop_read_string(struct property_set *pset, - const char *propname, const char **strings) -{ - struct property_entry *prop; - const char **pointer; - - prop = pset_prop_get(pset, propname); - if (!prop) - return -EINVAL; - if (!prop->is_string) - return -EILSEQ; - if (prop->is_array) { - pointer = prop->pointer.str; - if (!pointer) - return -ENODATA; - } else { - pointer = &prop->value.str; - if (*pointer && strnlen(*pointer, prop->length) >= prop->length) - return -EILSEQ; - } - - *strings = *pointer; - return 0; -} - struct fwnode_handle *dev_fwnode(struct device *dev) { return IS_ENABLED(CONFIG_OF) && dev->of_node ? @@ -577,19 +552,6 @@ static int __fwnode_property_read_string_array(struct fwnode_handle *fwnode, return -ENXIO; } -static int __fwnode_property_read_string(struct fwnode_handle *fwnode, - const char *propname, const char **val) -{ - if (is_of_node(fwnode)) - return of_property_read_string(to_of_node(fwnode), propname, val); - else if (is_acpi_node(fwnode)) - return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING, - val, 1); - else if (is_pset_node(fwnode)) - return pset_prop_read_string(to_pset_node(fwnode), propname, val); - return -ENXIO; -} - /** * fwnode_property_read_string_array - return string array property of a node * @fwnode: Firmware node to get the property of @@ -641,13 +603,8 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string_array); int fwnode_property_read_string(struct fwnode_handle *fwnode, const char *propname, const char **val) { - int ret; + int ret = fwnode_property_read_string_array(fwnode, propname, val, 1); - ret = __fwnode_property_read_string(fwnode, propname, val); - if (ret == -EINVAL && !IS_ERR_OR_NULL(fwnode) && - !IS_ERR_OR_NULL(fwnode->secondary)) - ret = __fwnode_property_read_string(fwnode->secondary, - propname, val); return ret < 0 ? ret : 0; } EXPORT_SYMBOL_GPL(fwnode_property_read_string); |