Re: [PATCH] platform: unify the platform_pm_* suspend/resume dispatch
From: Greg KH
Date: Thu Aug 20 2026 - 04:24:12 EST
On Thu, Aug 20, 2026 at 04:07:35PM +0800, KrisPoint wrote:
> The six platform_pm_suspend()/platform_pm_resume()/platform_pm_freeze()/
> platform_pm_thaw()/platform_pm_poweroff()/platform_pm_restore() callbacks
> all follow the same pattern: return early when the device has no driver,
> call the matching dev_pm_ops callback when one is present, and otherwise
> fall back to the legacy platform suspend/resume callbacks. This skeleton
> is currently open-coded in each of the six functions, leaving about 110
> lines of near-identical logic that must be kept in sync by hand.
>
> Add a common platform_pm_dispatch() helper that implements the shared
> logic, driven by the dev_pm_ops callback, the legacy callback and the
> pm message to pass, and turn the six callbacks into thin wrappers around
> it. A platform_legacy_resume_state() adapter is added so the legacy
> callbacks share a single signature.
>
> No functional change intended.
>
> Signed-off-by: KrisPoint <KrisPointCSGO@xxxxxxxxx>
Real name please.
While I appreciate the goal of making code smaller, you have to admit,
these lines:
> + return platform_pm_dispatch(dev,
> + drv && drv->pm ? drv->pm->suspend : NULL,
> + platform_legacy_suspend, PMSG_SUSPEND);
Are pretty unreadable.
Now we need to go look up the platform_pm_dispatch parameters each time
and try to figure out the suspend vs. NULL mess.
We write code for people first, compilers second. And this feels to me,
like making it harder for people to understand.
thanks,
greg k-h