lkml.org 
[lkml]   [2019]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/7] devfreq: move transition statistics allocations to set_freq_stats()
Date
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@samsung.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
\
 
 \ /
  Last update: 2019-11-13 10:15    [W:0.221 / U:1.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site