linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 07/20] cpufreq: exynos: Use cpufreq_for_each_entry macro for iteration
@ 2014-04-14 21:09 Stratos Karafotis
  2014-04-15  5:39 ` Viresh Kumar
  0 siblings, 1 reply; 2+ 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/exynos-cpufreq.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99cfe2..0e19bce 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -28,18 +28,18 @@ static unsigned int locking_frequency;
 
 static int exynos_cpufreq_get_index(unsigned int freq)
 {
-	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
-	int index;
+	struct cpufreq_frequency_table *pos, *freq_table;
 
-	for (index = 0;
-		freq_table[index].frequency != CPUFREQ_TABLE_END; index++)
-		if (freq_table[index].frequency == freq)
+	freq_table = exynos_info->freq_table;
+	cpufreq_for_each_entry(pos, freq_table) {
+		if (pos->frequency == freq)
 			break;
+	}
 
-	if (freq_table[index].frequency == CPUFREQ_TABLE_END)
+	if (pos->frequency == CPUFREQ_TABLE_END)
 		return -EINVAL;
 
-	return index;
+	return pos - freq_table;
 }
 
 static int exynos_cpufreq_scale(unsigned int target_freq)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 07/20] cpufreq: exynos: Use cpufreq_for_each_entry macro for iteration
  2014-04-14 21:09 [PATCH 07/20] cpufreq: exynos: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
@ 2014-04-15  5:39 ` Viresh Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2014-04-15  5:39 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:
> 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/exynos-cpufreq.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index f99cfe2..0e19bce 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -28,18 +28,18 @@ static unsigned int locking_frequency;
>
>  static int exynos_cpufreq_get_index(unsigned int freq)
>  {
> -       struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
> -       int index;
> +       struct cpufreq_frequency_table *pos, *freq_table;
>
> -       for (index = 0;
> -               freq_table[index].frequency != CPUFREQ_TABLE_END; index++)
> -               if (freq_table[index].frequency == freq)
> +       freq_table = exynos_info->freq_table;

Keep it as it was, i.e. fill freq_table during its definition. If with
addition of
pos it is crossing 80 columns, then define pos in a separate line.

> +       cpufreq_for_each_entry(pos, freq_table) {
> +               if (pos->frequency == freq)
>                         break;
> +       }
>
> -       if (freq_table[index].frequency == CPUFREQ_TABLE_END)
> +       if (pos->frequency == CPUFREQ_TABLE_END)
>                 return -EINVAL;
>
> -       return index;
> +       return pos - freq_table;
>  }
>
>  static int exynos_cpufreq_scale(unsigned int target_freq)
> --
> 1.9.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-15  5:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-14 21:09 [PATCH 07/20] cpufreq: exynos: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
2014-04-15  5:39 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).