Commit 60ba032e authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI / property: Drop size_prop from acpi_dev_get_property_reference()

The size_prop argument of the recently added function
acpi_dev_get_property_reference() is not used by the only current
caller of that function and is very unlikely to be used at any time
going forward.

Namely, for a property whose value is a list of items each containing
a references to a device object possibly accompanied by some integers,
the number of items in the list can always be computed as the number
of elements of type ACPI_TYPE_LOCAL_REFERENCE in the property package.
Thus it should never be necessary to provide an additional "cells"
property with a value equal to the number of items in that list.  It
also should never be necessary to provide a "cells" property specifying
how many integers are supposed to be following each reference.

For this reason, drop the size_prop argument from
acpi_dev_get_property_reference() and update its caller accordingly.

Link: http://marc.info/?l=linux-kernel&m=141511255610556&w=2Suggested-by: default avatarGrant Likely <grant.likely@linaro.org>
Acked-by: default avatarGrant Likely <grant.likely@linaro.org>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c673a2b4
...@@ -273,25 +273,21 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property_array); ...@@ -273,25 +273,21 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property_array);
* acpi_dev_get_property_reference - returns handle to the referenced object * acpi_dev_get_property_reference - returns handle to the referenced object
* @adev: ACPI device to get property * @adev: ACPI device to get property
* @name: Name of the property * @name: Name of the property
* @size_prop: Name of the "size" property in referenced object
* @index: Index of the reference to return * @index: Index of the reference to return
* @args: Location to store the returned reference with optional arguments * @args: Location to store the returned reference with optional arguments
* *
* Find property with @name, verifify that it is a package containing at least * Find property with @name, verifify that it is a package containing at least
* one object reference and if so, store the ACPI device object pointer to the * one object reference and if so, store the ACPI device object pointer to the
* target object in @args->adev. * target object in @args->adev. If the reference includes arguments, store
* them in the @args->args[] array.
* *
* If the reference includes arguments (@size_prop is not %NULL) follow the * If there's more than one reference in the property value package, @index is
* reference and check whether or not there is an integer property @size_prop * used to select the one to return.
* under the target object and if so, whether or not its value matches the
* number of arguments that follow the reference. If there's more than one
* reference in the property value package, @index is used to select the one to
* return.
* *
* Return: %0 on success, negative error code on failure. * Return: %0 on success, negative error code on failure.
*/ */
int acpi_dev_get_property_reference(struct acpi_device *adev, const char *name, int acpi_dev_get_property_reference(struct acpi_device *adev,
const char *size_prop, size_t index, const char *name, size_t index,
struct acpi_reference_args *args) struct acpi_reference_args *args)
{ {
const union acpi_object *element, *end; const union acpi_object *element, *end;
...@@ -308,7 +304,7 @@ int acpi_dev_get_property_reference(struct acpi_device *adev, const char *name, ...@@ -308,7 +304,7 @@ int acpi_dev_get_property_reference(struct acpi_device *adev, const char *name,
* return that reference then. * return that reference then.
*/ */
if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) { if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) {
if (size_prop || index) if (index)
return -EINVAL; return -EINVAL;
ret = acpi_bus_get_device(obj->reference.handle, &device); ret = acpi_bus_get_device(obj->reference.handle, &device);
...@@ -348,42 +344,16 @@ int acpi_dev_get_property_reference(struct acpi_device *adev, const char *name, ...@@ -348,42 +344,16 @@ int acpi_dev_get_property_reference(struct acpi_device *adev, const char *name,
element++; element++;
nargs = 0; nargs = 0;
if (size_prop) { /* assume following integer elements are all args */
const union acpi_object *prop; for (i = 0; element + i < end; i++) {
int type = element[i].type;
/*
* Find out how many arguments the refenced object
* expects by reading its size_prop property.
*/
ret = acpi_dev_get_property(device, size_prop,
ACPI_TYPE_INTEGER, &prop);
if (ret)
return ret;
nargs = prop->integer.value;
if (nargs > MAX_ACPI_REFERENCE_ARGS
|| element + nargs > end)
return -EPROTO;
/* if (type == ACPI_TYPE_INTEGER)
* Skip to the start of the arguments and verify nargs++;
* that they all are in fact integers. else if (type == ACPI_TYPE_LOCAL_REFERENCE)
*/ break;
for (i = 0; i < nargs; i++) else
if (element[i].type != ACPI_TYPE_INTEGER) return -EPROTO;
return -EPROTO;
} else {
/* assume following integer elements are all args */
for (i = 0; element + i < end; i++) {
int type = element[i].type;
if (type == ACPI_TYPE_INTEGER)
nargs++;
else if (type == ACPI_TYPE_LOCAL_REFERENCE)
break;
else
return -EPROTO;
}
} }
if (idx++ == index) { if (idx++ == index) {
......
...@@ -405,7 +405,7 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, ...@@ -405,7 +405,7 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname); dev_dbg(&adev->dev, "GPIO: looking up %s\n", propname);
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
ret = acpi_dev_get_property_reference(adev, propname, NULL, ret = acpi_dev_get_property_reference(adev, propname,
index, &args); index, &args);
if (ret) { if (ret) {
bool found = acpi_get_driver_gpio_data(adev, propname, bool found = acpi_get_driver_gpio_data(adev, propname,
......
...@@ -718,8 +718,8 @@ int acpi_dev_get_property(struct acpi_device *adev, const char *name, ...@@ -718,8 +718,8 @@ int acpi_dev_get_property(struct acpi_device *adev, const char *name,
int acpi_dev_get_property_array(struct acpi_device *adev, const char *name, int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
acpi_object_type type, acpi_object_type type,
const union acpi_object **obj); const union acpi_object **obj);
int acpi_dev_get_property_reference(struct acpi_device *adev, const char *name, int acpi_dev_get_property_reference(struct acpi_device *adev,
const char *cells_name, size_t index, const char *name, size_t index,
struct acpi_reference_args *args); struct acpi_reference_args *args);
int acpi_dev_prop_get(struct acpi_device *adev, const char *propname, int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment