Re: [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name()

From: Rafael J. Wysocki

Date: Thu Apr 30 2026 - 05:57:55 EST


On Thu, Apr 30, 2026 at 9:34 AM Bartosz Golaszewski
<bartosz.golaszewski@xxxxxxxxxxxxxxxx> wrote:
>
> Provide a helper allowing to locate an ACPI device by its name.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>

Acked-by: Rafael J. Wysocki (Intel) <rafael@xxxxxxxxxx>

> ---
> drivers/acpi/bus.c | 13 +++++++++++++
> include/linux/acpi.h | 7 +++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 2ec095e2009e40b0645f654fb051429e5679dc7c..5dd8459be03db4165bcb59943b94ea7db273ad7b 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -1181,6 +1181,19 @@ int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data)
> }
> EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev);
>
> +/**
> + * acpi_bus_find_device_by_name() - Locate an ACPI device by its name
> + * @name: Name of the device to match
> + *
> + * Returns:
> + * New reference to the matched device or NULL if the device can't be found.
> + */
> +struct device *acpi_bus_find_device_by_name(const char *name)
> +{
> + return bus_find_device_by_name(&acpi_bus_type, NULL, name);
> +}
> +EXPORT_SYMBOL_GPL(acpi_bus_find_device_by_name);
> +
> struct acpi_dev_walk_context {
> int (*fn)(struct acpi_device *, void *);
> void *data;
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 67effb91fa98373d7bf19be5ae3d8baa9328d6e1..10d6c6c11bdffcad14100601e104520366dfc30b 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -798,6 +798,8 @@ int acpi_get_local_u64_address(acpi_handle handle, u64 *addr);
> int acpi_get_local_address(acpi_handle handle, u32 *addr);
> const char *acpi_get_subsystem_id(acpi_handle handle);
>
> +struct device *acpi_bus_find_device_by_name(const char *name);
> +
> #ifdef CONFIG_ACPI_MRRM
> int acpi_mrrm_max_mem_region(void);
> #endif
> @@ -1106,6 +1108,11 @@ static inline const char *acpi_get_subsystem_id(acpi_handle handle)
> return ERR_PTR(-ENODEV);
> }
>
> +static inline struct device *acpi_bus_find_device_by_name(const char *name)
> +{
> + return NULL;
> +}
> +
> static inline int acpi_register_wakeup_handler(int wake_irq,
> bool (*wakeup)(void *context), void *context)
> {
>
> --
> 2.47.3
>