From nobody Fri Dec 19 14:21:15 2025 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84AA91E32D3 for ; Thu, 6 Nov 2025 01:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762391692; cv=none; b=mgZX2koYUofGuAELQxsLuCHV4jQ/ZZweGeOuIJQBmTfXOsUCNp5ubtCkJl4qooJ4b1TeqBurk/um1OmQhXXpesnptdnBy7lc4ObS6oNoFp+tOEOPfMFCPuclAJD9ITe0KILOlzl5arL++YZER0ng/YuXB3xp/7boxC9POvvpSSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762391692; c=relaxed/simple; bh=GqiSEFjJpS60vknr4o7YkvEXtHCaMxx+InwVSzChCtY=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=JAfBP545or282kuZDNCuNzhNqw5Ors3901dAbS2+9D3MDXzrEsRwRfRWf0RYeoOP/A5VpQHEW8ai1o8B+k33dMngIq1XIRtN7yAScfWiCaX5fSjX0o45Q4Y09kw0RukTkOVLSTHYlsMZV+yQZBAd3Q1lEJ+cWJiFuIn42LkxZ/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Mg6b+Jal; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mg6b+Jal" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b62da7602a0so372725a12.2 for ; Wed, 05 Nov 2025 17:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1762391690; x=1762996490; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=39ivioua6pnMjSf3oDat2VB6KzK+NMcakhy3huJbtbA=; b=Mg6b+JalVoK55gYj7KWr+vHIEhRFW2jczU3YZQZolgfaOLStelq/+gu4wcgCvewRXm F00O6SsG9rH8E938T3kWelwnzji4ohv5qywMuVeSzwLfC/kzvngQrh34NB7C+PQ++WJP i5zSY88fIhyUaqwc3HzZ56TIywyegbbl7ixUqOAE9nN+SZkqUsP/WnSAvF/50yoSnD/r 2KotY7vI62JCNhWUZ25mSoJs/MKvB10jV7JF3OnurzNPSRtdkZB1q/7417zGh9E2yyIm 6XKGFNUMmLdrJIh2fcWdcjhX+EYJ5VMJoZDh6uBHr2Mx6BfWTb1xrTBn3NvdVVrVN4kS JIxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762391690; x=1762996490; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=39ivioua6pnMjSf3oDat2VB6KzK+NMcakhy3huJbtbA=; b=X+Zswsuz7RT6ULCMnY5+sTYO9pJZPwGqfnB1hvLmRROriRZ3j/BfCmrZwYN6YWt4lr w4Ou+55ChJnvwEB5hfPLmIrF3gqm7kXFyLKPuRmBxGxNwEzNZf584W1MVDjCpb3lNon9 YFGYIMTn7UCGM9TTYWjeCdRbiKuQjtyPycs+nONPnXFV0g/pDvkUsRJQQMUzCu9SWvZn BIEams5MwjrvInpCHdCgKwGB5YYlANEy3e7rzJzesFYPV9Dy2VENHEt8Eak92/PS19O0 qGhhWyuzSq+q3bNlHEgsTxnOPXLstBUiPZhhflLVultPuW2kLoteCr5X1u/mBnLrebvd qNXA== X-Forwarded-Encrypted: i=1; AJvYcCXRrboAZRJqBRPVV1difM+aNG7oXaiYVbIx5FoA1RLb1pOdd0qKfpKoNKW06laeHSSw3vBC31F8IM22NVo=@vger.kernel.org X-Gm-Message-State: AOJu0YwQAaFRxLDOA+Tz8cJGt1kd7+ZDGNmWnqNxAxncEluU3DvuHzyv 6nq7uGdZAIVN15+zuVoOQ1y3XicxMJHZDE+bw2EJkZz8KuKDc2o3RQQo/psmnK0GScjcc4uNDvB //tWo0A== X-Google-Smtp-Source: AGHT+IGHknY9aqu1w+W4IBmjhbnbPVtNg3MS81ewEb5IJ6RCNy2Yl/JqwF6vF+FFSuv2t1tS8YOwfKaj34E= X-Received: from dlbqc8.prod.google.com ([2002:a05:7023:a88:b0:119:49ca:6ba4]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:3d8e:b0:343:68f2:3728 with SMTP id adf61e73a8af0-34f83f06e42mr7119443637.15.1762391689940; Wed, 05 Nov 2025 17:14:49 -0800 (PST) Date: Thu, 6 Nov 2025 01:14:46 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.51.2.1041.gc1ab5b90ca-goog Message-ID: <20251106011446.2052583-1-jthies@google.com> Subject: [PATCH v3] usb: typec: ucsi: psy: Set max current to zero when disconnected From: Jameson Thies To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dmitry.baryshkov@oss.qualcomm.com, bleung@chromium.org, gregkh@linuxfoundation.org, akuchynski@chromium.org, abhishekpandit@chromium.org, sebastian.reichel@collabora.com, kenny@panix.com, linux-pm@vger.kernel.org, stable@vger.kernel.org, Jameson Thies Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The ucsi_psy_get_current_max function defaults to 0.1A when it is not clear how much current the partner device can support. But this does not check the port is connected, and will report 0.1A max current when nothing is connected. Update ucsi_psy_get_current_max to report 0A when there is no connection. Fixes: af833e7f7db3 ("usb: typec: ucsi: psy: Set current max to 100mA for B= C 1.2 and Default") Cc: stable@vger.kernel.org Signed-off-by: Jameson Thies Reviewed-by: Benson Leung Reviewed-by: Heikki Krogerus Reviewed-by: Sebastian Reichel Tested-by: Kenneth R. Crudup --- v3 changes: - change log moved under "--" v2 changes: - added cc stable tag to commit message drivers/usb/typec/ucsi/psy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c index 2b0225821502..3abe9370ffaa 100644 --- a/drivers/usb/typec/ucsi/psy.c +++ b/drivers/usb/typec/ucsi/psy.c @@ -169,6 +169,11 @@ static int ucsi_psy_get_current_max(struct ucsi_connec= tor *con, { u32 pdo; =20 + if (!UCSI_CONSTAT(con, CONNECTED)) { + val->intval =3D 0; + return 0; + } + switch (UCSI_CONSTAT(con, PWR_OPMODE)) { case UCSI_CONSTAT_PWR_OPMODE_PD: if (con->num_pdos > 0) { base-commit: 18514fd70ea4ca9de137bb3bceeac1bac4bcad75 --=20 2.51.2.1041.gc1ab5b90ca-goog