* [PATCH][V2] cpufreq: longhaul: Make array speeds static const
@ 2022-11-03 15:04 Colin Ian King
2022-11-03 18:14 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2022-11-03 15:04 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, linux-pm; +Cc: kernel-janitors, linux-kernel
Don't populate the read-only array speeds on the stack but instead
make it static. Also makes the object code a little smaller. Replace
hard-coded loop array bounds with ARRAY_SIZE.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
V2: replace 4 with ARRAY_SIZE in for-loop as suggested by Joe Perches.
---
drivers/cpufreq/longhaul.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 3e000e1a75c6..4c57c6725c13 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -407,10 +407,10 @@ static int guess_fsb(int mult)
{
int speed = cpu_khz / 1000;
int i;
- int speeds[] = { 666, 1000, 1333, 2000 };
+ static const int speeds[] = { 666, 1000, 1333, 2000 };
int f_max, f_min;
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < ARRAY_SIZE(speeds); i++) {
f_max = ((speeds[i] * mult) + 50) / 100;
f_max += (ROUNDING / 2);
f_min = f_max - ROUNDING;
--
2.38.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][V2] cpufreq: longhaul: Make array speeds static const
2022-11-03 15:04 [PATCH][V2] cpufreq: longhaul: Make array speeds static const Colin Ian King
@ 2022-11-03 18:14 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2022-11-03 18:14 UTC (permalink / raw)
To: Colin Ian King
Cc: Rafael J . Wysocki, Viresh Kumar, linux-pm, kernel-janitors,
linux-kernel
On Thu, Nov 3, 2022 at 4:04 PM Colin Ian King <colin.i.king@gmail.com> wrote:
>
> Don't populate the read-only array speeds on the stack but instead
> make it static. Also makes the object code a little smaller. Replace
> hard-coded loop array bounds with ARRAY_SIZE.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> V2: replace 4 with ARRAY_SIZE in for-loop as suggested by Joe Perches.
> ---
> drivers/cpufreq/longhaul.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
> index 3e000e1a75c6..4c57c6725c13 100644
> --- a/drivers/cpufreq/longhaul.c
> +++ b/drivers/cpufreq/longhaul.c
> @@ -407,10 +407,10 @@ static int guess_fsb(int mult)
> {
> int speed = cpu_khz / 1000;
> int i;
> - int speeds[] = { 666, 1000, 1333, 2000 };
> + static const int speeds[] = { 666, 1000, 1333, 2000 };
> int f_max, f_min;
>
> - for (i = 0; i < 4; i++) {
> + for (i = 0; i < ARRAY_SIZE(speeds); i++) {
> f_max = ((speeds[i] * mult) + 50) / 100;
> f_max += (ROUNDING / 2);
> f_min = f_max - ROUNDING;
> --
Applied as 6.2 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-03 18:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 15:04 [PATCH][V2] cpufreq: longhaul: Make array speeds static const Colin Ian King
2022-11-03 18:14 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®