[PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()

Rafael J. Wysocki posted 1 patch 1 week, 3 days ago
drivers/acpi/pci_root.c |   10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
[PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()
Posted by Rafael J. Wysocki 1 week, 3 days ago
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>
---
 drivers/acpi/pci_root.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -307,24 +307,20 @@ struct pci_dev *acpi_get_pci_dev(acpi_ha
 {
 	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);
Re: [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()
Posted by Andy Shevchenko 1 week, 3 days ago
On Wed, Jul 15, 2026 at 05:15:02PM +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.

...

> -	mutex_lock(&adev->physical_node_lock);
> +	guard(mutex)(&adev->physical_node_lock);

This needs a cleanup.h to be included (yes, I see the current inclusion block
and it's a mess :-( ).

-- 
With Best Regards,
Andy Shevchenko