[PATCH v4 01/42] dtoc: Drop use of DECL() macros

Simon Glass sjg at chromium.org
Mon Mar 15 05:25:11 CET 2021


We can use extern instead, so let's drop these macros. It adds one more
thing to learn about and doesn't make the code any clearer.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v3)

Changes in v3:
- Add new patch to drop DECL() macros from dtoc (to squash in)

 tools/dtoc/dtb_platdata.py |  8 ++---
 tools/dtoc/test_dtoc.py    | 64 +++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index f5b5ad5f71a..b5c449ebb47 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -902,14 +902,14 @@ class DtbPlatdata():
         self.buf(
             '/* driver declarations - these allow DM_DRIVER_GET() to be used */\n')
         for node in nodes_to_output:
-            self.buf('DM_DRIVER_DECL(%s);\n' % node.struct_name);
+            self.buf('extern U_BOOT_DRIVER(%s);\n' % node.struct_name);
         self.buf('\n')
 
         if self._instantiate:
             self.buf(
                 '/* device declarations - these allow DM_DEVICE_REF() to be used */\n')
             for node in nodes_to_output:
-                self.buf('DM_DEVICE_DECL(%s);\n' % node.var_name)
+                self.buf('extern DM_DEVICE_INST(%s);\n' % node.var_name)
             self.buf('\n')
 
         uclass_list = self._valid_uclasses
@@ -917,13 +917,13 @@ class DtbPlatdata():
         self.buf(
             '/* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */\n')
         for uclass in uclass_list:
-            self.buf('DM_UCLASS_DRIVER_DECL(%s);\n' % uclass.name)
+            self.buf('extern UCLASS_DRIVER(%s);\n' % uclass.name)
 
         if self._instantiate:
             self.buf('\n')
             self.buf('/* uclass declarations - needed for DM_UCLASS_REF() */\n')
             for uclass in uclass_list:
-                self.buf('DM_UCLASS_DECL(%s);\n' % uclass.name)
+                self.buf('extern DM_UCLASS_INST(%s);\n' % uclass.name)
         self.out(''.join(self.get_buf()))
 
     def assign_seqs(self):
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index bb689f3b6e9..1912a8723f2 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -241,52 +241,52 @@ class TestDtoc(unittest.TestCase):
 #include <dm/uclass-internal.h>
 
 /* driver declarations - these allow DM_DRIVER_GET() to be used */
-DM_DRIVER_DECL(sandbox_i2c);
-DM_DRIVER_DECL(sandbox_pmic);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_i2c);
+extern U_BOOT_DRIVER(sandbox_pmic);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_spl_test);
 
 /* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */
-DM_UCLASS_DRIVER_DECL(i2c);
-DM_UCLASS_DRIVER_DECL(misc);
-DM_UCLASS_DRIVER_DECL(pmic);
+extern UCLASS_DRIVER(i2c);
+extern UCLASS_DRIVER(misc);
+extern UCLASS_DRIVER(pmic);
 '''
     decl_text_inst = DECL_HEADER + '''
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
 
 /* driver declarations - these allow DM_DRIVER_GET() to be used */
-DM_DRIVER_DECL(sandbox_i2c);
-DM_DRIVER_DECL(root_driver);
-DM_DRIVER_DECL(denx_u_boot_test_bus);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(sandbox_spl_test);
-DM_DRIVER_DECL(denx_u_boot_fdt_test);
-DM_DRIVER_DECL(denx_u_boot_fdt_test);
+extern U_BOOT_DRIVER(sandbox_i2c);
+extern U_BOOT_DRIVER(root_driver);
+extern U_BOOT_DRIVER(denx_u_boot_test_bus);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(sandbox_spl_test);
+extern U_BOOT_DRIVER(denx_u_boot_fdt_test);
+extern U_BOOT_DRIVER(denx_u_boot_fdt_test);
 
 /* device declarations - these allow DM_DEVICE_REF() to be used */
-DM_DEVICE_DECL(i2c);
-DM_DEVICE_DECL(root);
-DM_DEVICE_DECL(some_bus);
-DM_DEVICE_DECL(spl_test);
-DM_DEVICE_DECL(spl_test3);
-DM_DEVICE_DECL(test);
-DM_DEVICE_DECL(test0);
+extern DM_DEVICE_INST(i2c);
+extern DM_DEVICE_INST(root);
+extern DM_DEVICE_INST(some_bus);
+extern DM_DEVICE_INST(spl_test);
+extern DM_DEVICE_INST(spl_test3);
+extern DM_DEVICE_INST(test);
+extern DM_DEVICE_INST(test0);
 
 /* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */
-DM_UCLASS_DRIVER_DECL(i2c);
-DM_UCLASS_DRIVER_DECL(misc);
-DM_UCLASS_DRIVER_DECL(root);
-DM_UCLASS_DRIVER_DECL(testbus);
-DM_UCLASS_DRIVER_DECL(testfdt);
+extern UCLASS_DRIVER(i2c);
+extern UCLASS_DRIVER(misc);
+extern UCLASS_DRIVER(root);
+extern UCLASS_DRIVER(testbus);
+extern UCLASS_DRIVER(testfdt);
 
 /* uclass declarations - needed for DM_UCLASS_REF() */
-DM_UCLASS_DECL(i2c);
-DM_UCLASS_DECL(misc);
-DM_UCLASS_DECL(root);
-DM_UCLASS_DECL(testbus);
-DM_UCLASS_DECL(testfdt);
+extern DM_UCLASS_INST(i2c);
+extern DM_UCLASS_INST(misc);
+extern DM_UCLASS_INST(root);
+extern DM_UCLASS_INST(testbus);
+extern DM_UCLASS_INST(testfdt);
 '''
     struct_text = HEADER + '''
 struct dtd_sandbox_i2c {
-- 
2.31.0.rc2.261.g7f71774620-goog



More information about the U-Boot mailing list