ACPI: properties: Align return codes of __acpi_node_get_property_reference()

acpi_fwnode_get_reference_args(), the function implementing ACPI
support for fwnode_property_get_reference_args(), returns directly
error codes from __acpi_node_get_property_reference(). The latter
uses different error codes than the OF implementation. In particular,
the OF implementation uses -ENOENT to indicate that the property is
not found, a reference entry is empty and there are no more
references.

Document and align the error codes for property for
fwnode_property_get_reference_args() so that they match with
of_parse_phandle_with_args().

Fixes: 3e3119d308 (device property: Introduce fwnode_property_get_reference_args)
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Sakari Ailus 2017-09-26 12:08:27 +03:00 committed by Rafael J. Wysocki
parent 5ab894aee0
commit c343bc2ce2
2 changed files with 13 additions and 10 deletions

View file

@ -571,10 +571,9 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
* } * }
* } * }
* *
* Calling this function with index %2 return %-ENOENT and with index %3 * Calling this function with index %2 or index %3 return %-ENOENT. If the
* returns the last entry. If the property does not contain any more values * property does not contain any more values %-ENOENT is returned. The NULL
* %-ENODATA is returned. The NULL entry must be single integer and * entry must be single integer and preferably contain value %0.
* preferably contain value %0.
* *
* Return: %0 on success, negative error code on failure. * Return: %0 on success, negative error code on failure.
*/ */
@ -590,7 +589,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
data = acpi_device_data_of_node(fwnode); data = acpi_device_data_of_node(fwnode);
if (!data) if (!data)
return -EINVAL; return -ENOENT;
ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj); ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj);
if (ret) if (ret)
@ -635,7 +634,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
ret = acpi_bus_get_device(element->reference.handle, ret = acpi_bus_get_device(element->reference.handle,
&device); &device);
if (ret) if (ret)
return -ENODEV; return -EINVAL;
nargs = 0; nargs = 0;
element++; element++;
@ -649,11 +648,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
else if (type == ACPI_TYPE_LOCAL_REFERENCE) else if (type == ACPI_TYPE_LOCAL_REFERENCE)
break; break;
else else
return -EPROTO; return -EINVAL;
} }
if (nargs > MAX_ACPI_REFERENCE_ARGS) if (nargs > MAX_ACPI_REFERENCE_ARGS)
return -EPROTO; return -EINVAL;
if (idx == index) { if (idx == index) {
args->adev = device; args->adev = device;
@ -670,13 +669,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
return -ENOENT; return -ENOENT;
element++; element++;
} else { } else {
return -EPROTO; return -EINVAL;
} }
idx++; idx++;
} }
return -ENODATA; return -ENOENT;
} }
EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference); EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);

View file

@ -683,6 +683,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);
* Caller is responsible to call fwnode_handle_put() on the returned * Caller is responsible to call fwnode_handle_put() on the returned
* args->fwnode pointer. * args->fwnode pointer.
* *
* Returns: %0 on success
* %-ENOENT when the index is out of bounds, the index has an empty
* reference or the property was not found
* %-EINVAL on parse error
*/ */
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop, const char *prop, const char *nargs_prop,