From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Linux PCI <linux-pci@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Bjorn Helgaas <helgaas@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Hans de Goede <hansg@kernel.org>
Subject: [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
Date: Wed, 15 Jul 2026 17:16:19 +0200 [thread overview]
Message-ID: <1961532.tdWV9SEqCh@rafael.j.wysocki> (raw)
In-Reply-To: <5115219.31r3eYUQgx@rafael.j.wysocki>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
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>
---
drivers/acpi/pci_root.c | 22 +++++++++++-----------
include/acpi/acpi_drivers.h | 9 +++++++--
2 files changed, 18 insertions(+), 13 deletions(-)
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -292,20 +292,20 @@ struct acpi_pci_root *acpi_pci_find_root
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.
+ * Get the first PCI device associated with @adev, if present, 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)
@@ -322,7 +322,7 @@ struct pci_dev *acpi_get_pci_dev(acpi_ha
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.
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -59,14 +59,19 @@ int acpi_pci_link_free_irq(acpi_handle h
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);
next prev parent reply other threads:[~2026-07-15 15:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 15:13 [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:52 ` Andy Shevchenko
2026-07-15 15:16 ` Rafael J. Wysocki [this message]
2026-07-15 15:56 ` [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Andy Shevchenko
2026-07-15 16:33 ` Rafael J. Wysocki (Intel)
2026-07-15 15:19 ` [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
2026-07-15 15:57 ` Andy Shevchenko
2026-07-15 15:21 ` [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:59 ` Andy Shevchenko
2026-07-15 16:34 ` Rafael J. Wysocki (Intel)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1961532.tdWV9SEqCh@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hansg@kernel.org \
--cc=helgaas@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox