From patchwork Tue Feb 11 16:03:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11375843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67B7414E3 for ; Tue, 11 Feb 2020 16:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49B772086A for ; Tue, 11 Feb 2020 16:03:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="KKmkEw7p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730560AbgBKQDo (ORCPT ); Tue, 11 Feb 2020 11:03:44 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:35570 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbgBKQDo (ORCPT ); Tue, 11 Feb 2020 11:03:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1581437018; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Eqz+dXWlx2geLx0boHuaL+MtB8wylUNe2oXXeMBk+b4=; b=KKmkEw7pd22w0XgOCjrbIn8PNXgZwPr6PRuxA/FyfEjE/JPYgR35m30PIIgztpPcbfmxzv YA1ncxuCcjkmEQcRXJuki64g3cZYqkzduz05OCyuynCtM9eJJFFDvED6KXWGB6MP4uwrDP Qv3ZweTZTU5hkOHryP25EXSu/kJj3AU= From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Pavel Machek Cc: Ulf Hansson , od@zcrc.me, linux-pm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [RFC PATCH 1/3] PM: introduce pm_ptr() and pm_sleep_ptr() Date: Tue, 11 Feb 2020 13:03:19 -0300 Message-Id: <20200211160321.22124-2-paul@crapouillou.net> In-Reply-To: <20200211160321.22124-1-paul@crapouillou.net> References: <20200211160321.22124-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org These macros are analogous to the infamous of_match_ptr(). If CONFIG_PM or CONFIG_PM_SLEEP are enabled (respectively), these macros will resolve to their argument, otherwise to NULL. Signed-off-by: Paul Cercueil --- include/linux/pm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/pm.h b/include/linux/pm.h index e057d1fa2469..1e183d78a1ae 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -374,6 +374,18 @@ const struct dev_pm_ops name = { \ SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ } +#ifdef CONFIG_PM +#define pm_ptr(_ptr) (_ptr) +#else +#define pm_ptr(_ptr) NULL +#endif + +#ifdef CONFIG_PM_SLEEP +#define pm_sleep_ptr(_ptr) (_ptr) +#else +#define pm_sleep_ptr(_ptr) NULL +#endif + /* * PM_EVENT_ messages * From patchwork Tue Feb 11 16:03:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11375849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA3A21580 for ; Tue, 11 Feb 2020 16:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D5D520714 for ; Tue, 11 Feb 2020 16:03:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="LwA+BxFF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730589AbgBKQDv (ORCPT ); Tue, 11 Feb 2020 11:03:51 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:35620 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbgBKQDv (ORCPT ); Tue, 11 Feb 2020 11:03:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1581437022; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JSs233FqwzrAQhGx3I3FXSTx8oMxW68K2mq8KzZioEg=; b=LwA+BxFFHor5krEJ8gi5GbgIf17RQl0b3XBN44Bma1gxBy0Zg6ckP6/ypWNq2b1h5T5fTL MktWsXHtpqOG/FX++/V2YxvUVcN79qkNAfP1VZH4SFMzDdAGzIPNB2nX4iip/Hrf5+gPm7 pvSuJN4Av4wo55g2uJo3OKsxcTg38zc= From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Pavel Machek Cc: Ulf Hansson , od@zcrc.me, linux-pm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [RFC PATCH 2/3] PM: Make *_DEV_PM_OPS macros use __maybe_unused Date: Tue, 11 Feb 2020 13:03:20 -0300 Message-Id: <20200211160321.22124-3-paul@crapouillou.net> In-Reply-To: <20200211160321.22124-1-paul@crapouillou.net> References: <20200211160321.22124-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This way, when the dev_pm_ops instance is not referenced anywhere, it will simply be dropped by the compiler without a warning. Signed-off-by: Paul Cercueil --- include/linux/pm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/pm.h b/include/linux/pm.h index 1e183d78a1ae..892e4fd198c0 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -351,7 +351,7 @@ struct dev_pm_ops { * to RAM and hibernation. */ #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ -const struct dev_pm_ops name = { \ +const struct dev_pm_ops __maybe_unused name = { \ SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ } @@ -369,7 +369,7 @@ const struct dev_pm_ops name = { \ * .runtime_resume(), respectively (and analogously for hibernation). */ #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \ -const struct dev_pm_ops name = { \ +const struct dev_pm_ops __maybe_unused name = { \ SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ } From patchwork Tue Feb 11 16:03:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11375853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D6241580 for ; Tue, 11 Feb 2020 16:04:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 335C020873 for ; Tue, 11 Feb 2020 16:04:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="aS9S3lr0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730638AbgBKQD6 (ORCPT ); Tue, 11 Feb 2020 11:03:58 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:35636 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbgBKQD6 (ORCPT ); Tue, 11 Feb 2020 11:03:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1581437025; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GxhdVQMuODyhj8Ef1OMGPYNtTlY3IQiUcj0GELNasU4=; b=aS9S3lr0RX/TZHUDSfSMyjljjgL6X7fGX0B/FV4bcp7eOErZXfYDigSnFOe7UXe/T5aufw bptWWqlgAXme/vwC2h/JJe7J5q60EROG4LV46T+mHPIqM9uqGnDp+frhwbj2FqzmrA2VWV QluMd154+yb1J0ZFtL8hNPmE8Oezbew= From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Pavel Machek Cc: Ulf Hansson , od@zcrc.me, linux-pm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [RFC PATCH 3/3] mmc: jz4740: Use pm_sleep_ptr() macro Date: Tue, 11 Feb 2020 13:03:21 -0300 Message-Id: <20200211160321.22124-4-paul@crapouillou.net> In-Reply-To: <20200211160321.22124-1-paul@crapouillou.net> References: <20200211160321.22124-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use the newly introduced pm_sleep_ptr() macro to simplify the code. Signed-off-by: Paul Cercueil --- drivers/mmc/host/jz4740_mmc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index fbae87d1f017..09554f9831de 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -1099,24 +1099,18 @@ static int jz4740_mmc_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP - -static int jz4740_mmc_suspend(struct device *dev) +static int __maybe_unused jz4740_mmc_suspend(struct device *dev) { return pinctrl_pm_select_sleep_state(dev); } -static int jz4740_mmc_resume(struct device *dev) +static int __maybe_unused jz4740_mmc_resume(struct device *dev) { return pinctrl_select_default_state(dev); } static SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend, jz4740_mmc_resume); -#define JZ4740_MMC_PM_OPS (&jz4740_mmc_pm_ops) -#else -#define JZ4740_MMC_PM_OPS NULL -#endif static struct platform_driver jz4740_mmc_driver = { .probe = jz4740_mmc_probe, @@ -1124,7 +1118,7 @@ static struct platform_driver jz4740_mmc_driver = { .driver = { .name = "jz4740-mmc", .of_match_table = of_match_ptr(jz4740_mmc_of_match), - .pm = JZ4740_MMC_PM_OPS, + .pm = pm_sleep_ptr(&jz4740_mmc_pm_ops), }, };