mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									aa43953e86
								
							
						
					
					
						commit
						e121be784d
					
				
					 1 changed files with 50 additions and 51 deletions
				
			
		| 
						 | 
					@ -882,45 +882,10 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f
 | 
				
			||||||
	return &dn->fwnode;
 | 
						return &dn->fwnode;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					static int acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
 | 
				
			||||||
 * __acpi_node_get_property_reference - returns handle to the referenced object
 | 
										  const char *propname, const char *nargs_prop,
 | 
				
			||||||
 * @fwnode: Firmware node to get the property from
 | 
										  unsigned int args_count, unsigned int index,
 | 
				
			||||||
 * @propname: Name of the property
 | 
										  struct fwnode_reference_args *args)
 | 
				
			||||||
 * @index: Index of the reference to return
 | 
					 | 
				
			||||||
 * @num_args: Maximum number of arguments after each reference
 | 
					 | 
				
			||||||
 * @args: Location to store the returned reference with optional arguments
 | 
					 | 
				
			||||||
 *	  (may be NULL)
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Find property with @name, verifify that it is a package containing at least
 | 
					 | 
				
			||||||
 * one object reference and if so, store the ACPI device object pointer to the
 | 
					 | 
				
			||||||
 * target object in @args->adev.  If the reference includes arguments, store
 | 
					 | 
				
			||||||
 * them in the @args->args[] array.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * If there's more than one reference in the property value package, @index is
 | 
					 | 
				
			||||||
 * used to select the one to return.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * It is possible to leave holes in the property value set like in the
 | 
					 | 
				
			||||||
 * example below:
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Package () {
 | 
					 | 
				
			||||||
 *     "cs-gpios",
 | 
					 | 
				
			||||||
 *     Package () {
 | 
					 | 
				
			||||||
 *        ^GPIO, 19, 0, 0,
 | 
					 | 
				
			||||||
 *        ^GPIO, 20, 0, 0,
 | 
					 | 
				
			||||||
 *        0,
 | 
					 | 
				
			||||||
 *        ^GPIO, 21, 0, 0,
 | 
					 | 
				
			||||||
 *     }
 | 
					 | 
				
			||||||
 * }
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Calling this function with index %2 or index %3 return %-ENOENT. If the
 | 
					 | 
				
			||||||
 * property does not contain any more values %-ENOENT is returned. The NULL
 | 
					 | 
				
			||||||
 * entry must be single integer and preferably contain value %0.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Return: %0 on success, negative error code on failure.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 | 
					 | 
				
			||||||
	const char *propname, size_t index, size_t num_args,
 | 
					 | 
				
			||||||
	struct fwnode_reference_args *args)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const union acpi_object *element, *end;
 | 
						const union acpi_object *element, *end;
 | 
				
			||||||
	const union acpi_object *obj;
 | 
						const union acpi_object *obj;
 | 
				
			||||||
| 
						 | 
					@ -999,7 +964,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ret = acpi_get_ref_args(idx == index ? args : NULL,
 | 
								ret = acpi_get_ref_args(idx == index ? args : NULL,
 | 
				
			||||||
						acpi_fwnode_handle(device),
 | 
											acpi_fwnode_handle(device),
 | 
				
			||||||
						&element, end, num_args);
 | 
											&element, end, args_count);
 | 
				
			||||||
			if (ret < 0)
 | 
								if (ret < 0)
 | 
				
			||||||
				return ret;
 | 
									return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1017,7 +982,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ret = acpi_get_ref_args(idx == index ? args : NULL,
 | 
								ret = acpi_get_ref_args(idx == index ? args : NULL,
 | 
				
			||||||
						ref_fwnode, &element, end,
 | 
											ref_fwnode, &element, end,
 | 
				
			||||||
						num_args);
 | 
											args_count);
 | 
				
			||||||
			if (ret < 0)
 | 
								if (ret < 0)
 | 
				
			||||||
				return ret;
 | 
									return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1039,6 +1004,50 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return -ENOENT;
 | 
						return -ENOENT;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * __acpi_node_get_property_reference - returns handle to the referenced object
 | 
				
			||||||
 | 
					 * @fwnode: Firmware node to get the property from
 | 
				
			||||||
 | 
					 * @propname: Name of the property
 | 
				
			||||||
 | 
					 * @index: Index of the reference to return
 | 
				
			||||||
 | 
					 * @num_args: Maximum number of arguments after each reference
 | 
				
			||||||
 | 
					 * @args: Location to store the returned reference with optional arguments
 | 
				
			||||||
 | 
					 *	  (may be NULL)
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Find property with @name, verifify that it is a package containing at least
 | 
				
			||||||
 | 
					 * one object reference and if so, store the ACPI device object pointer to the
 | 
				
			||||||
 | 
					 * target object in @args->adev.  If the reference includes arguments, store
 | 
				
			||||||
 | 
					 * them in the @args->args[] array.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * If there's more than one reference in the property value package, @index is
 | 
				
			||||||
 | 
					 * used to select the one to return.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * It is possible to leave holes in the property value set like in the
 | 
				
			||||||
 | 
					 * example below:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Package () {
 | 
				
			||||||
 | 
					 *     "cs-gpios",
 | 
				
			||||||
 | 
					 *     Package () {
 | 
				
			||||||
 | 
					 *        ^GPIO, 19, 0, 0,
 | 
				
			||||||
 | 
					 *        ^GPIO, 20, 0, 0,
 | 
				
			||||||
 | 
					 *        0,
 | 
				
			||||||
 | 
					 *        ^GPIO, 21, 0, 0,
 | 
				
			||||||
 | 
					 *     }
 | 
				
			||||||
 | 
					 * }
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Calling this function with index %2 or index %3 return %-ENOENT. If the
 | 
				
			||||||
 | 
					 * property does not contain any more values %-ENOENT is returned. The NULL
 | 
				
			||||||
 | 
					 * entry must be single integer and preferably contain value %0.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Return: %0 on success, negative error code on failure.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
 | 
				
			||||||
 | 
									       const char *propname, size_t index,
 | 
				
			||||||
 | 
									       size_t num_args,
 | 
				
			||||||
 | 
									       struct fwnode_reference_args *args)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return acpi_fwnode_get_reference_args(fwnode, propname, NULL, index, num_args, args);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
 | 
					EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 | 
					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,
 | 
				
			||||||
				   val, nval);
 | 
									   val, nval);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					 | 
				
			||||||
acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
 | 
					 | 
				
			||||||
			       const char *prop, const char *nargs_prop,
 | 
					 | 
				
			||||||
			       unsigned int args_count, unsigned int index,
 | 
					 | 
				
			||||||
			       struct fwnode_reference_args *args)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return __acpi_node_get_property_reference(fwnode, prop, index,
 | 
					 | 
				
			||||||
						  args_count, args);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode)
 | 
					static const char *acpi_fwnode_get_name(const struct fwnode_handle *fwnode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct acpi_device *adev;
 | 
						const struct acpi_device *adev;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue