From patchwork Mon Apr 13 12:32:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11485495 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 B11DC13B2 for ; Mon, 13 Apr 2020 12:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9775A2073E for ; Mon, 13 Apr 2020 12:32:15 +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="NrwbG2DM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729488AbgDMMcP (ORCPT ); Mon, 13 Apr 2020 08:32:15 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:38224 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728392AbgDMMcO (ORCPT ); Mon, 13 Apr 2020 08:32:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1586781132; 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:references; bh=QlPjAfIdxHj090lbf0AL7B7989su6jjJKS5OiMvvzVo=; b=NrwbG2DMnHeYDYnmBQ+HqRUSGSlIHH5XnXzPDiJSIODzVNKjXubrbXIDykEIIjbfE6HeUO KQN54fBp1Br1FWhIXSqUMOQsevNi/WkNXZmfd/hNylSTL81Cn6T+mpymu0HCTYkhfOnWts ho5GTCRvVdlClxVX7Bu5/SwzucQPvy4= From: Paul Cercueil To: Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Len Brown Cc: od@zcrc.me, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Paul Cercueil Subject: [PATCH v2 1/3] PM: introduce pm_ptr() macro Date: Mon, 13 Apr 2020 14:32:05 +0200 Message-Id: <20200413123207.74552-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 macro is analogous to the infamous of_match_ptr(). If CONFIG_PM is enabled, this macro will resolve to its argument, otherwise to NULL. Signed-off-by: Paul Cercueil --- Notes: v2: Remove pm_sleep_ptr() macro include/linux/pm.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/pm.h b/include/linux/pm.h index e057d1fa2469..1c0eec06905d 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -374,6 +374,12 @@ 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 + /* * PM_EVENT_ messages * From patchwork Mon Apr 13 12:32:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11485499 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 ABD5B112C for ; Mon, 13 Apr 2020 12:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93BDF20753 for ; Mon, 13 Apr 2020 12:32:28 +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="MF7/qoYv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728462AbgDMMcY (ORCPT ); Mon, 13 Apr 2020 08:32:24 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:38288 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728392AbgDMMcX (ORCPT ); Mon, 13 Apr 2020 08:32:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1586781133; 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=/VVfu6H9KODoFY0A3raww+c9Oss15tNQdxGds+ellWQ=; b=MF7/qoYvm7gxXkQzfeAA4I2UB7fq+Qkr+r1xUogxTqJYRNFRFQJ6+LZOeVCj5CWpQ9/lm6 nIhvPDd0XX6ZT7cCH7pNX2Ngjq9etWEiu9vBm54059CwB2qvwfLOew6G/eALqWX6xRPo1Q QCMJ5UHSfIJDlgCH43OkG+s9yV0f+G0= From: Paul Cercueil To: Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Len Brown Cc: od@zcrc.me, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Paul Cercueil Subject: [PATCH v2 2/3] PM: Make *_DEV_PM_OPS macros use __maybe_unused Date: Mon, 13 Apr 2020 14:32:06 +0200 Message-Id: <20200413123207.74552-2-paul@crapouillou.net> In-Reply-To: <20200413123207.74552-1-paul@crapouillou.net> References: <20200413123207.74552-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 --- Notes: v2: No change 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 1c0eec06905d..5c9760f32d4f 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 Mon Apr 13 12:32:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11485501 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 126BE112C for ; Mon, 13 Apr 2020 12:32:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E239520753 for ; Mon, 13 Apr 2020 12:32:33 +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="YPJ7DoQI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728500AbgDMMcd (ORCPT ); Mon, 13 Apr 2020 08:32:33 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:38334 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728392AbgDMMcc (ORCPT ); Mon, 13 Apr 2020 08:32:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1586781134; 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=hVWhGN40RSlSv5uwpog3K158+gjiBbBlgbkIIpZ+xZQ=; b=YPJ7DoQISxOOPlHi9Czzn/d0KYRrVte1bRSD9EUo1tXaDntVEfroaVsTcEw1zRZo6ES3X3 5vzT4s3fkdUd/Vzfn0FqLV48c19ZVNzVYhTCMeQ4nxDPKgYl80X8kwHF5Db4ssRWaXEqRC 4tOSzgQktT/TXGd/p8vWu9KWzf1efec= From: Paul Cercueil To: Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Len Brown Cc: od@zcrc.me, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Paul Cercueil Subject: [PATCH v2 3/3] mmc: jz4740: Use pm_ptr() macro Date: Mon, 13 Apr 2020 14:32:07 +0200 Message-Id: <20200413123207.74552-3-paul@crapouillou.net> In-Reply-To: <20200413123207.74552-1-paul@crapouillou.net> References: <20200413123207.74552-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_ptr() macro to simplify the code. Signed-off-by: Paul Cercueil Reviewed-by: Ulf Hansson --- Notes: v2: Use pm_ptr() macro instead of pm_sleep_ptr() 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..2d41e7e5ec43 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_ptr(&jz4740_mmc_pm_ops), }, };