Re: [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
"Rafael J. Wysocki (Intel)" <[email protected]>
| Newsgroups | org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <CAJZ5v0iAJZ6zAexDiF8bGbTwuxQFPRV0+k820DQK62UN1J2Nsg@mail.gmail.com> |
On Wed, Jul 15, 2026 at 5:56 PM Andy Shevchenko <[email protected]> wrote: > > On Wed, Jul 15, 2026 at 05:16:19PM +0200, Rafael J. Wysocki wrote: > > > 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(). > > ... > > > /** > > - * 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. > > + * Get the first PCI device associated with @adev, if present, and bump up its > > What is the meaning of the "first PCI device" in terms of ACPI specification (and > implementation in the Linux kernel)? I think it's impossible case to have more > than one object to be a companion to a PCI device. Am I wrong? The ACPI specification is kind of agnostic to that. In the kernel, there can be multiple physical devices associated with one ACPI device object, but I agree that every PCI device has at most one ACPI companion. I'll drop the word "first" from this comment. > > + * 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. > > */ > > --