2023-03-29 15:54:45

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 00/19] DT header disentangling, part 1

This is the first of a series of clean-ups to disentangle the DT
includes. There's a decade plus old comment in of_device.h:

#include <linux/of_platform.h> /* temporary until merge */

Who's this Grant person that wrote this? ;)

It gets better. of_device.h also pulls in of.h, and of_platform.h
includes of_device.h. So naturally, drivers include all combinations of
those 3 headers and sometimes they actually need them.

I started on fixing this years ago, but just dropping the circular
includes and fixing all the fallout was massive and didn't sit well.
Pulling in of_device.h in all the drivers that happen to call only
of_device_get_match_data/of_match_device didn't seem great when the rest
of of_device.h would never be needed. of_device.h being everything that
works on a struct device is not a great split because several types of
users deal with struct device. The better split seems to be by user
(subsys driver vs. consumer) which several subsystems now do. For
of_device.h, the users can primarily be split between bus
implementations and device drivers. Device drivers also typically need
of.h to read properties. So let's move of_device.h towards just bus
related functions and move device driver related functions to of.h.

This series is just the first step. It makes a couple of clean-ups to
replace some includes with forward declarations. It moves
of_device_get_match_data() and of_cpu_device_node_get() to of.h. The
former move is transparent for now and preparation for the next series.
The last part of the series updates drivers using
of_cpu_device_node_get() and/or relying on the implicit cpu.h include
which is removed in the last patch.

Signed-off-by: Rob Herring <[email protected]>
---
Rob Herring (19):
of: Make devtree_lock declaration private
of: Move of_device_(add|register|unregister) to of_platform.h
of: Move of_device_get_match_data() declaration
of: Move CPU node related functions to their own file
of: Drop unnecessary includes in headers
ARM: sunxi: Drop of_device.h include
ARM: cpuidle: Drop of_device.h include
riscv: Add explicit include for cpu.h
riscv: cacheinfo: Adjust includes to remove of_device.h
cacheinfo: Adjust includes to remove of_device.h
clocksource: ingenic: Add explicit include for cpuhotplug.h
thermal: cpuidle_cooling: Adjust includes to remove of_device.h
soc: mediatek: mtk-svs: Add explicit include for cpu.h
cpufreq: Adjust includes to remove of_device.h
cpufreq: sun50i: Add explicit include for cpu.h
cpuidle: Adjust includes to remove of_device.h
irqchip: loongson-eiointc: Add explicit include for cpuhotplug.h
OPP: Adjust includes to remove of_device.h
of: Drop cpu.h include from of_device.h

arch/arm/kernel/cpuidle.c | 1 -
arch/arm/mach-sunxi/mc_smp.c | 1 -
arch/riscv/kernel/cacheinfo.c | 1 -
arch/riscv/kernel/setup.c | 2 +-
arch/sparc/include/asm/prom.h | 3 +
drivers/base/cacheinfo.c | 2 +-
drivers/clocksource/ingenic-timer.c | 3 +-
drivers/cpufreq/cpufreq-dt-platdev.c | 1 -
drivers/cpufreq/kirkwood-cpufreq.c | 2 +-
drivers/cpufreq/maple-cpufreq.c | 2 +-
drivers/cpufreq/pmac32-cpufreq.c | 2 +-
drivers/cpufreq/pmac64-cpufreq.c | 2 +-
drivers/cpufreq/qcom-cpufreq-hw.c | 4 +-
drivers/cpufreq/spear-cpufreq.c | 2 +-
drivers/cpufreq/sun50i-cpufreq-nvmem.c | 3 +-
drivers/cpufreq/tegra124-cpufreq.c | 1 -
drivers/cpufreq/tegra20-cpufreq.c | 2 +-
drivers/cpuidle/cpuidle-psci.c | 1 -
drivers/cpuidle/cpuidle-qcom-spm.c | 3 +-
drivers/cpuidle/cpuidle-riscv-sbi.c | 2 +-
drivers/cpuidle/dt_idle_states.c | 1 -
drivers/irqchip/irq-loongson-eiointc.c | 5 +-
drivers/of/Makefile | 2 +-
drivers/of/base.c | 187 -----------------------------
drivers/of/cpu.c | 210 +++++++++++++++++++++++++++++++++
drivers/of/of_private.h | 1 +
drivers/opp/of.c | 2 +-
drivers/soc/mediatek/mtk-svs.c | 1 +
drivers/thermal/cpuidle_cooling.c | 3 +-
include/linux/cpufreq.h | 1 -
include/linux/of.h | 28 +++--
include/linux/of_device.h | 24 +---
include/linux/of_platform.h | 10 +-
33 files changed, 261 insertions(+), 254 deletions(-)
---
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230329-dt-cpu-header-cleanups-c7bed8c0b352

Best regards,
--
Rob Herring <[email protected]>


2023-03-29 15:54:45

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 17/19] irqchip: loongson-eiointc: Add explicit include for cpuhotplug.h

Removing the include of cpu.h from of_device.h causes an error:

drivers/irqchip/irq-loongson-eiointc.c:420:9: error: implicit declaration of function 'cpuhp_setup_state_nocalls' [-Werror=implicit-function-declaration]

This driver doesn't even use DT, so all the DT includes can be dropped.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/irqchip/irq-loongson-eiointc.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c
index d15fd38c1756..fd9d87f1470e 100644
--- a/drivers/irqchip/irq-loongson-eiointc.c
+++ b/drivers/irqchip/irq-loongson-eiointc.c
@@ -7,16 +7,13 @@

#define pr_fmt(fmt) "eiointc: " fmt

+#include <linux/cpuhotplug.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irqchip.h>
#include <linux/irqdomain.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
-#include <linux/of_platform.h>
#include <linux/syscore_ops.h>

#define EIOINTC_REG_NODEMAP 0x14a0

--
2.39.2

2023-03-29 15:54:52

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 10/19] cacheinfo: Adjust includes to remove of_device.h

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Update the
includes to use of.h instead of of_device.h.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/base/cacheinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index f6573c335f4c..a5f7a1063411 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -14,7 +14,7 @@
#include <linux/cpu.h>
#include <linux/device.h>
#include <linux/init.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/smp.h>

--
2.39.2

2023-03-29 15:54:52

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 01/19] of: Make devtree_lock declaration private

Sparc is the only place devtree_lock is used outside of drivers/of/.
Move the devtree_lock declaration into of_private.h and Sparc's prom.h
so pulling in spinlock.h to of.h can be avoided for everything besides
Sparc.

Signed-off-by: Rob Herring <[email protected]>
---
arch/sparc/include/asm/prom.h | 3 +++
drivers/of/of_private.h | 1 +
include/linux/of.h | 2 --
3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index 587edb8b5a65..8184575b1336 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -19,11 +19,14 @@
#include <linux/mutex.h>
#include <linux/atomic.h>
#include <linux/irqdomain.h>
+#include <linux/spinlock.h>

#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2))
#define of_node_cmp(s1, s2) strcmp((s1), (s2))

+extern raw_spinlock_t devtree_lock;
+
struct of_irq_controller {
unsigned int (*irq_build)(struct device_node *, unsigned int, void *);
void *data;
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index fb6792d381a6..b57f1014e419 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -38,6 +38,7 @@ struct alias_prop {
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1

extern struct mutex of_mutex;
+extern raw_spinlock_t devtree_lock;
extern struct list_head aliases_lookup;
extern struct kset *of_kset;

diff --git a/include/linux/of.h b/include/linux/of.h
index 0af611307db2..36cf94596eba 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -16,7 +16,6 @@
#include <linux/errno.h>
#include <linux/kobject.h>
#include <linux/mod_devicetable.h>
-#include <linux/spinlock.h>
#include <linux/topology.h>
#include <linux/notifier.h>
#include <linux/property.h>
@@ -145,7 +144,6 @@ extern struct device_node *of_root;
extern struct device_node *of_chosen;
extern struct device_node *of_aliases;
extern struct device_node *of_stdout;
-extern raw_spinlock_t devtree_lock;

/*
* struct device_node flag descriptions

--
2.39.2

2023-03-29 15:54:53

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 12/19] thermal: cpuidle_cooling: Adjust includes to remove of_device.h

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Adjust the
include files with what was implicitly included by of_device.h (cpu.h and
of.h) and drop including of_device.h.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/thermal/cpuidle_cooling.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index 4f41102e8b16..6f6daead485e 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -7,12 +7,13 @@
*/
#define pr_fmt(fmt) "cpuidle cooling: " fmt

+#include <linux/cpu.h>
#include <linux/cpu_cooling.h>
#include <linux/cpuidle.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/idle_inject.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/slab.h>
#include <linux/thermal.h>


--
2.39.2

2023-03-29 15:54:52

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 15/19] cpufreq: sun50i: Add explicit include for cpu.h

Removing the include of cpu.h from of_device.h causes an error:

drivers/cpufreq/sun50i-cpufreq-nvmem.c:42:19: error: implicit declaration of function ‘get_cpu_device’; did you mean ‘get_device’? [-Werror=implicit-function-declaration]

As of_device.h is not otherwise needed, it can be replaced with of.h
(also implicitly included).

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/cpufreq/sun50i-cpufreq-nvmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
index 1583a370da39..4321d7bbe769 100644
--- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
@@ -10,9 +10,10 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

+#include <linux/cpu.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_opp.h>
#include <linux/slab.h>

--
2.39.2

2023-03-29 15:55:16

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 09/19] riscv: cacheinfo: Adjust includes to remove of_device.h

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Adjust the
include files with what was implicitly included by of_device.h (cpu.h and
of.h) and drop including of_device.h.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
arch/riscv/kernel/cacheinfo.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c
index 3a13113f1b29..e3829d2de5d9 100644
--- a/arch/riscv/kernel/cacheinfo.c
+++ b/arch/riscv/kernel/cacheinfo.c
@@ -5,7 +5,6 @@

#include <linux/cpu.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include <asm/cacheinfo.h>

static struct riscv_cacheinfo_ops *rv_cache_ops;

--
2.39.2

2023-03-29 15:55:17

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 18/19] OPP: Adjust includes to remove of_device.h

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Adjust the
include files with what was implicitly included by of_device.h (cpu.h and
of.h) and drop including of_device.h.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/opp/of.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index e55c6095adf0..63b126c6215e 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -13,7 +13,7 @@
#include <linux/cpu.h>
#include <linux/errno.h>
#include <linux/device.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/pm_domain.h>
#include <linux/slab.h>
#include <linux/export.h>

--
2.39.2

2023-03-29 15:55:31

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 06/19] ARM: sunxi: Drop of_device.h include

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Just drop
including of_device.h as of.h is already included.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
arch/arm/mach-sunxi/mc_smp.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/mc_smp.c b/arch/arm/mach-sunxi/mc_smp.c
index 26cbce135338..cb63921232a6 100644
--- a/arch/arm/mach-sunxi/mc_smp.c
+++ b/arch/arm/mach-sunxi/mc_smp.c
@@ -19,7 +19,6 @@
#include <linux/irqchip/arm-gic.h>
#include <linux/of.h>
#include <linux/of_address.h>
-#include <linux/of_device.h>
#include <linux/smp.h>

#include <asm/cacheflush.h>

--
2.39.2

2023-03-29 15:55:31

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 14/19] cpufreq: Adjust includes to remove of_device.h

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Adjust the
include files with what was implicitly included by of_device.h (cpu.h and
of.h) and drop including of_device.h.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/cpufreq/cpufreq-dt-platdev.c | 1 -
drivers/cpufreq/kirkwood-cpufreq.c | 2 +-
drivers/cpufreq/maple-cpufreq.c | 2 +-
drivers/cpufreq/pmac32-cpufreq.c | 2 +-
drivers/cpufreq/pmac64-cpufreq.c | 2 +-
drivers/cpufreq/qcom-cpufreq-hw.c | 4 ++--
drivers/cpufreq/spear-cpufreq.c | 2 +-
drivers/cpufreq/tegra124-cpufreq.c | 1 -
drivers/cpufreq/tegra20-cpufreq.c | 2 +-
include/linux/cpufreq.h | 1 -
10 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index e85703651098..f9675e1a8529 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -6,7 +6,6 @@

#include <linux/err.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include <linux/platform_device.h>

#include "cpufreq-dt.h"
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 70ad8fe1d78b..95588101efbd 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -9,7 +9,7 @@
#include <linux/module.h>
#include <linux/clk.h>
#include <linux/cpufreq.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <asm/proc-fns.h>
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 28d346062166..f9306410a07f 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -23,7 +23,7 @@
#include <linux/completion.h>
#include <linux/mutex.h>
#include <linux/time.h>
-#include <linux/of_device.h>
+#include <linux/of.h>

#define DBG(fmt...) pr_debug(fmt)

diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 4b8ee2014da6..a28716d8fc54 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -23,7 +23,7 @@
#include <linux/init.h>
#include <linux/device.h>
#include <linux/hardirq.h>
-#include <linux/of_device.h>
+#include <linux/of.h>

#include <asm/machdep.h>
#include <asm/irq.h>
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index ba9c31d98bd6..2cd2b06849a2 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -21,7 +21,7 @@
#include <linux/init.h>
#include <linux/completion.h>
#include <linux/mutex.h>
-#include <linux/of_device.h>
+#include <linux/of.h>

#include <asm/machdep.h>
#include <asm/irq.h>
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 2f581d2d617d..df165a078d14 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -11,8 +11,8 @@
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
#include <linux/pm_opp.h>
#include <linux/pm_qos.h>
#include <linux/slab.h>
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index c6fdf019dbde..78b875db6b66 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -18,7 +18,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/types.h>
diff --git a/drivers/cpufreq/tegra124-cpufreq.c b/drivers/cpufreq/tegra124-cpufreq.c
index 7a1ea6fdcab6..312ca5ddc6c4 100644
--- a/drivers/cpufreq/tegra124-cpufreq.c
+++ b/drivers/cpufreq/tegra124-cpufreq.c
@@ -11,7 +11,6 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_opp.h>
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index ab7ac7df9e62..5d1f5f87e46d 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -12,7 +12,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_opp.h>
#include <linux/types.h>
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 65623233ab2f..3ac4a10d4651 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -15,7 +15,6 @@
#include <linux/kobject.h>
#include <linux/notifier.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include <linux/pm_opp.h>
#include <linux/pm_qos.h>
#include <linux/spinlock.h>

--
2.39.2

2023-03-29 15:55:33

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 08/19] riscv: Add explicit include for cpu.h

Removing the include of cpu.h from of_device.h (included by
of_platform.h) causes an error in setup.c:

arch/riscv/kernel/setup.c:313:22: error: arithmetic on a pointer to an incomplete type 'typeof(struct cpu)' (aka 'struct cpu')

The of_platform.h header is not necessary either, so it can be dropped.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
arch/riscv/kernel/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 376d2827e736..dcfa4b6fa4b1 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -8,6 +8,7 @@
* Nick Kossifidis <[email protected]>
*/

+#include <linux/cpu.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/memblock.h>
@@ -15,7 +16,6 @@
#include <linux/console.h>
#include <linux/screen_info.h>
#include <linux/of_fdt.h>
-#include <linux/of_platform.h>
#include <linux/sched/task.h>
#include <linux/smp.h>
#include <linux/efi.h>

--
2.39.2

2023-03-29 15:55:52

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 04/19] of: Move CPU node related functions to their own file

drivers/of/base.c is quite long and we've accumulated a number of CPU
node functions. Let's move them to a new file, cpu.c, along with the
lone of_cpu_device_node_get() in of_device.h. Moving the declaration has
no effect yet as of.h is included by of_device.h. This serves as
preparation to disentangle the includes in of_device.h and
of_platform.h.

Signed-off-by: Rob Herring <[email protected]>
---
drivers/of/Makefile | 2 +-
drivers/of/base.c | 187 -----------------------------------------
drivers/of/cpu.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of.h | 19 +++--
include/linux/of_device.h | 14 ----
5 files changed, 223 insertions(+), 209 deletions(-)

diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index e0360a44306e..10f704592561 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-obj-y = base.o device.o platform.o property.o
+obj-y = base.o cpu.o device.o platform.o property.o
obj-$(CONFIG_OF_KOBJ) += kobj.o
obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
obj-$(CONFIG_OF_FLATTREE) += fdt.o
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ac6fde53342f..7f1720af813c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -286,193 +286,6 @@ const void *of_get_property(const struct device_node *np, const char *name,
}
EXPORT_SYMBOL(of_get_property);

-/**
- * of_get_cpu_hwid - Get the hardware ID from a CPU device node
- *
- * @cpun: CPU number(logical index) for which device node is required
- * @thread: The local thread number to get the hardware ID for.
- *
- * Return: The hardware ID for the CPU node or ~0ULL if not found.
- */
-u64 of_get_cpu_hwid(struct device_node *cpun, unsigned int thread)
-{
- const __be32 *cell;
- int ac, len;
-
- ac = of_n_addr_cells(cpun);
- cell = of_get_property(cpun, "reg", &len);
- if (!cell || !ac || ((sizeof(*cell) * ac * (thread + 1)) > len))
- return ~0ULL;
-
- cell += ac * thread;
- return of_read_number(cell, ac);
-}
-
-/*
- * arch_match_cpu_phys_id - Match the given logical CPU and physical id
- *
- * @cpu: logical cpu index of a core/thread
- * @phys_id: physical identifier of a core/thread
- *
- * CPU logical to physical index mapping is architecture specific.
- * However this __weak function provides a default match of physical
- * id to logical cpu index. phys_id provided here is usually values read
- * from the device tree which must match the hardware internal registers.
- *
- * Returns true if the physical identifier and the logical cpu index
- * correspond to the same core/thread, false otherwise.
- */
-bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
-{
- return (u32)phys_id == cpu;
-}
-
-/*
- * Checks if the given "prop_name" property holds the physical id of the
- * core/thread corresponding to the logical cpu 'cpu'. If 'thread' is not
- * NULL, local thread number within the core is returned in it.
- */
-static bool __of_find_n_match_cpu_property(struct device_node *cpun,
- const char *prop_name, int cpu, unsigned int *thread)
-{
- const __be32 *cell;
- int ac, prop_len, tid;
- u64 hwid;
-
- ac = of_n_addr_cells(cpun);
- cell = of_get_property(cpun, prop_name, &prop_len);
- if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0))
- return true;
- if (!cell || !ac)
- return false;
- prop_len /= sizeof(*cell) * ac;
- for (tid = 0; tid < prop_len; tid++) {
- hwid = of_read_number(cell, ac);
- if (arch_match_cpu_phys_id(cpu, hwid)) {
- if (thread)
- *thread = tid;
- return true;
- }
- cell += ac;
- }
- return false;
-}
-
-/*
- * arch_find_n_match_cpu_physical_id - See if the given device node is
- * for the cpu corresponding to logical cpu 'cpu'. Return true if so,
- * else false. If 'thread' is non-NULL, the local thread number within the
- * core is returned in it.
- */
-bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun,
- int cpu, unsigned int *thread)
-{
- /* Check for non-standard "ibm,ppc-interrupt-server#s" property
- * for thread ids on PowerPC. If it doesn't exist fallback to
- * standard "reg" property.
- */
- if (IS_ENABLED(CONFIG_PPC) &&
- __of_find_n_match_cpu_property(cpun,
- "ibm,ppc-interrupt-server#s",
- cpu, thread))
- return true;
-
- return __of_find_n_match_cpu_property(cpun, "reg", cpu, thread);
-}
-
-/**
- * of_get_cpu_node - Get device node associated with the given logical CPU
- *
- * @cpu: CPU number(logical index) for which device node is required
- * @thread: if not NULL, local thread number within the physical core is
- * returned
- *
- * The main purpose of this function is to retrieve the device node for the
- * given logical CPU index. It should be used to initialize the of_node in
- * cpu device. Once of_node in cpu device is populated, all the further
- * references can use that instead.
- *
- * CPU logical to physical index mapping is architecture specific and is built
- * before booting secondary cores. This function uses arch_match_cpu_phys_id
- * which can be overridden by architecture specific implementation.
- *
- * Return: A node pointer for the logical cpu with refcount incremented, use
- * of_node_put() on it when done. Returns NULL if not found.
- */
-struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
-{
- struct device_node *cpun;
-
- for_each_of_cpu_node(cpun) {
- if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
- return cpun;
- }
- return NULL;
-}
-EXPORT_SYMBOL(of_get_cpu_node);
-
-/**
- * of_cpu_node_to_id: Get the logical CPU number for a given device_node
- *
- * @cpu_node: Pointer to the device_node for CPU.
- *
- * Return: The logical CPU number of the given CPU device_node or -ENODEV if the
- * CPU is not found.
- */
-int of_cpu_node_to_id(struct device_node *cpu_node)
-{
- int cpu;
- bool found = false;
- struct device_node *np;
-
- for_each_possible_cpu(cpu) {
- np = of_cpu_device_node_get(cpu);
- found = (cpu_node == np);
- of_node_put(np);
- if (found)
- return cpu;
- }
-
- return -ENODEV;
-}
-EXPORT_SYMBOL(of_cpu_node_to_id);
-
-/**
- * of_get_cpu_state_node - Get CPU's idle state node at the given index
- *
- * @cpu_node: The device node for the CPU
- * @index: The index in the list of the idle states
- *
- * Two generic methods can be used to describe a CPU's idle states, either via
- * a flattened description through the "cpu-idle-states" binding or via the
- * hierarchical layout, using the "power-domains" and the "domain-idle-states"
- * bindings. This function check for both and returns the idle state node for
- * the requested index.
- *
- * Return: An idle state node if found at @index. The refcount is incremented
- * for it, so call of_node_put() on it when done. Returns NULL if not found.
- */
-struct device_node *of_get_cpu_state_node(struct device_node *cpu_node,
- int index)
-{
- struct of_phandle_args args;
- int err;
-
- err = of_parse_phandle_with_args(cpu_node, "power-domains",
- "#power-domain-cells", 0, &args);
- if (!err) {
- struct device_node *state_node =
- of_parse_phandle(args.np, "domain-idle-states", index);
-
- of_node_put(args.np);
- if (state_node)
- return state_node;
- }
-
- return of_parse_phandle(cpu_node, "cpu-idle-states", index);
-}
-EXPORT_SYMBOL(of_get_cpu_state_node);
-
/**
* __of_device_is_compatible() - Check if the node matches given constraints
* @device: pointer to node
diff --git a/drivers/of/cpu.c b/drivers/of/cpu.c
new file mode 100644
index 000000000000..d17b2f851082
--- /dev/null
+++ b/drivers/of/cpu.c
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/cpu.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+
+/**
+ * of_get_cpu_hwid - Get the hardware ID from a CPU device node
+ *
+ * @cpun: CPU number(logical index) for which device node is required
+ * @thread: The local thread number to get the hardware ID for.
+ *
+ * Return: The hardware ID for the CPU node or ~0ULL if not found.
+ */
+u64 of_get_cpu_hwid(struct device_node *cpun, unsigned int thread)
+{
+ const __be32 *cell;
+ int ac, len;
+
+ ac = of_n_addr_cells(cpun);
+ cell = of_get_property(cpun, "reg", &len);
+ if (!cell || !ac || ((sizeof(*cell) * ac * (thread + 1)) > len))
+ return ~0ULL;
+
+ cell += ac * thread;
+ return of_read_number(cell, ac);
+}
+
+/*
+ * arch_match_cpu_phys_id - Match the given logical CPU and physical id
+ *
+ * @cpu: logical cpu index of a core/thread
+ * @phys_id: physical identifier of a core/thread
+ *
+ * CPU logical to physical index mapping is architecture specific.
+ * However this __weak function provides a default match of physical
+ * id to logical cpu index. phys_id provided here is usually values read
+ * from the device tree which must match the hardware internal registers.
+ *
+ * Returns true if the physical identifier and the logical cpu index
+ * correspond to the same core/thread, false otherwise.
+ */
+bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+ return (u32)phys_id == cpu;
+}
+
+/*
+ * Checks if the given "prop_name" property holds the physical id of the
+ * core/thread corresponding to the logical cpu 'cpu'. If 'thread' is not
+ * NULL, local thread number within the core is returned in it.
+ */
+static bool __of_find_n_match_cpu_property(struct device_node *cpun,
+ const char *prop_name, int cpu, unsigned int *thread)
+{
+ const __be32 *cell;
+ int ac, prop_len, tid;
+ u64 hwid;
+
+ ac = of_n_addr_cells(cpun);
+ cell = of_get_property(cpun, prop_name, &prop_len);
+ if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0))
+ return true;
+ if (!cell || !ac)
+ return false;
+ prop_len /= sizeof(*cell) * ac;
+ for (tid = 0; tid < prop_len; tid++) {
+ hwid = of_read_number(cell, ac);
+ if (arch_match_cpu_phys_id(cpu, hwid)) {
+ if (thread)
+ *thread = tid;
+ return true;
+ }
+ cell += ac;
+ }
+ return false;
+}
+
+/*
+ * arch_find_n_match_cpu_physical_id - See if the given device node is
+ * for the cpu corresponding to logical cpu 'cpu'. Return true if so,
+ * else false. If 'thread' is non-NULL, the local thread number within the
+ * core is returned in it.
+ */
+bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun,
+ int cpu, unsigned int *thread)
+{
+ /* Check for non-standard "ibm,ppc-interrupt-server#s" property
+ * for thread ids on PowerPC. If it doesn't exist fallback to
+ * standard "reg" property.
+ */
+ if (IS_ENABLED(CONFIG_PPC) &&
+ __of_find_n_match_cpu_property(cpun,
+ "ibm,ppc-interrupt-server#s",
+ cpu, thread))
+ return true;
+
+ return __of_find_n_match_cpu_property(cpun, "reg", cpu, thread);
+}
+
+/**
+ * of_get_cpu_node - Get device node associated with the given logical CPU
+ *
+ * @cpu: CPU number(logical index) for which device node is required
+ * @thread: if not NULL, local thread number within the physical core is
+ * returned
+ *
+ * The main purpose of this function is to retrieve the device node for the
+ * given logical CPU index. It should be used to initialize the of_node in
+ * cpu device. Once of_node in cpu device is populated, all the further
+ * references can use that instead.
+ *
+ * CPU logical to physical index mapping is architecture specific and is built
+ * before booting secondary cores. This function uses arch_match_cpu_phys_id
+ * which can be overridden by architecture specific implementation.
+ *
+ * Return: A node pointer for the logical cpu with refcount incremented, use
+ * of_node_put() on it when done. Returns NULL if not found.
+ */
+struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
+{
+ struct device_node *cpun;
+
+ for_each_of_cpu_node(cpun) {
+ if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
+ return cpun;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL(of_get_cpu_node);
+
+/**
+ * of_cpu_device_node_get: Get the CPU device_node for a given logical CPU number
+ *
+ * @cpu: The logical CPU number
+ *
+ * Return: Pointer to the device_node for CPU with its reference count
+ * incremented of the given logical CPU number or NULL if the CPU device_node
+ * is not found.
+ */
+struct device_node *of_cpu_device_node_get(int cpu)
+{
+ struct device *cpu_dev;
+ cpu_dev = get_cpu_device(cpu);
+ if (!cpu_dev)
+ return of_get_cpu_node(cpu, NULL);
+ return of_node_get(cpu_dev->of_node);
+}
+EXPORT_SYMBOL(of_cpu_device_node_get);
+
+/**
+ * of_cpu_node_to_id: Get the logical CPU number for a given device_node
+ *
+ * @cpu_node: Pointer to the device_node for CPU.
+ *
+ * Return: The logical CPU number of the given CPU device_node or -ENODEV if the
+ * CPU is not found.
+ */
+int of_cpu_node_to_id(struct device_node *cpu_node)
+{
+ int cpu;
+ bool found = false;
+ struct device_node *np;
+
+ for_each_possible_cpu(cpu) {
+ np = of_cpu_device_node_get(cpu);
+ found = (cpu_node == np);
+ of_node_put(np);
+ if (found)
+ return cpu;
+ }
+
+ return -ENODEV;
+}
+EXPORT_SYMBOL(of_cpu_node_to_id);
+
+/**
+ * of_get_cpu_state_node - Get CPU's idle state node at the given index
+ *
+ * @cpu_node: The device node for the CPU
+ * @index: The index in the list of the idle states
+ *
+ * Two generic methods can be used to describe a CPU's idle states, either via
+ * a flattened description through the "cpu-idle-states" binding or via the
+ * hierarchical layout, using the "power-domains" and the "domain-idle-states"
+ * bindings. This function check for both and returns the idle state node for
+ * the requested index.
+ *
+ * Return: An idle state node if found at @index. The refcount is incremented
+ * for it, so call of_node_put() on it when done. Returns NULL if not found.
+ */
+struct device_node *of_get_cpu_state_node(struct device_node *cpu_node,
+ int index)
+{
+ struct of_phandle_args args;
+ int err;
+
+ err = of_parse_phandle_with_args(cpu_node, "power-domains",
+ "#power-domain-cells", 0, &args);
+ if (!err) {
+ struct device_node *state_node =
+ of_parse_phandle(args.np, "domain-idle-states", index);
+
+ of_node_put(args.np);
+ if (state_node)
+ return state_node;
+ }
+
+ return of_parse_phandle(cpu_node, "cpu-idle-states", index);
+}
+EXPORT_SYMBOL(of_get_cpu_state_node);
diff --git a/include/linux/of.h b/include/linux/of.h
index b7118d68c73a..1f1e847a1c13 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -359,6 +359,8 @@ extern const void *of_get_property(const struct device_node *node,
const char *name,
int *lenp);
extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
+extern struct device_node *of_cpu_device_node_get(int cpu);
+extern int of_cpu_node_to_id(struct device_node *np);
extern struct device_node *of_get_next_cpu_node(struct device_node *prev);
extern struct device_node *of_get_cpu_state_node(struct device_node *cpu_node,
int index);
@@ -439,8 +441,6 @@ const char *of_prop_next_string(struct property *prop, const char *cur);

bool of_console_check(struct device_node *dn, char *name, int index);

-extern int of_cpu_node_to_id(struct device_node *np);
-
int of_map_id(struct device_node *np, u32 id,
const char *map_name, const char *map_mask_name,
struct device_node **target, u32 *id_out);
@@ -635,6 +635,16 @@ static inline struct device_node *of_get_cpu_node(int cpu,
return NULL;
}

+static inline struct device_node *of_cpu_device_node_get(int cpu)
+{
+ return NULL;
+}
+
+static inline int of_cpu_node_to_id(struct device_node *np)
+{
+ return -ENODEV;
+}
+
static inline struct device_node *of_get_next_cpu_node(struct device_node *prev)
{
return NULL;
@@ -837,11 +847,6 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag
{
}

-static inline int of_cpu_node_to_id(struct device_node *np)
-{
- return -ENODEV;
-}
-
static inline int of_map_id(struct device_node *np, u32 id,
const char *map_name, const char *map_mask_name,
struct device_node **target, u32 *id_out)
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 6af4c3acd502..910951a22eb4 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -32,15 +32,6 @@ extern int of_device_request_module(struct device *dev);
extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env);

-static inline struct device_node *of_cpu_device_node_get(int cpu)
-{
- struct device *cpu_dev;
- cpu_dev = get_cpu_device(cpu);
- if (!cpu_dev)
- return of_get_cpu_node(cpu, NULL);
- return of_node_get(cpu_dev->of_node);
-}
-
int of_dma_configure_id(struct device *dev,
struct device_node *np,
bool force_dma, const u32 *id);
@@ -89,11 +80,6 @@ static inline const struct of_device_id *of_match_device(
return NULL;
}

-static inline struct device_node *of_cpu_device_node_get(int cpu)
-{
- return NULL;
-}
-
static inline int of_dma_configure_id(struct device *dev,
struct device_node *np,
bool force_dma,

--
2.39.2

2023-03-29 15:56:06

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 13/19] soc: mediatek: mtk-svs: Add explicit include for cpu.h

Removing the include of cpu.h from of_device.h (included by
of_platform.h) causes an error:

drivers/soc/mediatek/mtk-svs.c:2134:41: error: implicit declaration of function 'get_cpu_device'; did you mean 'get_swap_device'? [-Werror=implicit-function-declaration]

of_platform.h is still needed for of_find_device_by_node().

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
drivers/soc/mediatek/mtk-svs.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index f26eb2f637d5..1b7579a5bec6 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -7,6 +7,7 @@
#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/completion.h>
+#include <linux/cpu.h>
#include <linux/cpuidle.h>
#include <linux/debugfs.h>
#include <linux/device.h>

--
2.39.2

2023-03-29 15:56:42

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 03/19] of: Move of_device_get_match_data() declaration

of_device.h mostly defines functions for bus drivers whereas
of_device_get_match_data() is used by drivers. Let's move it to of.h.

Signed-off-by: Rob Herring <[email protected]>
---
include/linux/of.h | 2 ++
include/linux/of_device.h | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/of.h b/include/linux/of.h
index 36cf94596eba..b7118d68c73a 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -416,6 +416,8 @@ extern int of_detach_node(struct device_node *);

#define of_match_ptr(_ptr) (_ptr)

+extern const void *of_device_get_match_data(const struct device *dev);
+
/*
* struct property *prop;
* const __be32 *p;
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index e4aa61cb2bd0..6af4c3acd502 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -26,8 +26,6 @@ static inline int of_driver_match_device(struct device *dev,
return of_match_device(drv->of_match_table, dev) != NULL;
}

-extern const void *of_device_get_match_data(const struct device *dev);
-
extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
extern int of_device_request_module(struct device *dev);


--
2.39.2

2023-03-29 15:56:57

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH 07/19] ARM: cpuidle: Drop of_device.h include

Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
implicitly including other includes, and is no longer needed. Just drop
including of_device.h as of.h is already included.

Signed-off-by: Rob Herring <[email protected]>
---
Please ack and I will take the series via the DT tree.
---
arch/arm/kernel/cpuidle.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
index 437ff39f7808..fba1f8bb03b5 100644
--- a/arch/arm/kernel/cpuidle.c
+++ b/arch/arm/kernel/cpuidle.c
@@ -5,7 +5,6 @@

#include <linux/cpuidle.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include <asm/cpuidle.h>

extern struct of_cpuidle_method __cpuidle_method_of_table[];

--
2.39.2

2023-03-29 16:01:56

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH 06/19] ARM: sunxi: Drop of_device.h include

On Wed, Mar 29, 2023 at 11:53 PM Rob Herring <[email protected]> wrote:
>
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Just drop
> including of_device.h as of.h is already included.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.

Acked-by: Chen-Yu Tsai <[email protected]>

I doubt this file would ever see any more changes.

> ---
> arch/arm/mach-sunxi/mc_smp.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/arch/arm/mach-sunxi/mc_smp.c b/arch/arm/mach-sunxi/mc_smp.c
> index 26cbce135338..cb63921232a6 100644
> --- a/arch/arm/mach-sunxi/mc_smp.c
> +++ b/arch/arm/mach-sunxi/mc_smp.c
> @@ -19,7 +19,6 @@
> #include <linux/irqchip/arm-gic.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> -#include <linux/of_device.h>
> #include <linux/smp.h>
>
> #include <asm/cacheflush.h>
>
> --
> 2.39.2
>

2023-03-29 16:02:32

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 14/19] cpufreq: Adjust includes to remove of_device.h

On Wed, Mar 29, 2023 at 5:53 PM Rob Herring <[email protected]> wrote:
>
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Adjust the
> include files with what was implicitly included by of_device.h (cpu.h and
> of.h) and drop including of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.

Acked-by: Rafael J. Wysocki <[email protected]>

> ---
> drivers/cpufreq/cpufreq-dt-platdev.c | 1 -
> drivers/cpufreq/kirkwood-cpufreq.c | 2 +-
> drivers/cpufreq/maple-cpufreq.c | 2 +-
> drivers/cpufreq/pmac32-cpufreq.c | 2 +-
> drivers/cpufreq/pmac64-cpufreq.c | 2 +-
> drivers/cpufreq/qcom-cpufreq-hw.c | 4 ++--
> drivers/cpufreq/spear-cpufreq.c | 2 +-
> drivers/cpufreq/tegra124-cpufreq.c | 1 -
> drivers/cpufreq/tegra20-cpufreq.c | 2 +-
> include/linux/cpufreq.h | 1 -
> 10 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
> index e85703651098..f9675e1a8529 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -6,7 +6,6 @@
>
> #include <linux/err.h>
> #include <linux/of.h>
> -#include <linux/of_device.h>
> #include <linux/platform_device.h>
>
> #include "cpufreq-dt.h"
> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
> index 70ad8fe1d78b..95588101efbd 100644
> --- a/drivers/cpufreq/kirkwood-cpufreq.c
> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
> @@ -9,7 +9,7 @@
> #include <linux/module.h>
> #include <linux/clk.h>
> #include <linux/cpufreq.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <asm/proc-fns.h>
> diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
> index 28d346062166..f9306410a07f 100644
> --- a/drivers/cpufreq/maple-cpufreq.c
> +++ b/drivers/cpufreq/maple-cpufreq.c
> @@ -23,7 +23,7 @@
> #include <linux/completion.h>
> #include <linux/mutex.h>
> #include <linux/time.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
>
> #define DBG(fmt...) pr_debug(fmt)
>
> diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
> index 4b8ee2014da6..a28716d8fc54 100644
> --- a/drivers/cpufreq/pmac32-cpufreq.c
> +++ b/drivers/cpufreq/pmac32-cpufreq.c
> @@ -23,7 +23,7 @@
> #include <linux/init.h>
> #include <linux/device.h>
> #include <linux/hardirq.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
>
> #include <asm/machdep.h>
> #include <asm/irq.h>
> diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
> index ba9c31d98bd6..2cd2b06849a2 100644
> --- a/drivers/cpufreq/pmac64-cpufreq.c
> +++ b/drivers/cpufreq/pmac64-cpufreq.c
> @@ -21,7 +21,7 @@
> #include <linux/init.h>
> #include <linux/completion.h>
> #include <linux/mutex.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
>
> #include <asm/machdep.h>
> #include <asm/irq.h>
> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
> index 2f581d2d617d..df165a078d14 100644
> --- a/drivers/cpufreq/qcom-cpufreq-hw.c
> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c
> @@ -11,8 +11,8 @@
> #include <linux/interrupt.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> -#include <linux/of_address.h>
> -#include <linux/of_platform.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> #include <linux/pm_opp.h>
> #include <linux/pm_qos.h>
> #include <linux/slab.h>
> diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
> index c6fdf019dbde..78b875db6b66 100644
> --- a/drivers/cpufreq/spear-cpufreq.c
> +++ b/drivers/cpufreq/spear-cpufreq.c
> @@ -18,7 +18,7 @@
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/module.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
> #include <linux/types.h>
> diff --git a/drivers/cpufreq/tegra124-cpufreq.c b/drivers/cpufreq/tegra124-cpufreq.c
> index 7a1ea6fdcab6..312ca5ddc6c4 100644
> --- a/drivers/cpufreq/tegra124-cpufreq.c
> +++ b/drivers/cpufreq/tegra124-cpufreq.c
> @@ -11,7 +11,6 @@
> #include <linux/init.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> -#include <linux/of_device.h>
> #include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_opp.h>
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
> index ab7ac7df9e62..5d1f5f87e46d 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -12,7 +12,7 @@
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/module.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_opp.h>
> #include <linux/types.h>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 65623233ab2f..3ac4a10d4651 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -15,7 +15,6 @@
> #include <linux/kobject.h>
> #include <linux/notifier.h>
> #include <linux/of.h>
> -#include <linux/of_device.h>
> #include <linux/pm_opp.h>
> #include <linux/pm_qos.h>
> #include <linux/spinlock.h>
>
> --
> 2.39.2
>

2023-03-29 16:03:33

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 12/19] thermal: cpuidle_cooling: Adjust includes to remove of_device.h

On Wed, Mar 29, 2023 at 5:53 PM Rob Herring <[email protected]> wrote:
>
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Adjust the
> include files with what was implicitly included by of_device.h (cpu.h and
> of.h) and drop including of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.

Acked-by: Rafael J. Wysocki <[email protected]>

> ---
> drivers/thermal/cpuidle_cooling.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
> index 4f41102e8b16..6f6daead485e 100644
> --- a/drivers/thermal/cpuidle_cooling.c
> +++ b/drivers/thermal/cpuidle_cooling.c
> @@ -7,12 +7,13 @@
> */
> #define pr_fmt(fmt) "cpuidle cooling: " fmt
>
> +#include <linux/cpu.h>
> #include <linux/cpu_cooling.h>
> #include <linux/cpuidle.h>
> #include <linux/device.h>
> #include <linux/err.h>
> #include <linux/idle_inject.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/slab.h>
> #include <linux/thermal.h>
>
>
> --
> 2.39.2
>

2023-03-29 16:25:50

by Jernej Škrabec

[permalink] [raw]
Subject: Re: [PATCH 15/19] cpufreq: sun50i: Add explicit include for cpu.h

Dne sreda, 29. marec 2023 ob 17:52:12 CEST je Rob Herring napisal(a):
> Removing the include of cpu.h from of_device.h causes an error:
>
> drivers/cpufreq/sun50i-cpufreq-nvmem.c:42:19: error: implicit declaration of
> function ‘get_cpu_device’; did you mean ‘get_device’?
> [-Werror=implicit-function-declaration]
>
> As of_device.h is not otherwise needed, it can be replaced with of.h
> (also implicitly included).
>
> Signed-off-by: Rob Herring <[email protected]>
> ---

Acked-by: Jernej Skrabec <[email protected]>

Best regards,
Jernej


2023-03-29 16:35:36

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 10/19] cacheinfo: Adjust includes to remove of_device.h

On Wed, Mar 29, 2023 at 10:52:07AM -0500, Rob Herring wrote:
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Update the
> includes to use of.h instead of of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.
> ---

Acked-by: Greg Kroah-Hartman <[email protected]>

2023-03-29 18:15:54

by Sudeep Holla

[permalink] [raw]
Subject: Re: [PATCH 04/19] of: Move CPU node related functions to their own file

On Wed, Mar 29, 2023 at 10:52:01AM -0500, Rob Herring wrote:
> drivers/of/base.c is quite long and we've accumulated a number of CPU
> node functions. Let's move them to a new file, cpu.c, along with the
> lone of_cpu_device_node_get() in of_device.h. Moving the declaration has
> no effect yet as of.h is included by of_device.h. This serves as
> preparation to disentangle the includes in of_device.h and
> of_platform.h.
>

Makes sense to have its own file for CPUs, I am sure there will be more
additions ????.

FWIW,

Reviewed-by: Sudeep Holla <[email protected]>

--
Regards,
Sudeep

2023-03-29 18:23:21

by Sudeep Holla

[permalink] [raw]
Subject: Re: [PATCH 10/19] cacheinfo: Adjust includes to remove of_device.h

On Wed, Mar 29, 2023 at 10:52:07AM -0500, Rob Herring wrote:
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Update the
> includes to use of.h instead of of_device.h.
>

Acked-by: Sudeep Holla <[email protected]>

--
Regards,
Sudeep

2023-03-30 03:55:30

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 14/19] cpufreq: Adjust includes to remove of_device.h

On 29-03-23, 10:52, Rob Herring wrote:
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Adjust the
> include files with what was implicitly included by of_device.h (cpu.h and
> of.h) and drop including of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.
> ---
> drivers/cpufreq/cpufreq-dt-platdev.c | 1 -
> drivers/cpufreq/kirkwood-cpufreq.c | 2 +-
> drivers/cpufreq/maple-cpufreq.c | 2 +-
> drivers/cpufreq/pmac32-cpufreq.c | 2 +-
> drivers/cpufreq/pmac64-cpufreq.c | 2 +-
> drivers/cpufreq/qcom-cpufreq-hw.c | 4 ++--
> drivers/cpufreq/spear-cpufreq.c | 2 +-
> drivers/cpufreq/tegra124-cpufreq.c | 1 -
> drivers/cpufreq/tegra20-cpufreq.c | 2 +-
> include/linux/cpufreq.h | 1 -
> 10 files changed, 8 insertions(+), 11 deletions(-)

Acked-by: Viresh Kumar <[email protected]>

--
viresh

2023-03-30 03:55:36

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 15/19] cpufreq: sun50i: Add explicit include for cpu.h

On 29-03-23, 10:52, Rob Herring wrote:
> Removing the include of cpu.h from of_device.h causes an error:
>
> drivers/cpufreq/sun50i-cpufreq-nvmem.c:42:19: error: implicit declaration of function ‘get_cpu_device’; did you mean ‘get_device’? [-Werror=implicit-function-declaration]
>
> As of_device.h is not otherwise needed, it can be replaced with of.h
> (also implicitly included).
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.
> ---
> drivers/cpufreq/sun50i-cpufreq-nvmem.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> index 1583a370da39..4321d7bbe769 100644
> --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> @@ -10,9 +10,10 @@
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> +#include <linux/cpu.h>
> #include <linux/module.h>
> #include <linux/nvmem-consumer.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_opp.h>
> #include <linux/slab.h>

Acked-by: Viresh Kumar <[email protected]>

--
viresh

2023-03-30 03:55:48

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 18/19] OPP: Adjust includes to remove of_device.h

On 29-03-23, 10:52, Rob Herring wrote:
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Adjust the
> include files with what was implicitly included by of_device.h (cpu.h and
> of.h) and drop including of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.
> ---
> drivers/opp/of.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/opp/of.c b/drivers/opp/of.c
> index e55c6095adf0..63b126c6215e 100644
> --- a/drivers/opp/of.c
> +++ b/drivers/opp/of.c
> @@ -13,7 +13,7 @@
> #include <linux/cpu.h>
> #include <linux/errno.h>
> #include <linux/device.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/pm_domain.h>
> #include <linux/slab.h>
> #include <linux/export.h>

Acked-by: Viresh Kumar <[email protected]>

--
viresh

2023-04-01 19:23:59

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH 12/19] thermal: cpuidle_cooling: Adjust includes to remove of_device.h

On 29/03/2023 17:52, Rob Herring wrote:
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Adjust the
> include files with what was implicitly included by of_device.h (cpu.h and
> of.h) and drop including of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.

Acked-by: Daniel Lezcano <[email protected]>

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

2023-04-29 19:17:33

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 09/19] riscv: cacheinfo: Adjust includes to remove of_device.h

On Wed, 29 Mar 2023 08:52:06 PDT (-0700), [email protected] wrote:
> Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just
> implicitly including other includes, and is no longer needed. Adjust the
> include files with what was implicitly included by of_device.h (cpu.h and
> of.h) and drop including of_device.h.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.
> ---
> arch/riscv/kernel/cacheinfo.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c
> index 3a13113f1b29..e3829d2de5d9 100644
> --- a/arch/riscv/kernel/cacheinfo.c
> +++ b/arch/riscv/kernel/cacheinfo.c
> @@ -5,7 +5,6 @@
>
> #include <linux/cpu.h>
> #include <linux/of.h>
> -#include <linux/of_device.h>
> #include <asm/cacheinfo.h>
>
> static struct riscv_cacheinfo_ops *rv_cache_ops;

Reviewed-by: Palmer Dabbelt <[email protected]>
Acked-by: Palmer Dabbelt <[email protected]>

2023-04-29 19:47:57

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 08/19] riscv: Add explicit include for cpu.h

On Wed, 29 Mar 2023 08:52:05 PDT (-0700), [email protected] wrote:
> Removing the include of cpu.h from of_device.h (included by
> of_platform.h) causes an error in setup.c:
>
> arch/riscv/kernel/setup.c:313:22: error: arithmetic on a pointer to an incomplete type 'typeof(struct cpu)' (aka 'struct cpu')
>
> The of_platform.h header is not necessary either, so it can be dropped.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> Please ack and I will take the series via the DT tree.
> ---
> arch/riscv/kernel/setup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
> index 376d2827e736..dcfa4b6fa4b1 100644
> --- a/arch/riscv/kernel/setup.c
> +++ b/arch/riscv/kernel/setup.c
> @@ -8,6 +8,7 @@
> * Nick Kossifidis <[email protected]>
> */
>
> +#include <linux/cpu.h>
> #include <linux/init.h>
> #include <linux/mm.h>
> #include <linux/memblock.h>
> @@ -15,7 +16,6 @@
> #include <linux/console.h>
> #include <linux/screen_info.h>
> #include <linux/of_fdt.h>
> -#include <linux/of_platform.h>
> #include <linux/sched/task.h>
> #include <linux/smp.h>
> #include <linux/efi.h>

Reviewed-by: Palmer Dabbelt <[email protected]>
Acked-by: Palmer Dabbelt <[email protected]>