Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, Philipp Stanner <phasta@kernel.org>
Subject: [PATCH 2/3] PCI: Better document pcim_enable_device()
Date: Tue,  1 Dec 2026 13:29:51 +0100	[thread overview]
Message-ID: <20261201122951.904104-4-phasta@kernel.org> (raw)
In-Reply-To: <20261201122951.904104-2-phasta@kernel.org>

pcim_enable_device() enables a PCI device and registers a devres action
which will automatically disable the device in remove(). Users should
only use it if they want to fully rely on automatic resource management.

Unfortunately, users often get the function's purpose wrong and
intermingle it with manual calls to pci_disable_device() et al.

Better document what pcim_enable_device() is intended for and when it
should be used.

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/pci/devres.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c
index 9a085fb18100..afc7e966bb32 100644
--- a/drivers/pci/devres.c
+++ b/drivers/pci/devres.c
@@ -365,7 +365,11 @@ static void pcim_disable_device(void *pdev_raw)
  * Returns: 0 on success, negative error code on failure.
  *
  * Managed pci_enable_device(). Device will automatically be disabled on
- * driver detach.
+ * driver detach. You should only use this function in probe(), not in, e.g.,
+ * resume().
+ *
+ * If you need manual enabling and disabling, use pci_enable_device() paired
+ * with pci_disable_device(). Do not mix them with pcim_enable_device().
  */
 int pcim_enable_device(struct pci_dev *pdev)
 {
-- 
2.56.0


  parent reply	other threads:[~2026-12-01 12:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:29 [PATCH 0/3] PCI: Improve devres documentation Philipp Stanner
2026-12-01 12:29 ` [PATCH 1/3] PCI: Deprecate public devres reversal functions Philipp Stanner
2026-12-01 12:40   ` sashiko-bot
2026-12-01 12:29 ` Philipp Stanner [this message]
2026-12-01 12:29 ` [PATCH 3/3] PCI: Deprecate pcim_pin_device() Philipp Stanner
2026-12-01 12:40 ` [PATCH 0/3] PCI: Improve devres documentation sashiko-bot

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=20261201122951.904104-4-phasta@kernel.org \
    --to=phasta@kernel.org \
    --cc=bhelgaas@google.com \
    --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