diff mbox series

usb: typec: intel_pmc_mux: Use correct response message bits

Message ID 20201203220813.16281-1-utkarsh.h.patel@intel.com
State New
Headers show
Series usb: typec: intel_pmc_mux: Use correct response message bits | expand

Commit Message

Patel, Utkarsh H Dec. 3, 2020, 10:08 p.m. UTC
When Intel PMC Mux agent driver receives the response message from PMC, it
checks for the same response bits for all the mux states.
Corrected it by checking correct response message bits, Bit 8 & 9 for the
SAFE Mode and Alternate Modes and Bit 16 & 17 for the Connect and
Disconnect Modes.

Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Heikki Krogerus Dec. 8, 2020, 9:38 a.m. UTC | #1
On Thu, Dec 03, 2020 at 02:08:13PM -0800, Utkarsh Patel wrote:
> When Intel PMC Mux agent driver receives the response message from PMC, it

> checks for the same response bits for all the mux states.

> Corrected it by checking correct response message bits, Bit 8 & 9 for the

> SAFE Mode and Alternate Modes and Bit 16 & 17 for the Connect and

> Disconnect Modes.

> 

> Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>


Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>


> ---

>  drivers/usb/typec/mux/intel_pmc_mux.c | 9 +++++++--

>  1 file changed, 7 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c

> index aa3211f1c4c3..e58ae8a7fefb 100644

> --- a/drivers/usb/typec/mux/intel_pmc_mux.c

> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c

> @@ -176,6 +176,7 @@ 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];

> +	u8 status_res;

>  	int ret;

>  

>  	/*

> @@ -189,9 +190,13 @@ static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)

>  	if (ret)

>  		return ret;

>  

> -	if (response[2] & PMC_USB_RESP_STATUS_FAILURE) {

> -		if (response[2] & PMC_USB_RESP_STATUS_FATAL)

> +	status_res = (msg[0] & 0xf) < PMC_USB_SAFE_MODE ?

> +		     response[2] : response[1];

> +

> +	if (status_res & PMC_USB_RESP_STATUS_FAILURE) {

> +		if (status_res & PMC_USB_RESP_STATUS_FATAL)

>  			return -EIO;

> +

>  		return -EBUSY;

>  	}

>  

> -- 

> 2.17.1


thanks,

-- 
heikki
diff mbox series

Patch

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index aa3211f1c4c3..e58ae8a7fefb 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -176,6 +176,7 @@  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];
+	u8 status_res;
 	int ret;
 
 	/*
@@ -189,9 +190,13 @@  static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
 	if (ret)
 		return ret;
 
-	if (response[2] & PMC_USB_RESP_STATUS_FAILURE) {
-		if (response[2] & PMC_USB_RESP_STATUS_FATAL)
+	status_res = (msg[0] & 0xf) < PMC_USB_SAFE_MODE ?
+		     response[2] : response[1];
+
+	if (status_res & PMC_USB_RESP_STATUS_FAILURE) {
+		if (status_res & PMC_USB_RESP_STATUS_FATAL)
 			return -EIO;
+
 		return -EBUSY;
 	}