From patchwork Thu Jul 16 12:42:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11667349 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 157281392 for ; Thu, 16 Jul 2020 12:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFFF92076D for ; Thu, 16 Jul 2020 12:43:00 +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="ixomCN9A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726898AbgGPMnA (ORCPT ); Thu, 16 Jul 2020 08:43:00 -0400 Received: from crapouillou.net ([89.234.176.41]:48620 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbgGPMnA (ORCPT ); Thu, 16 Jul 2020 08:43:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1594903377; 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=JtOYxXJepZlIjXy1qPF7xJcQfR1PdsqM0RsBODDedHY=; b=ixomCN9AwshC9ASwXo6Ec/GH9LXWIOMX490wSGerGVufLPooHfY4RRJODZf3bD8muevXGd jmqn04W5dXbba/ePFvNxwCyzDL56inqYc9wyBJJUSxiBXdw4j04UIoXPvT/kii5jJNQxHZ aUjfheP+Zm8Xps0KI32ClhNPypIOiNM= From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Pavel Machek Cc: Ulf Hansson , od@zcrc.me, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Paul Cercueil Subject: [PATCH v3 1/3] PM: introduce pm_ptr() macro Date: Thu, 16 Jul 2020 14:42:48 +0200 Message-Id: <20200716124250.9829-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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 Reviewed-by: Ulf Hansson --- Notes: v2: Remove pm_sleep_ptr() macro v3: Rebase on 5.8-rc5 and add Ulf's Reviewed-by include/linux/pm.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/pm.h b/include/linux/pm.h index 121c104a4090..1f227c518db3 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 Thu Jul 16 12:42:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11667355 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 6EBD51392 for ; Thu, 16 Jul 2020 12:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 560352076D for ; Thu, 16 Jul 2020 12:43:11 +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="DUq7Xnb6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728096AbgGPMnH (ORCPT ); Thu, 16 Jul 2020 08:43:07 -0400 Received: from crapouillou.net ([89.234.176.41]:48696 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbgGPMnH (ORCPT ); Thu, 16 Jul 2020 08:43:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1594903378; 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=LjKImepJE6g0k1UCqOuIM6bQ4GRf7cW6YruWjxoUqzY=; b=DUq7Xnb6cPjBcbFvsJ6QiOEIQGVKvUzXx+dTtuR66Ib9CIkLjSAbDN18PUDrMABQIhG8el 9VzI1Ac6IiI7DiAfZptUXbFZmHTmzSTC7AjCdusY9NAR+hakkh82uv5dWI2SaXHu+xSmAv K0+EgXcaUyQAyrq8EG5xfB75TKRJakg= From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Pavel Machek Cc: Ulf Hansson , od@zcrc.me, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Paul Cercueil Subject: [PATCH v3 2/3] PM: Make *_DEV_PM_OPS macros use __maybe_unused Date: Thu, 16 Jul 2020 14:42:49 +0200 Message-Id: <20200716124250.9829-2-paul@crapouillou.net> In-Reply-To: <20200716124250.9829-1-paul@crapouillou.net> References: <20200716124250.9829-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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 Reviewed-by: Ulf Hansson --- Notes: v2: No change v3: Rebase on 5.8-rc5 and add Ulf's Reviewed-by 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 1f227c518db3..a30a4b54df52 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 Thu Jul 16 12:42:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11667357 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 649E51392 for ; Thu, 16 Jul 2020 12:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DD7020739 for ; Thu, 16 Jul 2020 12:43: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="FUWkqx6B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbgGPMnO (ORCPT ); Thu, 16 Jul 2020 08:43:14 -0400 Received: from crapouillou.net ([89.234.176.41]:48810 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbgGPMnO (ORCPT ); Thu, 16 Jul 2020 08:43:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1594903380; 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=LhQckHNurdhS6vBban56gv482FE8HQsr0t2XKo3IDvQ=; b=FUWkqx6BwzsJoj0gcdVLKpTuSI/+GvOzmToecvnSI7wO1LANUtU2V2wGQ5venagbYnuyUz DVRxT4bALigB1jwEpn/t1JeMIgmdELHDP4i61Z0Nmc+t9MFvAIcnkHM2SP/gAfEVFeVHkN g+3ztltYQukgEt88WD3hScm0wN+lYaQ= From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Pavel Machek Cc: Ulf Hansson , od@zcrc.me, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Paul Cercueil Subject: [PATCH v3 3/3] mmc: jz4740: Use pm_ptr() macro Date: Thu, 16 Jul 2020 14:42:50 +0200 Message-Id: <20200716124250.9829-3-paul@crapouillou.net> In-Reply-To: <20200716124250.9829-1-paul@crapouillou.net> References: <20200716124250.9829-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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() v3: Rebase on 5.8-rc5 and add Ulf's Reviewed-by 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 cba7a6fcd178..447552ac25c4 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -1108,24 +1108,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, @@ -1133,7 +1127,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), }, };