Skip to content

Commit b646e7d

Browse files
groeckEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_sysfs: Report range of error codes from EC
Since commit c5cd2b4 ("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> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
1 parent 064df88 commit b646e7d

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

‎drivers/platform/chrome/cros_ec_sysfs.c‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,10 @@ static ssize_t version_show(struct device *dev,
150150
msg->command = EC_CMD_GET_BUILD_INFO + ec->cmd_offset;
151151
msg->insize = EC_HOST_PARAM_SIZE;
152152
ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
153-
if (ret == -EPROTO) {
154-
count += scnprintf(buf + count, PAGE_SIZE - count,
155-
"Build info: EC error %d\n", msg->result);
156-
} else if (ret < 0) {
153+
if (ret < 0) {
157154
count += scnprintf(buf + count, PAGE_SIZE - count,
158-
"Build info: XFER ERROR %d\n", ret);
155+
"Build info: XFER / EC ERROR %d / %d\n",
156+
ret, msg->result);
159157
} else {
160158
msg->data[EC_HOST_PARAM_SIZE - 1] = '\0';
161159
count += scnprintf(buf + count, PAGE_SIZE - count,
@@ -166,12 +164,10 @@ static ssize_t version_show(struct device *dev,
166164
msg->command = EC_CMD_GET_CHIP_INFO + ec->cmd_offset;
167165
msg->insize = sizeof(*r_chip);
168166
ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
169-
if (ret == -EPROTO) {
170-
count += scnprintf(buf + count, PAGE_SIZE - count,
171-
"Chip info: EC error %d\n", msg->result);
172-
} else if (ret < 0) {
167+
if (ret < 0) {
173168
count += scnprintf(buf + count, PAGE_SIZE - count,
174-
"Chip info: XFER ERROR %d\n", ret);
169+
"Chip info: XFER / EC ERROR %d / %d\n",
170+
ret, msg->result);
175171
} else {
176172
r_chip = (struct ec_response_get_chip_info *)msg->data;
177173

@@ -190,12 +186,10 @@ static ssize_t version_show(struct device *dev,
190186
msg->command = EC_CMD_GET_BOARD_VERSION + ec->cmd_offset;
191187
msg->insize = sizeof(*r_board);
192188
ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
193-
if (ret == -EPROTO) {
194-
count += scnprintf(buf + count, PAGE_SIZE - count,
195-
"Board version: EC error %d\n", msg->result);
196-
} else if (ret < 0) {
189+
if (ret < 0) {
197190
count += scnprintf(buf + count, PAGE_SIZE - count,
198-
"Board version: XFER ERROR %d\n", ret);
191+
"Board version: XFER / EC ERROR %d / %d\n",
192+
ret, msg->result);
199193
} else {
200194
r_board = (struct ec_response_board_version *)msg->data;
201195

0 commit comments

Comments
 (0)