mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Konrad Dybcio <konrad.dybcio@somainline.org>
Cc: Caleb Connolly <caleb.connolly@linaro.org>,
	linux-arm-msm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [RFC 1/2] soc: qcom_stats: Add state container
Date: Thu, 18 Aug 2022 17:22:14 +0300	[thread overview]
Message-ID: <20220818142215.2282365-1-abel.vesa@linaro.org> (raw)

In order to allow the dynamic creation of debugfs subsystem entries,
the notifier and the notifier_block need to be stored in a per-subsystem
fashion. For that we need some kind of state container, so add it and group
everything related to the probing device into it.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
 drivers/soc/qcom/qcom_stats.c | 39 +++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c
index d6bfd1bbdc2a..fa30540b6583 100644
--- a/drivers/soc/qcom/qcom_stats.c
+++ b/drivers/soc/qcom/qcom_stats.c
@@ -68,6 +68,13 @@ struct appended_stats {
 	u32 reserved[3];
 };
 
+struct qcom_stats_priv {
+	struct device dev;
+	struct stats_data *data;
+	struct dentry *root;
+	const struct stats_config *config;
+};
+
 static void qcom_print_stats(struct seq_file *s, const struct sleep_stats *stat)
 {
 	u64 accumulated = stat->accumulated;
@@ -121,10 +128,13 @@ static int qcom_soc_sleep_stats_show(struct seq_file *s, void *unused)
 DEFINE_SHOW_ATTRIBUTE(qcom_soc_sleep_stats);
 DEFINE_SHOW_ATTRIBUTE(qcom_subsystem_sleep_stats);
 
-static void qcom_create_soc_sleep_stat_files(struct dentry *root, void __iomem *reg,
-					     struct stats_data *d,
-					     const struct stats_config *config)
+static void qcom_create_soc_sleep_stat_files(struct qcom_stats_priv *stats,
+						void __iomem *reg)
 {
+	struct dentry *root = stats->root;
+	struct stats_data *d = stats->data;
+	const struct stats_config *config = stats->config;
+
 	char stat_type[sizeof(u32) + 1] = {0};
 	size_t stats_offset = config->stats_offset;
 	u32 offset = 0, type;
@@ -167,10 +177,11 @@ static void qcom_create_soc_sleep_stat_files(struct dentry *root, void __iomem *
 	}
 }
 
-static void qcom_create_subsystem_stat_files(struct dentry *root,
-					     const struct stats_config *config)
+static void qcom_create_subsystem_stat_files(struct qcom_stats_priv *stats)
 {
 	const struct sleep_stats *stat;
+	const struct stats_config *config = stats->config;
+	struct dentry *root = stats->root;
 	int i;
 
 	if (!config->subsystem_stats_in_smem)
@@ -188,12 +199,17 @@ static void qcom_create_subsystem_stat_files(struct dentry *root,
 
 static int qcom_stats_probe(struct platform_device *pdev)
 {
+	struct qcom_stats_priv *stats = NULL;
 	void __iomem *reg;
 	struct dentry *root;
 	const struct stats_config *config;
 	struct stats_data *d;
 	int i;
 
+	stats = devm_kzalloc(&pdev->dev, sizeof(*stats), GFP_KERNEL);
+	if (!stats)
+		return -ENOMEM;
+
 	config = device_get_match_data(&pdev->dev);
 	if (!config)
 		return -ENODEV;
@@ -212,17 +228,22 @@ static int qcom_stats_probe(struct platform_device *pdev)
 
 	root = debugfs_create_dir("qcom_stats", NULL);
 
-	qcom_create_subsystem_stat_files(root, config);
-	qcom_create_soc_sleep_stat_files(root, reg, d, config);
+	stats->config = config;
+	stats->data = d;
+	stats->root = root;
+
+	qcom_create_subsystem_stat_files(stats);
+	qcom_create_soc_sleep_stat_files(stats, reg);
 
-	platform_set_drvdata(pdev, root);
+	platform_set_drvdata(pdev, stats);
 
 	return 0;
 }
 
 static int qcom_stats_remove(struct platform_device *pdev)
 {
-	struct dentry *root = platform_get_drvdata(pdev);
+	struct qcom_stats_priv *stats = platform_get_drvdata(pdev);
+	struct dentry *root = stats->root;
 
 	debugfs_remove_recursive(root);
 
-- 
2.34.1


             reply	other threads:[~2022-08-18 14:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 14:22 Abel Vesa [this message]
2022-08-18 14:22 ` [RFC 2/2] soc: qcom_stats: Add dynamic debugfs entries for subsystems Abel Vesa
2022-08-18 18:04   ` Abel Vesa
2022-08-23 11:47   ` Maulik Shah (mkshah)

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=20220818142215.2282365-1-abel.vesa@linaro.org \
    --to=abel.vesa@linaro.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=caleb.connolly@linaro.org \
    --cc=konrad.dybcio@somainline.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.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®