drivers/acpi/pci_root.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
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@intel.com>
---
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);
--
2.51.0
On Thu, 16 Jul 2026, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> 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@intel.com>
> ---
>
> 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@linux.intel.com>
--
i.
On Thu, Jul 16, 2026 at 04:04:43PM +0200, Rafael J. Wysocki wrote: > 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. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> -- With Best Regards, Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.