From patchwork Tue Oct 16 09:59:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1599711 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 4E900DFFED for ; Tue, 16 Oct 2012 10:05:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753312Ab2JPKFG (ORCPT ); Tue, 16 Oct 2012 06:05:06 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:42206 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752415Ab2JPKFF (ORCPT ); Tue, 16 Oct 2012 06:05:05 -0400 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q9GA50UD008342; Tue, 16 Oct 2012 05:05:00 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9GA503a009651; Tue, 16 Oct 2012 05:05:00 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.1.323.3; Tue, 16 Oct 2012 05:05:00 -0500 Received: from localhost (h64-10.vpn.ti.com [172.24.64.10]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9GA4xno016062; Tue, 16 Oct 2012 05:04:59 -0500 Date: Tue, 16 Oct 2012 12:59:33 +0300 From: Felipe Balbi To: Vikas Sajjan CC: , , , , , , , Abhilash Kesavan , Doug Anderson Subject: Re: [PATCH v3 2/3] usb: xhci: Add the suspend/resume functionality Message-ID: <20121016095932.GA17416@arwen.pp.htv.fi> Reply-To: References: <1350380738-32473-1-git-send-email-vikas.sajjan@linaro.org> <1350380738-32473-3-git-send-email-vikas.sajjan@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1350380738-32473-3-git-send-email-vikas.sajjan@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Hi, On Tue, Oct 16, 2012 at 03:15:37PM +0530, Vikas Sajjan wrote: > Adds power management support to XHCI platform driver. > This patch facilitates the transition of xHCI host controller > between S0 and S3/S4 power states, during suspend/resume cycles. > > Signed-off-by: Abhilash Kesavan > Signed-off-by: Vikas C Sajjan > CC: Doug Anderson > --- > drivers/usb/host/xhci-plat.c | 28 ++++++++++++++++++++++++++++ > 1 files changed, 28 insertions(+), 0 deletions(-) > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > index df90fe5..eaf3a07 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -185,11 +185,39 @@ static int xhci_plat_remove(struct platform_device *dev) > return 0; > } > > +#ifdef CONFIG_PM_SLEEP > +static int xhci_plat_suspend(struct device *dev) > +{ > + struct usb_hcd *hcd = dev_get_drvdata(dev); > + struct xhci_hcd *xhci = hcd_to_xhci(hcd); > + > + /* Make sure that the HCD Core has set state to HC_STATE_SUSPENDED */ > + if (hcd->state != HC_STATE_SUSPENDED || > + xhci->shared_hcd->state != HC_STATE_SUSPENDED) > + return -EINVAL; > + > + return xhci_suspend(xhci); this is pretty much what xhci_pci_suspend() is doing. Sarah, would you be ok with a patch such as: usb: host: xhci: move HC_STATE_SUSPENDED check to xhci_suspend() [ STILL NEED TO WRITE A PROPER COMMIT LOG ] NYET-Signed-off-by: Felipe Balbi --- do you think there is any reason to keep replicating the HC_STATE_SUSPENDED test all over the place ? diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 8345d7c..aeb3973 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -218,15 +218,8 @@ static void xhci_pci_remove(struct pci_dev *dev) static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - int retval = 0; - if (hcd->state != HC_STATE_SUSPENDED || - xhci->shared_hcd->state != HC_STATE_SUSPENDED) - return -EINVAL; - - retval = xhci_suspend(xhci); - - return retval; + return xhci_suspend(xhci); } static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 8d7fcbb..b85029e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -879,6 +879,10 @@ int xhci_suspend(struct xhci_hcd *xhci) struct usb_hcd *hcd = xhci_to_hcd(xhci); u32 command; + if (hcd->state != HC_STATE_SUSPENDED || + xhci->shared_hcd->state != HC_STATE_SUSPENDED) + return -EINVAL; + spin_lock_irq(&xhci->lock); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);