All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: KrisPoint <krispointcsgo@gmail.com>
Cc: rafael@kernel.org, dakr@kernel.org, driver-core@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform: unify the platform_pm_* suspend/resume dispatch
Date: Thu, 20 Aug 2026 10:22:26 +0200	[thread overview]
Message-ID: <2026082049-subplot-stipend-0c00@gregkh> (raw)
In-Reply-To: <20260820080735.691297-1-KrisPointCSGO@gmail.com>

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@gmail.com>

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

      reply	other threads:[~2026-08-20  8:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  8:07 [PATCH] platform: unify the platform_pm_* suspend/resume dispatch KrisPoint
2026-08-20  8:22 ` Greg KH [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=2026082049-subplot-stipend-0c00@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=krispointcsgo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.