From patchwork Sun Oct 7 07:27:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 1560671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 158123FC1A for ; Sun, 7 Oct 2012 07:40:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TKlRf-0006r8-8k; Sun, 07 Oct 2012 07:38:39 +0000 Received: from 9.mo1.mail-out.ovh.net ([178.32.108.172] helo=mo1.mail-out.ovh.net) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TKlRK-0006om-GA for linux-arm-kernel@lists.infradead.org; Sun, 07 Oct 2012 07:38:20 +0000 Received: from mail625.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo1.mail-out.ovh.net (Postfix) with SMTP id 11152FFB05A for ; Sun, 7 Oct 2012 09:39:10 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 7 Oct 2012 09:29:54 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 7 Oct 2012 09:29:52 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org X-Ovh-Mailout: 178.32.228.1 (mo1.mail-out.ovh.net) Subject: [PATCH 5/6] usb: at91_ude: switch pm ops Date: Sun, 7 Oct 2012 09:27:19 +0200 Message-Id: <1349594840-11374-5-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1349594840-11374-1-git-send-email-plagnioj@jcrosoft.com> References: <20121006161429.GD12462@game.jcrosoft.org> <1349594840-11374-1-git-send-email-plagnioj@jcrosoft.com> X-Ovh-Tracer-Id: 3418232118546443261 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehuddrudduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehuddrudduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [178.32.108.172 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Nicolas Ferre , linux-usb@vger.kernel.org, Jean-Christophe PLAGNIOL-VILLARD , linux-pm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org so we can detect when we enter in slow_clock mode and drop at91_suspend_entering_slow_clock Cc: Nicolas Ferre Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: linux-pm@vger.kernel.org Cc: linux-usb@vger.kernel.org --- drivers/usb/gadget/at91_udc.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 89d90b5..ba5b0af 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1910,10 +1910,10 @@ static int __exit at91udc_remove(struct platform_device *pdev) } #ifdef CONFIG_PM -static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) +static int at91udc_suspend(struct device *dev, int slow_clock) { - struct at91_udc *udc = platform_get_drvdata(pdev); - int wake = udc->driver && device_may_wakeup(&pdev->dev); + struct at91_udc *udc = dev_get_drvdata(dev); + int wake = udc->driver && device_may_wakeup(dev); unsigned long flags; /* Unless we can act normally to the host (letting it wake us up @@ -1923,7 +1923,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) */ if ((!udc->suspended && udc->addr) || !wake - || at91_suspend_entering_slow_clock()) { + || slow_clock) { spin_lock_irqsave(&udc->lock, flags); pullup(udc, 0); wake = 0; @@ -1937,9 +1937,19 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) return 0; } -static int at91udc_resume(struct platform_device *pdev) +static int at91udc_suspend_standby(struct device *dev) { - struct at91_udc *udc = platform_get_drvdata(pdev); + return at91udc_suspend(dev, 0); +} + +static int at91udc_suspend_mem(struct device *dev) +{ + return at91udc_suspend(dev, 1); +} + +static int at91udc_resume(struct device *dev) +{ + struct at91_udc *udc = dev_get_drvdata(dev); unsigned long flags; if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled && @@ -1956,11 +1966,14 @@ static int at91udc_resume(struct platform_device *pdev) } return 0; } -#else -#define at91udc_suspend NULL -#define at91udc_resume NULL #endif +static struct dev_pm_ops at91_udc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(at91udc_suspend_standby, at91udc_resume) + SET_SYSTEM_SLEEP_STANDBY_MEM_PM_OPS(at91udc_suspend_standby, + at91udc_suspend_mem) +}; + #if defined(CONFIG_OF) static const struct of_device_id at91_udc_dt_ids[] = { { .compatible = "atmel,at91rm9200-udc" }, @@ -1973,11 +1986,10 @@ MODULE_DEVICE_TABLE(of, at91_udc_dt_ids); static struct platform_driver at91_udc_driver = { .remove = __exit_p(at91udc_remove), .shutdown = at91udc_shutdown, - .suspend = at91udc_suspend, - .resume = at91udc_resume, .driver = { .name = (char *) driver_name, .owner = THIS_MODULE, + .pm = &at91_udc_pm_ops, .of_match_table = of_match_ptr(at91_udc_dt_ids), }, };