ACPI: PCI: Introduce acpi_dev_get_pci_dev()

Some acpi_get_pci_dev() callers already have a struct ACPI device for
which they want to get the struct pci_dev pointer of the associated
PCI device, so they don't need to look for one.

For this reason, add acpi_dev_get_pci_dev() that will get a PCI device
for a given ACPI one (if possible) and turn acpi_get_pci_dev() into
a static inline helper passing the acpi_fetch_acpi_dev() return value
directly to acpi_dev_get_pci_dev().

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/3430928.44csPzL39Z@rafael.j.wysocki
This commit is contained in:
Rafael J. Wysocki
2026-07-21 16:59:46 +02:00
parent 5d42a19dac
commit 9d4f0ecb87
2 changed files with 18 additions and 13 deletions
+11 -11
View File
@@ -293,20 +293,20 @@ struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
EXPORT_SYMBOL_GPL(acpi_pci_find_root);
/**
* acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev
* @handle: the handle in question
* acpi_dev_get_pci_dev - Get a struct pci_dev for a given ACPI device
* @adev: Target ACPI device.
*
* Given an ACPI CA handle, the desired PCI device is located in the
* list of PCI devices.
* Find the PCI device associated with @adev, if any, and bump up its reference
* counter.
*
* If the device is found, its reference count is increased and this
* function returns a pointer to its data structure. The caller must
* decrement the reference count by calling pci_dev_put().
* If no device is found, %NULL is returned.
* Callers are responsible for dropping the PCI device reference obtained by
* this function.
*
* Return: The struct pci_dev pointer of a reference-counted PCI device on
* success or NULL on failure.
*/
struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
struct pci_dev *acpi_dev_get_pci_dev(struct acpi_device *adev)
{
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
struct acpi_device_physical_node *pn;
if (!adev)
@@ -323,7 +323,7 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
return NULL;
}
EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
EXPORT_SYMBOL_GPL(acpi_dev_get_pci_dev);
/**
* acpi_pci_osc_control_set - Request control of PCI root _OSC features.
+7 -2
View File
@@ -59,14 +59,19 @@ int acpi_pci_link_free_irq(acpi_handle handle);
struct pci_bus;
#ifdef CONFIG_PCI
struct pci_dev *acpi_get_pci_dev(acpi_handle);
struct pci_dev *acpi_dev_get_pci_dev(struct acpi_device *adev);
#else
static inline struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
static inline struct pci_dev *acpi_dev_get_pci_dev(struct acpi_device *adev)
{
return NULL;
}
#endif
static inline struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
{
return acpi_dev_get_pci_dev(acpi_fetch_acpi_dev(handle));
}
/* Arch-defined function to add a bus to the system */
struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root);