mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gwendal Grignou <gwendal@chromium.org>
To: groeck@chromium.org, bleung@chromium.org,
	enric.balletbo@collabora.com, twawrzynczak@chromium.org
Cc: linux-kernel@vger.kernel.org, Gwendal Grignou <gwendal@chromium.org>
Subject: [PATCH] platform: cros_ec_debugfs: control uptime information request
Date: Wed, 20 May 2020 22:28:32 -0700	[thread overview]
Message-ID: <20200521052832.66620-1-gwendal@chromium.org> (raw)

When EC does not support uptime command (EC_CMD_GET_UPTIME_INFO),
return -EPROTO to read of /sys/kernel/debug/cros_ec/uptime without
calling the EC after the first try.

The EC console log will not contain EC_CMD_GET_UPTIME_INFO anymore.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 drivers/platform/chrome/cros_ec_debugfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c
index 6ae484989d1f5..70a29afb6d9e7 100644
--- a/drivers/platform/chrome/cros_ec_debugfs.c
+++ b/drivers/platform/chrome/cros_ec_debugfs.c
@@ -49,6 +49,8 @@ struct cros_ec_debugfs {
 	struct delayed_work log_poll_work;
 	/* EC panicinfo */
 	struct debugfs_blob_wrapper panicinfo_blob;
+	/* EC uptime */
+	bool uptime_supported;
 };
 
 /*
@@ -256,12 +258,19 @@ static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
 	char read_buf[32];
 	int ret;
 
+	if (!debug_info->uptime_supported)
+		return -EPROTO;
+
 	resp = (struct ec_response_uptime_info *)&msg.resp;
 
 	msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
 	msg.cmd.insize = sizeof(*resp);
 
 	ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
+	if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND) {
+		debug_info->uptime_supported = false;
+		return ret;
+	}
 	if (ret < 0)
 		return ret;
 
@@ -434,6 +443,9 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
 	debug_info->ec = ec;
 	debug_info->dir = debugfs_create_dir(name, NULL);
 
+	/* Give uptime a chance to run. */
+	debug_info->uptime_supported = true;
+
 	ret = cros_ec_create_panicinfo(debug_info);
 	if (ret)
 		goto remove_debugfs;
-- 
2.26.2.761.g0e0b3e54be-goog


             reply	other threads:[~2020-05-21  5:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21  5:28 Gwendal Grignou [this message]
2020-05-21  9:21 ` Enric Balletbo i Serra
2020-05-26 18:49   ` Gwendal Grignou

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=20200521052832.66620-1-gwendal@chromium.org \
    --to=gwendal@chromium.org \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=twawrzynczak@chromium.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

all inboxes | Powered by JetHome®