From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Andrew Pam <andrew@fastmailteam.com>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
"Sebastian Reichel" <sre@kernel.org>,
"Benson Leung" <bleung@chromium.org>,
"Guenter Roeck" <groeck@chromium.org>,
"Matt DeVillier" <matt.devillier@gmail.com>,
chrome-platform@lists.linux.dev, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: supply: cros_charge-control: restore EC state on resume
Date: Mon, 5 Oct 2026 04:20:33 +0000 [thread overview]
Message-ID: <asMlkcx5P3Qgolgh@google.com> (raw)
In-Reply-To: <20261004225606.30577-1-andrew@fastmailteam.com>
On Mon, Oct 05, 2026 at 09:56:06AM +1100, Andrew Pam wrote:
> Nothing notices the reset. Commit 4fc88ba435da ("power: supply:
> cros_charge-control: adopt EC charge state on probe") made the driver
The commit 4fc88ba435da doesn't exist.
> initialise its cached state from the EC, but it does so only on probe,
^^^^
To be precise, this should be "to".
> Note that re-reading the state from the EC on resume, by reusing
> cros_chctl_init_state() or otherwise, would be wrong even on the command
cros_chctl_init_state() doesn't exist.
> #define EC_CHARGE_CONTROL_BEHAVIOURS (BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) | \
> @@ -420,6 +421,7 @@ static int cros_chctl_probe(struct platform_device *pdev)
>
> priv->dev = dev;
> priv->cros_ec = cros_ec;
> + platform_set_drvdata(pdev, priv);
Even though functionally identical, to be symmetric to cros_chctl_resume(),
maybe use:
dev_set_drvdata(dev, priv)
> +static int cros_chctl_resume(struct device *dev)
> +{
> + struct cros_chctl_priv *priv = dev_get_drvdata(dev);
> +
> + /*
> + * The EC resets its charge control state when the AP powers off, so the
> + * configuration is lost across hibernation. As the driver never reads
> + * the state back from the EC, the values exposed to userspace would
> + * still describe the lost configuration. Reprogram the EC from the
> + * cached state to keep both in sync.
> + */
> + guard(mutex)(&priv->lock);
> + return cros_chctl_configure_ec(priv);
It may be worth adding a dev_err() or dev_warn() log if the configuration
fails.
> @@ -447,6 +466,7 @@ MODULE_DEVICE_TABLE(platform, cros_chctl_id);
>
> static struct platform_driver cros_chctl_driver = {
> .driver.name = "cros-charge-control",
> + .driver.pm = pm_sleep_ptr(&cros_chctl_pm_ops),
To be neat,
.driver = {
.name = ...
.pm = ...
}
next prev parent reply other threads:[~2026-10-05 4:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 22:56 [PATCH] power: supply: cros_charge-control: restore EC state on resume Andrew Pam
2026-10-05 4:20 ` Tzung-Bi Shih [this message]
2026-10-05 4:44 ` Andrew Pam
2026-10-05 6:25 ` Tzung-Bi Shih
2026-10-05 4:34 ` [PATCH v2] " Andrew Pam
2026-10-05 6:24 ` Tzung-Bi Shih
2026-10-07 8:01 ` Thomas Weißschuh
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=asMlkcx5P3Qgolgh@google.com \
--to=tzungbi@kernel.org \
--cc=andrew@fastmailteam.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=matt.devillier@gmail.com \
--cc=sre@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.