[PATCH v3 2/3] PCI/sysfs: Use runtime PM class macro for auto-cleanup
From: Rafael J. Wysocki
Date: Mon Sep 22 2025 - 11:33:23 EST
From: Takashi Iwai <tiwai@xxxxxxx>
Use the newly introduced class macro to simplify the code.
Also, add the proper error handling for the PM runtime get errors.
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Link: https://patch.msgid.link/20250919163147.4743-3-tiwai@xxxxxxx
[ rjw: Adjusted the subject and the name of the class ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
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;
+ CLASS(pm_runtime_get_active, pmdev)(dev);
+ if (IS_ERR(pmdev))
+ return -ENXIO;
if (sysfs_streq(buf, "default")) {
pci_init_reset_methods(pdev);