[PATCH 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def

From: Amit Sunil Dhamne via B4 Relay

Date: Thu Oct 01 2026 - 18:58:48 EST


From: Amit Sunil Dhamne <amitsd@xxxxxxxxxx>

tcpm_get_current_limit() folds the default label into the
TYPEC_CC_RP_DEF case, so tcpc_dev::get_current_limit() is also called
for CC states that do not advertise Rp, such as TYPEC_CC_OPEN,
TYPEC_CC_RA and TYPEC_CC_RD. Its kerneldoc has always scoped it to
cc=Rp-def:

@get_current_limit:
Optional; called by the tcpm core when configured as a snk
and cc=Rp-def. This allows the tcpm to provide a fallback
current-limit detection method for the cc=Rp-def case.

A chip driver has nothing to interpret in the other states. Therefore,
split the cases and report 0 when CC is not an Rp.

Assisted-by: LLM
Signed-off-by: Amit Sunil Dhamne <amitsd@xxxxxxxxxx>
Reviewed-by: Badhri Jagan Sridharan <badhri@xxxxxxxxxx>
---
drivers/usb/typec/tcpm/tcpm.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 2d6b14aa20856..2e7371ada8642 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -1268,7 +1268,7 @@ static int tcpm_set_vconn(struct tcpm_port *port, bool enable)
static u32 tcpm_get_current_limit(struct tcpm_port *port)
{
enum typec_cc_status cc;
- u32 limit;
+ u32 limit = 0;

cc = port->polarity ? port->cc2 : port->cc1;
switch (cc) {
@@ -1279,11 +1279,10 @@ static u32 tcpm_get_current_limit(struct tcpm_port *port)
limit = 3000;
break;
case TYPEC_CC_RP_DEF:
- default:
if (port->tcpc->get_current_limit)
limit = port->tcpc->get_current_limit(port->tcpc);
- else
- limit = 0;
+ break;
+ default:
break;
}


--
2.56.0.rc1.315.gc6ed9934b7-goog