Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1383370ybt; Thu, 25 Jun 2020 04:55:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8PXjAL5k0NJZ9teFZ8PnGun6tejun42JCGxKE7oqfU7QcE2VABN4t7uqJE+DaaPoH4yW7 X-Received: by 2002:a17:907:40c7:: with SMTP id nv7mr28628530ejb.316.1593086139153; Thu, 25 Jun 2020 04:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593086139; cv=none; d=google.com; s=arc-20160816; b=gXkObFbNQx1PC5WwoNyTx2SAP0oFr32CTkczO0oW9Fqv2YnfAOzBvWKCqbmoSNcu2N W2UGixehowd6t0HGZpOFIGEBhvVcuBHxHsyHq75NGXnqoo/Bf9x78Y7dOKLNfDZeA7wn iMMsn79fTIiRlMThBkgwDraqMMV+jp7GbGVSK1nJnIY2uxixPkj2Wj1HfS+huJXNDaPe /Rj69xOSbxx9FeGwB0kzJWOs4uGqamViqcUKcwJB7gEHHfWHprDKZq6BymTu1IKI469j IrW3D1hmTEUEU0pgLXGBle5RlLFkXSoV+0sJxiOMOhDNFeCMdYDnqHZzOWR8l8lnW/Tx e4tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+gyRETEOXgy77gb4iRKB4wWIiZ+AosnQ43XwyhZcqh8=; b=x5p8AhQecg+GzHy8Pa7HsY1FK2A6BYlUVI1Ow4TQQ3f/h1ZXmb6nmFpfXPoG2G3Fua T3+cTbzmSCvESi9QOpZ+k9vKaGCUkp6PXsSlmVvVfGtBFK36NSTjMADX8XDWKzp/tkqc eQodwmIW5nwu3w6LdHxW43vtrbf2gEeyswTMCRfCr5Wil87OgWHkl6obWPG//r6iNEwV cpVYbeN0PXePEOgWkxGQEInM+APRSKrPbXD+4yuDTyjPYrSF5yJe/T3wHBqhz+51K2S9 1VC7IomptdNlDN8kKXSjgxpawea3Emk5Awced4I0dVMNv8Zj2q0ip2+nCC52p+jsUylW NDiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re6si1534710ejb.381.2020.06.25.04.55.16; Thu, 25 Jun 2020 04:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404443AbgFYLxp (ORCPT + 99 others); Thu, 25 Jun 2020 07:53:45 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:36056 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404406AbgFYLxl (ORCPT ); Thu, 25 Jun 2020 07:53:41 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 4EFF32A50E0 Subject: Re: [PATCH v2] platform: cros_ec_debugfs: control uptime information request To: Gwendal Grignou , groeck@chromium.org, bleung@chromium.org, twawrzynczak@chromium.org Cc: linux-kernel@vger.kernel.org References: <20200526185328.231840-1-gwendal@chromium.org> From: Enric Balletbo i Serra Message-ID: <09ba7001-6a24-7d96-0328-4ae1d1c62520@collabora.com> Date: Thu, 25 Jun 2020 13:53:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200526185328.231840-1-gwendal@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gwendal, Thank you for your patch. On 26/5/20 20:53, Gwendal Grignou wrote: > 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 Applied for 5.9 > --- > drivers/platform/chrome/cros_ec_debugfs.c | 24 +++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c > index 6ae484989d1f5..303a8c4686f89 100644 > --- a/drivers/platform/chrome/cros_ec_debugfs.c > +++ b/drivers/platform/chrome/cros_ec_debugfs.c > @@ -243,6 +243,25 @@ static ssize_t cros_ec_pdinfo_read(struct file *file, > read_buf, p - read_buf); > } > > +static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev) > +{ > + struct { > + struct cros_ec_command cmd; > + struct ec_response_uptime_info resp; > + } __packed msg = {}; > + int ret; > + > + msg.cmd.command = EC_CMD_GET_UPTIME_INFO; > + msg.cmd.insize = sizeof(msg.resp); > + > + ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd); > + if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND) > + return false; > + > + /* Other errors maybe a transient error, do not rule about support. */ > + return true; > +} > + > static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf, > size_t count, loff_t *ppos) > { > @@ -445,8 +464,9 @@ static int cros_ec_debugfs_probe(struct platform_device *pd) > debugfs_create_file("pdinfo", 0444, debug_info->dir, debug_info, > &cros_ec_pdinfo_fops); > > - debugfs_create_file("uptime", 0444, debug_info->dir, debug_info, > - &cros_ec_uptime_fops); > + if (cros_ec_uptime_is_supported(ec->ec_dev)) > + debugfs_create_file("uptime", 0444, debug_info->dir, debug_info, > + &cros_ec_uptime_fops); > > debugfs_create_x32("last_resume_result", 0444, debug_info->dir, > &ec->ec_dev->last_resume_result); >