Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp825648ybv; Thu, 20 Feb 2020 07:59:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyExWIPQ/DTuGij9d+RMa23lxsI4ZABMOykz8t0IKS5tlyGvkjwKphkeZADZkxBWvkuebEn X-Received: by 2002:aca:1011:: with SMTP id 17mr2696542oiq.72.1582214381632; Thu, 20 Feb 2020 07:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582214381; cv=none; d=google.com; s=arc-20160816; b=drRpCPX1BIOTac3/7BPkMyJpBfpQRuN/68NGJFhnWhDsRT76FAeuG2+AywEY0ZpQuc G0xdBF06P1AZM6laarlb1bRjqgK0SpnQ/nnUUHv4DWO3Cz6I+gzRX0LP+xLBk+txiMf3 2dkMYg8J93kU6KV+506CJK8B8rXwlUCCd8IOb+uqUmZD8qpbDoL1bIohUR8bFjjcoO8x 3XmVtp98zjCo8+jmA1uMLez6mxpTii54v5Exg2gBJsxxo4pIUCNM+NSLc/oGNXUTAt0o C4lnU/VTxkA4aHvXMlV2SugSYpQEsdUrFPAM1c51F8vkVCNLnO7O9KvPvNA+GRfsAEM6 zm9g== 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=DxRbxIrvp5mXv41bZPP4gr1HMm3oeD0Z25e1wmEtu6o=; b=fTC5BXfgAx/k7UNbWvUfgOY6kYJ2YxXxX+W0T/jRc2aEKn8IUwuiDd99jEXnY6LkGQ y8SoezZw8qX/IHEaew4O163p67jbV67ZnaNfmHvAbYxUjvfI+gMTi0d3NG5DEcZJ/TtL jG4V7vLyKdp6Z3sJ253l60l7UhJY7wJHawN/Vz6px+1MwDhqZ6Dyn8VOxZ/yQIiCeOn9 TIXgZkFg8NlJq8/IErIDxOh5/yqLsz8OXz+Vt0+GgupQ66V+9m6qmLW3eOn3RVNZnmcf 11Qo1kWM28R2ILowT4Vo+6LVH7VfGb1FRhuv8K9YlGs57iSjpiT2bi8uq8XxGNSFD8SE OdBQ== 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 v23si1771692oto.81.2020.02.20.07.59.28; Thu, 20 Feb 2020 07:59:41 -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 S1728642AbgBTP7U (ORCPT + 99 others); Thu, 20 Feb 2020 10:59:20 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47592 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728585AbgBTP7U (ORCPT ); Thu, 20 Feb 2020 10:59:20 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 5748829519F 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 1/8] platform/chrome: cros_ec_proto: Report command not supported Date: Thu, 20 Feb 2020 16:58:52 +0100 Message-Id: <20200220155859.906647-2-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 In practice most drivers that use the EC protocol what really care is if the result was successful or not, hence, we introduced a cros_ec_cmd_xfer_status() function that converts EC errors to standard Linux error codes. On some few cases, though, we are interested on know if the command is supported or not, and in such cases, just ignore the error. To achieve this, return a -ENOTSUPP error when the command is not supported. This will allow us to finish the conversion of all users to use the cros_ec_cmd_xfer_status() function instead of cros_ec_cmd_xfer() and make the latest private to the protocol driver, so users of the protocol are not confused in which function they should use. Signed-off-by: Enric Balletbo i Serra --- drivers/platform/chrome/cros_ec_proto.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index 3cfa643f1d07..3e745e0fe092 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -553,7 +553,10 @@ EXPORT_SYMBOL(cros_ec_cmd_xfer); * replied with success status. It's not necessary to check msg->result when * using this function. * - * Return: The number of bytes transferred on success or negative error code. + * Return: + * >=0 - The number of bytes transferred + * -ENOTSUPP - Operation not supported + * -EPROTO - Protocol error */ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) @@ -563,6 +566,10 @@ int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, ret = cros_ec_cmd_xfer(ec_dev, msg); if (ret < 0) { dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret); + } else if (msg->result == EC_RES_INVALID_VERSION) { + dev_dbg(ec_dev->dev, "Command invalid version (err:%d)\n", + msg->result); + return -ENOTSUPP; } else if (msg->result != EC_RES_SUCCESS) { dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result); return -EPROTO; -- 2.25.0