public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnd Bergmann <arnd@kernel.org>, Haibo Chen <haibo.chen@nxp.com>,
	"Ulf Hansson" <ulf.hansson@linaro.org>,
	Shawn Guo <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	Luke Wang <ziniu.wang_1@nxp.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Josua Mayer <josua@solid-run.com>, <imx@lists.linux.dev>,
	<linux-mmc@vger.kernel.org>, <s32@nxp.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [v2] mmc: esdhc-imx: convert to modern PM_OPS
Date: Wed, 16 Apr 2025 20:47:05 +0300	[thread overview]
Message-ID: <97f0d613-82ab-46aa-84b7-4bd04f7bbece@intel.com> (raw)
In-Reply-To: <20250411085932.1902662-1-arnd@kernel.org>

On 11/04/25 11:59, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Two newly added functions are unused in configurations without
> power management support:
> 
> drivers/mmc/host/sdhci-esdhc-imx.c:1586:13: error: unused function 'sdhc_esdhc_tuning_save' [-Werror,-Wunused-function]
>  1586 | static void sdhc_esdhc_tuning_save(struct sdhci_host *host)
>       |             ^~~~~~~~~~~~~~~~~~~~~~
> drivers/mmc/host/sdhci-esdhc-imx.c:1608:13: error: unused function 'sdhc_esdhc_tuning_restore' [-Werror,-Wunused-function]
>  1608 | static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
>       |             ^~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Remove the #ifdef checks and instead use the better macros that
> silently drop the unused functions when PM is disabled. This also
> requires using pm_ptr() to eliminate both the runtime and pm_sleep
> operations.

This explanation is still a bit mysterious.  SYSTEM_SLEEP_PM_OPS()
and pm_ptr() make use of PTR_IF() which uses a conditional expression
so that the pointers have a reference during compile time but not at
link time.  That way unused functions still get compiled without
triggering -Wunused-function, but get dropped by the linker's
dead code elimination.

It is perhaps worth noting that dead code elimination is not
default unless -O1 or above optimization level is used.  The
kernel currently uses -O2 or -Os both of which do dead code
elimination.

> 
> Fixes: 3d1eea493894 ("mmc: sdhci-esdhc-imx: Save tuning value when card stays powered in suspend")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Nevertheless, together with the chunk from:

https://lore.kernel.org/all/3d544dbc-863d-4ac5-9839-aef3a36881d1@app.fastmail.com/

i.e.

diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index cd0e35a80542..4ee2695b0202 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -874,12 +874,10 @@ irqreturn_t sdhci_thread_irq(int irq, void *dev_id);
 void sdhci_adma_write_desc(struct sdhci_host *host, void **desc,
                           dma_addr_t addr, int len, unsigned int cmd);
 
-#ifdef CONFIG_PM
 int sdhci_suspend_host(struct sdhci_host *host);
 int sdhci_resume_host(struct sdhci_host *host);
 int sdhci_runtime_suspend_host(struct sdhci_host *host);
 int sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset);
-#endif
 
 void sdhci_cqe_enable(struct mmc_host *mmc);
 void sdhci_cqe_disable(struct mmc_host *mmc, bool recovery);


Acked-by: Adrian Hunter <adrian.hunter@intel.com>


> ---
> v2: add pm_ptr()
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 7e8addaed697..3c2e50d0260d 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1942,7 +1942,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device *pdev)
>  	sdhci_pltfm_free(pdev);
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int sdhci_esdhc_suspend(struct device *dev)
>  {
>  	struct sdhci_host *host = dev_get_drvdata(dev);
> @@ -2021,9 +2020,7 @@ static int sdhci_esdhc_resume(struct device *dev)
>  
>  	return ret;
>  }
> -#endif
>  
> -#ifdef CONFIG_PM
>  static int sdhci_esdhc_runtime_suspend(struct device *dev)
>  {
>  	struct sdhci_host *host = dev_get_drvdata(dev);
> @@ -2103,11 +2100,10 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
>  		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
>  	return err;
>  }
> -#endif
>  
>  static const struct dev_pm_ops sdhci_esdhc_pmops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
> -	SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
> +	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
> +	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
>  				sdhci_esdhc_runtime_resume, NULL)
>  };
>  
> @@ -2116,7 +2112,7 @@ static struct platform_driver sdhci_esdhc_imx_driver = {
>  		.name	= "sdhci-esdhc-imx",
>  		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
>  		.of_match_table = imx_esdhc_dt_ids,
> -		.pm	= &sdhci_esdhc_pmops,
> +		.pm	= pm_ptr(&sdhci_esdhc_pmops),
>  	},
>  	.probe		= sdhci_esdhc_imx_probe,
>  	.remove		= sdhci_esdhc_imx_remove,


      parent reply	other threads:[~2025-04-16 17:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11  8:59 [PATCH] [v2] mmc: esdhc-imx: convert to modern PM_OPS Arnd Bergmann
2025-04-11 11:02 ` [EXT] " Luke Wang
2025-04-11 11:47   ` Adrian Hunter
2025-04-14  6:49     ` Luke Wang
2025-04-14  8:08 ` kernel test robot
2025-04-14 10:32 ` kernel test robot
2025-04-15  3:15 ` [EXT] " Luke Wang
2025-04-15 12:57   ` Arnd Bergmann
2025-04-16  2:42     ` Luke Wang
2025-04-16 17:47 ` Adrian Hunter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=97f0d613-82ab-46aa-84b7-4bd04f7bbece@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=festevam@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=josua@solid-run.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s32@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=ziniu.wang_1@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox