diff mbox series

hwmon: raspberrypi: add PM suspend/resume support

Message ID 20241202115832.33628-1-wahrenst@gmx.net (mailing list archive)
State Accepted
Headers show
Series hwmon: raspberrypi: add PM suspend/resume support | expand

Commit Message

Stefan Wahren Dec. 2, 2024, 11:58 a.m. UTC
Add suspend/resume handler in order to stop firmware polling
during s2idle. This was just waking-up the system without a real
benefit.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/hwmon/raspberrypi-hwmon.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

--
2.34.1

Comments

Guenter Roeck Dec. 3, 2024, 6:05 a.m. UTC | #1
On Mon, Dec 02, 2024 at 12:58:32PM +0100, Stefan Wahren wrote:
> Add suspend/resume handler in order to stop firmware polling
> during s2idle. This was just waking-up the system without a real
> benefit.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>

Applied.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
index 10ef1e1f9458..a2938881ccd2 100644
--- a/drivers/hwmon/raspberrypi-hwmon.c
+++ b/drivers/hwmon/raspberrypi-hwmon.c
@@ -128,10 +128,32 @@  static int rpi_hwmon_probe(struct platform_device *pdev)
 	return 0;
 }

+static int rpi_hwmon_suspend(struct device *dev)
+{
+	struct rpi_hwmon_data *data = dev_get_drvdata(dev);
+
+	cancel_delayed_work_sync(&data->get_values_poll_work);
+
+	return 0;
+}
+
+static int rpi_hwmon_resume(struct device *dev)
+{
+	struct rpi_hwmon_data *data = dev_get_drvdata(dev);
+
+	get_values_poll(&data->get_values_poll_work.work);
+
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(rpi_hwmon_pm_ops, rpi_hwmon_suspend,
+				rpi_hwmon_resume);
+
 static struct platform_driver rpi_hwmon_driver = {
 	.probe = rpi_hwmon_probe,
 	.driver = {
 		.name = "raspberrypi-hwmon",
+		.pm = pm_ptr(&rpi_hwmon_pm_ops),
 	},
 };
 module_platform_driver(rpi_hwmon_driver);