diff mbox

[2/7] usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock

Message ID 1350642285-8145-2-git-send-email-chf.fritz@googlemail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Christoph Fritz Oct. 19, 2012, 10:24 a.m. UTC
This patch reworks fsl_pullup() against the background of switching over
to udc_start()/udc_stop() style:

Protect function fsl_pullup() with a spin_lock. Also set vbus_active as
default to true. This prevents disabling USB controller if there is no
driver support for an external transceiver (or GPIO) that detects a VBUS
power session starting.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 drivers/usb/gadget/fsl_udc_core.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Felipe Balbi Oct. 19, 2012, 10:25 a.m. UTC | #1
Hi,

On Fri, Oct 19, 2012 at 12:24:40PM +0200, Christoph Fritz wrote:
> This patch reworks fsl_pullup() against the background of switching over
> to udc_start()/udc_stop() style:
> 
> Protect function fsl_pullup() with a spin_lock. Also set vbus_active as
> default to true. This prevents disabling USB controller if there is no

the vbus_active part should be in a separate patch as it has no relation
with $SUBJECT

> driver support for an external transceiver (or GPIO) that detects a VBUS
> power session starting.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  drivers/usb/gadget/fsl_udc_core.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
> index 340451d..0a0d6a6 100644
> --- a/drivers/usb/gadget/fsl_udc_core.c
> +++ b/drivers/usb/gadget/fsl_udc_core.c
> @@ -1242,8 +1242,10 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
>  static int fsl_pullup(struct usb_gadget *gadget, int is_on)
>  {
>  	struct fsl_udc *udc;
> +	unsigned long flags;
>  
>  	udc = container_of(gadget, struct fsl_udc, gadget);
> +	spin_lock_irqsave(&udc->lock, flags);
>  	udc->softconnect = (is_on != 0);
>  	if (can_pullup(udc))
>  		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
> @@ -1251,6 +1253,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on)
>  	else
>  		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
>  				&dr_regs->usbcmd);
> +	spin_unlock_irqrestore(&udc->lock, flags);
>  
>  	return 0;
>  }
> @@ -2557,6 +2560,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
>  	INIT_LIST_HEAD(&udc_controller->gadget.ep_list);
>  	udc_controller->gadget.speed = USB_SPEED_UNKNOWN;
>  	udc_controller->gadget.name = driver_name;
> +	udc->vbus_active = true;
>  
>  	/* Setup gadget.dev and register with kernel */
>  	dev_set_name(&udc_controller->gadget.dev, "gadget");
> -- 
> 1.7.2.5
>
diff mbox

Patch

diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 340451d..0a0d6a6 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1242,8 +1242,10 @@  static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
 static int fsl_pullup(struct usb_gadget *gadget, int is_on)
 {
 	struct fsl_udc *udc;
+	unsigned long flags;
 
 	udc = container_of(gadget, struct fsl_udc, gadget);
+	spin_lock_irqsave(&udc->lock, flags);
 	udc->softconnect = (is_on != 0);
 	if (can_pullup(udc))
 		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
@@ -1251,6 +1253,7 @@  static int fsl_pullup(struct usb_gadget *gadget, int is_on)
 	else
 		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
 				&dr_regs->usbcmd);
+	spin_unlock_irqrestore(&udc->lock, flags);
 
 	return 0;
 }
@@ -2557,6 +2560,7 @@  static int __init fsl_udc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&udc_controller->gadget.ep_list);
 	udc_controller->gadget.speed = USB_SPEED_UNKNOWN;
 	udc_controller->gadget.name = driver_name;
+	udc->vbus_active = true;
 
 	/* Setup gadget.dev and register with kernel */
 	dev_set_name(&udc_controller->gadget.dev, "gadget");