device property: Align return codes of acpi_fwnode_get_reference_with_args
Subsystems (3)
Sakari Ailus
reviewerPATCH 1/1 device property: Align return codes of acpi_fwnode_get_reference_with_args
acpi_fwnode_get_reference_with_args(), the function implementing ACPI support for fwnode_property_get_reference_with_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 there are no more entries whereas the former uses -ENODATA for the purpose.
To make matters more complicated, the ACPI implementation uses -ENOENT but for a different purpose --- when an entry exists but contains no reference. This isn't recognised by OF.
Document and align the error codes for property for fwnode_property_get_reference_with_args() so that they match with of_parse_phandle_with_args(), with the difference that -ENODATA is returned whenever an entry exists but contains no reference.
--- drivers/acpi/property.c | 4 ++++ drivers/base/property.c | 4 ++++ 2 files changed, 8 insertions(+)
drivers/acpi/property.c +4 -0
@@ -1207,6 +1207,10 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, ret =__acpi_node_get_property_reference (fwnode, prop, index, args_count, &acpi_args); +if (ret == -ENODATA ) +return -ENOENT ; +if (ret == -ENOENT ) +return -ENODATA ;if (ret <0 )return ret;if (!args)
drivers/base/property.c +4 -0
@@ -682,6 +682,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);* Caller is responsible to call fwnode_handle_put() on the returned * args->fwnode pointer. * +* Returns: %0 on success +* %-EINVAL on parse error +* %-ENODATA when an entry exists but contains no reference +* %-ENOENT when the index is out of bounds */ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, const char *prop, const char *nargs_prop,
Signature · 1 line
2.11.0
Quoted 11 lines · Sakari Ailus
acpi_fwnode_get_reference_with_args(), the function implementing ACPI support forfwnode_property_get_reference_with_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-ENOENTto indicate there are no more entries whereas the former uses-ENODATAfor the purpose.To make matters more complicated, the ACPI implementation uses
-ENOENTbut for a different purpose --- when an entry exists but contains no reference. This isn't recognised by OF.
Quoted 7 lines
Document and align the error codes for property for
fwnode_property_get_reference_with_args()so that they match withof_parse_phandle_with_args(), with the difference that-ENODATAis returned whenever an entry exists but contains no reference.Fixes 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")Signed-off-by Sakari Ailus <[email protected]>
You should CC Rafael and linux-acpi.
Also why not follow ACPI error codes and convert the corresponding DT function to return those instead?
Quoted 10 lines
--- drivers/acpi/property.c | 4 ++++ drivers/base/property.c | 4 ++++ 2 files changed, 8 insertions(+)drivers/acpi/property.c +0
-0
drivers/acpi/property.c acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, · line 1213
Quoted 7 lines
drivers/acpi/property.c +4
-0@@ -1207,6 +1207,10 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, ret =__acpi_node_get_property_reference (fwnode, prop, index, args_count, &acpi_args); +if (ret == -ENODATA ) +return -ENOENT ; +if (ret == -ENOENT ) +return -ENODATA ;
This kind of construct without any comments explaining why this is needed, looks suspicious.