mbox series

[00/19] DT header disentangling, part 1

Message ID 20230329-dt-cpu-header-cleanups-v1-0-581e2605fe47@kernel.org
Headers show
Series DT header disentangling, part 1 | expand

Message

Rob Herring (Arm) March 29, 2023, 3:51 p.m. UTC
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 <robh@kernel.org>
---
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,

Comments

Viresh Kumar March 30, 2023, 3:54 a.m. UTC | #1
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 <robh@kernel.org>
> ---
> 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 <viresh.kumar@linaro.org>
Viresh Kumar March 30, 2023, 3:54 a.m. UTC | #2
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 <robh@kernel.org>
> ---
> 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 <viresh.kumar@linaro.org>
Daniel Lezcano April 1, 2023, 7:22 p.m. UTC | #3
On 29/03/2023 17:52, Rob Herring wrote:
> Removing include of cpu.h from of_device.h (included by of_platform.h)
> causes an error in ingenic-timer:
> 
> drivers/clocksource/ingenic-timer.c: In function ‘ingenic_tcu_init’:
> drivers/clocksource/ingenic-timer.c:338:15: error: implicit declaration of function ‘cpuhp_setup_state’
> 
> The of_platform.h header is not necessary either, so it and of_address.h
> can be dropped.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take the series via the DT tree.
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Daniel Lezcano April 1, 2023, 7:22 p.m. UTC | #4
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 <robh@kernel.org>
> ---
> Please ack and I will take the series via the DT tree.

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>