Skip to content

Commit e121be7

Browse files
vlsunilPaul Walmsley
authored andcommitted
ACPI: property: Refactor acpi_fwnode_get_reference_args() to support nargs_prop
Currently, acpi_fwnode_get_reference_args() delegates to the internal function __acpi_node_get_property_reference() to retrieve property references. However, this function does not handle the nargs_prop (cells property) parameter, and instead expects the number of arguments (nargs) to be known or hardcoded. As a result, when fwnode_property_get_reference_args() is used with a valid nargs_prop, the ACPI backend ignores it, whereas the Device Tree (DT) backend uses the #*-cells property from the reference node to determine the number of arguments dynamically. To support the nargs_prop in ACPI, refactor the code as follows: - Move the implementation from __acpi_node_get_property_reference() into acpi_fwnode_get_reference_args(). - Update __acpi_node_get_property_reference() to call the (now updated) acpi_fwnode_get_reference_args() passing NULL as nargs_prop to keep the behavior of __acpi_node_get_property_reference() intact. Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Acked-by: Jassi Brar <jassisinghbrar@gmail.com> Link: https://lore.kernel.org/r/20250818040920.272664-15-apatel@ventanamicro.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent aa43953 commit e121be7

1 file changed

Lines changed: 50 additions & 51 deletions

File tree

drivers/acpi/property.c

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -882,45 +882,10 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f
882882
return &dn->fwnode;
883883
}
884884

885-
/**
886-
* __acpi_node_get_property_reference - returns handle to the referenced object
887-
* @fwnode: Firmware node to get the property from
888-
* @propname: Name of the property
889-
* @index: Index of the reference to return
890-
* @num_args: Maximum number of arguments after each reference
891-
* @args: Location to store the returned reference with optional arguments
892-
* (may be NULL)
893-
*
894-
* Find property with @name, verifify that it is a package containing at least
895-
* one object reference and if so, store the ACPI device object pointer to the
896-
* target object in @args->adev. If the reference includes arguments, store
897-
* them in the @args->args[] array.
898-
*
899-
* If there's more than one reference in the property value package, @index is
900-
* used to select the one to return.
901-
*
902-
* It is possible to leave holes in the property value set like in the
903-
* example below:
904-
*
905-
* Package () {
906-
* "cs-gpios",
907-
* Package () {
908-
* ^GPIO, 19, 0, 0,
909-
* ^GPIO, 20, 0, 0,
910-
* 0,
911-
* ^GPIO, 21, 0, 0,
912-
* }
913-
* }
914-
*
915-
* Calling this function with index %2 or index %3 return %-ENOENT. If the
916-
* property does not contain any more values %-ENOENT is returned. The NULL
917-
* entry must be single integer and preferably contain value %0.
918-
*
919-
* Return: %0 on success, negative error code on failure.
920-
*/
921-
int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
922-
const char *propname, size_t index, size_t num_args,
923-
struct fwnode_reference_args *args)
885+
static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
886+
const char *propname, const char *nargs_prop,
887+
unsigned int args_count, unsigned int index,
888+
struct fwnode_reference_args *args)
924889
{
925890
const union acpi_object *element, *end;
926891
const union acpi_object *obj;
@@ -999,7 +964,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
999964

1000965
ret = acpi_get_ref_args(idx == index ? args : NULL,
1001966
acpi_fwnode_handle(device),
1002-
&element, end, num_args);
967+
&element, end, args_count);
1003968
if (ret < 0)
1004969
return ret;
1005970

@@ -1017,7 +982,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1017982

1018983
ret = acpi_get_ref_args(idx == index ? args : NULL,
1019984
ref_fwnode, &element, end,
1020-
num_args);
985+
args_count);
1021986
if (ret < 0)
1022987
return ret;
1023988

@@ -1039,6 +1004,50 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
10391004

10401005
return -ENOENT;
10411006
}
1007+
1008+
/**
1009+
* __acpi_node_get_property_reference - returns handle to the referenced object
1010+
* @fwnode: Firmware node to get the property from
1011+
* @propname: Name of the property
1012+
* @index: Index of the reference to return
1013+
* @num_args: Maximum number of arguments after each reference
1014+
* @args: Location to store the returned reference with optional arguments
1015+
* (may be NULL)
1016+
*
1017+
* Find property with @name, verifify that it is a package containing at least
1018+
* one object reference and if so, store the ACPI device object pointer to the
1019+
* target object in @args->adev. If the reference includes arguments, store
1020+
* them in the @args->args[] array.
1021+
*
1022+
* If there's more than one reference in the property value package, @index is
1023+
* used to select the one to return.
1024+
*
1025+
* It is possible to leave holes in the property value set like in the
1026+
* example below:
1027+
*
1028+
* Package () {
1029+
* "cs-gpios",
1030+
* Package () {
1031+
* ^GPIO, 19, 0, 0,
1032+
* ^GPIO, 20, 0, 0,
1033+
* 0,
1034+
* ^GPIO, 21, 0, 0,
1035+
* }
1036+
* }
1037+
*
1038+
* Calling this function with index %2 or index %3 return %-ENOENT. If the
1039+
* property does not contain any more values %-ENOENT is returned. The NULL
1040+
* entry must be single integer and preferably contain value %0.
1041+
*
1042+
* Return: %0 on success, negative error code on failure.
1043+
*/
1044+
int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1045+
const char *propname, size_t index,
1046+
size_t num_args,
1047+
struct fwnode_reference_args *args)
1048+
{
1049+
return acpi_fwnode_get_reference_args(fwnode, propname, NULL, index, num_args, args);
1050+
}
10421051
EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
10431052

10441053
static int acpi_data_prop_read_single(const struct acpi_device_data *data,
@@ -1558,16 +1567,6 @@ acpi_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
15581567
val, nval);
15591568
}
15601569

1561-
static int
1562-
acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
1563-
const char *prop, const char *nargs_prop,
1564-
unsigned int args_count, unsigned int index,
1565-
struct fwnode_reference_args *args)
1566-
{
1567-
return __acpi_node_get_property_reference(fwnode, prop, index,
1568-
args_count, args);
1569-
}
1570-
15711570
static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode)
15721571
{
15731572
const struct acpi_device *adev;

0 commit comments

Comments
 (0)