diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2017-03-28 15:22:19 +0300 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2017-11-27 14:12:20 +0800 |
commit | 5f17e4a7306fdb5aa9dfcdb4dc2b8ea1fd9fd16d (patch) | |
tree | d4be4f935e328820c70a88c8ac10271a633e5178 /drivers/acpi | |
parent | 12d3eea6d8e66c3f041a95fb6fa06bd7a4ab858c (diff) |
UPSTREAM: device property: fwnode_property_read_string_array() returns nr of strings
Functionally fwnode_property_read_string_array() should match
of_property_read_string_array() and work as a drop-in substitute for the
latter. of_property_read_string_array() returns the number of strings read
if the target string pointer array is non-NULL. Make
fwnode_property_read_string_array() do the same.
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 b0b027cee090a1e3278960e1c8257213fda40f10)
Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
BUG=b:64133998
TEST=media device topology shows subdevs registered successfully
TEST=no camera regression
Change-Id: I4f3c78b8fc99e8bf1590468631551b9cafb0eecf
Reviewed-on: https://chromium-review.googlesource.com/692690
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/acpi')
-rw-r--r-- | drivers/acpi/property.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 4c7e66ea69c4..83102dae256c 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -627,6 +627,8 @@ static int acpi_data_prop_read_single(struct acpi_device_data *data, return ret; *(char **)val = obj->string.pointer; + + return 1; } else { ret = -EINVAL; } @@ -636,7 +638,15 @@ static int acpi_data_prop_read_single(struct acpi_device_data *data, int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, enum dev_prop_type proptype, void *val) { - return adev ? acpi_data_prop_read_single(&adev->data, propname, proptype, val) : -EINVAL; + int ret; + + if (!adev) + return -EINVAL; + + ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); + if (ret < 0 || proptype != ACPI_TYPE_STRING) + return ret; + return 0; } static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val, @@ -712,7 +722,7 @@ static int acpi_copy_property_array_string(const union acpi_object *items, val[i] = items[i].string.pointer; } - return 0; + return nval; } static int acpi_data_prop_read(struct acpi_device_data *data, @@ -726,7 +736,7 @@ static int acpi_data_prop_read(struct acpi_device_data *data, if (val && nval == 1) { ret = acpi_data_prop_read_single(data, propname, proptype, val); - if (!ret) + if (ret >= 0) return ret; } @@ -737,7 +747,7 @@ static int acpi_data_prop_read(struct acpi_device_data *data, if (!val) return obj->package.count; - if (nval > obj->package.count) + if (proptype != DEV_PROP_STRING && nval > obj->package.count) return -EOVERFLOW; else if (nval <= 0) return -EINVAL; @@ -758,7 +768,9 @@ static int acpi_data_prop_read(struct acpi_device_data *data, ret = acpi_copy_property_array_u64(items, (u64 *)val, nval); break; case DEV_PROP_STRING: - ret = acpi_copy_property_array_string(items, (char **)val, nval); + ret = acpi_copy_property_array_string( + items, (char **)val, + min_t(u32, nval, obj->package.count)); break; default: ret = -EINVAL; |