From: Benson Leung <bleung@google.com>
To: Brady Norander <bradynorander@gmail.com>
Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Guenter Roeck <groeck@chromium.org>
Subject: Re: [PATCH v2] platform/chrome: cros_ec_lightbar: Check if ec supports suspend commands
Date: Thu, 30 Oct 2025 20:21:55 +0000 [thread overview]
Message-ID: <aQPI4y-S5oN8sqWU@google.com> (raw)
In-Reply-To: <20251030195910.8625-2-bradynorander@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3035 bytes --]
On Thu, Oct 30, 2025 at 03:59:11PM -0400, Brady Norander wrote:
> The Chromebook Pixel 2013 (Link)'s ec does not support the lightbar manual suspend commands.
> As a result, attempting to suspend the device fails and prints the following error:
>
> cros-ec-lightbar cros-ec-lightbar.3.auto: PM: dpm_run_callback(): platform_pm_suspend returns -22
> cros-ec-lightbar cros-ec-lightbar.3.auto: PM: failed to suspend: error -22
> PM: Some devices failed to suspend, or early wake event detected
>
> Check the return value of lb_manual_suspend_ctrl in cros_ec_lightbar_probe and disable manual
> suspend control if -EINVAL is returned.
>
> Signed-off-by: Brady Norander <bradynorander@gmail.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
>
> v2:
> - Only catch -EINVAL from lb_manual_suspend_ctrl()
>
> drivers/platform/chrome/cros_ec_lightbar.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c
> index 87634f6921b7..893d269f6384 100644
> --- a/drivers/platform/chrome/cros_ec_lightbar.c
> +++ b/drivers/platform/chrome/cros_ec_lightbar.c
> @@ -30,6 +30,13 @@ static unsigned long lb_interval_jiffies = 50 * HZ / 1000;
> */
> static bool userspace_control;
>
> +/*
> + * Whether or not the lightbar supports the manual suspend commands.
> + * The Pixel 2013 (Link) does not while all other devices with a
> + * lightbar do.
> +*/
> +static bool has_manual_suspend;
> +
> static ssize_t interval_msec_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> @@ -550,7 +557,7 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
> return -ENODEV;
>
> /* Take control of the lightbar from the EC. */
> - lb_manual_suspend_ctrl(ec_dev, 1);
> + has_manual_suspend = (lb_manual_suspend_ctrl(ec_dev, 1) != -EINVAL);
>
> ret = sysfs_create_group(&ec_dev->class_dev.kobj,
> &cros_ec_lightbar_attr_group);
> @@ -569,14 +576,15 @@ static void cros_ec_lightbar_remove(struct platform_device *pd)
> &cros_ec_lightbar_attr_group);
>
> /* Let the EC take over the lightbar again. */
> - lb_manual_suspend_ctrl(ec_dev, 0);
> + if (has_manual_suspend)
> + lb_manual_suspend_ctrl(ec_dev, 0);
> }
>
> static int __maybe_unused cros_ec_lightbar_resume(struct device *dev)
> {
> struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
>
> - if (userspace_control)
> + if (userspace_control || !has_manual_suspend)
> return 0;
>
> return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_RESUME);
> @@ -586,7 +594,7 @@ static int __maybe_unused cros_ec_lightbar_suspend(struct device *dev)
> {
> struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
>
> - if (userspace_control)
> + if (userspace_control || !has_manual_suspend)
> return 0;
>
> return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_SUSPEND);
> --
> 2.51.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-10-30 20:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 19:59 [PATCH v2] platform/chrome: cros_ec_lightbar: Check if ec supports suspend commands Brady Norander
2025-10-30 20:21 ` Benson Leung [this message]
2025-10-31 1:44 ` Tzung-Bi Shih
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=aQPI4y-S5oN8sqWU@google.com \
--to=bleung@google.com \
--cc=bleung@chromium.org \
--cc=bradynorander@gmail.com \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tzungbi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox