From patchwork Tue Jun 28 02:49:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 12897565 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CCC5368 for ; Tue, 28 Jun 2022 02:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B7D9C341CC; Tue, 28 Jun 2022 02:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656384577; bh=/mCONiNi6+rv5jRQfmF6KXwkU9b+H5v0JzqV3x5Sslg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jo4S5RZzxr1vph9vG7CefP5Cj1E24kKfkP/fvyN6K6toynuuXtPCubkrkEwjNmuDu rhZgGvxnTL0E7TFOkF9DfB/bB/ZyBEfmBN20JuoPy3p2YUr/JtCSLvBoiWG7lYNxU5 CSGSck6NVcCODFpp5XIUeTVuqWdwsdE4EzY/R99j0D7r2oQg3pRj6UytmMWHh2RNST Vwdui8G14JWJgpfAEtr6THk13InceS5ikD85SEDHZM++NeBIniU8LFylfDcwDPNa0T UQqeiLfZovKKWpiqGmLx59i0mg9H0pWx2spe0ariAWEPEL2kiMHHsB9C8QLuDhnhHj BNoUPWAOaqs/A== From: Tzung-Bi Shih To: bleung@chromium.org, groeck@chromium.org Cc: chrome-platform@lists.linux.dev, tzungbi@kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH 04/11] platform/chrome: cros_ec_proto: separate cros_ec_xfer_command() Date: Tue, 28 Jun 2022 02:49:06 +0000 Message-Id: <20220628024913.1755292-5-tzungbi@kernel.org> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220628024913.1755292-1-tzungbi@kernel.org> References: <20220628024913.1755292-1-tzungbi@kernel.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cros_ec_send_command() has extra logic to handle EC_RES_IN_PROGRESS. Separate the command transfer part into cros_ec_xfer_command() so that other functions can re-use it. Reviewed-by: Guenter Roeck Signed-off-by: Tzung-Bi Shih --- drivers/platform/chrome/cros_ec_proto.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index b02fd1414e52..0cec013be3d3 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -107,7 +107,7 @@ static int prepare_tx_legacy(struct cros_ec_device *ec_dev, return EC_MSG_TX_PROTO_BYTES + msg->outsize; } -static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) +static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) { int ret; int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg); @@ -123,14 +123,21 @@ static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_co * the EC is trying to use protocol v2, on an underlying * communication mechanism that does not support v2. */ - dev_err_once(ec_dev->dev, - "missing EC transfer API, cannot send command\n"); + dev_err_once(ec_dev->dev, "missing EC transfer API, cannot send command\n"); return -EIO; } trace_cros_ec_request_start(msg); ret = (*xfer_fxn)(ec_dev, msg); trace_cros_ec_request_done(msg, ret); + + return ret; +} + +static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) +{ + int ret = cros_ec_xfer_command(ec_dev, msg); + if (msg->result == EC_RES_IN_PROGRESS) { int i; struct cros_ec_command *status_msg;