[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1462244665-27681-2-git-send-email-changbin.du@intel.com>
Date: Tue, 3 May 2016 11:04:24 +0800
From: changbin.du@...el.com
To: balbi@...nel.org
Cc: gregkh@...uxfoundation.org, corbet@....net,
linux-usb@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
"Du, Changbin" <changbin.du@...il.com>, Du@...r.kernel.org,
Changbin <changbin.du@...el.com>
Subject: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC
From: "Du, Changbin" <changbin.du@...il.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@...il.com>
Signed-off-by: Du, Changbin <changbin.du@...el.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
Powered by blists - more mailing lists