cpufreq: highbank: do not initialize array with a loop
PATCH 1/1 cpufreq: highbank: do not initialize array with a loop
As uninitialized array members will be initialized to zero, we can avoid using a for loop by setting a value to it.
---
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(-)
drivers/cpufreq/highbank-cpufreq.c +1 -5
@@ -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); }
Signature · 7 lines
1.8.2.rc0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Viresh Kumar
maintainerQuoted 16 lines · 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 <[email protected]>---
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(-)drivers/cpufreq/highbank-cpufreq.c +0
-0
drivers/cpufreq/highbank-cpufreq.c line 33
Quoted 9 lines
drivers/cpufreq/highbank-cpufreq.c +1
-3@@ -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};
Quoted 13 lines
drivers/cpufreq/highbank-cpufreq.c +0
-3-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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello,
Quoted 24 lines · Viresh Kumar
Quoted 23 lines · 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 <[email protected]>---
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(-)drivers/cpufreq/highbank-cpufreq.c +1
-2@@ -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 };
Quoted 9 lines
drivers/cpufreq/highbank-cpufreq.c line 33
Quoted 2 lines
drivers/cpufreq/highbank-cpufreq.c +0
-1- 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
PATCH v2 1/1 cpufreq: highbank: do not initialize array with a loop
In reply to Emilio LópezAs uninitialized array members will be initialized to zero, we can avoid using a for loop by setting a value to it.
---
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(-)
drivers/cpufreq/highbank-cpufreq.c +1 -7
@@ -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); }
Signature · 1 line
1.8.2.rc0
Quoted 21 lines · 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 <[email protected]>---
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 Kumardrivers/cpufreq/highbank-cpufreq.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/cpufreq/highbank-cpufreq.c +0
-0@@ -28,13 +28,7 @@
drivers/cpufreq/highbank-cpufreq.c line 31
Quoted 10 lines
drivers/cpufreq/highbank-cpufreq.c +1
-7static 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:
Quoted 3 lines
drivers/cpufreq/highbank-cpufreq.c +0
-0return pl320_ipc_transmit (msg); }
Quoted 25 lines · 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 <[email protected]>---
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 Kumardrivers/cpufreq/highbank-cpufreq.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/cpufreq/highbank-cpufreq.c +0
-1@@ -28,13 +28,7 @@static int hb_voltage_change (unsigned int freq) { -int i;
drivers/cpufreq/highbank-cpufreq.c line 34
Quoted 10 lines
drivers/cpufreq/highbank-cpufreq.c +1
-6-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.
--Mark Langsdorf
Calxeda, Inc.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel