device properties: Fix return codes for __acpi_node_get_property_reference
PATCH v2 1/1 device properties: Fix return codes for __acpi_node_get_property_reference
Fix more return codes for device property: Align return codes of __acpi_node_get_property_reference. In particular what was missed previously:
-EPROTO could be returned in certain cases, now -EINVAL; -EINVAL was returned if the property was not found, now -ENOENT; -EINVAL was returned also if the index was higher than the number of entries in a package, now -ENOENT.
---
since v1:
- Remove the ugly switch from acpi_data_get_property() return value handling. Only -EINVAL and -EPROTO are returned by the function.
drivers/acpi/property.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/property.c +6 -4
@@ -593,7 +593,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ret =acpi_data_get_property (data, propname,ACPI_TYPE_ANY , &obj);if (ret) -return ret; +return ret == -EINVAL ? -ENOENT : -EINVAL ;/* * The simplest case is when the value is a single reference. Just
@@ -605,7 +605,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ret =acpi_bus_get_device (obj->reference.handle, &device);if (ret) -return ret; +return ret == -ENODEV ? -EINVAL : ret; args->adev = device; args->nargs =0 ;
@@ -621,8 +621,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,* The index argument is then used to determine which reference * the caller wants (along with the arguments). */ -if (obj->type !=ACPI_TYPE_PACKAGE || index >= obj->package.count) -return -EPROTO ; +if (obj->type !=ACPI_TYPE_PACKAGE ) +return -EINVAL ; +if (index >= obj->package.count) +return -ENOENT ; element = obj->package.elements; end = element + obj->package.count;
Signature · 1 line
2.11.0
Quoted 48 lines · CEST Sakari Ailus
Fix more return codes for device property: Align return codes of
__acpi_node_get_property_reference. In particular what was missed previously:(quoted diff) +0
-3-EPROTO could be returned in certain cases, now -EINVAL; -EINVAL was returned if the property was not found, now -ENOENT; -EINVAL was returned also if the index was higher than the number ofentries in a package, now
-ENOENT.Reported-by Hyungwoo Yang <[email protected]>Fixes ("device property: Align return codes of __acpi_node_get_property_reference")Signed-off-by Sakari Ailus <[email protected]>Tested-by Hyungwoo Yang <[email protected]>---
since v1:- Remove the ugly switch from
acpi_data_get_property()return value handling. Only-EINVALand-EPROTOare returned by the function.drivers/acpi/property.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/acpi/property.c +2
-2@@ -593,7 +593,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ret =acpi_data_get_property (data, propname,ACPI_TYPE_ANY , &obj);if (ret) -return ret; +return ret == -EINVAL ? -ENOENT : -EINVAL ;/* * The simplest case is when the value is a single reference. Just @@ -605,7 +605,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ret =acpi_bus_get_device (obj->reference.handle, &device);if (ret) -return ret; +return ret == -ENODEV ? -EINVAL : ret; args->adev = device; args->nargs =0 ;@@ -621,8 +621,10 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,* The index argument is then used to determine which reference * the caller wants (along with the arguments).
drivers/acpi/property.c int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, · line 630
Quoted 10 lines
drivers/acpi/property.c +4
-2*/ -if (obj->type !=ACPI_TYPE_PACKAGE || index >= obj->package.count) -return -EPROTO ; +if (obj->type !=ACPI_TYPE_PACKAGE ) +return -EINVAL ; +if (index >= obj->package.count) +return -ENOENT ; element = obj->package.elements; end = element + obj->package.count;
Applied (along with the previous one), thanks!
Please double check my current linux-next branch, though, as I'm going to push this stuff to Linus tomorrow.