Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1393003

[PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC

From changbin.du@intel.com
Newsgroups linux.kernel
Subject [PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC
Date 2016-05-03 05:20 +0200
Message-ID <ruz2p-4U-1@gated-at.bofh.it> (permalink)
References <ruz2p-4U-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC changbin.du@intel.com - 2016-05-03 05:20 +0200
  Re: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as  binding to *any* UDC Krzysztof Opasiak <k.opasiak@samsung.com> - 2016-05-04 10:20 +0200
    RE: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as  binding to *any* UDC "Du, Changbin" <changbin.du@intel.com> - 2016-05-05 07:50 +0200
      Re: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as  binding to *any* UDC Krzysztof Opasiak <k.opasiak@samsung.com> - 2016-05-05 09:40 +0200
        RE: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as  binding to *any* UDC "Du, Changbin" <changbin.du@intel.com> - 2016-05-06 04:50 +0200
          Re: [PATCH 1/2] usb: configfs: allow UDC binding rule configured as  binding to *any* UDC Krzysztof Opasiak <k.opasiak@samsung.com> - 2016-05-06 08:00 +0200

csiph-web