[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191113091336.5218-7-k.konieczny@samsung.com>
Date: Wed, 13 Nov 2019 10:13:35 +0100
From: Kamil Konieczny <k.konieczny@...sung.com>
To: k.konieczny@...sung.com
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
Chanwoo Choi <cw00.choi@...sung.com>,
Kamil Konieczny <k.konieczny@...tner.samsung.com>,
Krzysztof Kozlowski <krzk@...nel.org>,
Kyungmin Park <kyungmin.park@...sung.com>,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
Marek Szyprowski <m.szyprowski@...sung.com>,
MyungJoo Ham <myungjoo.ham@...sung.com>
Subject: [PATCH 6/7] devfreq: move transition statistics allocations to
set_freq_stats()
All users of [devm_]devfreq_add_device() don't set freq_table
nor max_state, and there is only one "struct devfreq_profile" per
every "struct devfreq", so move transition memory allocations to
function set_freq_stats() and initialize there other statistics fields.
Signed-off-by: Kamil Konieczny <k.konieczny@...sung.com>
---
drivers/devfreq/devfreq.c | 44 +++++++++++++++++----------------------
1 file changed, 19 insertions(+), 25 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 70533b787744..d79412b0de59 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -147,7 +147,26 @@ static int set_freq_table(struct devfreq *devfreq)
profile->freq_table[i] = freq;
}
+ profile->trans_table = devm_kzalloc(devfreq->dev.parent,
+ array3_size(sizeof(unsigned int),
+ count, count),
+ GFP_KERNEL);
+ if (!profile->trans_table)
+ goto err_no_mem;
+
+ profile->time_in_state = devm_kcalloc(devfreq->dev.parent, count,
+ sizeof(*profile->time_in_state),
+ GFP_KERNEL);
+ if (!profile->time_in_state)
+ goto err_no_mem;
+
+ profile->last_time = get_jiffies_64();
+ spin_lock_init(&profile->stats_lock);
+
return 0;
+err_no_mem:
+ profile->max_state = 0;
+ return -ENOMEM;
}
/**
@@ -694,30 +713,6 @@ struct devfreq *devfreq_add_device(struct device *dev,
goto err_out;
}
- profile->trans_table = devm_kzalloc(&devfreq->dev,
- array3_size(sizeof(unsigned int),
- profile->max_state,
- profile->max_state),
- GFP_KERNEL);
- if (!profile->trans_table) {
- mutex_unlock(&devfreq->lock);
- err = -ENOMEM;
- goto err_devfreq;
- }
-
- profile->time_in_state = devm_kcalloc(&devfreq->dev,
- profile->max_state,
- sizeof(*profile->time_in_state),
- GFP_KERNEL);
- if (!profile->time_in_state) {
- mutex_unlock(&devfreq->lock);
- err = -ENOMEM;
- goto err_devfreq;
- }
-
- profile->last_time = get_jiffies_64();
- spin_lock_init(&profile->stats_lock);
-
srcu_init_notifier_head(&devfreq->transition_notifier_list);
mutex_unlock(&devfreq->lock);
@@ -749,7 +744,6 @@ struct devfreq *devfreq_add_device(struct device *dev,
err_init:
mutex_unlock(&devfreq_list_lock);
-err_devfreq:
devfreq_remove_device(devfreq);
devfreq = NULL;
err_dev:
--
2.24.0
Powered by blists - more mailing lists