Re: [rfc patch 1/3] usb: gadget: composite: we should deactivate per-configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Jul 27, 2009 at 02:43:40PM +0200, ext Sergei Shtylyov wrote:
> > diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> > index 4f6bb3d..7e2c119 100644
> > --- a/include/linux/usb/composite.h
> > +++ b/include/linux/usb/composite.h
> > @@ -330,11 +330,6 @@ struct usb_composite_dev {
> >  	struct usb_composite_driver	*driver;
> >  	u8				next_string_id;
> >  
> > -	/* the gadget driver won't enable the data pullup
> > -	 * while the deactivation count is nonzero.
> > -	 */
> > -	unsigned			deactivations;
> > -
> >  	/* protects at least deactivation count */
> >  	spinlock_t			lock;
> >  };
> 
>     I'm not seeing where are you adding 'deactivations' to the 'struct 
> usb_configuration'...

oops, good catch, I forgot to add one hunk, here's updated patch. Sorry
for that.

====== cut here ========

>From 263464b34aaca10898a2f874b7129934b85c2d73 Mon Sep 17 00:00:00 2001
From: Felipe Balbi <felipe.balbi@xxxxxxxxx>
Date: Mon, 27 Jul 2009 13:10:23 +0300
Subject: [rfc patch 1/3] usb: gadget: composite: we should deactivate per-configuration

gadgets with multiple configurations will have problems with
deactivations since they will register function_driver * configurations
instances of each function driver, which will make
cdev->deactivations to never become zero as it should.

Moving deactivations to usb_configuration in order seems to
be the right fix to prevent the failure where gadget won't
ever connect to usb bus.

Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxx>
---
 drivers/usb/gadget/composite.c |   16 +++++++++-------
 include/linux/usb/composite.h  |   10 +++++-----
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 59e8523..3e3380d 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -148,16 +148,17 @@ done:
  */
 int usb_function_deactivate(struct usb_function *function)
 {
-	struct usb_composite_dev	*cdev = function->config->cdev;
+	struct usb_configuration	*config = function->config;
+	struct usb_composite_dev	*cdev = config->cdev;
 	unsigned long			flags;
 	int				status = 0;
 
 	spin_lock_irqsave(&cdev->lock, flags);
 
-	if (cdev->deactivations == 0)
+	if (config->deactivations == 0)
 		status = usb_gadget_disconnect(cdev->gadget);
 	if (status == 0)
-		cdev->deactivations++;
+		config->deactivations++;
 
 	spin_unlock_irqrestore(&cdev->lock, flags);
 	return status;
@@ -175,16 +176,17 @@ int usb_function_deactivate(struct usb_function *function)
  */
 int usb_function_activate(struct usb_function *function)
 {
-	struct usb_composite_dev	*cdev = function->config->cdev;
+	struct usb_configuration	*config = function->config;
+	struct usb_composite_dev	*cdev = config->cdev;
 	int				status = 0;
 
 	spin_lock(&cdev->lock);
 
-	if (WARN_ON(cdev->deactivations == 0))
+	if (WARN_ON(config->deactivations == 0))
 		status = -EINVAL;
 	else {
-		cdev->deactivations--;
-		if (cdev->deactivations == 0)
+		config->deactivations--;
+		if (config->deactivations == 0)
 			status = usb_gadget_connect(cdev->gadget);
 	}
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 4f6bb3d..2c987c9 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -220,6 +220,11 @@ struct usb_configuration {
 
 	struct usb_composite_dev	*cdev;
 
+	/* the gadget driver won't enable the data pullup
+	 * while the deactivation count is nonzero.
+	 */
+	unsigned			deactivations;
+
 	/* private: */
 	/* internals */
 	struct list_head	list;
@@ -330,11 +335,6 @@ struct usb_composite_dev {
 	struct usb_composite_driver	*driver;
 	u8				next_string_id;
 
-	/* the gadget driver won't enable the data pullup
-	 * while the deactivation count is nonzero.
-	 */
-	unsigned			deactivations;
-
 	/* protects at least deactivation count */
 	spinlock_t			lock;
 };
-- 
1.6.3.3.385.g60647


-- 
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux