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: Add support for nargs_prop in acpi_fwnode_get_reference_args()

Currently, ACPI does not support the use of a nargs_prop (e.g.,
associated with a reference in fwnode_property_get_reference_args().
Instead, ACPI expects the number of arguments (nargs) to be explicitly
passed or known.

This behavior diverges from Open Firmware (OF), which allows the use of
a #*-cells property in the referenced node to determine the number of
arguments. Since fwnode_property_get_reference_args() is a common
interface used across both OF and ACPI firmware paradigms, it is
desirable to have a unified calling convention that works seamlessly for
both.

Add the support for ACPI to parse a nargs_prop from the referenced
fwnode, aligning its behavior with the OF backend. This allows drivers
and subsystems using fwnode_property_get_reference_args() to work in a
firmware-agnostic way without having to hardcode or special-case
argument counts for ACPI.

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@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-16-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>

authored by

Sunil V L and committed by
Paul Walmsley
159c86f3 e121be78

+26 -5
+25 -4
drivers/acpi/property.c
··· 804 804 return NULL; 805 805 } 806 806 807 + static unsigned int acpi_fwnode_get_args_count(struct fwnode_handle *fwnode, 808 + const char *nargs_prop) 809 + { 810 + const struct acpi_device_data *data; 811 + const union acpi_object *obj; 812 + int ret; 813 + 814 + data = acpi_device_data_of_node(fwnode); 815 + if (!data) 816 + return 0; 817 + 818 + ret = acpi_data_get_property(data, nargs_prop, ACPI_TYPE_INTEGER, &obj); 819 + if (ret) 820 + return 0; 821 + 822 + return obj->integer.value; 823 + } 824 + 807 825 static int acpi_get_ref_args(struct fwnode_reference_args *args, 808 826 struct fwnode_handle *ref_fwnode, 827 + const char *nargs_prop, 809 828 const union acpi_object **element, 810 829 const union acpi_object *end, size_t num_args) 811 830 { 812 831 u32 nargs = 0, i; 832 + 833 + if (nargs_prop) 834 + num_args = acpi_fwnode_get_args_count(ref_fwnode, nargs_prop); 813 835 814 836 /* 815 837 * Assume the following integer elements are all args. Stop counting on ··· 983 961 return -EINVAL; 984 962 985 963 element++; 986 - 987 964 ret = acpi_get_ref_args(idx == index ? args : NULL, 988 965 acpi_fwnode_handle(device), 989 - &element, end, args_count); 966 + nargs_prop, &element, end, 967 + args_count); 990 968 if (ret < 0) 991 969 return ret; 992 970 ··· 1001 979 return -EINVAL; 1002 980 1003 981 element++; 1004 - 1005 982 ret = acpi_get_ref_args(idx == index ? args : NULL, 1006 - ref_fwnode, &element, end, 983 + ref_fwnode, nargs_prop, &element, end, 1007 984 args_count); 1008 985 if (ret < 0) 1009 986 return ret;
+1 -1
drivers/base/property.c
··· 578 578 * @prop: The name of the property 579 579 * @nargs_prop: The name of the property telling the number of 580 580 * arguments in the referred node. NULL if @nargs is known, 581 - * otherwise @nargs is ignored. Only relevant on OF. 581 + * otherwise @nargs is ignored. 582 582 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL. 583 583 * @index: Index of the reference, from zero onwards. 584 584 * @args: Result structure with reference and integer arguments.