Skip to contentSkip to conversation

cpufreq: SPEAr: Make read-only array sys_clk_src static

PATCH Applied Colin Ian King 4 participants 6 messages Nov 3, 2022 – Nov 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: SPEAr: Make read-only array sys_clk_src static

Don't populate the read-only array sys_clk_src on the stack but instead make it static and add in a missing const. Also makes the object code a little smaller.

---
 drivers/cpufreq/spear-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/spear-cpufreq.c +1 -1
index 7d0d62a06bf3..c6fdf019dbde 100644
@@ -39,7 +39,7 @@ static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)
 	 * In SPEAr1340, cpu clk's parent sys clk can take input from
 	 * following sources
 	 */
-	const char *sys_clk_src[] = {
+	static const char * const sys_clk_src[] = {
 		"sys_syn_clk",
 		"pll1_clk",
 		"pll2_clk",
Signature · 1 line
2.38.1
maintainer
#1 lore raw
Quoted 14 lines · Colin Ian King

Don't populate the read-only array sys_clk_src on the stack but instead make it static and add in a missing const. Also makes the object code a little smaller.

---
 drivers/cpufreq/spear-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/spear-cpufreq.c +0 -0
index 7d0d62a06bf3..c6fdf019dbde 100644

drivers/cpufreq/spear-cpufreq.c static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq) · line 45

Quoted 8 lines
drivers/cpufreq/spear-cpufreq.c +1 -1
@@ -39,7 +39,7 @@ static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)
 	 * In SPEAr1340, cpu clk's parent sys clk can take input from
 	 * following sources
 	 */
-	const char *sys_clk_src[] = {
+	static const char * const sys_clk_src[] = {
 		"sys_syn_clk",
 		"pll1_clk",
 		"pll2_clk",

Same questions from longhaul patch apply here too.

Signature · 1 line
viresh
#2 lore raw
Quoted 10 lines · Viresh Kumar
Quoted 9 lines · Colin Ian King

Don't populate the read-only array sys_clk_src on the stack but instead make it static and add in a missing const. Also makes the object code a little smaller.

---
  drivers/cpufreq/spear-cpufreq.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/cpufreq/spear-cpufreq.c static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq) · line 45

Quoted 13 lines
drivers/cpufreq/spear-cpufreq.c +1 -1
index 7d0d62a06bf3..c6fdf019dbde 100644
@@ -39,7 +39,7 @@ static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)
  	 * In SPEAr1340, cpu clk's parent sys clk can take input from
  	 * following sources
  	 */
-	const char *sys_clk_src[] = {
+	static const char * const sys_clk_src[] = {
  		"sys_syn_clk",
  		"pll1_clk",
  		"pll2_clk",

Same questions from longhaul patch apply here too.

See answer in that patch :-)

But really, this is kind of basic C level stuff. I suggest reading K&R 2nd Edition, Section 4.6, last paragraph before exercise 4-11.

maintainer
#3 lore raw
Quoted 2 lines · Colin King (gmail)

But really, this is kind of basic C level stuff. I suggest reading K&R 2nd Edition, Section 4.6, last paragraph before exercise 4-11.

Yeah it is and I said this for the benefit of later readers of the commit log, who may not know the exact reason of the same:

"I am just looking for a valid answer in commit log".

Anyway, the patches look fine otherwise.

Signature · 1 line
viresh
maintainer Applied
#4 lore raw
In reply to Colin Ian King
Quoted 15 lines · Colin Ian King

Don't populate the read-only array sys_clk_src on the stack but instead make it static and add in a missing const. Also makes the object code a little smaller.

---
 drivers/cpufreq/spear-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/spear-cpufreq.c +0 -0
index 7d0d62a06bf3..c6fdf019dbde 100644

drivers/cpufreq/spear-cpufreq.c static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)

Quoted 9 lines
drivers/cpufreq/spear-cpufreq.c +1 -2
@@ -39,7 +39,7 @@ static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)
         * In SPEAr1340, cpu clk's parent sys clk can take input from
         * following sources
         */
-       const char *sys_clk_src[] = {
+       static const char * const sys_clk_src[] = {
                "sys_syn_clk",
                "pll1_clk",
                "pll2_clk",
--

Applied as 6.2 material, thanks!

#5 lore raw
In reply to Colin Ian King
Quoted 3 lines · Colin Ian King

Don't populate the read-only array sys_clk_src on the stack but instead make it static and add in a missing const. Also makes the object code a little smaller.

[]

drivers/cpufreq/spear-cpufreq.c

Quoted 1 line
drivers/cpufreq/spear-cpufreq.c +0 -0

[]

drivers/cpufreq/spear-cpufreq.c static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq) · line 45

Quoted 9 lines
drivers/cpufreq/spear-cpufreq.c +1 -1
@@ -39,7 +39,7 @@ static struct clk *spear1340_cpu_get_possible_parent(unsigned long newfreq)
 	 * In SPEAr1340, cpu clk's parent sys clk can take input from
 	 * following sources
 	 */
-	const char *sys_clk_src[] = {
+	static const char * const sys_clk_src[] = {
 		"sys_syn_clk",
 		"pll1_clk",
 		"pll2_clk",

sys_clk_src[2] isn't used and could be deleted with the pclk indices changed.

Dunno what happened to the > 500000000 && != 600000000 range.