public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: highbank: do not initialize array with a loop
@ 2013-02-24 17:01 Emilio López
  2013-02-25  3:41 ` Viresh Kumar
  2013-02-25 11:07 ` [PATCH v2] " Emilio López
  0 siblings, 2 replies; 6+ messages in thread
From: Emilio López @ 2013-02-24 17:01 UTC (permalink / raw)
  To: rjw, shawn.guo, mark.langsdorf
  Cc: linux-arm-kernel, cpufreq, linux-pm, linux-kernel,
	Emilio López

As uninitialized array members will be initialized to zero, we can
avoid using a for loop by setting a value to it.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
---
Note that I don't own any device using this driver, it has only been compile
tested, but it shouldn't cause any issues.

 drivers/cpufreq/highbank-cpufreq.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
index 66e3a71..30d4ae1 100644
--- a/drivers/cpufreq/highbank-cpufreq.c
+++ b/drivers/cpufreq/highbank-cpufreq.c
@@ -28,13 +28,9 @@
 
 static int hb_voltage_change(unsigned int freq)
 {
-	int i;
-	u32 msg[HB_CPUFREQ_IPC_LEN];
+	u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE};
 
-	msg[0] = HB_CPUFREQ_CHANGE_NOTE;
 	msg[1] = freq / 1000000;
-	for (i = 2; i < HB_CPUFREQ_IPC_LEN; i++)
-		msg[i] = 0;
 
 	return pl320_ipc_transmit(msg);
 }
-- 
1.8.2.rc0


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

* Re: [PATCH] cpufreq: highbank: do not initialize array with a loop
  2013-02-24 17:01 [PATCH] cpufreq: highbank: do not initialize array with a loop Emilio López
@ 2013-02-25  3:41 ` Viresh Kumar
  2013-02-25 10:58   ` Emilio López
  2013-02-25 11:07 ` [PATCH v2] " Emilio López
  1 sibling, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2013-02-25  3:41 UTC (permalink / raw)
  To: Emilio López
  Cc: rjw, shawn.guo, mark.langsdorf, linux-kernel, cpufreq,
	linux-arm-kernel, linux-pm

On Sun, Feb 24, 2013 at 10:31 PM, Emilio López <emilio@elopez.com.ar> wrote:
> As uninitialized array members will be initialized to zero, we can
> avoid using a for loop by setting a value to it.
>
> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> ---
> Note that I don't own any device using this driver, it has only been compile
> tested, but it shouldn't cause any issues.
>
>  drivers/cpufreq/highbank-cpufreq.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
> index 66e3a71..30d4ae1 100644
> --- a/drivers/cpufreq/highbank-cpufreq.c
> +++ b/drivers/cpufreq/highbank-cpufreq.c
> @@ -28,13 +28,9 @@
>
>  static int hb_voltage_change(unsigned int freq)
>  {
> -       int i;
> -       u32 msg[HB_CPUFREQ_IPC_LEN];
> +       u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE};
>
> -       msg[0] = HB_CPUFREQ_CHANGE_NOTE;
>         msg[1] = freq / 1000000;

I think this can also be part of the definition of array, isn't it?

So it would be something like:

u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE, freq / 1000000};

> -       for (i = 2; i < HB_CPUFREQ_IPC_LEN; i++)
> -               msg[i] = 0;
>
>         return pl320_ipc_transmit(msg);
>  }
> --
> 1.8.2.rc0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] cpufreq: highbank: do not initialize array with a loop
  2013-02-25  3:41 ` Viresh Kumar
@ 2013-02-25 10:58   ` Emilio López
  0 siblings, 0 replies; 6+ messages in thread
From: Emilio López @ 2013-02-25 10:58 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rjw, shawn.guo, mark.langsdorf, linux-kernel, cpufreq,
	linux-arm-kernel, linux-pm

Hello,

El 25/02/13 00:41, Viresh Kumar escribió:
> On Sun, Feb 24, 2013 at 10:31 PM, Emilio López <emilio@elopez.com.ar> wrote:
>> As uninitialized array members will be initialized to zero, we can
>> avoid using a for loop by setting a value to it.
>>
>> Signed-off-by: Emilio López <emilio@elopez.com.ar>
>> ---
>> Note that I don't own any device using this driver, it has only been compile
>> tested, but it shouldn't cause any issues.
>>
>>  drivers/cpufreq/highbank-cpufreq.c | 6 +-----
>>  1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
>> index 66e3a71..30d4ae1 100644
>> --- a/drivers/cpufreq/highbank-cpufreq.c
>> +++ b/drivers/cpufreq/highbank-cpufreq.c
>> @@ -28,13 +28,9 @@
>>
>>  static int hb_voltage_change(unsigned int freq)
>>  {
>> -       int i;
>> -       u32 msg[HB_CPUFREQ_IPC_LEN];
>> +       u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE};
>>
>> -       msg[0] = HB_CPUFREQ_CHANGE_NOTE;
>>         msg[1] = freq / 1000000;
> 
> I think this can also be part of the definition of array, isn't it?
> 
> So it would be something like:
> 
> u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE, freq / 1000000};
> 

I incorrectly assumed that sparse would complain, but after testing I
see it doesn't. Thanks for pointing it out, I'll send a v2 in a minute.

Emilio

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

* [PATCH v2] cpufreq: highbank: do not initialize array with a loop
  2013-02-24 17:01 [PATCH] cpufreq: highbank: do not initialize array with a loop Emilio López
  2013-02-25  3:41 ` Viresh Kumar
@ 2013-02-25 11:07 ` Emilio López
  2013-02-25 11:12   ` Viresh Kumar
  2013-02-25 13:53   ` Mark Langsdorf
  1 sibling, 2 replies; 6+ messages in thread
From: Emilio López @ 2013-02-25 11:07 UTC (permalink / raw)
  To: viresh.kumar, rjw, shawn.guo, mark.langsdorf
  Cc: linux-arm-kernel, cpufreq, linux-pm, linux-kernel,
	Emilio López

As uninitialized array members will be initialized to zero, we can
avoid using a for loop by setting a value to it.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
---

Note that I don't own any device using this driver, it has only been compile
tested, but it shouldn't cause any issues.

Changes v1 -> v2:
  * Move freq / 1000000 to the array definition as suggested by Viresh Kumar

 drivers/cpufreq/highbank-cpufreq.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
index 66e3a71..b61b5a3 100644
--- a/drivers/cpufreq/highbank-cpufreq.c
+++ b/drivers/cpufreq/highbank-cpufreq.c
@@ -28,13 +28,7 @@
 
 static int hb_voltage_change(unsigned int freq)
 {
-	int i;
-	u32 msg[HB_CPUFREQ_IPC_LEN];
-
-	msg[0] = HB_CPUFREQ_CHANGE_NOTE;
-	msg[1] = freq / 1000000;
-	for (i = 2; i < HB_CPUFREQ_IPC_LEN; i++)
-		msg[i] = 0;
+	u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE, freq / 1000000};
 
 	return pl320_ipc_transmit(msg);
 }
-- 
1.8.2.rc0


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

* Re: [PATCH v2] cpufreq: highbank: do not initialize array with a loop
  2013-02-25 11:07 ` [PATCH v2] " Emilio López
@ 2013-02-25 11:12   ` Viresh Kumar
  2013-02-25 13:53   ` Mark Langsdorf
  1 sibling, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2013-02-25 11:12 UTC (permalink / raw)
  To: Emilio López
  Cc: rjw, shawn.guo, mark.langsdorf, linux-arm-kernel, cpufreq,
	linux-pm, linux-kernel

On Mon, Feb 25, 2013 at 4:37 PM, Emilio López <emilio@elopez.com.ar> wrote:
> As uninitialized array members will be initialized to zero, we can
> avoid using a for loop by setting a value to it.
>
> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> ---
>
> Note that I don't own any device using this driver, it has only been compile
> tested, but it shouldn't cause any issues.
>
> Changes v1 -> v2:
>   * Move freq / 1000000 to the array definition as suggested by Viresh Kumar
>
>  drivers/cpufreq/highbank-cpufreq.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
> index 66e3a71..b61b5a3 100644
> --- a/drivers/cpufreq/highbank-cpufreq.c
> +++ b/drivers/cpufreq/highbank-cpufreq.c
> @@ -28,13 +28,7 @@
>
>  static int hb_voltage_change(unsigned int freq)
>  {
> -       int i;
> -       u32 msg[HB_CPUFREQ_IPC_LEN];
> -
> -       msg[0] = HB_CPUFREQ_CHANGE_NOTE;
> -       msg[1] = freq / 1000000;
> -       for (i = 2; i < HB_CPUFREQ_IPC_LEN; i++)
> -               msg[i] = 0;
> +       u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE, freq / 1000000};

If you haven't crossed 80 width:

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

>
>         return pl320_ipc_transmit(msg);
>  }

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

* Re: [PATCH v2] cpufreq: highbank: do not initialize array with a loop
  2013-02-25 11:07 ` [PATCH v2] " Emilio López
  2013-02-25 11:12   ` Viresh Kumar
@ 2013-02-25 13:53   ` Mark Langsdorf
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Langsdorf @ 2013-02-25 13:53 UTC (permalink / raw)
  To: Emilio López
  Cc: viresh.kumar@linaro.org, rjw@sisk.pl, shawn.guo@linaro.org,
	linux-arm-kernel@lists.infradead.org, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org

On 02/25/2013 05:07 AM, Emilio López wrote:
> As uninitialized array members will be initialized to zero, we can
> avoid using a for loop by setting a value to it.
> 
> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> ---
> 
> Note that I don't own any device using this driver, it has only been compile
> tested, but it shouldn't cause any issues.
> 
> Changes v1 -> v2:
>   * Move freq / 1000000 to the array definition as suggested by Viresh Kumar
> 
>  drivers/cpufreq/highbank-cpufreq.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
> index 66e3a71..b61b5a3 100644
> --- a/drivers/cpufreq/highbank-cpufreq.c
> +++ b/drivers/cpufreq/highbank-cpufreq.c
> @@ -28,13 +28,7 @@
>  
>  static int hb_voltage_change(unsigned int freq)
>  {
> -	int i;
> -	u32 msg[HB_CPUFREQ_IPC_LEN];
> -
> -	msg[0] = HB_CPUFREQ_CHANGE_NOTE;
> -	msg[1] = freq / 1000000;
> -	for (i = 2; i < HB_CPUFREQ_IPC_LEN; i++)
> -		msg[i] = 0;
> +	u32 msg[HB_CPUFREQ_IPC_LEN] = {HB_CPUFREQ_CHANGE_NOTE, freq / 1000000};
>  
>  	return pl320_ipc_transmit(msg);
>  }
> 
Thanks for the improvement.

Acked-By: Mark Langsdorf <mark.langsdorf@calxeda.com>

--Mark Langsdorf
Calxeda, Inc.

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

end of thread, other threads:[~2013-02-25 13:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-24 17:01 [PATCH] cpufreq: highbank: do not initialize array with a loop Emilio López
2013-02-25  3:41 ` Viresh Kumar
2013-02-25 10:58   ` Emilio López
2013-02-25 11:07 ` [PATCH v2] " Emilio López
2013-02-25 11:12   ` Viresh Kumar
2013-02-25 13:53   ` Mark Langsdorf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox