Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Sunil V L and committed by
Paul Walmsley
e121be78 aa43953e

+50 -51
+50 -51
drivers/acpi/property.c
··· 882 882 return &dn->fwnode; 883 883 } 884 884 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) 924 889 { 925 890 const union acpi_object *element, *end; 926 891 const union acpi_object *obj; ··· 964 999 965 1000 ret = acpi_get_ref_args(idx == index ? args : NULL, 966 1001 acpi_fwnode_handle(device), 967 - &element, end, num_args); 1002 + &element, end, args_count); 968 1003 if (ret < 0) 969 1004 return ret; 970 1005 ··· 982 1017 983 1018 ret = acpi_get_ref_args(idx == index ? args : NULL, 984 1019 ref_fwnode, &element, end, 985 - num_args); 1020 + args_count); 986 1021 if (ret < 0) 987 1022 return ret; 988 1023 ··· 1003 1038 } 1004 1039 1005 1040 return -ENOENT; 1041 + } 1042 + 1043 + /** 1044 + * __acpi_node_get_property_reference - returns handle to the referenced object 1045 + * @fwnode: Firmware node to get the property from 1046 + * @propname: Name of the property 1047 + * @index: Index of the reference to return 1048 + * @num_args: Maximum number of arguments after each reference 1049 + * @args: Location to store the returned reference with optional arguments 1050 + * (may be NULL) 1051 + * 1052 + * Find property with @name, verifify that it is a package containing at least 1053 + * one object reference and if so, store the ACPI device object pointer to the 1054 + * target object in @args->adev. If the reference includes arguments, store 1055 + * them in the @args->args[] array. 1056 + * 1057 + * If there's more than one reference in the property value package, @index is 1058 + * used to select the one to return. 1059 + * 1060 + * It is possible to leave holes in the property value set like in the 1061 + * example below: 1062 + * 1063 + * Package () { 1064 + * "cs-gpios", 1065 + * Package () { 1066 + * ^GPIO, 19, 0, 0, 1067 + * ^GPIO, 20, 0, 0, 1068 + * 0, 1069 + * ^GPIO, 21, 0, 0, 1070 + * } 1071 + * } 1072 + * 1073 + * Calling this function with index %2 or index %3 return %-ENOENT. If the 1074 + * property does not contain any more values %-ENOENT is returned. The NULL 1075 + * entry must be single integer and preferably contain value %0. 1076 + * 1077 + * Return: %0 on success, negative error code on failure. 1078 + */ 1079 + int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1080 + const char *propname, size_t index, 1081 + size_t num_args, 1082 + struct fwnode_reference_args *args) 1083 + { 1084 + return acpi_fwnode_get_reference_args(fwnode, propname, NULL, index, num_args, args); 1006 1085 } 1007 1086 EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference); 1008 1087 ··· 1565 1556 { 1566 1557 return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING, 1567 1558 val, nval); 1568 - } 1569 - 1570 - static int 1571 - acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, 1572 - const char *prop, const char *nargs_prop, 1573 - unsigned int args_count, unsigned int index, 1574 - struct fwnode_reference_args *args) 1575 - { 1576 - return __acpi_node_get_property_reference(fwnode, prop, index, 1577 - args_count, args); 1578 1559 } 1579 1560 1580 1561 static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode)