Skip to content

Commit c343bc2

Browse files
Sakari Ailusrafaeljw
authored andcommitted
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: 3e3119d (device property: Introduce fwnode_property_get_reference_args) Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 5ab894a commit c343bc2

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

drivers/acpi/property.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,9 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
571571
* }
572572
* }
573573
*
574-
* Calling this function with index %2 return %-ENOENT and with index %3
575-
* returns the last entry. If the property does not contain any more values
576-
* %-ENODATA is returned. The NULL entry must be single integer and
577-
* preferably contain value %0.
574+
* Calling this function with index %2 or index %3 return %-ENOENT. If the
575+
* property does not contain any more values %-ENOENT is returned. The NULL
576+
* entry must be single integer and preferably contain value %0.
578577
*
579578
* Return: %0 on success, negative error code on failure.
580579
*/
@@ -590,7 +589,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
590589

591590
data = acpi_device_data_of_node(fwnode);
592591
if (!data)
593-
return -EINVAL;
592+
return -ENOENT;
594593

595594
ret = acpi_data_get_property(data, propname, ACPI_TYPE_ANY, &obj);
596595
if (ret)
@@ -635,7 +634,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
635634
ret = acpi_bus_get_device(element->reference.handle,
636635
&device);
637636
if (ret)
638-
return -ENODEV;
637+
return -EINVAL;
639638

640639
nargs = 0;
641640
element++;
@@ -649,11 +648,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
649648
else if (type == ACPI_TYPE_LOCAL_REFERENCE)
650649
break;
651650
else
652-
return -EPROTO;
651+
return -EINVAL;
653652
}
654653

655654
if (nargs > MAX_ACPI_REFERENCE_ARGS)
656-
return -EPROTO;
655+
return -EINVAL;
657656

658657
if (idx == index) {
659658
args->adev = device;
@@ -670,13 +669,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
670669
return -ENOENT;
671670
element++;
672671
} else {
673-
return -EPROTO;
672+
return -EINVAL;
674673
}
675674

676675
idx++;
677676
}
678677

679-
return -ENODATA;
678+
return -ENOENT;
680679
}
681680
EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
682681

drivers/base/property.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);
683683
* Caller is responsible to call fwnode_handle_put() on the returned
684684
* args->fwnode pointer.
685685
*
686+
* Returns: %0 on success
687+
* %-ENOENT when the index is out of bounds, the index has an empty
688+
* reference or the property was not found
689+
* %-EINVAL on parse error
686690
*/
687691
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
688692
const char *prop, const char *nargs_prop,

0 commit comments

Comments
 (0)