linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"Benson Leung" <bleung@chromium.org>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lee Jones" <lee.jones@linaro.org>,
	"Gwendal Grignou" <gwendal@chromium.org>,
	"Brian Norris" <briannorris@chromium.org>,
	"Yu-Hsuan Hsu" <yuhsuan@chromium.org>,
	"Prashant Malani" <pmalani@chromium.org>,
	linux-iio@vger.kernel.org, linux-input@vger.kernel.org,
	linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Guenter Roeck" <linux@roeck-us.net>
Subject: [PATCH v4 3/7] platform/chrome: cros_ec_sysfs: Report range of error codes from EC
Date: Thu,  6 Aug 2020 08:33:04 -0700	[thread overview]
Message-ID: <20200806153308.204605-4-linux@roeck-us.net> (raw)
In-Reply-To: <20200806153308.204605-1-linux@roeck-us.net>

Since commit c5cd2b47b203 ("platform/chrome: cros_ec_proto: Report command
not supported") we can no longer assume that cros_ec_cmd_xfer_status()
reports -EPROTO for all errors returned by the EC itself. A follow-up
patch will change cros_ec_cmd_xfer_status() to report additional errors
reported by the EC as distinguished Linux error codes.

Prepare for this change by always reporting both the Linux error code
and the EC error code in sysfs attributes.

Cc: Gwendal Grignou <gwendal@chromium.org>
Cc: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Cc: Prashant Malani <pmalani@chromium.org>
Cc: Brian Norris <briannorris@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v4: No change
v3: No change
v2: Added patch

 drivers/platform/chrome/cros_ec_sysfs.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index d45ea5d5bfa4..9c1e0998a721 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -150,12 +150,10 @@ static ssize_t version_show(struct device *dev,
 	msg->command = EC_CMD_GET_BUILD_INFO + ec->cmd_offset;
 	msg->insize = EC_HOST_PARAM_SIZE;
 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
-	if (ret == -EPROTO) {
-		count += scnprintf(buf + count, PAGE_SIZE - count,
-				   "Build info:    EC error %d\n", msg->result);
-	} else if (ret < 0) {
+	if (ret < 0) {
 		count += scnprintf(buf + count, PAGE_SIZE - count,
-				   "Build info:    XFER ERROR %d\n", ret);
+				   "Build info:    XFER / EC ERROR %d / %d\n",
+				   ret, msg->result);
 	} else {
 		msg->data[EC_HOST_PARAM_SIZE - 1] = '\0';
 		count += scnprintf(buf + count, PAGE_SIZE - count,
@@ -166,12 +164,10 @@ static ssize_t version_show(struct device *dev,
 	msg->command = EC_CMD_GET_CHIP_INFO + ec->cmd_offset;
 	msg->insize = sizeof(*r_chip);
 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
-	if (ret == -EPROTO) {
-		count += scnprintf(buf + count, PAGE_SIZE - count,
-				   "Chip info:     EC error %d\n", msg->result);
-	} else if (ret < 0) {
+	if (ret < 0) {
 		count += scnprintf(buf + count, PAGE_SIZE - count,
-				   "Chip info:     XFER ERROR %d\n", ret);
+				   "Chip info:     XFER / EC ERROR %d / %d\n",
+				   ret, msg->result);
 	} else {
 		r_chip = (struct ec_response_get_chip_info *)msg->data;
 
@@ -190,12 +186,10 @@ static ssize_t version_show(struct device *dev,
 	msg->command = EC_CMD_GET_BOARD_VERSION + ec->cmd_offset;
 	msg->insize = sizeof(*r_board);
 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
-	if (ret == -EPROTO) {
-		count += scnprintf(buf + count, PAGE_SIZE - count,
-				   "Board version: EC error %d\n", msg->result);
-	} else if (ret < 0) {
+	if (ret < 0) {
 		count += scnprintf(buf + count, PAGE_SIZE - count,
-				   "Board version: XFER ERROR %d\n", ret);
+				   "Board version: XFER / EC ERROR %d / %d\n",
+				   ret, msg->result);
 	} else {
 		r_board = (struct ec_response_board_version *)msg->data;
 
-- 
2.17.1


  parent reply	other threads:[~2020-08-06 16:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 15:33 [PATCH v4 0/7] platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes Guenter Roeck
2020-08-06 15:33 ` [PATCH v4 1/7] iio: cros_ec: Accept -EOPNOTSUPP as 'not supported' error code Guenter Roeck
2020-08-06 15:33 ` [PATCH v4 2/7] cros_ec_lightbar: Accept more error codes from cros_ec_cmd_xfer_status Guenter Roeck
2020-08-06 15:33 ` Guenter Roeck [this message]
2020-08-06 15:33 ` [PATCH v4 4/7] pwm: cros-ec: " Guenter Roeck
2020-08-06 18:35   ` Uwe Kleine-König
2020-08-06 15:33 ` [PATCH v4 5/7] platform/input: cros_ec: Replace -ENOTSUPP with -ENOPROTOOPT Guenter Roeck
2020-08-06 15:33 ` [PATCH v4 6/7] platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes Guenter Roeck
2020-08-06 15:33 ` [PATCH v4 7/7] pwm: cros-ec: Simplify EC error handling Guenter Roeck
2020-08-06 18:34   ` Uwe Kleine-König
2020-08-06 21:33   ` Brian Norris
2020-08-21  8:21 ` [PATCH v4 0/7] platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes Enric Balletbo i Serra
2020-08-21 15:39   ` Guenter Roeck

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=20200806153308.204605-4-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=bleung@chromium.org \
    --cc=briannorris@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=enric.balletbo@collabora.com \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=pmalani@chromium.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=yuhsuan@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;
as well as URLs for NNTP newsgroup(s).