Skip to content

Commit c862381

Browse files
Brady NoranderTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_lightbar: Check if ec supports suspend commands
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> Link: https://lore.kernel.org/r/20251030195910.8625-2-bradynorander@gmail.com Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
1 parent e4ee0bb commit c862381

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/platform/chrome/cros_ec_lightbar.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ static unsigned long lb_interval_jiffies = 50 * HZ / 1000;
3030
*/
3131
static bool userspace_control;
3232

33+
/*
34+
* Whether or not the lightbar supports the manual suspend commands.
35+
* The Pixel 2013 (Link) does not while all other devices with a
36+
* lightbar do.
37+
*/
38+
static bool has_manual_suspend;
39+
3340
static ssize_t interval_msec_show(struct device *dev,
3441
struct device_attribute *attr, char *buf)
3542
{
@@ -550,7 +557,7 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
550557
return -ENODEV;
551558

552559
/* Take control of the lightbar from the EC. */
553-
lb_manual_suspend_ctrl(ec_dev, 1);
560+
has_manual_suspend = (lb_manual_suspend_ctrl(ec_dev, 1) != -EINVAL);
554561

555562
ret = sysfs_create_group(&ec_dev->class_dev.kobj,
556563
&cros_ec_lightbar_attr_group);
@@ -569,14 +576,15 @@ static void cros_ec_lightbar_remove(struct platform_device *pd)
569576
&cros_ec_lightbar_attr_group);
570577

571578
/* Let the EC take over the lightbar again. */
572-
lb_manual_suspend_ctrl(ec_dev, 0);
579+
if (has_manual_suspend)
580+
lb_manual_suspend_ctrl(ec_dev, 0);
573581
}
574582

575583
static int __maybe_unused cros_ec_lightbar_resume(struct device *dev)
576584
{
577585
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
578586

579-
if (userspace_control)
587+
if (userspace_control || !has_manual_suspend)
580588
return 0;
581589

582590
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)
586594
{
587595
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
588596

589-
if (userspace_control)
597+
if (userspace_control || !has_manual_suspend)
590598
return 0;
591599

592600
return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_SUSPEND);

0 commit comments

Comments
 (0)