diff mbox series

[v7,1/5] module.h: MODULE_DEVICE_TABLE for built-in modules

Message ID 20221216221703.294683-2-allenwebb@google.com
State New
Headers show
Series Generate modules.builtin.alias from match ids | expand

Commit Message

Allen Webb Dec. 16, 2022, 10:16 p.m. UTC
Implement MODULE_DEVICE_TABLE for build-in modules to make it possible
to generate a builtin.alias file to complement modules.alias.

Signed-off-by: Allen Webb <allenwebb@google.com>
---
 include/linux/module.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

kernel test robot Dec. 17, 2022, 3:59 a.m. UTC | #1
Hi Allen,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on masahiroy-kbuild/fixes]
[also build test ERROR on mcgrof/modules-next westeri-thunderbolt/next linus/master v6.1 next-20221216]
[cannot apply to masahiroy-kbuild/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Allen-Webb/module-h-MODULE_DEVICE_TABLE-for-built-in-modules/20221217-071949
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git fixes
patch link:    https://lore.kernel.org/r/20221216221703.294683-2-allenwebb%40google.com
patch subject: [PATCH v7 1/5] module.h: MODULE_DEVICE_TABLE for built-in modules
config: sh-allmodconfig
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/403b6f73d008681a1db43482df4038dd670f1bd4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Allen-Webb/module-h-MODULE_DEVICE_TABLE-for-built-in-modules/20221217-071949
        git checkout 403b6f73d008681a1db43482df4038dd670f1bd4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/cpumask.h:10,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/rcupdate.h:29,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/ratelimit.h:6,
                    from include/linux/dev_printk.h:16,
                    from include/linux/device.h:15,
                    from include/linux/spi/spi.h:10,
                    from drivers/mfd/stmpe-spi.c:10:
>> include/linux/module.h:251:21: error: '__mod_spi__stmpe_id__kmod_stmpe_spi_device_table' aliased to undefined symbol 'stmpe_id'
     251 |         CONCATENATE(__mod_##type##__##name##__,                         \
         |                     ^~~~~~
   include/linux/kernel.h:491:24: note: in definition of macro '__CONCAT'
     491 | #define __CONCAT(a, b) a ## b
         |                        ^
   include/linux/module.h:250:14: note: in expansion of macro 'CONCATENATE'
     250 | extern void *CONCATENATE(                                               \
         |              ^~~~~~~~~~~
   include/linux/kernel.h:492:27: note: in expansion of macro '__CONCAT'
     492 | #define CONCATENATE(a, b) __CONCAT(a, b)
         |                           ^~~~~~~~
   include/linux/module.h:251:9: note: in expansion of macro 'CONCATENATE'
     251 |         CONCATENATE(__mod_##type##__##name##__,                         \
         |         ^~~~~~~~~~~
   drivers/mfd/stmpe-spi.c:132:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
     132 | MODULE_DEVICE_TABLE(spi, stmpe_id);
         | ^~~~~~~~~~~~~~~~~~~
--
   In file included from include/linux/clk.h:13,
                    from drivers/mailbox/rockchip-mailbox.c:6:
>> include/linux/module.h:251:21: error: '__mod_of__rockchp_mbox_of_match__kmod_rockchip_mailbox_device_table' aliased to undefined symbol 'rockchp_mbox_of_match'
     251 |         CONCATENATE(__mod_##type##__##name##__,                         \
         |                     ^~~~~~
   include/linux/kernel.h:491:24: note: in definition of macro '__CONCAT'
     491 | #define __CONCAT(a, b) a ## b
         |                        ^
   include/linux/module.h:250:14: note: in expansion of macro 'CONCATENATE'
     250 | extern void *CONCATENATE(                                               \
         |              ^~~~~~~~~~~
   include/linux/kernel.h:492:27: note: in expansion of macro '__CONCAT'
     492 | #define CONCATENATE(a, b) __CONCAT(a, b)
         |                           ^~~~~~~~
   include/linux/module.h:251:9: note: in expansion of macro 'CONCATENATE'
     251 |         CONCATENATE(__mod_##type##__##name##__,                         \
         |         ^~~~~~~~~~~
   drivers/mailbox/rockchip-mailbox.c:162:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
     162 | MODULE_DEVICE_TABLE(of, rockchp_mbox_of_match);
         | ^~~~~~~~~~~~~~~~~~~
--
   In file included from include/linux/clk.h:13,
                    from drivers/soc/imx/imx8mp-blk-ctrl.c:7:
>> include/linux/module.h:251:21: error: '__mod_of__imx8m_blk_ctrl_of_match__kmod_imx8mp_blk_ctrl_device_table' aliased to undefined symbol 'imx8m_blk_ctrl_of_match'
     251 |         CONCATENATE(__mod_##type##__##name##__,                         \
         |                     ^~~~~~
   include/linux/kernel.h:491:24: note: in definition of macro '__CONCAT'
     491 | #define __CONCAT(a, b) a ## b
         |                        ^
   include/linux/module.h:250:14: note: in expansion of macro 'CONCATENATE'
     250 | extern void *CONCATENATE(                                               \
         |              ^~~~~~~~~~~
   include/linux/kernel.h:492:27: note: in expansion of macro '__CONCAT'
     492 | #define CONCATENATE(a, b) __CONCAT(a, b)
         |                           ^~~~~~~~
   include/linux/module.h:251:9: note: in expansion of macro 'CONCATENATE'
     251 |         CONCATENATE(__mod_##type##__##name##__,                         \
         |         ^~~~~~~~~~~
   drivers/soc/imx/imx8mp-blk-ctrl.c:746:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
     746 | MODULE_DEVICE_TABLE(of, imx8m_blk_ctrl_of_match);
         | ^~~~~~~~~~~~~~~~~~~


vim +251 include/linux/module.h

   239	
   240	#ifdef MODULE
   241	/* Creates an alias so file2alias.c can find device table. */
   242	#define MODULE_DEVICE_TABLE(type, name)					\
   243	extern typeof(name) __mod_##type##__##name##_device_table		\
   244	  __attribute__ ((unused, alias(__stringify(name))))
   245	#else  /* !MODULE */
   246	/* The names may not be unique for built-in modules, so include the module name
   247	 * to guarantee uniqueness.
   248	 */
   249	#define MODULE_DEVICE_TABLE(type, name)					\
   250	extern void *CONCATENATE(						\
 > 251		CONCATENATE(__mod_##type##__##name##__,				\
   252			__KBUILD_MODNAME),					\
   253		_device_table)							\
   254		__attribute__ ((unused, alias(__stringify(name))))
   255	#endif
   256
diff mbox series

Patch

diff --git a/include/linux/module.h b/include/linux/module.h
index ec61fb53979a9..49e4019393127 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -243,7 +243,15 @@  extern void cleanup_module(void);
 extern typeof(name) __mod_##type##__##name##_device_table		\
   __attribute__ ((unused, alias(__stringify(name))))
 #else  /* !MODULE */
-#define MODULE_DEVICE_TABLE(type, name)
+/* The names may not be unique for built-in modules, so include the module name
+ * to guarantee uniqueness.
+ */
+#define MODULE_DEVICE_TABLE(type, name)					\
+extern void *CONCATENATE(						\
+	CONCATENATE(__mod_##type##__##name##__,				\
+		__KBUILD_MODNAME),					\
+	_device_table)							\
+	__attribute__ ((unused, alias(__stringify(name))))
 #endif
 
 /* Version of form [<epoch>:]<version>[-<extra-version>].