From patchwork Thu Apr 18 10:00:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 10906943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 884EA1515 for ; Thu, 18 Apr 2019 10:02:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68F3528C6F for ; Thu, 18 Apr 2019 10:02:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57BEF28C73; Thu, 18 Apr 2019 10:02:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,URIBL_RHS_DOB autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EBAAC28C6F for ; Thu, 18 Apr 2019 10:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W0GJHxSgKQZVm5MbxD6jrHTwB213vwMgYZxPb1XDs/Y=; b=ewBE7BZ2JqFwMj Y8wgoIoQchU8sSUUb9gd8mTdZc9uXn9SCqNZO1syeCqJFONxf+2ThW3yATqDnklq2ivbXesTVE1BP CFeBQHl+aEuFFcz1hF63oD4/rF2T8B1eX4zPxDVgDDrkimWkryZZ7NMCIqlSv8I9+mTzgeYXE206a D3eDpXK08LM4c+qWRNu/h4PuLxz+WvuerXjmuZ8tgfh9tM+UQgIDckzE8A2P+Uwq4BJ8qerrDWbMr NDJ73AZr2foiaAEUHYSuqO22v4Fo+HmoO4Jc9p8pePevQ70Cop3PLMcEs+PyuLo3AZiXEOX8BZ4BV HsRTqa3BRUz8SiZ73zhA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hH3rl-000863-Ng; Thu, 18 Apr 2019 10:02:01 +0000 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hH3qv-0006w1-Ki for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2019 10:01:15 +0000 X-Originating-IP: 109.212.207.226 Received: from localhost (alyon-652-1-176-226.w109-212.abo.wanadoo.fr [109.212.207.226]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 27F5DFF808; Thu, 18 Apr 2019 10:01:04 +0000 (UTC) From: Alexandre Belloni To: linux-rtc@vger.kernel.org Subject: [PATCH 5/7] rtc: jz4740: use dev_pm_set_wake_irq() to simplify code Date: Thu, 18 Apr 2019 12:00:43 +0200 Message-Id: <20190418100045.29288-5-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190418100045.29288-1-alexandre.belloni@bootlin.com> References: <20190418100045.29288-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190418_030110_146199_9AC71593 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Cercueil , Mathieu Malaterre , Alexandre Belloni , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use dev_pm_set_wake_irq() to set the RTC as a wakeup source for suspend. This allows to remove the whole dev_pm_ops structure. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-jz4740.c | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c index 91ccb45bb886..fa15ad9fbe13 100644 --- a/drivers/rtc/rtc-jz4740.c +++ b/drivers/rtc/rtc-jz4740.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -346,6 +347,12 @@ static int jz4740_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); + ret = dev_pm_set_wake_irq(&pdev->dev, rtc->irq); + if (ret) { + dev_err(&pdev->dev, "Failed to set wake irq: %d\n", ret); + return ret; + } + rtc->rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc->rtc)) { ret = PTR_ERR(rtc->rtc); @@ -403,35 +410,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM -static int jz4740_rtc_suspend(struct device *dev) -{ - struct jz4740_rtc *rtc = dev_get_drvdata(dev); - - if (device_may_wakeup(dev)) - enable_irq_wake(rtc->irq); - return 0; -} - -static int jz4740_rtc_resume(struct device *dev) -{ - struct jz4740_rtc *rtc = dev_get_drvdata(dev); - - if (device_may_wakeup(dev)) - disable_irq_wake(rtc->irq); - return 0; -} - -static const struct dev_pm_ops jz4740_pm_ops = { - .suspend = jz4740_rtc_suspend, - .resume = jz4740_rtc_resume, -}; -#define JZ4740_RTC_PM_OPS (&jz4740_pm_ops) - -#else -#define JZ4740_RTC_PM_OPS NULL -#endif /* CONFIG_PM */ - static const struct platform_device_id jz4740_rtc_ids[] = { { "jz4740-rtc", ID_JZ4740 }, { "jz4780-rtc", ID_JZ4780 }, @@ -443,7 +421,6 @@ static struct platform_driver jz4740_rtc_driver = { .probe = jz4740_rtc_probe, .driver = { .name = "jz4740-rtc", - .pm = JZ4740_RTC_PM_OPS, .of_match_table = of_match_ptr(jz4740_rtc_of_match), }, .id_table = jz4740_rtc_ids,