[PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers
From: Alexander Stein
Date: Wed Jan 10 2024 - 04:54:19 EST
If the registers shall be read from device, runtime resume it in order
to enable a possiblly attached power domain before accessing the device.
Signed-off-by: Alexander Stein <alexander.stein@xxxxxxxxxxxxxxx>
---
drivers/base/regmap/regmap-debugfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fb84cda92a753..063ede23173af 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -12,6 +12,7 @@
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/list.h>
+#include <linux/pm_runtime.h>
#include "internal.h"
@@ -233,6 +234,10 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
if (!buf)
return -ENOMEM;
+ ret = pm_runtime_resume_and_get(map->dev);
+ if (ret)
+ goto out_free;
+
regmap_calc_tot_len(map, buf, count);
/* Work out which register we're starting at */
@@ -277,6 +282,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
*ppos += buf_pos;
out:
+ pm_runtime_put(map->dev);
+out_free:
kfree(buf);
return ret;
}
--
2.34.1