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: 1560641 Return-Path: X-Original-To: patchwork-linux-pm@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 81C87DFF71 for ; Sun, 7 Oct 2012 07:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002Ab2JGHiT (ORCPT ); Sun, 7 Oct 2012 03:38:19 -0400 Received: from 13.mo1.mail-out.ovh.net ([178.33.253.128]:45491 "EHLO mo1.mail-out.ovh.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751624Ab2JGHiR (ORCPT ); Sun, 7 Oct 2012 03:38:17 -0400 X-Greylist: delayed 501 seconds by postgrey-1.27 at vger.kernel.org; Sun, 07 Oct 2012 03:38:17 EDT Received: from mail625.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo1.mail-out.ovh.net (Postfix) with SMTP id 8BEE0FFB05D for ; Sun, 7 Oct 2012 09:39:09 +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 Cc: Jean-Christophe PLAGNIOL-VILLARD , Nicolas Ferre , linux-pm@vger.kernel.org, linux-usb@vger.kernel.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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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), }, };