All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Mani, Rajmohan" <rajmohan.mani@intel.com>,
	linux-usb@vger.kernel.org,
	Madhusudanarao Amara <madhusudanarao.amara@intel.com>
Subject: [PATCH 3/3] usb: typec: intel_pmc_mux: Handle SCU IPC error conditions
Date: Wed, 16 Sep 2020 12:11:02 +0300	[thread overview]
Message-ID: <20200916091102.27118-4-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <20200916091102.27118-1-heikki.krogerus@linux.intel.com>

From: Madhusudanarao Amara <madhusudanarao.amara@intel.com>

Check and return if there are errors. The response bits are valid
only on no errors.

Fixes: b7404a29cd3d ("usb: typec: intel_pmc_mux: Definitions for response status bits")
Signed-off-by: Madhusudanarao Amara <madhusudanarao.amara@intel.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index 109c1a796e844..d7f63b74c6b14 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -176,13 +176,19 @@ static int hsl_orientation(struct pmc_usb_port *port)
 static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
 {
 	u8 response[4];
+	int ret;
 
 	/*
 	 * Error bit will always be 0 with the USBC command.
-	 * Status can be checked from the response message.
+	 * Status can be checked from the response message if the
+	 * function intel_scu_ipc_dev_command succeeds.
 	 */
-	intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, len,
-				  response, sizeof(response));
+	ret = intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg,
+					len, response, sizeof(response));
+
+	if (ret)
+		return ret;
+
 	if (response[2] & PMC_USB_RESP_STATUS_FAILURE) {
 		if (response[2] & PMC_USB_RESP_STATUS_FATAL)
 			return -EIO;
-- 
2.28.0


  parent reply	other threads:[~2020-09-16  9:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  9:10 [PATCH v2 0/3] USB Type-C fixes for usb-next Heikki Krogerus
2020-09-16  9:11 ` [PATCH 1/3] usb: typec: intel_pmc_mux: Add dependency on ACPI Heikki Krogerus
2020-09-16  9:11 ` [PATCH 2/3] usb: typec: intel_pmc_mux: Pass correct USB Type-C port number to SoC Heikki Krogerus
2020-09-16  9:11 ` Heikki Krogerus [this message]
2020-09-16  9:42   ` [PATCH 3/3] usb: typec: intel_pmc_mux: Handle SCU IPC error conditions Greg Kroah-Hartman
     [not found]     ` <20200916105845.GE1358028@kuha.fi.intel.com>
2020-09-16 11:09       ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200916091102.27118-4-heikki.krogerus@linux.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=madhusudanarao.amara@intel.com \
    --cc=rajmohan.mani@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.