Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp825741ybv; Thu, 20 Feb 2020 07:59:46 -0800 (PST) X-Google-Smtp-Source: APXvYqx46dOnDJjYSSyovb11XdtO5p5ZVlU9bywYasrUHnnVQT4yLokcReUZT2tSQZLJHh9wvWmy X-Received: by 2002:a05:6830:1305:: with SMTP id p5mr22493223otq.124.1582214386399; Thu, 20 Feb 2020 07:59:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582214386; cv=none; d=google.com; s=arc-20160816; b=EGe/hJVOk1iWTsoP+bltEXBepW7wZUTBZO/BJo1meYsRMHen3GVD+gRg2wTFHzuxm6 0CHhtM8CAtuttTTFxPbu99Or7AVVlE/e2yoE7LiB1DZ4KKeez+19xkHvZcmFy8PB3rn1 WVB9aWIX4gv3kY6ALcNmGNq+CluKXMtBnFzFctlVzELn3GcTuQ1VUvnKJqd2KAJRLSUC St+2Wv4D0GSyR7nTqupL9BWpsME6InzMN0MGBqsGAxi4OV/fMbOSORweTObwrxsizAhS BoshNw6ZXE18cJx4Tf/2JJX8J/GDO+Q5Bi5TV9OtjWj0wcEfe3gwwAk/VcP2juE3pUba JQhw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QdWYQP9RDU7WqZ8/CGkYZ3iZIs8CNA2P/MAz2snqrgU=; b=mxtYfPrihniDqgAJ6npOb2mBJ86gaMUhhoKcHo/ar39YcPI+hseSg0xo8Ic+9QKHrr hpJvLLJQrHBb9aJf+WtI/thRXdy5YAA/Sl8FlWaN/pEZHl6/D0cr5e7wMLzLFzCN+2LB UurKgl0jXFulsmdJInQZ/hXnxV4Cjhvf+7T3MoFX7hCUUjjdOjgceRNVkKlSH9yFazPf y+WOzB5Lr0qzrrXY6bwGi6QlzyBrvx4ExA714JQqgbWI1Be8+SWsSLa8mN9+KZIQOcwu GMb4KGS6g/UoHUJFvvs1GdlJLL/8Mml+Rrwx/5OHoYe/WQMdeubpPPRi9hC6VTQytX4K AbQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i15si11051228oik.46.2020.02.20.07.59.34; Thu, 20 Feb 2020 07:59:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728714AbgBTP7Z (ORCPT + 99 others); Thu, 20 Feb 2020 10:59:25 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47606 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728664AbgBTP7W (ORCPT ); Thu, 20 Feb 2020 10:59:22 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 9BD312951A0 From: Enric Balletbo i Serra To: linux-kernel@vger.kernel.org Cc: Collabora Kernel ML , groeck@chromium.org, bleung@chromium.org, dtor@chromium.org, gwendal@chromium.org, pmalani@chromium.org Subject: [PATCH 5/8] platform/chrome: cros_ec_sysfs: Use cros_ec_cmd_xfer_status helper Date: Thu, 20 Feb 2020 16:58:56 +0100 Message-Id: <20200220155859.906647-6-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200220155859.906647-1-enric.balletbo@collabora.com> References: <20200220155859.906647-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch makes use of cros_ec_cmd_xfer_status() instead of cros_ec_cmd_xfer(). In this case the change is trivial and the only reason to do it is because we want to make cros_ec_cmd_xfer() a private function for the EC protocol and let people only use the cros_ec_cmd_xfer_status() to return Linux standard error codes. Looking at the code I am even unsure that makes sense differentiate these two errors but let's not change the behaviour for now. Signed-off-by: Enric Balletbo i Serra --- drivers/platform/chrome/cros_ec_sysfs.c | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c index 07dac97ad57c..d45ea5d5bfa4 100644 --- a/drivers/platform/chrome/cros_ec_sysfs.c +++ b/drivers/platform/chrome/cros_ec_sysfs.c @@ -149,14 +149,14 @@ static ssize_t version_show(struct device *dev, /* Get build info. */ msg->command = EC_CMD_GET_BUILD_INFO + ec->cmd_offset; msg->insize = EC_HOST_PARAM_SIZE; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0) - count += scnprintf(buf + count, PAGE_SIZE - count, - "Build info: XFER ERROR %d\n", ret); - else if (msg->result != EC_RES_SUCCESS) + 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 { + } else if (ret < 0) { + count += scnprintf(buf + count, PAGE_SIZE - count, + "Build info: XFER ERROR %d\n", ret); + } else { msg->data[EC_HOST_PARAM_SIZE - 1] = '\0'; count += scnprintf(buf + count, PAGE_SIZE - count, "Build info: %s\n", msg->data); @@ -165,14 +165,14 @@ static ssize_t version_show(struct device *dev, /* Get chip info. */ msg->command = EC_CMD_GET_CHIP_INFO + ec->cmd_offset; msg->insize = sizeof(*r_chip); - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0) - count += scnprintf(buf + count, PAGE_SIZE - count, - "Chip info: XFER ERROR %d\n", ret); - else if (msg->result != EC_RES_SUCCESS) + 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 { + } else if (ret < 0) { + count += scnprintf(buf + count, PAGE_SIZE - count, + "Chip info: XFER ERROR %d\n", ret); + } else { r_chip = (struct ec_response_get_chip_info *)msg->data; r_chip->vendor[sizeof(r_chip->vendor) - 1] = '\0'; @@ -189,14 +189,14 @@ static ssize_t version_show(struct device *dev, /* Get board version */ msg->command = EC_CMD_GET_BOARD_VERSION + ec->cmd_offset; msg->insize = sizeof(*r_board); - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0) - count += scnprintf(buf + count, PAGE_SIZE - count, - "Board version: XFER ERROR %d\n", ret); - else if (msg->result != EC_RES_SUCCESS) + 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 { + } else if (ret < 0) { + count += scnprintf(buf + count, PAGE_SIZE - count, + "Board version: XFER ERROR %d\n", ret); + } else { r_board = (struct ec_response_board_version *)msg->data; count += scnprintf(buf + count, PAGE_SIZE - count, -- 2.25.0