diff mbox series

platform/chrome: cros_usbpd_logger: fail probe if HC not supported

Message ID 20250220023441.158615-1-dhs@frame.work (mailing list archive)
State New
Headers show
Series platform/chrome: cros_usbpd_logger: fail probe if HC not supported | expand

Commit Message

Daniel Schaefer Feb. 20, 2025, 2:34 a.m. UTC
If the EC_CMD_PD_GET_LOG_ENTRY does not exist, the driver does not need
to stay active.

Framework Computer systems don't use the PD infrastructure in the chrome
EC firmware, so it does not support this host command.

Previously the driver probe would always succeed and periodically keep
trying to use this host command, resulting in unnecessary EC traffic and
EC log error messages.

Cc: Benson Leung <bleung@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Dustin L. Howett <dustin@howett.net>
Cc: <linux@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
---

With this patch the following dmesg log appears on Framework systems.
[   25.171086] cros-usbpd-logger cros-usbpd-logger.8.auto: host command not supported.

 drivers/platform/chrome/cros_usbpd_logger.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Tzung-Bi Shih Feb. 20, 2025, 9:48 a.m. UTC | #1
On Thu, Feb 20, 2025 at 10:34:41AM +0800, Daniel Schaefer wrote:
> If the EC_CMD_PD_GET_LOG_ENTRY does not exist, the driver does not need
> to stay active.
> 
> Framework Computer systems don't use the PD infrastructure in the chrome
> EC firmware, so it does not support this host command.

Does the firmware still report `EC_FEATURE_USB_PD` feature [1]?  Similarly,
do "cros-charge-control" and "cros-usbpd-charger" need to stay active [2]?

[1]: https://elixir.bootlin.com/linux/v6.13/source/drivers/mfd/cros_ec_dev.c#L263
[2]: https://elixir.bootlin.com/linux/v6.13/source/drivers/mfd/cros_ec_dev.c#L89
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_usbpd_logger.c b/drivers/platform/chrome/cros_usbpd_logger.c
index 7ce75e2e039e..df6b1d97589a 100644
--- a/drivers/platform/chrome/cros_usbpd_logger.c
+++ b/drivers/platform/chrome/cros_usbpd_logger.c
@@ -207,6 +207,11 @@  static int cros_usbpd_logger_probe(struct platform_device *pd)
 	logger->dev = dev;
 	logger->ec_dev = ec_dev;
 
+	if (-EOPNOTSUPP == PTR_ERR(ec_get_log_entry(logger))) {
+		dev_info(dev, "host command not supported.\n");
+		return -ENODEV;
+	}
+
 	platform_set_drvdata(pd, logger);
 
 	/* Retrieve PD event logs periodically */