Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp826097ybv; Thu, 20 Feb 2020 08:00:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzZfGH4UcLwpUrfzwAfNOglELO7jVLw//2PFu1oLPlavNvZ1uhqYYxMGtFYCCbanUBfKf5N X-Received: by 2002:a05:6808:1d3:: with SMTP id x19mr2643465oic.77.1582214413552; Thu, 20 Feb 2020 08:00:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582214413; cv=none; d=google.com; s=arc-20160816; b=PSxg6kRjtfNOPHz82cZzv/XMwZa+pAVtOvQaYA+fhelGL4kGBLc2e/BkMqozmV6K6X PXAoTNWyRTWQU2NeUMkG2zWNYDRZ21oCHTWEzZuL9e7ivuQtQBM1lA/uUMmBQdRPuubL jcf3yzjPTr+WcANFPKznkswm5ubqmoMN1HvaMHyFdT3Mug2anHHHLvt2LDcPmP2lYs3q rUwqHzc/bWqNRfq/G8m0WnEhdmTMJGWjTTrgs+LvlR+ArIq97S1QMi1d+mOsErgeNKLI NmjK8cp+BruB2zxgAzqZobhScCLkUHhRzqSiokl+UnyDfafnA5oxdVOfirugB0Zdg0L9 21Ig== 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=B+VZXSt7tu3Ikogy/QkXq4LJ1MhOKyEIIQ0EicdGIqI=; b=Zw8RtpHvBCsEPuxumXSdVKVQPORlC7G81dVsgBHcFQtc7XV6+xKs1k+2VIBa7kRzXX fj38VFTFuTMCLy7c+B94HegNNMebnz/3tNeibHunqLtuXQfZGdPI3iGxrIG2Se1NW1Yb zV62gvqzt5tpoK+wG1RcMBUuDiit/jQbmvIUJMgy1S4Im445P1PdNWnP1umwbuE6Jx/+ 91sJw8QVojiG7ea2Mw0bJvlMMJkoFiBJ4I2za4Czn3wC3C/dO9bHAnNqzG8PG0RKL1RP d0o7t4GW2RhJobaYCNvawx37PJR89scoqk05EyfJbBFv1JAQdyXYpMr8lCt3KDyzKIxF Wyqw== 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 k202si10717184oih.244.2020.02.20.08.00.00; Thu, 20 Feb 2020 08:00:13 -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 S1728755AbgBTP7k (ORCPT + 99 others); Thu, 20 Feb 2020 10:59:40 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47612 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728684AbgBTP7X (ORCPT ); Thu, 20 Feb 2020 10:59:23 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 5A61C2951A3 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 6/8] platform/chrome: cros_ec_lightbar: Use cros_ec_cmd_xfer_status helper Date: Thu, 20 Feb 2020 16:58:57 +0100 Message-Id: <20200220155859.906647-7-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(). It allows us to remove some redundand code. In this case, though, we are changing a bit the behaviour because of returning -EINVAL on protocol error we propagate the error return for cros_ec_cmd_xfer_status() function, but I think it will be fine, even more clear as we don't mask the Linux error code. Signed-off-by: Enric Balletbo i Serra --- drivers/platform/chrome/cros_ec_lightbar.c | 50 ++++++---------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c index b4c110c5fee0..b59180bff5a3 100644 --- a/drivers/platform/chrome/cros_ec_lightbar.c +++ b/drivers/platform/chrome/cros_ec_lightbar.c @@ -116,7 +116,7 @@ static int get_lightbar_version(struct cros_ec_dev *ec, param = (struct ec_params_lightbar *)msg->data; param->cmd = LIGHTBAR_CMD_VERSION; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) { ret = 0; goto exit; @@ -193,15 +193,10 @@ static ssize_t brightness_store(struct device *dev, if (ret) goto exit; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) goto exit; - if (msg->result != EC_RES_SUCCESS) { - ret = -EINVAL; - goto exit; - } - ret = count; exit: kfree(msg); @@ -258,13 +253,10 @@ static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr, goto exit; } - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) goto exit; - if (msg->result != EC_RES_SUCCESS) - goto exit; - i = 0; ok = 1; } @@ -305,14 +297,13 @@ static ssize_t sequence_show(struct device *dev, if (ret) goto exit; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0) - goto exit; - - if (msg->result != EC_RES_SUCCESS) { + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); + if (ret == -EPROTO) { ret = scnprintf(buf, PAGE_SIZE, "ERROR: EC returned %d\n", msg->result); goto exit; + } else if (ret < 0) { + goto exit; } resp = (struct ec_response_lightbar *)msg->data; @@ -344,13 +335,10 @@ static int lb_send_empty_cmd(struct cros_ec_dev *ec, uint8_t cmd) if (ret) goto error; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) goto error; - if (msg->result != EC_RES_SUCCESS) { - ret = -EINVAL; - goto error; - } + ret = 0; error: kfree(msg); @@ -377,13 +365,10 @@ static int lb_manual_suspend_ctrl(struct cros_ec_dev *ec, uint8_t enable) if (ret) goto error; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) goto error; - if (msg->result != EC_RES_SUCCESS) { - ret = -EINVAL; - goto error; - } + ret = 0; error: kfree(msg); @@ -425,15 +410,10 @@ static ssize_t sequence_store(struct device *dev, struct device_attribute *attr, if (ret) goto exit; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) goto exit; - if (msg->result != EC_RES_SUCCESS) { - ret = -EINVAL; - goto exit; - } - ret = count; exit: kfree(msg); @@ -487,13 +467,9 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr, */ msg->outsize = count + extra_bytes; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) goto exit; - if (msg->result != EC_RES_SUCCESS) { - ret = -EINVAL; - goto exit; - } ret = count; exit: -- 2.25.0