From: changbin.du@intel.com
To: balbi@kernel.org
Cc: gregkh@linuxfoundation.org, corbet@lwn.net,
linux-usb@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, "Du,
Changbin" <changbin.du@gmail.com>,
Du@vger.kernel.org, Changbin <changbin.du@intel.com>
Subject: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC
Date: Tue, 3 May 2016 11:04:24 +0800 [thread overview]
Message-ID: <1462244665-27681-2-git-send-email-changbin.du@intel.com> (raw)
In-Reply-To: <1462244665-27681-1-git-send-email-changbin.du@intel.com>
From: "Du, Changbin" <changbin.du@gmail.com>
On most platforms, there is only one device controller available.
In this case, we desn't care the UDC's name. So let's ignore the
name by setting 'UDC' to 'any'. And also we can change UDC name
at any time if it is not binded (no need set to "" first).
Signed-off-by: Du, Changbin <changbin.du@gmail.com>
Signed-off-by: Du, Changbin <changbin.du@intel.com>
---
drivers/usb/gadget/configfs.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index b6f60ca..5da2991 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -230,16 +230,18 @@ static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item,
static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page)
{
- char *udc_name = to_gadget_info(item)->composite.gadget_driver.udc_name;
+ struct gadget_info *gi = to_gadget_info(item);
+ char *udc_name = gi->composite.gadget_driver.udc_name;
- return sprintf(page, "%s\n", udc_name ?: "");
+ return sprintf(page, "%s\n", udc_name ?:
+ (gi->cdev.gadget ? "any" : ""));
}
static int unregister_gadget(struct gadget_info *gi)
{
int ret;
- if (!gi->composite.gadget_driver.udc_name)
+ if (!gi->cdev.gadget)
return -ENODEV;
ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver);
@@ -270,10 +272,14 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
if (ret)
goto err;
} else {
- if (gi->composite.gadget_driver.udc_name) {
+ if (gi->cdev.gadget) {
ret = -EBUSY;
goto err;
}
+ if (!strcmp(name, "any")) {
+ kfree(name);
+ name = NULL;
+ }
gi->composite.gadget_driver.udc_name = name;
ret = usb_gadget_probe_driver(&gi->composite.gadget_driver);
if (ret) {
@@ -428,9 +434,9 @@ static int config_usb_cfg_unlink(
* remove the function.
*/
mutex_lock(&gi->lock);
- if (gi->composite.gadget_driver.udc_name)
+ if (gi->cdev.gadget)
unregister_gadget(gi);
- WARN_ON(gi->composite.gadget_driver.udc_name);
+ WARN_ON(gi->cdev.gadget);
list_for_each_entry(f, &cfg->func_list, list) {
if (f->fi == fi) {
@@ -873,10 +879,10 @@ static int os_desc_unlink(struct config_item *os_desc_ci,
struct usb_composite_dev *cdev = &gi->cdev;
mutex_lock(&gi->lock);
- if (gi->composite.gadget_driver.udc_name)
+ if (gi->cdev.gadget)
unregister_gadget(gi);
cdev->os_desc_config = NULL;
- WARN_ON(gi->composite.gadget_driver.udc_name);
+ WARN_ON(gi->cdev.gadget);
mutex_unlock(&gi->lock);
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2016-05-03 3:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-03 3:04 [PATCH 0/2] Add binding rule *any* support for USB Gadget Configfs changbin.du
2016-05-03 3:04 ` changbin.du [this message]
2016-05-04 8:14 ` [PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC Krzysztof Opasiak
2016-05-05 5:46 ` Du, Changbin
2016-05-05 7:31 ` Krzysztof Opasiak
2016-05-06 2:46 ` Du, Changbin
2016-05-06 5:49 ` Krzysztof Opasiak
2016-06-04 20:56 ` Pavel Machek
2016-06-06 2:21 ` Du, Changbin
2016-05-03 3:04 ` [PATCH 2/2] Documentation: gadget_configfs: update UDC binding changbin.du
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=1462244665-27681-2-git-send-email-changbin.du@intel.com \
--to=changbin.du@intel.com \
--cc=Du@vger.kernel.org \
--cc=balbi@kernel.org \
--cc=changbin.du@gmail.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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