diff mbox series

[2/6] ACPI: bus: Add iterator for dependent devices

Message ID 20220216225304.53911-3-djrscally@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Add multiple-consumer support to int3472-tps68470 driver | expand

Commit Message

Daniel Scally Feb. 16, 2022, 10:53 p.m. UTC
Add a helper macro to iterate over ACPI devices that are flagged
as consumers of an initial supplier ACPI device.

Signed-off-by: Daniel Scally <djrscally@gmail.com>
---
 include/acpi/acpi_bus.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Hans de Goede Feb. 21, 2022, 9:52 a.m. UTC | #1
Hi,

On 2/16/22 23:53, Daniel Scally wrote:
> Add a helper macro to iterate over ACPI devices that are flagged
> as consumers of an initial supplier ACPI device.
> 
> Signed-off-by: Daniel Scally <djrscally@gmail.com>
> ---
>  include/acpi/acpi_bus.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 8b06fef04722..72103bcdd5b3 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -723,6 +723,18 @@ bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
>  struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,
>  						   struct acpi_device *start);
>  struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier);
> +
> +/**
> + * for_each_acpi_consumer_dev - iterate over the consumer ACPI devices for a
> + *				given supplier
> + * @supplier: Pointer to the supplier's ACPI device
> + * @consumer: Pointer to &struct acpi_device to hold the consumer, initially NULL
> + */
> +#define for_each_acpi_consumer_dev(supplier, consumer)			\
> +	for (consumer = acpi_dev_get_first_consumer_dev(supplier);	\

If we drop acpi_dev_get_first_consumer_dev() this needs to be updated to:

	for (consumer = acpi_dev_get_next_consumer_dev(supplier, NULL);  \

Otherwise this looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans

> +	     consumer;							\
> +	     consumer = acpi_dev_get_next_consumer_dev(supplier, consumer))
> +
>  struct acpi_device *
>  acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv);
>  struct acpi_device *
diff mbox series

Patch

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 8b06fef04722..72103bcdd5b3 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -723,6 +723,18 @@  bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
 struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,
 						   struct acpi_device *start);
 struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier);
+
+/**
+ * for_each_acpi_consumer_dev - iterate over the consumer ACPI devices for a
+ *				given supplier
+ * @supplier: Pointer to the supplier's ACPI device
+ * @consumer: Pointer to &struct acpi_device to hold the consumer, initially NULL
+ */
+#define for_each_acpi_consumer_dev(supplier, consumer)			\
+	for (consumer = acpi_dev_get_first_consumer_dev(supplier);	\
+	     consumer;							\
+	     consumer = acpi_dev_get_next_consumer_dev(supplier, consumer))
+
 struct acpi_device *
 acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv);
 struct acpi_device *