diff mbox series

usb: gadget: update DECLARE_USB_FUNCTION(_INIT) macro

Message ID 1652069653-6961-1-git-send-email-quic_linyyuan@quicinc.com
State New
Headers show
Series usb: gadget: update DECLARE_USB_FUNCTION(_INIT) macro | expand

Commit Message

Linyu Yuan May 9, 2022, 4:14 a.m. UTC
Take DECLARE_USB_FUNCTION_INIT(ffs, ffs_alloc_inst, ffs_alloc) as example,
it will generate function ffsmod_init/ffsmod_exit()
and variable ffsusb_func.

Add possible character '_' in the macro which will generate
function/variable name in common format, ffs_mod_init/ffs_mod_exit()
and ffs_usb_func.

It will apply to all gadget functions which use this macro.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 include/linux/usb/composite.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

kernel test robot May 9, 2022, 6:10 a.m. UTC | #1
Hi Linyu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.18-rc6 next-20220506]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Linyu-Yuan/usb-gadget-update-DECLARE_USB_FUNCTION-_INIT-macro/20220509-122915
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: hexagon-randconfig-r045-20220509 (https://download.01.org/0day-ci/archive/20220509/202205091426.o1eXthPp-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a385645b470e2d3a1534aae618ea56b31177639f)
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/ce4965d3f282c0e6971a978b6b892f2f8352553d
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Linyu-Yuan/usb-gadget-update-DECLARE_USB_FUNCTION-_INIT-macro/20220509-122915
        git checkout ce4965d3f282c0e6971a978b6b892f2f8352553d
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/usb/gadget/function/

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

All errors (new ones prefixed by >>):

>> drivers/usb/gadget/function/f_loopback.c:590:32: error: use of undeclared identifier 'Loopbackusb_func'; did you mean 'Loopback_usb_func'?
           return usb_function_register(&Loopbackusb_func);
                                         ^~~~~~~~~~~~~~~~
                                         Loopback_usb_func
   drivers/usb/gadget/function/f_loopback.c:586:1: note: 'Loopback_usb_func' declared here
   DECLARE_USB_FUNCTION(Loopback, loopback_alloc_instance, loopback_alloc);
   ^
   include/linux/usb/composite.h:614:36: note: expanded from macro 'DECLARE_USB_FUNCTION'
           static struct usb_function_driver _name ## _usb_func = {        \
                                             ^
   <scratch space>:94:1: note: expanded from here
   Loopback_usb_func
   ^
   drivers/usb/gadget/function/f_loopback.c:595:27: error: use of undeclared identifier 'Loopbackusb_func'; did you mean 'Loopback_usb_func'?
           usb_function_unregister(&Loopbackusb_func);
                                    ^~~~~~~~~~~~~~~~
                                    Loopback_usb_func
   drivers/usb/gadget/function/f_loopback.c:586:1: note: 'Loopback_usb_func' declared here
   DECLARE_USB_FUNCTION(Loopback, loopback_alloc_instance, loopback_alloc);
   ^
   include/linux/usb/composite.h:614:36: note: expanded from macro 'DECLARE_USB_FUNCTION'
           static struct usb_function_driver _name ## _usb_func = {        \
                                             ^
   <scratch space>:94:1: note: expanded from here
   Loopback_usb_func
   ^
   2 errors generated.
--
>> drivers/usb/gadget/function/f_sourcesink.c:1273:31: error: use of undeclared identifier 'SourceSinkusb_func'; did you mean 'SourceSink_usb_func'?
           ret = usb_function_register(&SourceSinkusb_func);
                                        ^~~~~~~~~~~~~~~~~~
                                        SourceSink_usb_func
   drivers/usb/gadget/function/f_sourcesink.c:1266:1: note: 'SourceSink_usb_func' declared here
   DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst,
   ^
   include/linux/usb/composite.h:614:36: note: expanded from macro 'DECLARE_USB_FUNCTION'
           static struct usb_function_driver _name ## _usb_func = {        \
                                             ^
   <scratch space>:136:1: note: expanded from here
   SourceSink_usb_func
   ^
   drivers/usb/gadget/function/f_sourcesink.c:1278:28: error: use of undeclared identifier 'SourceSinkusb_func'; did you mean 'SourceSink_usb_func'?
                   usb_function_unregister(&SourceSinkusb_func);
                                            ^~~~~~~~~~~~~~~~~~
                                            SourceSink_usb_func
   drivers/usb/gadget/function/f_sourcesink.c:1266:1: note: 'SourceSink_usb_func' declared here
   DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst,
   ^
   include/linux/usb/composite.h:614:36: note: expanded from macro 'DECLARE_USB_FUNCTION'
           static struct usb_function_driver _name ## _usb_func = {        \
                                             ^
   <scratch space>:136:1: note: expanded from here
   SourceSink_usb_func
   ^
   drivers/usb/gadget/function/f_sourcesink.c:1283:27: error: use of undeclared identifier 'SourceSinkusb_func'; did you mean 'SourceSink_usb_func'?
           usb_function_unregister(&SourceSinkusb_func);
                                    ^~~~~~~~~~~~~~~~~~
                                    SourceSink_usb_func
   drivers/usb/gadget/function/f_sourcesink.c:1266:1: note: 'SourceSink_usb_func' declared here
   DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst,
   ^
   include/linux/usb/composite.h:614:36: note: expanded from macro 'DECLARE_USB_FUNCTION'
           static struct usb_function_driver _name ## _usb_func = {        \
                                             ^
   <scratch space>:136:1: note: expanded from here
   SourceSink_usb_func
   ^
   3 errors generated.


vim +590 drivers/usb/gadget/function/f_loopback.c

cf9a08ae5aece8 drivers/usb/gadget/f_loopback.c          Sebastian Andrzej Siewior 2012-12-23  587  
cf9a08ae5aece8 drivers/usb/gadget/f_loopback.c          Sebastian Andrzej Siewior 2012-12-23  588  int __init lb_modinit(void)
cf9a08ae5aece8 drivers/usb/gadget/f_loopback.c          Sebastian Andrzej Siewior 2012-12-23  589  {
5387c920372a3a drivers/usb/gadget/function/f_loopback.c Colin Ian King            2016-09-08 @590  	return usb_function_register(&Loopbackusb_func);
e5760fdac8c8ae drivers/usb/gadget/f_loopback.c          David Brownell            2008-06-19  591  }
5387c920372a3a drivers/usb/gadget/function/f_loopback.c Colin Ian King            2016-09-08  592
diff mbox series

Patch

diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 9d27622..0eac583 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -611,7 +611,7 @@  int usb_add_config_only(struct usb_composite_dev *cdev,
 void usb_remove_function(struct usb_configuration *c, struct usb_function *f);
 
 #define DECLARE_USB_FUNCTION(_name, _inst_alloc, _func_alloc)		\
-	static struct usb_function_driver _name ## usb_func = {		\
+	static struct usb_function_driver _name ## _usb_func = {	\
 		.name = __stringify(_name),				\
 		.mod  = THIS_MODULE,					\
 		.alloc_inst = _inst_alloc,				\
@@ -621,16 +621,16 @@  void usb_remove_function(struct usb_configuration *c, struct usb_function *f);
 
 #define DECLARE_USB_FUNCTION_INIT(_name, _inst_alloc, _func_alloc)	\
 	DECLARE_USB_FUNCTION(_name, _inst_alloc, _func_alloc)		\
-	static int __init _name ## mod_init(void)			\
+	static int __init _name ## _mod_init(void)			\
 	{								\
-		return usb_function_register(&_name ## usb_func);	\
+		return usb_function_register(&_name ## _usb_func);	\
 	}								\
-	static void __exit _name ## mod_exit(void)			\
+	static void __exit _name ## _mod_exit(void)			\
 	{								\
-		usb_function_unregister(&_name ## usb_func);		\
+		usb_function_unregister(&_name ## _usb_func);		\
 	}								\
-	module_init(_name ## mod_init);					\
-	module_exit(_name ## mod_exit)
+	module_init(_name ## _mod_init);				\
+	module_exit(_name ## _mod_exit)
 
 /* messaging utils */
 #define DBG(d, fmt, args...) \