[04/11] ARM: sa1100: make cpufreq driver build standalone

Message ID 20221021155000.4108406-5-arnd@kernel.org
State New
Headers
Series ARM: sa1100, mmp: drop unused board files |

Commit Message

Arnd Bergmann Oct. 21, 2022, 3:49 p.m. UTC
  From: Arnd Bergmann <arnd@arndb.de>

Commit 59a2e613d07f ("cpufreq: sa11x0: move cpufreq driver
to drivers/cpufreq") added an unnecessary reference to
mach/generic.h. Just remove it again after moving the code
into the corresponding driver.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-sa1100/generic.c              | 32 ---------------------
 arch/arm/mach-sa1100/generic.h              |  4 ---
 arch/arm/mach-sa1100/include/mach/generic.h |  1 -
 drivers/cpufreq/sa1110-cpufreq.c            | 32 +++++++++++++++++++++
 4 files changed, 32 insertions(+), 37 deletions(-)
 delete mode 100644 arch/arm/mach-sa1100/include/mach/generic.h
  

Comments

Viresh Kumar Oct. 25, 2022, 5:07 a.m. UTC | #1
On 21-10-22, 17:49, Arnd Bergmann wrote:
> --- a/drivers/cpufreq/sa1110-cpufreq.c
> +++ b/drivers/cpufreq/sa1110-cpufreq.c
> @@ -29,6 +29,38 @@
>  
>  #undef DEBUG
>  
> +#define NR_FREQS	16
> +
> +/*
> + * This table is setup for a 3.6864MHz Crystal.
> + */
> +static struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = {
> +	{ .frequency = 59000,	/*  59.0 MHz */},
> +	{ .frequency = 73700,	/*  73.7 MHz */},
> +	{ .frequency = 88500,	/*  88.5 MHz */},
> +	{ .frequency = 103200,	/* 103.2 MHz */},
> +	{ .frequency = 118000,	/* 118.0 MHz */},
> +	{ .frequency = 132700,	/* 132.7 MHz */},
> +	{ .frequency = 147500,	/* 147.5 MHz */},
> +	{ .frequency = 162200,	/* 162.2 MHz */},
> +	{ .frequency = 176900,	/* 176.9 MHz */},
> +	{ .frequency = 191700,	/* 191.7 MHz */},
> +	{ .frequency = 206400,	/* 206.4 MHz */},
> +	{ .frequency = 221200,	/* 221.2 MHz */},
> +	{ .frequency = 235900,	/* 235.9 MHz */},
> +	{ .frequency = 250700,	/* 250.7 MHz */},
> +	{ .frequency = 265400,	/* 265.4 MHz */},
> +	{ .frequency = 280200,	/* 280.2 MHz */},
> +	{ .frequency = CPUFREQ_TABLE_END, },
> +};
> +
> +static unsigned int sa11x0_getspeed(unsigned int cpu)
> +{
> +	if (cpu)
> +		return 0;
> +	return sa11x0_freq_table[PPCR & 0xf].frequency;
> +}
> +
>  struct sdram_params {
>  	const char name[20];
>  	u_char  rows;		/* bits				 */

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
  
Russell King (Oracle) Oct. 25, 2022, 8:28 a.m. UTC | #2
On Fri, Oct 21, 2022 at 05:49:34PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Commit 59a2e613d07f ("cpufreq: sa11x0: move cpufreq driver
> to drivers/cpufreq") added an unnecessary reference to
> mach/generic.h. Just remove it again after moving the code
> into the corresponding driver.

So how does arch/arm/mach-sa1100/clock.c get the MPLL rate with this
change?
  
Arnd Bergmann Oct. 25, 2022, 10:14 a.m. UTC | #3
On Tue, Oct 25, 2022, at 10:28, Russell King (Oracle) wrote:
> On Fri, Oct 21, 2022 at 05:49:34PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> Commit 59a2e613d07f ("cpufreq: sa11x0: move cpufreq driver
>> to drivers/cpufreq") added an unnecessary reference to
>> mach/generic.h. Just remove it again after moving the code
>> into the corresponding driver.
>
> So how does arch/arm/mach-sa1100/clock.c get the MPLL rate with this
> change?

You are right, that's broken. It works for the defconfigs that
enable the cpufreq driver, but it seems I need to improve my
randconfig build testing to make sure I find problems like this
sooner.

I don't think anything depends on this patch, so I've dropped
it from my series now.

Thanks,

    Arnd
  
Russell King (Oracle) Oct. 25, 2022, 12:12 p.m. UTC | #4
On Tue, Oct 25, 2022 at 12:14:19PM +0200, Arnd Bergmann wrote:
> On Tue, Oct 25, 2022, at 10:28, Russell King (Oracle) wrote:
> > On Fri, Oct 21, 2022 at 05:49:34PM +0200, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >> 
> >> Commit 59a2e613d07f ("cpufreq: sa11x0: move cpufreq driver
> >> to drivers/cpufreq") added an unnecessary reference to
> >> mach/generic.h. Just remove it again after moving the code
> >> into the corresponding driver.
> >
> > So how does arch/arm/mach-sa1100/clock.c get the MPLL rate with this
> > change?
> 
> You are right, that's broken. It works for the defconfigs that
> enable the cpufreq driver,

Umm. How? I think your testing must be seriously flawed!

You add sa11x0_getspeed() to the sa1110 cpufreq driver as a static
function, which means it won't be visible to clock.c - and clock.c
is always built, and always references sa11x0_getspeed()... so you
should be getting an unconditional build failure at link time and
a compiler warning that sa11x0_getspeed() is not declared.

Are you not seeing that?
  

Patch

diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 6c21f214cd60..424f08eece20 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -39,38 +39,6 @@ 
 #include "generic.h"
 #include <clocksource/pxa.h>
 
-#define NR_FREQS	16
-
-/*
- * This table is setup for a 3.6864MHz Crystal.
- */
-struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = {
-	{ .frequency = 59000,	/*  59.0 MHz */},
-	{ .frequency = 73700,	/*  73.7 MHz */},
-	{ .frequency = 88500,	/*  88.5 MHz */},
-	{ .frequency = 103200,	/* 103.2 MHz */},
-	{ .frequency = 118000,	/* 118.0 MHz */},
-	{ .frequency = 132700,	/* 132.7 MHz */},
-	{ .frequency = 147500,	/* 147.5 MHz */},
-	{ .frequency = 162200,	/* 162.2 MHz */},
-	{ .frequency = 176900,	/* 176.9 MHz */},
-	{ .frequency = 191700,	/* 191.7 MHz */},
-	{ .frequency = 206400,	/* 206.4 MHz */},
-	{ .frequency = 221200,	/* 221.2 MHz */},
-	{ .frequency = 235900,	/* 235.9 MHz */},
-	{ .frequency = 250700,	/* 250.7 MHz */},
-	{ .frequency = 265400,	/* 265.4 MHz */},
-	{ .frequency = 280200,	/* 280.2 MHz */},
-	{ .frequency = CPUFREQ_TABLE_END, },
-};
-
-unsigned int sa11x0_getspeed(unsigned int cpu)
-{
-	if (cpu)
-		return 0;
-	return sa11x0_freq_table[PPCR & 0xf].frequency;
-}
-
 /*
  * Default power-off for SA1100
  */
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 158a4fd5ca24..cc891c57d306 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -4,7 +4,6 @@ 
  *
  * Author: Nicolas Pitre
  */
-#include <linux/cpufreq.h>
 #include <linux/reboot.h>
 
 extern void sa1100_timer_init(void);
@@ -21,9 +20,6 @@  extern void sa11x0_init_late(void);
 extern void sa1110_mb_enable(void);
 extern void sa1110_mb_disable(void);
 
-extern struct cpufreq_frequency_table sa11x0_freq_table[];
-extern unsigned int sa11x0_getspeed(unsigned int cpu);
-
 struct flash_platform_data;
 struct resource;
 
diff --git a/arch/arm/mach-sa1100/include/mach/generic.h b/arch/arm/mach-sa1100/include/mach/generic.h
deleted file mode 100644
index 665542e0c9e2..000000000000
--- a/arch/arm/mach-sa1100/include/mach/generic.h
+++ /dev/null
@@ -1 +0,0 @@ 
-#include "../../generic.h"
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c
index bb7f591a8b05..ce636c1147a6 100644
--- a/drivers/cpufreq/sa1110-cpufreq.c
+++ b/drivers/cpufreq/sa1110-cpufreq.c
@@ -29,6 +29,38 @@ 
 
 #undef DEBUG
 
+#define NR_FREQS	16
+
+/*
+ * This table is setup for a 3.6864MHz Crystal.
+ */
+static struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = {
+	{ .frequency = 59000,	/*  59.0 MHz */},
+	{ .frequency = 73700,	/*  73.7 MHz */},
+	{ .frequency = 88500,	/*  88.5 MHz */},
+	{ .frequency = 103200,	/* 103.2 MHz */},
+	{ .frequency = 118000,	/* 118.0 MHz */},
+	{ .frequency = 132700,	/* 132.7 MHz */},
+	{ .frequency = 147500,	/* 147.5 MHz */},
+	{ .frequency = 162200,	/* 162.2 MHz */},
+	{ .frequency = 176900,	/* 176.9 MHz */},
+	{ .frequency = 191700,	/* 191.7 MHz */},
+	{ .frequency = 206400,	/* 206.4 MHz */},
+	{ .frequency = 221200,	/* 221.2 MHz */},
+	{ .frequency = 235900,	/* 235.9 MHz */},
+	{ .frequency = 250700,	/* 250.7 MHz */},
+	{ .frequency = 265400,	/* 265.4 MHz */},
+	{ .frequency = 280200,	/* 280.2 MHz */},
+	{ .frequency = CPUFREQ_TABLE_END, },
+};
+
+static unsigned int sa11x0_getspeed(unsigned int cpu)
+{
+	if (cpu)
+		return 0;
+	return sa11x0_freq_table[PPCR & 0xf].frequency;
+}
+
 struct sdram_params {
 	const char name[20];
 	u_char  rows;		/* bits				 */