linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/20] cpufreq: acpi-cpufreq: Use cpufreq_for_each_entry macro for iteration
@ 2014-04-14 21:08 Stratos Karafotis
  2014-04-15  5:32 ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Stratos Karafotis @ 2014-04-14 21:08 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar
  Cc: cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, 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/acpi-cpufreq.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 000e4e0..12a5750 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -213,7 +213,7 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
 
 static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
 {
-	int i;
+	struct cpufreq_frequency_table *pos;
 	struct acpi_processor_performance *perf;
 
 	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
@@ -223,11 +223,11 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
 
 	perf = data->acpi_data;
 
-	for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
-		if (msr == perf->states[data->freq_table[i].driver_data].status)
-			return data->freq_table[i].frequency;
+	cpufreq_for_each_entry(pos, data->freq_table) {
+		if (msr == perf->states[pos->driver_data].status)
+			return pos->frequency;
 	}
-	return data->freq_table[0].frequency;
+	return data->freq_table->frequency;
 }
 
 static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data)
-- 
1.9.0

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

* Re: [PATCH 02/20] cpufreq: acpi-cpufreq: Use cpufreq_for_each_entry macro for iteration
  2014-04-14 21:08 [PATCH 02/20] cpufreq: acpi-cpufreq: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
@ 2014-04-15  5:32 ` Viresh Kumar
  2014-04-15 11:00   ` Stratos Karafotis
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2014-04-15  5:32 UTC (permalink / raw)
  To: Stratos Karafotis
  Cc: Rafael J. Wysocki, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, LKML

On 15 April 2014 02:38, 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/acpi-cpufreq.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 000e4e0..12a5750 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -213,7 +213,7 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
>
>  static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
>  {
> -       int i;
> +       struct cpufreq_frequency_table *pos;
>         struct acpi_processor_performance *perf;
>
>         if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
> @@ -223,11 +223,11 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
>
>         perf = data->acpi_data;
>
> -       for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
> -               if (msr == perf->states[data->freq_table[i].driver_data].status)
> -                       return data->freq_table[i].frequency;
> +       cpufreq_for_each_entry(pos, data->freq_table) {
> +               if (msr == perf->states[pos->driver_data].status)
> +                       return pos->frequency;
>         }
> -       return data->freq_table[0].frequency;
> +       return data->freq_table->frequency;

This isn't a related change, isn't it? Also it make it less readable.
So probably
just leave it as is.

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

* Re: [PATCH 02/20] cpufreq: acpi-cpufreq: Use cpufreq_for_each_entry macro for iteration
  2014-04-15  5:32 ` Viresh Kumar
@ 2014-04-15 11:00   ` Stratos Karafotis
  0 siblings, 0 replies; 3+ messages in thread
From: Stratos Karafotis @ 2014-04-15 11:00 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, LKML

On 15/04/2014 08:32 πμ, Viresh Kumar wrote:
> On 15 April 2014 02:38, 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/acpi-cpufreq.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index 000e4e0..12a5750 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -213,7 +213,7 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
>>
>>  static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
>>  {
>> -       int i;
>> +       struct cpufreq_frequency_table *pos;
>>         struct acpi_processor_performance *perf;
>>
>>         if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
>> @@ -223,11 +223,11 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
>>
>>         perf = data->acpi_data;
>>
>> -       for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
>> -               if (msr == perf->states[data->freq_table[i].driver_data].status)
>> -                       return data->freq_table[i].frequency;
>> +       cpufreq_for_each_entry(pos, data->freq_table) {
>> +               if (msr == perf->states[pos->driver_data].status)
>> +                       return pos->frequency;
>>         }
>> -       return data->freq_table[0].frequency;
>> +       return data->freq_table->frequency;
> 
> This isn't a related change, isn't it? Also it make it less readable.
> So probably
> just leave it as is.
> 

I thought that since we use pointer notation it would be more clear.
But, I will change it according to your suggestion.


Stratos

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

end of thread, other threads:[~2014-04-15 11:00 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:08 [PATCH 02/20] cpufreq: acpi-cpufreq: Use cpufreq_for_each_entry macro for iteration Stratos Karafotis
2014-04-15  5:32 ` Viresh Kumar
2014-04-15 11:00   ` Stratos Karafotis

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).