mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amit Sunil Dhamne via B4 Relay <devnull+amitsd.google.com@kernel.org>
To: Badhri Jagan Sridharan <badhri@google.com>,
	 Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	"André Draszik" <andre.draszik@linaro.org>,
	"RD Babiera" <rdbabiera@google.com>,
	"Kyle Tso" <kyletso@google.com>,
	"Amit Sunil Dhamne" <amitsd@google.com>
Subject: [PATCH 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def
Date: Thu, 01 Oct 2026 22:51:13 +0000	[thread overview]
Message-ID: <20261001-max77759-icl-typec-v1-1-99ada1f65ced@google.com> (raw)
In-Reply-To: <20261001-max77759-icl-typec-v1-0-99ada1f65ced@google.com>

From: Amit Sunil Dhamne <amitsd@google.com>

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@google.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
---
 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



  reply	other threads:[~2026-10-01 22:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 22:51 [PATCH 0/3] usb: typec: report a current limit for non-PD Rp-def sources Amit Sunil Dhamne via B4 Relay
2026-10-01 22:51 ` Amit Sunil Dhamne via B4 Relay [this message]
2026-10-02  9:48   ` [PATCH 1/3] usb: typec: tcpm: only call get_current_limit() for cc=Rp-def André Draszik
2026-10-01 22:51 ` [PATCH 2/3] usb: typec: tcpci: implement get_current_limit Amit Sunil Dhamne via B4 Relay
2026-10-01 22:51 ` [PATCH 3/3] usb: typec: tcpci_maxim: " Amit Sunil Dhamne via B4 Relay
2026-10-09 11:19 ` [PATCH 0/3] usb: typec: report a current limit for non-PD Rp-def sources Heikki Krogerus
2026-10-09 11:32   ` Heikki Krogerus

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=20261001-max77759-icl-typec-v1-1-99ada1f65ced@google.com \
    --to=devnull+amitsd.google.com@kernel.org \
    --cc=amitsd@google.com \
    --cc=andre.draszik@linaro.org \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rdbabiera@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®