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@xxxxxxxxxx> --- 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