* [PATCH v2 4/8] mips: lemote 2f: Use cpufreq_for_each_entry macro for iteration
@ 2014-04-15 22:26 Stratos Karafotis
2014-04-21 23:01 ` [PATCH v4 " Stratos Karafotis
0 siblings, 1 reply; 2+ messages in thread
From: Stratos Karafotis @ 2014-04-15 22:26 UTC (permalink / raw)
To: Ralf Baechle, Viresh Kumar, Rafael J. Wysocki
Cc: John Crispin, Simon Horman, Paul Gortmaker, linux-mips, LKML
The cpufreq core now 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>
---
arch/mips/loongson/lemote-2f/clock.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c
index e1f427f..1eed38e 100644
--- a/arch/mips/loongson/lemote-2f/clock.c
+++ b/arch/mips/loongson/lemote-2f/clock.c
@@ -91,9 +91,9 @@ EXPORT_SYMBOL(clk_put);
int clk_set_rate(struct clk *clk, unsigned long rate)
{
+ struct cpufreq_frequency_table *pos;
int ret = 0;
int regval;
- int i;
if (likely(clk->ops && clk->ops->set_rate)) {
unsigned long flags;
@@ -106,22 +106,16 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
propagate_rate(clk);
- for (i = 0; loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END;
- i++) {
- if (loongson2_clockmod_table[i].frequency ==
- CPUFREQ_ENTRY_INVALID)
- continue;
- if (rate == loongson2_clockmod_table[i].frequency)
+ cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table)
+ if (rate == pos->frequency)
break;
- }
- if (rate != loongson2_clockmod_table[i].frequency)
+ if (rate != pos->frequency)
return -ENOTSUPP;
clk->rate = rate;
regval = LOONGSON_CHIPCFG0;
- regval = (regval & ~0x7) |
- (loongson2_clockmod_table[i].driver_data - 1);
+ regval = (regval & ~0x7) | (pos->driver_data - 1);
LOONGSON_CHIPCFG0 = regval;
return ret;
--
1.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v4 4/8] mips: lemote 2f: Use cpufreq_for_each_entry macro for iteration
2014-04-15 22:26 [PATCH v2 4/8] mips: lemote 2f: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
@ 2014-04-21 23:01 ` Stratos Karafotis
0 siblings, 0 replies; 2+ messages in thread
From: Stratos Karafotis @ 2014-04-21 23:01 UTC (permalink / raw)
To: Ralf Baechle, Viresh Kumar, Rafael J. Wysocki
Cc: John Crispin, Simon Horman, Paul Gortmaker, linux-mips, LKML,
linux-pm@vger.kernel.org
The cpufreq core now 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>
---
arch/mips/loongson/lemote-2f/clock.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c
index e1f427f..1eed38e 100644
--- a/arch/mips/loongson/lemote-2f/clock.c
+++ b/arch/mips/loongson/lemote-2f/clock.c
@@ -91,9 +91,9 @@ EXPORT_SYMBOL(clk_put);
int clk_set_rate(struct clk *clk, unsigned long rate)
{
+ struct cpufreq_frequency_table *pos;
int ret = 0;
int regval;
- int i;
if (likely(clk->ops && clk->ops->set_rate)) {
unsigned long flags;
@@ -106,22 +106,16 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
propagate_rate(clk);
- for (i = 0; loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END;
- i++) {
- if (loongson2_clockmod_table[i].frequency ==
- CPUFREQ_ENTRY_INVALID)
- continue;
- if (rate == loongson2_clockmod_table[i].frequency)
+ cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table)
+ if (rate == pos->frequency)
break;
- }
- if (rate != loongson2_clockmod_table[i].frequency)
+ if (rate != pos->frequency)
return -ENOTSUPP;
clk->rate = rate;
regval = LOONGSON_CHIPCFG0;
- regval = (regval & ~0x7) |
- (loongson2_clockmod_table[i].driver_data - 1);
+ regval = (regval & ~0x7) | (pos->driver_data - 1);
LOONGSON_CHIPCFG0 = regval;
return ret;
--
1.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-21 23:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-15 22:26 [PATCH v2 4/8] mips: lemote 2f: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
2014-04-21 23:01 ` [PATCH v4 " Stratos Karafotis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox