From patchwork Fri Oct 19 10:24:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Fritz X-Patchwork-Id: 192637 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id E743B2C022F for ; Fri, 19 Oct 2012 21:26:18 +1100 (EST) Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id AB8DE2C036F for ; Fri, 19 Oct 2012 21:25:25 +1100 (EST) Received: by mail-bk0-f51.google.com with SMTP id e19so111780bku.38 for ; Fri, 19 Oct 2012 03:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=coNJTjzrHp//Po402lgoTbsjS3xDfHxGal9x1Ck4H3o=; b=PHTR/WiE7ZH/QUFrOcaHKu9yx1zcbdFu3wtrb10d3b2IDJNOyzj+zfNCWDujDAV6cM cYGkPeD6DoXERPYYr22cy2wC8szvxyMxAvcZ4blXwdnb3Ss06rbZyfJ/gZ3ILPk7G4iF QZ3lJuFum7DbGuNdmxsUJlnDgcyBrnUORxZPYTGU1BmWk7HN52JX9aGasDtdQI9sHG6A fyQxIlrqdjH5EDZx6vr1wsvIINsO8GSPpnncRrWs1svFnLUwuvT3uZWpoRKCukqVukAG 4h2Dqt5BMlq9lpcgEI+A0G0aAANPvuQxolkr7MOgvAgb2XBZEkUQh3C58Yx/YruVZKOi hocg== Received: by 10.204.3.214 with SMTP id 22mr222343bko.108.1350642324817; Fri, 19 Oct 2012 03:25:24 -0700 (PDT) Received: from localhost.localdomain (p5DD1557F.dip.t-dialin.net. [93.209.85.127]) by mx.google.com with ESMTPS id v14sm598539bkv.10.2012.10.19.03.25.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 03:25:24 -0700 (PDT) From: Christoph Fritz To: Felipe Balbi Subject: [PATCH 2/7] usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock Date: Fri, 19 Oct 2012 12:24:40 +0200 Message-Id: <1350642285-8145-2-git-send-email-chf.fritz@googlemail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1350642156-8034-1-git-send-email-chf.fritz@googlemail.com> References: <1350642156-8034-1-git-send-email-chf.fritz@googlemail.com> Cc: Estevam Fabio-R49496 , Li Yang-R58472 , Greg Kroah-Hartman , Chen Peter-B29397 , Sascha Hauer , linux-usb@vger.kernel.org, "Hans J. Koch" , Daniel Mack , Christian Hemp , linuxppc-dev@lists.ozlabs.org, Teresa Gamez , Sebastian Andrzej Siewior X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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");