From: Armin Wolf <W_Armin@gmx.de>
To: rafael@kernel.org, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/6] ACPI: fan: Use platform device for devres-related actions
Date: Wed, 8 Oct 2025 01:41:46 +0200 [thread overview]
Message-ID: <20251007234149.2769-4-W_Armin@gmx.de> (raw)
In-Reply-To: <20251007234149.2769-1-W_Armin@gmx.de>
Device-managed resources are cleaned up when the driver unbinds from
the underlying device. In our case this is the platform device as this
driver is a platform driver. Registering device-managed resources on
the associated ACPI device will thus result in a resource leak when
this driver unbinds.
Ensure that any device-managed resources are only registered on the
platform device to ensure that they are cleaned up during removal.
Fixes: 35c50d853adc ("ACPI: fan: Add hwmon support")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/acpi/fan.h | 4 ++--
drivers/acpi/fan_core.c | 2 +-
drivers/acpi/fan_hwmon.c | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/fan.h b/drivers/acpi/fan.h
index 022bc215cdbc..0d73433c3889 100644
--- a/drivers/acpi/fan.h
+++ b/drivers/acpi/fan.h
@@ -98,9 +98,9 @@ int acpi_fan_create_attributes(struct acpi_device *device);
void acpi_fan_delete_attributes(struct acpi_device *device);
#if IS_REACHABLE(CONFIG_HWMON)
-int devm_acpi_fan_create_hwmon(struct acpi_device *device);
+int devm_acpi_fan_create_hwmon(struct device *dev);
#else
-static inline int devm_acpi_fan_create_hwmon(struct acpi_device *device) { return 0; };
+static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
#endif
#endif
diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c
index ea2c646c470c..46e7fe7a506d 100644
--- a/drivers/acpi/fan_core.c
+++ b/drivers/acpi/fan_core.c
@@ -347,7 +347,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
}
if (fan->has_fst) {
- result = devm_acpi_fan_create_hwmon(device);
+ result = devm_acpi_fan_create_hwmon(&pdev->dev);
if (result)
return result;
diff --git a/drivers/acpi/fan_hwmon.c b/drivers/acpi/fan_hwmon.c
index 5581aa6fdfa0..47a02ef5a606 100644
--- a/drivers/acpi/fan_hwmon.c
+++ b/drivers/acpi/fan_hwmon.c
@@ -162,12 +162,12 @@ static const struct hwmon_chip_info acpi_fan_hwmon_chip_info = {
.info = acpi_fan_hwmon_info,
};
-int devm_acpi_fan_create_hwmon(struct acpi_device *device)
+int devm_acpi_fan_create_hwmon(struct device *dev)
{
- struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_fan *fan = dev_get_drvdata(dev);
struct device *hdev;
- hdev = devm_hwmon_device_register_with_info(&device->dev, "acpi_fan", fan,
- &acpi_fan_hwmon_chip_info, NULL);
+ hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, &acpi_fan_hwmon_chip_info,
+ NULL);
return PTR_ERR_OR_ZERO(hdev);
}
--
2.39.5
next prev parent reply other threads:[~2025-10-07 23:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 23:41 [PATCH v2 0/6] ACPI fan _DSM support Armin Wolf
2025-10-07 23:41 ` [PATCH v2 1/6] ACPI: fan: Use ACPI handle when retrieving _FST Armin Wolf
2025-10-07 23:41 ` [PATCH v2 2/6] ACPI: fan: Workaround for 64-bit firmware bug Armin Wolf
2025-10-07 23:41 ` Armin Wolf [this message]
2025-10-23 19:03 ` [PATCH v2 3/6] ACPI: fan: Use platform device for devres-related actions Rafael J. Wysocki
2025-10-07 23:41 ` [PATCH v2 4/6] ACPI: fan: Add basic notification support Armin Wolf
2025-10-07 23:41 ` [PATCH v2 5/6] ACPI: fan: Add hwmon " Armin Wolf
2025-10-07 23:41 ` [PATCH v2 6/6] ACPI: fan: Add support for Microsoft fan extensions Armin Wolf
2025-10-22 21:41 ` [PATCH v2 0/6] ACPI fan _DSM support Armin Wolf
2025-10-23 9:59 ` Rafael J. Wysocki
2025-10-23 19:22 ` Rafael J. Wysocki
2025-10-23 20:13 ` Armin Wolf
2025-10-24 8:35 ` 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=20251007234149.2769-4-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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
all inboxes | Powered by JetHome®