From 160348d634389f496695541d76d3c64599fb88fc Mon Sep 17 00:00:00 2001 From: Jonghwa Lee Date: Mon, 3 Aug 2015 19:17:16 +0900 Subject: thermal: devfreq_cooling: Return the max cooling state correctly. After initialization with prebuilt opp table, max_state value is not correct. This patch fixes it. Signed-off-by: Jonghwa Lee --- drivers/thermal/devfreq_cooling.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index 4c36684b019e..fb2c0654fa7d 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -188,6 +188,8 @@ __devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq) } rcu_read_unlock(); + devfreq_dev->max_state -= 1; + /* * Use the freq_table of devfreq_dev_profile structure * if the devfreq_dev_profile includes already filled frequency table. @@ -200,13 +202,12 @@ __devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq) /* Allocate the frequency table and fill it */ rcu_read_lock(); devfreq_dev->freq_table = kzalloc(sizeof(*devfreq_dev->freq_table) * - devfreq_dev->max_state, GFP_KERNEL); + devfreq_dev->max_state + 1, GFP_KERNEL); if (!devfreq_dev->freq_table) { rcu_read_unlock(); cool_dev = ERR_PTR(-ENOMEM); goto free_cdev; } - devfreq_dev->max_state -= 1; freq = ULONG_MAX; for (i = 0; i <= devfreq_dev->max_state; i++, freq--) { -- cgit v1.2.3