From patchwork Wed Apr 3 08:45:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15846 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1291623E21 for ; Wed, 3 Apr 2013 08:48:44 +0000 (UTC) Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by fiordland.canonical.com (Postfix) with ESMTP id 94453A184B7 for ; Wed, 3 Apr 2013 08:48:43 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id b4sf2174222qen.4 for ; Wed, 03 Apr 2013 01:48:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=7Cqdb+IH4d7CSccDBUA+DIiV9QEXuSmQDp4M6J5Gdos=; b=KBb05O1NHAUWbMhri1HB6TSAtY32v27GoVyyMLROLumxNSMcdxMYCfrCqTcX7lhuez 41MGwWHlC9RvJWL/KOl0lh4yD6XsYWg2Qb6nAo04J/cQ2bM+tDPm+Hkf2OXO8PnPGKEW dPcN/Lz/90hvrjE2ilOnNWLVpoLG/3BPQc62OAfynYvzOsjwvs8sr0+m+of4iO+5kdkN FbOWMySs/jH32uaQyEatIMuLfb4wEYLb2KzvOtm99kqC3/5xEubNCpAO7mCy+zGBYGU9 kequ5iiFC9Mz8xs4uU/T4/dTtfeZ1AsRqbjHB2qM+ikwMjG7tknfblthvRqNi7l+aCIc XU/g== X-Received: by 10.224.110.68 with SMTP id m4mr708006qap.2.1364978923045; Wed, 03 Apr 2013 01:48:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.129.99 with SMTP id nv3ls763454qeb.6.gmail; Wed, 03 Apr 2013 01:48:42 -0700 (PDT) X-Received: by 10.52.230.167 with SMTP id sz7mr430330vdc.81.1364978922911; Wed, 03 Apr 2013 01:48:42 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id iu6si4263228vcb.52.2013.04.03.01.48.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:48:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id m17so1295870vca.11 for ; Wed, 03 Apr 2013 01:48:42 -0700 (PDT) X-Received: by 10.59.3.9 with SMTP id bs9mr500566ved.38.1364978922787; Wed, 03 Apr 2013 01:48:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp160672ved; Wed, 3 Apr 2013 01:48:42 -0700 (PDT) X-Received: by 10.14.173.196 with SMTP id v44mr1810100eel.29.1364978921626; Wed, 03 Apr 2013 01:48:41 -0700 (PDT) Received: from mail-ea0-x231.google.com (mail-ea0-x231.google.com [2a00:1450:4013:c01::231]) by mx.google.com with ESMTPS id h2si7575236eeg.145.2013.04.03.01.48.41 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:48:41 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4013:c01::231 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=2a00:1450:4013:c01::231; Received: by mail-ea0-f177.google.com with SMTP id q14so549012eaj.8 for ; Wed, 03 Apr 2013 01:48:41 -0700 (PDT) X-Received: by 10.14.200.137 with SMTP id z9mr1859709een.20.1364978920875; Wed, 03 Apr 2013 01:48:40 -0700 (PDT) Received: from localhost ([2a01:2003:1:1e91:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id n2sm6878871eeo.10.2013.04.03.01.48.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 01:48:40 -0700 (PDT) From: Fabio Baltieri To: Felipe Balbi Cc: Linus Walleij , Praveena Nadahally , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Sakethram Bommisetti , Fabio Baltieri Subject: [PATCH 12/12] usb: phy: ab8500-usb: call phy_dis_work only when necessary Date: Wed, 3 Apr 2013 10:45:13 +0200 Message-Id: <1364978713-19612-13-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1364978713-19612-1-git-send-email-fabio.baltieri@linaro.org> References: <1364978713-19612-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQlqXSA/Q+VpEx4TFMXju2xboDEzjv6ct99mtCb5dTtFscxpYe6Lzr94sI87miNf5EgX+yAe X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Sakethram Bommisetti Modify ab8500_usb_set_peripheral() and ab8500_usb_set_host() code to schedule phy_dis_work only when necessary in order to prevent regulator count mismatch during reboot/shutdown. Signed-off-by: Sakethram Bommisetti Acked-by: Linus Walleij Signed-off-by: Fabio Baltieri --- drivers/usb/phy/phy-ab8500-usb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index 30adfee..81d1a5a 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c @@ -613,17 +613,16 @@ static int ab8500_usb_set_peripheral(struct usb_otg *otg, ab = phy_to_ab(otg->phy); + ab->phy.otg->gadget = gadget; + /* Some drivers call this function in atomic context. * Do not update ab8500 registers directly till this * is fixed. */ - if (!gadget) { - otg->gadget = NULL; + if ((ab->mode != USB_IDLE) && (!gadget)) { + ab->mode = USB_IDLE; schedule_work(&ab->phy_dis_work); - } else { - otg->gadget = gadget; - otg->phy->state = OTG_STATE_B_IDLE; } return 0; @@ -638,16 +637,16 @@ static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host) ab = phy_to_ab(otg->phy); + ab->phy.otg->host = host; + /* Some drivers call this function in atomic context. * Do not update ab8500 registers directly till this * is fixed. */ - if (!host) { - otg->host = NULL; + if ((ab->mode != USB_IDLE) && (!host)) { + ab->mode = USB_IDLE; schedule_work(&ab->phy_dis_work); - } else { - otg->host = host; } return 0;