Re: [PATCH] net: can: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
From: Marc Kleine-Budde
Date: Thu Nov 19 2026 - 06:19:20 EST
On 22.08.2026 07:47:01, Triet Hoang wrote:
> drivers/net/can/ctucanfd/ctucanfd.h | 4 ++--
> drivers/net/can/ctucanfd/ctucanfd_pci.c | 4 ++--
> drivers/net/can/ctucanfd/ctucanfd_platform.c | 4 ++--
Clashiko has found an issue with the ctucanfd driver. Can you re-spin
the ctucanfd changes only?
regards,
Marc
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118092955.1283165-5-mkl@xxxxxxxxxxxxxx
--- Patch [4]: [PATCH net-next 04/12] can: convert to DEFINE_SIMPLE_DEV_PM_OPS() ---
commit 2eebc61f80e1b0678405e6e773cda6ae37343aba
Author: Triet Hoang <triet.hoang.dev@xxxxxxxxx>
can: convert to DEFINE_SIMPLE_DEV_PM_OPS()
This converts seven CAN drivers from SIMPLE_DEV_PM_OPS() to
DEFINE_SIMPLE_DEV_PM_OPS() and wraps the .pm pointers in pm_sleep_ptr().
It also drops the __maybe_unused annotations from the suspend and resume
callbacks.
Link: https://patch.msgid.link/20260822074701.22856-1-triet.hoang.dev@xxxxxxxxx
> diff --git a/drivers/net/can/ctucanfd/ctucanfd.h b/drivers/net/can/ctucanfd/ctucanfd.h
> index 0e9904f6a05d6..7dcd7dc507e49 100644
> --- a/drivers/net/can/ctucanfd/ctucanfd.h
> +++ b/drivers/net/can/ctucanfd/ctucanfd.h
> @@ -76,7 +76,7 @@ int ctucan_probe_common(struct device *dev, void __iomem *addr,
> void (*set_drvdata_fnc)(struct device *dev,
> struct net_device *ndev));
>
> -int ctucan_suspend(struct device *dev) __maybe_unused;
> -int ctucan_resume(struct device *dev) __maybe_unused;
> +int ctucan_suspend(struct device *dev);
> +int ctucan_resume(struct device *dev);
Discovered by: opus-5-5 · Missed by: sashiko-gemini
This isn't a bug, but does the size reduction in the commit message hold
for the ctucanfd drivers?
"also reduces kernel size in case CONFIG_PM or CONFIG_PM_SLEEP is
disabled."
ctucan_suspend() and ctucan_resume() are global functions in
ctucanfd_base.c. They are exported with no CONFIG_PM_SLEEP guard:
drivers/net/can/ctucanfd/ctucanfd_base.c:
int ctucan_suspend(struct device *dev)
{
...
}
EXPORT_SYMBOL(ctucan_suspend);
int ctucan_resume(struct device *dev)
{
...
}
EXPORT_SYMBOL(ctucan_resume);
With CONFIG_PM_SLEEP=n, pm_sleep_ptr() only lets the compiler drop the
static ctucan_pci_pm_ops and ctucan_platform_pm_ops structs. The callback
bodies and their export entries are still built and linked.
The __maybe_unused removal in this header also has no effect.
-Wunused-function does not warn about non-static functions, so the
attribute was not suppressing anything here.
To get the saving for ctucanfd, could the base module export the PM ops
instead, for example with EXPORT_SIMPLE_DEV_PM_OPS() or
EXPORT_GPL_SIMPLE_DEV_PM_OPS() in ctucanfd_base.c, and have the glue
drivers use pm_sleep_ptr() on that? Alternatively, the commit message
could say that the claim does not apply to ctucanfd.
No later patch in the series touches drivers/net/can/ctucanfd/, so this
is still the case at the end of the series.
> diff --git a/drivers/net/can/ctucanfd/ctucanfd_pci.c b/drivers/net/can/ctucanfd/ctucanfd_pci.c
> index 4b6db28f7b670..9c9c41c3058c0 100644
> --- a/drivers/net/can/ctucanfd/ctucanfd_pci.c
> +++ b/drivers/net/can/ctucanfd/ctucanfd_pci.c
> @@ -259,7 +259,7 @@ static void ctucan_pci_remove(struct pci_dev *pdev)
> kfree(bdata);
> }
>
> -static SIMPLE_DEV_PM_OPS(ctucan_pci_pm_ops, ctucan_suspend, ctucan_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(ctucan_pci_pm_ops, ctucan_suspend, ctucan_resume);
[ ... ]
> diff --git a/drivers/net/can/ctucanfd/ctucanfd_platform.c b/drivers/net/can/ctucanfd/ctucanfd_platform.c
> index 70e2577c85416..4962b00ee8ac0 100644
> --- a/drivers/net/can/ctucanfd/ctucanfd_platform.c
> +++ b/drivers/net/can/ctucanfd/ctucanfd_platform.c
> @@ -99,7 +99,7 @@ static void ctucan_platform_remove(struct platform_device *pdev)
> free_candev(ndev);
> }
>
> -static SIMPLE_DEV_PM_OPS(ctucan_platform_pm_ops, ctucan_suspend, ctucan_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(ctucan_platform_pm_ops, ctucan_suspend, ctucan_resume);
[ ... ]
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature