Skip to content

Commit d378cdd

Browse files
gwendalcrEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_debugfs: Control uptime information request
When EC does not support uptime command (EC_CMD_GET_UPTIME_INFO), do not create the uptime sysfs entry point. User space application will not probe the file needlessly. The EC console log will not contain EC_CMD_GET_UPTIME_INFO anymore. Signed-off-by: Gwendal Grignou <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent b3a9e3b commit d378cdd

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/platform/chrome/cros_ec_debugfs.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
242242
read_buf, p - read_buf);
243243
}
244244

245+
static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
246+
{
247+
struct {
248+
struct cros_ec_command cmd;
249+
struct ec_response_uptime_info resp;
250+
} __packed msg = {};
251+
int ret;
252+
253+
msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
254+
msg.cmd.insize = sizeof(msg.resp);
255+
256+
ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
257+
if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND)
258+
return false;
259+
260+
/* Other errors maybe a transient error, do not rule about support. */
261+
return true;
262+
}
263+
245264
static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
246265
size_t count, loff_t *ppos)
247266
{
@@ -444,8 +463,9 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
444463
debugfs_create_file("pdinfo", 0444, debug_info->dir, debug_info,
445464
&cros_ec_pdinfo_fops);
446465

447-
debugfs_create_file("uptime", 0444, debug_info->dir, debug_info,
448-
&cros_ec_uptime_fops);
466+
if (cros_ec_uptime_is_supported(ec->ec_dev))
467+
debugfs_create_file("uptime", 0444, debug_info->dir, debug_info,
468+
&cros_ec_uptime_fops);
449469

450470
debugfs_create_x32("last_resume_result", 0444, debug_info->dir,
451471
&ec->ec_dev->last_resume_result);

0 commit comments

Comments
 (0)