mmc: core: fix the pointer cast of freq_table
The freq_table in devfreq_dev_profile is changed from
unsigned int to unsigned long. Fix the pointer cast here
by allocating a individual memory to pointer freq_table.
Change-Id: I2f7f17df0c3bd8de725daca1aa89572ce1911edd
Signed-off-by: Xiaonian Wang <xiaonian@codeaurora.org>
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 220ba6d..1397d03 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -617,12 +617,25 @@
}
out:
- clk_scaling->devfreq_profile.freq_table = (unsigned long *)clk_scaling->freq_table;
+ /**
+ * devfreq requires unsigned long type freq_table while the
+ * freq_table in clk_scaling is un32. Here allocates an individual
+ * memory space for it and release it when exit clock scaling.
+ */
+ clk_scaling->devfreq_profile.freq_table = kzalloc(
+ clk_scaling->freq_table_sz *
+ sizeof(*(clk_scaling->devfreq_profile.freq_table)),
+ GFP_KERNEL);
+ if (!clk_scaling->devfreq_profile.freq_table)
+ return -ENOMEM;
clk_scaling->devfreq_profile.max_state = clk_scaling->freq_table_sz;
- for (i = 0; i < clk_scaling->freq_table_sz; i++)
+ for (i = 0; i < clk_scaling->freq_table_sz; i++) {
+ clk_scaling->devfreq_profile.freq_table[i] =
+ clk_scaling->freq_table[i];
pr_debug("%s: freq[%d] = %u\n",
mmc_hostname(host), i, clk_scaling->freq_table[i]);
+ }
return 0;
}
@@ -858,6 +871,8 @@
return err;
}
+ kfree(host->clk_scaling.devfreq_profile.freq_table);
+
host->clk_scaling.devfreq = NULL;
atomic_set(&host->clk_scaling.devfreq_abort, 1);
pr_debug("%s: devfreq was removed\n", mmc_hostname(host));