Skip to contentSkip to conversation

usb: typec: tcpm: Fix error while calculating PPS out values

PATCH In review Badhri Jagan Sridharan 2 participants 3 messages Apr 15, 2021

Subsystems (4)
lore
Share & tools
lore

Badhri Jagan Sridharan

author maintainer
#0 lore raw

PATCH 1/1 usb: typec: tcpm: Fix error while calculating PPS out values

"usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply" introduced a regression for req_out_volt and req_op_curr calculation.

req_out_volt should consider the newly calculated max voltage instead of previously accepted max voltage by the port partner. Likewise, req_op_curr should consider the newly calculated max current instead of previously accepted max current by the port partner.

Fixes e3a072022487 ("usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply")
---
 drivers/usb/typec/tcpm/tcpm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -3
index 1c32bdf62852..04652aa1f54e 100644
@@ -3132,10 +3132,10 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
 		port->pps_data.req_max_volt = min(pdo_pps_apdo_max_voltage(src),
 						  pdo_pps_apdo_max_voltage(snk));
 		port->pps_data.req_max_curr = min_pps_apdo_current(src, snk);
-		port->pps_data.req_out_volt = min(port->pps_data.max_volt,
-						  max(port->pps_data.min_volt,
+		port->pps_data.req_out_volt = min(port->pps_data.req_max_volt,
+						  max(port->pps_data.req_min_volt,
 						      port->pps_data.req_out_volt));
-		port->pps_data.req_op_curr = min(port->pps_data.max_curr,
+		port->pps_data.req_op_curr = min(port->pps_data.req_max_curr,
 						 port->pps_data.req_op_curr);
 	}
 
Signature · 1 line
2.31.1.295.g9ea45b61b8-goog
author maintainer
#1 lore raw
Quoted 36 lines · Badhri Jagan Sridharan

"usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply" introduced a regression for req_out_volt and req_op_curr calculation.

req_out_volt should consider the newly calculated max voltage instead of previously accepted max voltage by the port partner. Likewise, req_op_curr should consider the newly calculated max current instead of previously accepted max current by the port partner.

Fixes e3a072022487 ("usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply")
---
 drivers/usb/typec/tcpm/tcpm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -4
index 1c32bdf62852..04652aa1f54e 100644
@@ -3132,10 +3132,10 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
                port->pps_data.req_max_volt = min(pdo_pps_apdo_max_voltage(src),
                                                  pdo_pps_apdo_max_voltage(snk));
                port->pps_data.req_max_curr = min_pps_apdo_current(src, snk);
-               port->pps_data.req_out_volt = min(port->pps_data.max_volt,
-                                                 max(port->pps_data.min_volt,
+               port->pps_data.req_out_volt = min(port->pps_data.req_max_volt,
+                                                 max(port->pps_data.req_min_volt,
                                                      port->pps_data.req_out_volt));
-               port->pps_data.req_op_curr = min(port->pps_data.max_curr,
+               port->pps_data.req_op_curr = min(port->pps_data.req_max_curr,
                                                 port->pps_data.req_op_curr);
        }
 
--

2.31.1.295.g9ea45b61b8-goog

Reviewed-by on v1 1/1
#2 lore raw
In reply to Badhri Jagan Sridharan
Quoted 10 lines · Badhri Jagan Sridharan

"usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply" introduced a regression for req_out_volt and req_op_curr calculation.

req_out_volt should consider the newly calculated max voltage instead of previously accepted max voltage by the port partner. Likewise, req_op_curr should consider the newly calculated max current instead of previously accepted max current by the port partner.

Fixes e3a072022487 ("usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply")
Quoted 23 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -3
index 1c32bdf62852..04652aa1f54e 100644
@@ -3132,10 +3132,10 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
 		port->pps_data.req_max_volt = min(pdo_pps_apdo_max_voltage(src),
 						  pdo_pps_apdo_max_voltage(snk));
 		port->pps_data.req_max_curr = min_pps_apdo_current(src, snk);
-		port->pps_data.req_out_volt = min(port->pps_data.max_volt,
-						  max(port->pps_data.min_volt,
+		port->pps_data.req_out_volt = min(port->pps_data.req_max_volt,
+						  max(port->pps_data.req_min_volt,
 						      port->pps_data.req_out_volt));
-		port->pps_data.req_op_curr = min(port->pps_data.max_curr,
+		port->pps_data.req_op_curr = min(port->pps_data.req_max_curr,
 						 port->pps_data.req_op_curr);
 	}