linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linyu Yuan <quic_linyyuan@quicinc.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>, Jack Pham <quic_jackp@quicinc.com>,
	"Linyu Yuan" <quic_linyyuan@quicinc.com>
Subject: [PATCH v3 4/4] usb: gadget: add '_' in DECLARE_USB_FUNCTION(_INIT) macros
Date: Mon, 9 May 2022 19:54:48 +0800	[thread overview]
Message-ID: <1652097288-19909-5-git-send-email-quic_linyyuan@quicinc.com> (raw)
In-Reply-To: <1652097288-19909-1-git-send-email-quic_linyyuan@quicinc.com>

DECLARE_USB_FUNCTION_INIT(ffs, ffs_alloc_inst, ffs_alloc)
will generate function ffsmod_init/ffsmod_exit()
and variable ffsusb_func.

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

f_tcm.c doing more thing in module init/exit, it will not use
DECLARE_USB_FUNCTION_INIT() macro, but we change DECLARE_USB_FUNCTION()
macro, it will change static struct usb_function_driver variable from
tcmusb_func to tcm_usb_func,
so update tcm_init()/tcm_exit() to use tcm_usb_func.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
v2: fix build issue from kernel test robot <lkp@intel.com>
v3: change commit description and add f_tcm.c change

 drivers/usb/gadget/function/f_tcm.c |  6 +++---
 include/linux/usb/composite.h       | 14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index 8e17ac8..4873587 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -2310,13 +2310,13 @@ static int tcm_init(void)
 {
 	int ret;
 
-	ret = usb_function_register(&tcmusb_func);
+	ret = usb_function_register(&tcm_usb_func);
 	if (ret)
 		return ret;
 
 	ret = target_register_template(&usbg_ops);
 	if (ret)
-		usb_function_unregister(&tcmusb_func);
+		usb_function_unregister(&tcm_usb_func);
 
 	return ret;
 }
@@ -2325,7 +2325,7 @@ module_init(tcm_init);
 static void tcm_exit(void)
 {
 	target_unregister_template(&usbg_ops);
-	usb_function_unregister(&tcmusb_func);
+	usb_function_unregister(&tcm_usb_func);
 }
 module_exit(tcm_exit);
 
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...) \
-- 
2.7.4


  parent reply	other threads:[~2022-05-09 11:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 11:54 [PATCH v3 0/4] usb: gadget: update DECLARE_USB_FUNCTION(_INIT) macro Linyu Yuan
2022-05-09 11:54 ` [PATCH v3 1/4] usb: gadget: f_mass_storage: fix warning of -Werror=unused-but-set-variable Linyu Yuan
2022-05-09 12:48   ` Greg Kroah-Hartman
2022-05-09 11:54 ` [PATCH v3 2/4] usb: gadget: f_sourcesink: use DECLARE_USB_FUNCTION_INIT() Linyu Yuan
2022-05-09 12:49   ` Greg Kroah-Hartman
2022-05-09 11:54 ` [PATCH v3 3/4] usb: gadget: f_loopback: use DECLARE_USB_FUNCTION_INIT() macro Linyu Yuan
2022-05-09 18:39   ` kernel test robot
2022-05-09 19:22   ` kernel test robot
2022-05-09 11:54 ` Linyu Yuan [this message]
2022-05-09 12:50   ` [PATCH v3 4/4] usb: gadget: add '_' in DECLARE_USB_FUNCTION(_INIT) macros Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1652097288-19909-5-git-send-email-quic_linyyuan@quicinc.com \
    --to=quic_linyyuan@quicinc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_jackp@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).