From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux PM <linux-pm@vger.kernel.org>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Bjorn Helgaas <helgaas@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>, LKML <linux-kernel@vger.kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
Alex Williamson <alex.williamson@redhat.com>,
Zhang Qilong <zhangqilong3@huawei.com>,
Ulf Hansson <ulf.hansson@linaro.org>, Frank Li <Frank.Li@nxp.com>,
Dhruva Gole <d-gole@ti.com>
Subject: [PATCH v4 2/3] PCI/sysfs: Use runtime PM guard macro for auto-cleanup
Date: Fri, 26 Sep 2025 18:24:05 +0200 [thread overview]
Message-ID: <2323750.iZASKD2KPV@rafael.j.wysocki> (raw)
In-Reply-To: <6196611.lOV4Wx5bFT@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Use the newly introduced pm_runtime_active_try guard to simplify
the code and add the proper error handling for PM runtime resume
errors.
Based on an earlier patch from Takashi Iwai <tiwai@suse.de> [1].
Link: https://patch.msgid.link/20250919163147.4743-3-tiwai@suse.de [1]
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v3 -> v4:
* Use ACQUIRE()/ACQUIRE_ERR() (Jonathan)
* Adjust subject and changelog
* Take patch ownership (it's all different now)
* Pick up Bjorn's ACK from v3 (Bjorn, please let me know if that's not OK)
v2 -> v3: No changes
v1 -> v2:
* Adjust the name of the class to handle the disabled runtime PM case
transparently (like the original code).
---
drivers/pci/pci-sysfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1475,8 +1475,9 @@ static ssize_t reset_method_store(struct
return count;
}
- pm_runtime_get_sync(dev);
- struct device *pmdev __free(pm_runtime_put) = dev;
+ ACQUIRE(pm_runtime_active_try, pm)(dev);
+ if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
+ return -ENXIO;
if (sysfs_streq(buf, "default")) {
pci_init_reset_methods(pdev);
next prev parent reply other threads:[~2025-09-26 16:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 15:40 [PATCH v4 0/3] PM: runtime: Auto-cleanup macros for runtime PM Rafael J. Wysocki
2025-09-26 15:47 ` [PATCH v4 1/3] PM: runtime: Add auto-cleanup macros for "resume and get" operations Rafael J. Wysocki
2025-09-26 19:48 ` dan.j.williams
2025-09-26 19:56 ` Rafael J. Wysocki
2025-09-29 13:24 ` Dhruva Gole
2025-09-26 16:24 ` Rafael J. Wysocki [this message]
2025-10-20 22:07 ` [PATCH v4 2/3] PCI/sysfs: Use runtime PM guard macro for auto-cleanup Farhan Ali
2025-10-21 12:44 ` Rafael J. Wysocki
2025-09-26 16:26 ` [PATCH v4 3/3] PM: runtime: Drop DEFINE_FREE() for pm_runtime_put() Rafael J. Wysocki
2025-09-26 16:48 ` Rafael J. Wysocki
2025-09-27 7:55 ` [PATCH v4 0/3] PM: runtime: Auto-cleanup macros for runtime PM Takashi Iwai
2025-09-29 11:15 ` Jonathan Cameron
2025-09-29 13:59 ` Rafael J. Wysocki
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=2323750.iZASKD2KPV@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=alex.williamson@redhat.com \
--cc=d-gole@ti.com \
--cc=helgaas@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=ulf.hansson@linaro.org \
--cc=zhangqilong3@huawei.com \
/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