diff mbox series

[v2] usb: gadget: update DECLARE_USB_FUNCTION(_INIT) macro

Message ID 1652077685-30622-1-git-send-email-quic_linyyuan@quicinc.com (mailing list archive)
State Superseded
Headers show
Series [v2] usb: gadget: update DECLARE_USB_FUNCTION(_INIT) macro | expand

Commit Message

Linyu Yuan May 9, 2022, 6:28 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.

Also do minor change accordingly to f_loopback.c and f_sourcesink.c.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
v2: fix issue report by kernel test robot <lkp@intel.com>

 drivers/usb/gadget/function/f_loopback.c   | 12 +-----------
 drivers/usb/gadget/function/f_sourcesink.c |  6 +++---
 include/linux/usb/composite.h              | 14 +++++++-------
 3 files changed, 11 insertions(+), 21 deletions(-)

Comments

Greg Kroah-Hartman May 9, 2022, 6:43 a.m. UTC | #1
On Mon, May 09, 2022 at 02:28:05PM +0800, Linyu Yuan wrote:
> 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.

I do not think "as example" is needed here, right?

> 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.

Ok, but why do this?  Why not add any other character?  What problem
does this solve?

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

That is a given for any macro, and you do nto needs to state this.

> 
> Also do minor change accordingly to f_loopback.c and f_sourcesink.c.

Why "also"?  What minor change are you making and why?

When you have "also" in a changelog text, that's a huge hint it should
be more than one commit, and I think this should be more than one commit
(hint, the f_loopback.c change can go first).

> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
> v2: fix issue report by kernel test robot <lkp@intel.com>
> 
>  drivers/usb/gadget/function/f_loopback.c   | 12 +-----------
>  drivers/usb/gadget/function/f_sourcesink.c |  6 +++---
>  include/linux/usb/composite.h              | 14 +++++++-------
>  3 files changed, 11 insertions(+), 21 deletions(-)

As the first version showed, you didn't test-build this so I really do
not understand why it is needed as you obviously are not using this
change anywhere..  Why the extra churn for no real advantage?

thanks,

greg k-h
Linyu Yuan May 9, 2022, 6:51 a.m. UTC | #2
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Sent: Monday, May 9, 2022 2:43 PM
> To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>
> Cc: linux-usb@vger.kernel.org; Jack Pham (QUIC) <quic_jackp@quicinc.com>
> Subject: Re: [PATCH v2] usb: gadget: update
> DECLARE_USB_FUNCTION(_INIT) macro
> 
> On Mon, May 09, 2022 at 02:28:05PM +0800, Linyu Yuan wrote:
> > 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.
> 
> I do not think "as example" is needed here, right?
> 
> > 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.
> 
> Ok, but why do this?  Why not add any other character?  What problem
> does this solve?
> 
> >
> > It will apply to all gadget functions which use this macro.
> 
> That is a given for any macro, and you do nto needs to state this.
Got it, thanks
> 
> >
> > Also do minor change accordingly to f_loopback.c and f_sourcesink.c.
> 
> Why "also"?  What minor change are you making and why?
> 

Will explain the detail change next version.

> When you have "also" in a changelog text, that's a huge hint it should
> be more than one commit, and I think this should be more than one commit
> (hint, the f_loopback.c change can go first).
> 
> > Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> > ---
> > v2: fix issue report by kernel test robot <lkp@intel.com>
> >
> >  drivers/usb/gadget/function/f_loopback.c   | 12 +-----------
> >  drivers/usb/gadget/function/f_sourcesink.c |  6 +++---
> >  include/linux/usb/composite.h              | 14 +++++++-------
> >  3 files changed, 11 insertions(+), 21 deletions(-)
> 
> As the first version showed, you didn't test-build this so I really do
> not understand why it is needed as you obviously are not using this
> change anywhere..  Why the extra churn for no real advantage?

No, on my local workspace, first I only choose f_fs.c to compile.
Sorry for that.

> 
> thanks,
> 
> greg k-h
kernel test robot May 9, 2022, 9:04 a.m. UTC | #3
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-144542
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: nios2-randconfig-r035-20220509 (https://download.01.org/0day-ci/archive/20220509/202205091634.SZNjdkFo-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.3.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/5c9f589ea23bf995436cde6bd39f1c5b2cc1ec4f
        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-144542
        git checkout 5c9f589ea23bf995436cde6bd39f1c5b2cc1ec4f
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=nios2 SHELL=/bin/bash

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 >>):

   nios2-linux-ld: drivers/usb/gadget/function/f_sourcesink.o: in function `sslb_modinit':
>> f_sourcesink.c:(.init.text+0x0): multiple definition of `init_module'; drivers/usb/gadget/function/f_loopback.o:f_loopback.c:(.init.text+0x0): first defined here
   nios2-linux-ld: drivers/usb/gadget/function/f_sourcesink.o: in function `sslb_modexit':
>> f_sourcesink.c:(.exit.text+0x0): multiple definition of `cleanup_module'; drivers/usb/gadget/function/f_loopback.o:f_loopback.c:(.exit.text+0x0): first defined here
kernel test robot May 9, 2022, 9:24 a.m. UTC | #4
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-144542
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: mips-randconfig-r024-20220509 (https://download.01.org/0day-ci/archive/20220509/202205091746.HoR8ueL5-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
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/5c9f589ea23bf995436cde6bd39f1c5b2cc1ec4f
        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-144542
        git checkout 5c9f589ea23bf995436cde6bd39f1c5b2cc1ec4f
        # 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=mips 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_tcm.c:2313:31: error: use of undeclared identifier 'tcmusb_func'; did you mean 'tcm_usb_func'?
           ret = usb_function_register(&tcmusb_func);
                                        ^~~~~~~~~~~
                                        tcm_usb_func
   drivers/usb/gadget/function/f_tcm.c:2307:1: note: 'tcm_usb_func' declared here
   DECLARE_USB_FUNCTION(tcm, tcm_alloc_inst, tcm_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>:20:1: note: expanded from here
   tcm_usb_func
   ^
   drivers/usb/gadget/function/f_tcm.c:2319:28: error: use of undeclared identifier 'tcmusb_func'; did you mean 'tcm_usb_func'?
                   usb_function_unregister(&tcmusb_func);
                                            ^~~~~~~~~~~
                                            tcm_usb_func
   drivers/usb/gadget/function/f_tcm.c:2307:1: note: 'tcm_usb_func' declared here
   DECLARE_USB_FUNCTION(tcm, tcm_alloc_inst, tcm_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>:20:1: note: expanded from here
   tcm_usb_func
   ^
   drivers/usb/gadget/function/f_tcm.c:2328:27: error: use of undeclared identifier 'tcmusb_func'; did you mean 'tcm_usb_func'?
           usb_function_unregister(&tcmusb_func);
                                    ^~~~~~~~~~~
                                    tcm_usb_func
   drivers/usb/gadget/function/f_tcm.c:2307:1: note: 'tcm_usb_func' declared here
   DECLARE_USB_FUNCTION(tcm, tcm_alloc_inst, tcm_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>:20:1: note: expanded from here
   tcm_usb_func
   ^
   3 errors generated.


vim +2313 drivers/usb/gadget/function/f_tcm.c

dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2308  
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2309  static int tcm_init(void)
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2310  {
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2311  	int ret;
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2312  
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11 @2313  	ret = usb_function_register(&tcmusb_func);
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2314  	if (ret)
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2315  		return ret;
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2316  
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2317  	ret = target_register_template(&usbg_ops);
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2318  	if (ret)
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2319  		usb_function_unregister(&tcmusb_func);
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2320  
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2321  	return ret;
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2322  }
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2323  module_init(tcm_init);
dc8c46a5ae770d Andrzej Pietrasiewicz 2015-12-11  2324
kernel test robot May 9, 2022, 10:45 a.m. UTC | #5
Hi Linyu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on balbi-usb/testing/next peter-chen-usb/for-usb-next 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-144542
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-randconfig-a011-20220509 (https://download.01.org/0day-ci/archive/20220509/202205091809.29x90X9b-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/5c9f589ea23bf995436cde6bd39f1c5b2cc1ec4f
        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-144542
        git checkout 5c9f589ea23bf995436cde6bd39f1c5b2cc1ec4f
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

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 >>):

   ld: drivers/usb/gadget/function/f_sourcesink.o: in function `sslb_modinit':
>> drivers/usb/gadget/function/f_sourcesink.c:1270: multiple definition of `init_module'; drivers/usb/gadget/function/f_loopback.o:drivers/usb/gadget/function/f_loopback.c:586: first defined here
   ld: drivers/usb/gadget/function/f_sourcesink.o: in function `sslb_modexit':
>> drivers/usb/gadget/function/f_sourcesink.c:1283: multiple definition of `cleanup_module'; drivers/usb/gadget/function/f_loopback.o:drivers/usb/gadget/function/f_loopback.c:586: first defined here


vim +1270 drivers/usb/gadget/function/f_sourcesink.c

cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1245  
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1246  static struct usb_function_instance *source_sink_alloc_inst(void)
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1247  {
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1248  	struct f_ss_opts *ss_opts;
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1249  
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1250  	ss_opts = kzalloc(sizeof(*ss_opts), GFP_KERNEL);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1251  	if (!ss_opts)
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1252  		return ERR_PTR(-ENOMEM);
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1253  	mutex_init(&ss_opts->lock);
9890e33013fae0d drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-04-18  1254  	ss_opts->func_inst.free_func_inst = source_sink_free_instance;
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1255  	ss_opts->isoc_interval = GZERO_ISOC_INTERVAL;
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1256  	ss_opts->isoc_maxpacket = GZERO_ISOC_MAXPACKET;
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1257  	ss_opts->bulk_buflen = GZERO_BULK_BUFLEN;
0d6c3d96678d115 drivers/usb/gadget/function/f_sourcesink.c Peter Chen                2015-11-19  1258  	ss_opts->bulk_qlen = GZERO_SS_BULK_QLEN;
0d6c3d96678d115 drivers/usb/gadget/function/f_sourcesink.c Peter Chen                2015-11-19  1259  	ss_opts->iso_qlen = GZERO_SS_ISO_QLEN;
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1260  
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1261  	config_group_init_type_name(&ss_opts->func_inst.group, "",
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1262  				    &ss_func_type);
25d8015177ae7ba drivers/usb/gadget/f_sourcesink.c          Andrzej Pietrasiewicz     2013-11-07  1263  
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1264  	return &ss_opts->func_inst;
544aca39e670421 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1265  }
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1266  DECLARE_USB_FUNCTION(SourceSink, source_sink_alloc_inst,
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1267  		source_sink_alloc_func);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1268  
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1269  static int __init sslb_modinit(void)
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23 @1270  {
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1271  	int ret;
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1272  
5c9f589ea23bf99 drivers/usb/gadget/function/f_sourcesink.c Linyu Yuan                2022-05-09  1273  	ret = usb_function_register(&SourceSink_usb_func);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1274  	if (ret)
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1275  		return ret;
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1276  	ret = lb_modinit();
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1277  	if (ret)
5c9f589ea23bf99 drivers/usb/gadget/function/f_sourcesink.c Linyu Yuan                2022-05-09  1278  		usb_function_unregister(&SourceSink_usb_func);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1279  	return ret;
544aca39e670421 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1280  }
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1281  static void __exit sslb_modexit(void)
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1282  {
5c9f589ea23bf99 drivers/usb/gadget/function/f_sourcesink.c Linyu Yuan                2022-05-09 @1283  	usb_function_unregister(&SourceSink_usb_func);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1284  	lb_modexit();
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1285  }
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1286  module_init(sslb_modinit);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1287  module_exit(sslb_modexit);
cf9a08ae5aece88 drivers/usb/gadget/f_sourcesink.c          Sebastian Andrzej Siewior 2012-12-23  1288
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
index ae41f55..b0eda4f 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -583,16 +583,6 @@  static struct usb_function_instance *loopback_alloc_instance(void)
 
 	return  &lb_opts->func_inst;
 }
-DECLARE_USB_FUNCTION(Loopback, loopback_alloc_instance, loopback_alloc);
-
-int __init lb_modinit(void)
-{
-	return usb_function_register(&Loopbackusb_func);
-}
-
-void __exit lb_modexit(void)
-{
-	usb_function_unregister(&Loopbackusb_func);
-}
+DECLARE_USB_FUNCTION_INIT(Loopback, loopback_alloc_instance, loopback_alloc);
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 6803cd6..2b7d1f2 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -1270,17 +1270,17 @@  static int __init sslb_modinit(void)
 {
 	int ret;
 
-	ret = usb_function_register(&SourceSinkusb_func);
+	ret = usb_function_register(&SourceSink_usb_func);
 	if (ret)
 		return ret;
 	ret = lb_modinit();
 	if (ret)
-		usb_function_unregister(&SourceSinkusb_func);
+		usb_function_unregister(&SourceSink_usb_func);
 	return ret;
 }
 static void __exit sslb_modexit(void)
 {
-	usb_function_unregister(&SourceSinkusb_func);
+	usb_function_unregister(&SourceSink_usb_func);
 	lb_modexit();
 }
 module_init(sslb_modinit);
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...) \