diff options
| author | Tom Rini <[email protected]> | 2026-02-17 13:51:26 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-02-17 13:51:26 -0600 |
| commit | 9ddccb51443d4856e5ad2f06cc3552627b86b3d9 (patch) | |
| tree | d42c5647f5f59098c626f8bd5d16e53b283f35f0 /test | |
| parent | 54f9b6528e34f1f75c2258ed29887f496a35dd6a (diff) | |
| parent | 0f90b1e715f8abe41b0875752eb184f46032ff11 (diff) | |
Merge patch series "treewide: Clean up usage of DECLARE_GLOBAL_DATA_PTR"
Peng Fan (OSS) <[email protected]> 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/[email protected]
Diffstat (limited to 'test')
| -rw-r--r-- | test/cmd/exit.c | 3 | ||||
| -rw-r--r-- | test/cmd/test_echo.c | 3 | ||||
| -rw-r--r-- | test/cmd/test_pause.c | 3 | ||||
| -rw-r--r-- | test/dm/blk.c | 3 | ||||
| -rw-r--r-- | test/dm/i3c.c | 2 | ||||
| -rw-r--r-- | test/lib/test_print.c | 3 | ||||
| -rw-r--r-- | test/log/log_filter.c | 4 |
7 files changed, 1 insertions, 20 deletions
diff --git a/test/cmd/exit.c b/test/cmd/exit.c index fdde054b928..e20bc5f7b98 100644 --- a/test/cmd/exit.c +++ b/test/cmd/exit.c @@ -7,11 +7,8 @@ #include <console.h> #include <mapmem.h> -#include <asm/global_data.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - /* Declare a new exit test */ #define EXIT_TEST(_name, _flags) UNIT_TEST(_name, _flags, exit) diff --git a/test/cmd/test_echo.c b/test/cmd/test_echo.c index 8b306cc907f..7ed534742f7 100644 --- a/test/cmd/test_echo.c +++ b/test/cmd/test_echo.c @@ -6,14 +6,11 @@ */ #include <command.h> -#include <asm/global_data.h> #include <display_options.h> #include <test/lib.h> #include <test/test.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - struct test_data { char *cmd; char *expected; diff --git a/test/cmd/test_pause.c b/test/cmd/test_pause.c index 174c31a3852..b2cf60d3e74 100644 --- a/test/cmd/test_pause.c +++ b/test/cmd/test_pause.c @@ -5,12 +5,9 @@ * Copyright 2022, Samuel Dionne-Riel <[email protected]> */ -#include <asm/global_data.h> #include <test/lib.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - static int lib_test_hush_pause(struct unit_test_state *uts) { /* Test default message */ diff --git a/test/dm/blk.c b/test/dm/blk.c index 1b928b27d9c..f67869107da 100644 --- a/test/dm/blk.c +++ b/test/dm/blk.c @@ -8,14 +8,11 @@ #include <part.h> #include <sandbox_host.h> #include <usb.h> -#include <asm/global_data.h> #include <asm/state.h> #include <dm/test.h> #include <test/test.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - /* Test that block devices can be created */ static int dm_test_blk_base(struct unit_test_state *uts) { diff --git a/test/dm/i3c.c b/test/dm/i3c.c index 81336e67555..816ecabd722 100644 --- a/test/dm/i3c.c +++ b/test/dm/i3c.c @@ -8,8 +8,6 @@ #include <dm/test.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - /* Basic test of the i3c uclass */ static int dm_test_i3c_base(struct unit_test_state *uts) { diff --git a/test/lib/test_print.c b/test/lib/test_print.c index cd7f3f85769..2aeb034b121 100644 --- a/test/lib/test_print.c +++ b/test/lib/test_print.c @@ -7,13 +7,10 @@ #include <command.h> #include <display_options.h> -#include <asm/global_data.h> #include <test/lib.h> #include <test/test.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - static int test_print_freq(struct unit_test_state *uts, uint64_t freq, char *expected) { diff --git a/test/log/log_filter.c b/test/log/log_filter.c index 8622dcf2913..147b83980cf 100644 --- a/test/log/log_filter.c +++ b/test/log/log_filter.c @@ -5,12 +5,10 @@ #include <console.h> #include <log.h> -#include <asm/global_data.h> +#include <vsprintf.h> #include <test/log.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR; - /* Test invalid options */ static int log_test_filter_invalid(struct unit_test_state *uts) { |
