* [PATCH 08/20] cpufreq: exynos5440: Use cpufreq_for_each_entry macro for iteration
@ 2014-04-14 21:09 Stratos Karafotis
2014-04-15 5:44 ` Viresh Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Stratos Karafotis @ 2014-04-14 21:09 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Kukjin Kim
Cc: cpufreq@vger.kernel.org, linux-pm@vger.kernel.org,
linux-arm-kernel, linux-samsung-soc, LKML
The cpufreq core supports the cpufreq_for_each_entry macro helper
for iteration over the cpufreq_frequency_table, so use it.
It should have no functional changes.
Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
---
drivers/cpufreq/exynos5440-cpufreq.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
index a6b8214..3e3dd0c 100644
--- a/drivers/cpufreq/exynos5440-cpufreq.c
+++ b/drivers/cpufreq/exynos5440-cpufreq.c
@@ -114,25 +114,23 @@ static struct cpufreq_freqs freqs;
static int init_div_table(void)
{
- struct cpufreq_frequency_table *freq_tbl = dvfs_info->freq_table;
+ struct cpufreq_frequency_table *pos, *freq_tbl = dvfs_info->freq_table;
unsigned int tmp, clk_div, ema_div, freq, volt_id;
- int i = 0;
struct dev_pm_opp *opp;
rcu_read_lock();
- for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) {
-
+ cpufreq_for_each_entry(pos, freq_tbl) {
opp = dev_pm_opp_find_freq_exact(dvfs_info->dev,
- freq_tbl[i].frequency * 1000, true);
+ pos->frequency * 1000, true);
if (IS_ERR(opp)) {
rcu_read_unlock();
dev_err(dvfs_info->dev,
"failed to find valid OPP for %u KHZ\n",
- freq_tbl[i].frequency);
+ pos->frequency);
return PTR_ERR(opp);
}
- freq = freq_tbl[i].frequency / 1000; /* In MHZ */
+ freq = pos->frequency / 1000; /* In MHZ */
clk_div = ((freq / CPU_DIV_FREQ_MAX) & P0_7_CPUCLKDEV_MASK)
<< P0_7_CPUCLKDEV_SHIFT;
clk_div |= ((freq / CPU_ATB_FREQ_MAX) & P0_7_ATBCLKDEV_MASK)
@@ -157,7 +155,8 @@ static int init_div_table(void)
tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT)
| ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT));
- __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i);
+ __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 *
+ (pos - freq_tbl));
}
rcu_read_unlock();
@@ -166,8 +165,9 @@ static int init_div_table(void)
static void exynos_enable_dvfs(unsigned int cur_frequency)
{
- unsigned int tmp, i, cpu;
+ unsigned int tmp, cpu;
struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;
+ struct cpufreq_frequency_table *pos;
/* Disable DVFS */
__raw_writel(0, dvfs_info->base + XMU_DVFS_CTRL);
@@ -182,15 +182,15 @@ static void exynos_enable_dvfs(unsigned int cur_frequency)
__raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN);
/* Set initial performance index */
- for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
- if (freq_table[i].frequency == cur_frequency)
+ cpufreq_for_each_entry(pos, freq_table) {
+ if (pos->frequency == cur_frequency)
break;
+ }
- if (freq_table[i].frequency == CPUFREQ_TABLE_END) {
+ if (pos->frequency == CPUFREQ_TABLE_END) {
dev_crit(dvfs_info->dev, "Boot up frequency not supported\n");
/* Assign the highest frequency */
- i = 0;
- cur_frequency = freq_table[i].frequency;
+ cur_frequency = freq_table->frequency;
}
dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ",
@@ -199,7 +199,7 @@ static void exynos_enable_dvfs(unsigned int cur_frequency)
for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) {
tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);
tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT);
- tmp |= (i << C0_3_PSTATE_NEW_SHIFT);
+ tmp |= ((pos - freq_table) << C0_3_PSTATE_NEW_SHIFT);
__raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);
}
--
1.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 08/20] cpufreq: exynos5440: Use cpufreq_for_each_entry macro for iteration
2014-04-14 21:09 [PATCH 08/20] cpufreq: exynos5440: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
@ 2014-04-15 5:44 ` Viresh Kumar
2014-04-15 11:02 ` Stratos Karafotis
0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2014-04-15 5:44 UTC (permalink / raw)
To: Stratos Karafotis
Cc: Rafael J. Wysocki, Kukjin Kim, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-samsung-soc, LKML
On 15 April 2014 02:39, Stratos Karafotis <stratosk@semaphore.gr> wrote:
> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
> static void exynos_enable_dvfs(unsigned int cur_frequency)
> {
> - unsigned int tmp, i, cpu;
> + unsigned int tmp, cpu;
> struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;
> + struct cpufreq_frequency_table *pos;
Merge above two.
> /* Disable DVFS */
> __raw_writel(0, dvfs_info->base + XMU_DVFS_CTRL);
>
> @@ -182,15 +182,15 @@ static void exynos_enable_dvfs(unsigned int cur_frequency)
> __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN);
>
> /* Set initial performance index */
> - for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
> - if (freq_table[i].frequency == cur_frequency)
> + cpufreq_for_each_entry(pos, freq_table) {
> + if (pos->frequency == cur_frequency)
> break;
> + }
>
> - if (freq_table[i].frequency == CPUFREQ_TABLE_END) {
> + if (pos->frequency == CPUFREQ_TABLE_END) {
> dev_crit(dvfs_info->dev, "Boot up frequency not supported\n");
> /* Assign the highest frequency */
> - i = 0;
> - cur_frequency = freq_table[i].frequency;
> + cur_frequency = freq_table->frequency;
First this is not readable enough and you introduced a bug here, see
below.
> }
>
> dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ",
> @@ -199,7 +199,7 @@ static void exynos_enable_dvfs(unsigned int cur_frequency)
> for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) {
> tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);
> tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT);
> - tmp |= (i << C0_3_PSTATE_NEW_SHIFT);
> + tmp |= ((pos - freq_table) << C0_3_PSTATE_NEW_SHIFT);
We used modified value of 'i' here earlier, i.e. 0 ..
> __raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4);
> }
>
> --
> 1.9.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 08/20] cpufreq: exynos5440: Use cpufreq_for_each_entry macro for iteration
2014-04-15 5:44 ` Viresh Kumar
@ 2014-04-15 11:02 ` Stratos Karafotis
0 siblings, 0 replies; 3+ messages in thread
From: Stratos Karafotis @ 2014-04-15 11:02 UTC (permalink / raw)
To: Viresh Kumar
Cc: Rafael J. Wysocki, Kukjin Kim, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-samsung-soc, LKML
On 15/04/2014 08:44 πμ, Viresh Kumar wrote:
> On 15 April 2014 02:39, Stratos Karafotis <stratosk@semaphore.gr> wrote:
>
>> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c
>
>> static void exynos_enable_dvfs(unsigned int cur_frequency)
>> {
>> - unsigned int tmp, i, cpu;
>> + unsigned int tmp, cpu;
>> struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;
>> + struct cpufreq_frequency_table *pos;
>
> Merge above two.
>
Then the line will be 82 characters long.
Do you mind to keep it as is?
Stratos
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-15 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-14 21:09 [PATCH 08/20] cpufreq: exynos5440: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
2014-04-15 5:44 ` Viresh Kumar
2014-04-15 11:02 ` Stratos Karafotis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox