Re: [PATCH v2 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()
From: Ilpo Järvinen
Date: Mon Jul 20 2026 - 06:23:14 EST
On Thu, 16 Jul 2026, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
>
> Use a mutex guard in acpi_get_pci_dev() for the physical_node_lock
> locking and drop local variable pci_dev that becomes redundant after
> that change.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> ---
>
> v1 -> v2:
> * Add cleanup.h include to pci_root.c (Andy)
>
> ---
> drivers/acpi/pci_root.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 4c06c3ffd0cb..d0dafc38b0cf 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -8,6 +8,7 @@
>
> #define pr_fmt(fmt) "ACPI: " fmt
>
> +#include <linux/cleanup.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/init.h>
> @@ -307,24 +308,20 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
> {
> struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
> struct acpi_device_physical_node *pn;
> - struct pci_dev *pci_dev = NULL;
>
> if (!adev)
> return NULL;
>
> - mutex_lock(&adev->physical_node_lock);
> + guard(mutex)(&adev->physical_node_lock);
>
> list_for_each_entry(pn, &adev->physical_node_list, node) {
> if (dev_is_pci(pn->dev)) {
> get_device(pn->dev);
> - pci_dev = to_pci_dev(pn->dev);
> - break;
> + return to_pci_dev(pn->dev);
> }
> }
>
> - mutex_unlock(&adev->physical_node_lock);
> -
> - return pci_dev;
> + return NULL;
> }
> EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
--
i.