]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Merge patch series "treewide: Clean up usage of DECLARE_GLOBAL_DATA_PTR"
authorTom Rini <trini@konsulko.com>
Tue, 17 Feb 2026 19:51:26 +0000 (13:51 -0600)
committerTom Rini <trini@konsulko.com>
Tue, 17 Feb 2026 19:51:26 +0000 (13:51 -0600)
Peng Fan (OSS) <peng.fan@oss.nxp.com> says:

This patch set primarily removes unused DECLARE_GLOBAL_DATA_PTR
instances.

Many files declare DECLARE_GLOBAL_DATA_PTR and include
asm/global_data.h even though gd is never used. In these cases,
asm/global_data.h is effectively treated as a proxy header, which is
not a good practice.

Following the Include What You Use principle, files should include
only the headers they actually depend on, rather than relying on
global_data.h indirectly. This approach is also adopted in Linux kernel
[1].

The first few patches are prepartion to avoid building break after
remove the including of global_data.h.

A script is for filtering the files:
list=`find . -name "*.[ch]"`
for source in ${list}
do
        result=`sed -n '/DECLARE_GLOBAL_DATA_PTR/p' ${source}`
        if [ "${result}" == "DECLARE_GLOBAL_DATA_PTR;" ]; then
                echo "Found in ${source}"

                result=`sed -n '/\<gd\>/p' ${source}`
                result2=`sed -n '/\<gd_/p' ${source}`
                result3=`sed -n '/\<gd->/p' ${source}`
                if [ "${result}" == "" ] && [ "${result2}" == "" ] && [ "${result3}" == "" ];then
                        echo "Cleanup ${source}"
                        sed -i '/DECLARE_GLOBAL_DATA_PTR/{N;/\n[[:space:]]*$/d;s/.*\n//;}' ${source}
                        sed -i '/DECLARE_GLOBAL_DATA_PTR/d' ${source}
                        sed -i '/global_data.h/d' ${source}
                        git add ${source}
                fi
        fi
done

[1] https://lpc.events/event/17/contributions/1620/attachments/1228/2520/Linux%20Kernel%20Header%20Optimization.pdf

CI: https://github.com/u-boot/u-boot/pull/865

Link: https://lore.kernel.org/r/20260209-cleanup-v2-0-73a3a84ddbdb@nxp.com
1  2 
arch/arm/mach-socfpga/misc_soc64.c
arch/arm/mach-socfpga/mmu-arm64_s10.c
arch/arm/mach-socfpga/reset_manager_s10.c
arch/arm/mach-socfpga/system_manager_soc64.c
drivers/clk/altera/clk-agilex.c
drivers/spi/spi-uclass.c
lib/efi_loader/efi_capsule.c
net/tftp.c

Simple merge
index 33520aae6cd937d4dccb301fe0c586fe30f67875,1a7f8d42415984c5edb4199c0b355c2dbfe7d666..9f68d12351f63363a16997299be1ff095bff0a9a
@@@ -5,11 -5,8 +5,8 @@@
   */
  
  #include <asm/armv8/mmu.h>
- #include <asm/global_data.h>
- DECLARE_GLOBAL_DATA_PTR;
  
 -#if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5)
 +#if IS_ENABLED(CONFIG_ARCH_SOCFPGA_AGILEX5)
  static struct mm_region socfpga_agilex5_mem_map[] = {
        {
                /* OCRAM 512KB */
index 94624deef101b6d8a897c0021508f95ec6b30445,a5c0387190b26a87eec1292816e25467c9818d59..2f2ac9330eef9106db42f18df6183deac064bb08
@@@ -9,10 -9,7 +9,8 @@@
  #include <asm/io.h>
  #include <linux/bitfield.h>
  
- DECLARE_GLOBAL_DATA_PTR;
 -#if IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5)
 +#if IS_ENABLED(CONFIG_ARCH_SOCFPGA_AGILEX5)
++
  /*
   * Setting RESET_PULSE_OVERRIDE bit for successful reset staggering pulse
   * generation and setting PORT_OVERCURRENT bit so that until we turn on the
Simple merge
Simple merge
Simple merge
diff --cc net/tftp.c
Simple merge