From nobody Sat Apr 11 02:17:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A69BC32773 for ; Tue, 16 Aug 2022 19:12:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232297AbiHPTMB (ORCPT ); Tue, 16 Aug 2022 15:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236907AbiHPTL6 (ORCPT ); Tue, 16 Aug 2022 15:11:58 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A187D1DD for ; Tue, 16 Aug 2022 12:11:55 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3344aa7e79aso22321217b3.23 for ; Tue, 16 Aug 2022 12:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc; bh=X/YkdclUGRbmTWtx7pCDnwB6JcrES8yYvjN/AvuuOws=; b=JBdb3tVJtQfGAYooIHg8G+7xnscUXc++JpjvqR7BGlAPRhgIIj4wkFphcp86Z7i9NS PUJfpaF9JABxy8z2VQV3FQZZEqBYabfppu4jrHtpOD56BqjYQxHKiQ+FLCpcze4CsMNc Pamq6on1eG5br1FaYUz/d9wClBGS7YVZ+OmViTijj5PliDle+4Jp/Y3hhT7fu4m3r56U zbkP7GNwE54SrFjfa1EswAu26i3mlhuTOB3uh6xAwygXwr2rp0sjfnSzYfgSJyuh0A1A hmQLFAPLg1jbc9spY8ABgKRzroNWadrB5VVQSuoJ74O6EGAiLHAMZj6QCKVyEWAGf+qC 6Gyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc; bh=X/YkdclUGRbmTWtx7pCDnwB6JcrES8yYvjN/AvuuOws=; b=JhWqQH2F1JCdJWHkaauPzvzgTxHus0tJHGWasF/SYreAoefp2AcwxW+4B42ef4RVTF nhG0wHaw/9JEbK9ssfDbHMswwj9Rx2VZn9E/vfoxagQt0TAv8O1JKmsObsZseMtYjc9O /feGrFuskIuB2CvQ6r5GfkpBPQ/M4mfTqXAQYzIVrgJAIm3+D8f0gJuyVn71SFKBC3xH BMYxXIG06TfGQwFwCFTter9RF2ck3/XOPTyAtiNKDr9mFi9wq4SPgEcs8D522bczxnjs gcm8JCqxa6O07hJhAfAehHdfFmUW9rxroEHdlZSzu+scEUGJuZeX3AwhDBAFpeYikOyO Ilaw== X-Gm-Message-State: ACgBeo3pSsIvt7wWpUdMDKYXf6ao/aWhg1RC0/vDVttI4mcF1lIAWlLf Zv3/ii8cIynkrWP1/+8b8nQuE87uAlg= X-Google-Smtp-Source: AA6agR7Ej5XeN1kk6sRNudElC0yOv+aIVrLG/331kS3Qv0cvLOVPouvYbE4PRfNshRSWWbsHNbvnpkTNarM= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:2019:e66e:d39a:1a4c]) (user=badhri job=sendgmr) by 2002:a25:e756:0:b0:68f:f129:243c with SMTP id e83-20020a25e756000000b0068ff129243cmr117948ybh.493.1660677114308; Tue, 16 Aug 2022 12:11:54 -0700 (PDT) Date: Tue, 16 Aug 2022 12:11:50 -0700 Message-Id: <20220816191150.1432166-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH v2] usb: typec: tcpm: Return ENOTSUPP for power supply prop writes From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org, Badhri Jagan Sridharan Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the port does not support USB PD, prevent transition to PD only states when power supply property is written. In this case, TCPM transitions to SNK_NEGOTIATE_CAPABILITIES which should not be the case given that the port is not pd_capable. [ 84.308251] state change SNK_READY -> SNK_NEGOTIATE_CAPABILITIES [rev3 N= ONE_AMS] [ 84.308335] Setting usb_comm capable false [ 84.323367] set_auto_vbus_discharge_threshold mode:3 pps_active:n vbus:5= 000 ret:0 [ 84.323376] state change SNK_NEGOTIATE_CAPABILITIES -> SNK_WAIT_CAPABILI= TIES [rev3 NONE_AMS] Fixes: e9e6e164ed8f6 ("usb: typec: tcpm: Support non-PD mode") Signed-off-by: Badhri Jagan Sridharan --- Changes since v1: - Add Fixes tag. --- drivers/usb/typec/tcpm/tcpm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index ea5a917c51b1..904c7b4ce2f0 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -6320,6 +6320,13 @@ static int tcpm_psy_set_prop(struct power_supply *ps= y, struct tcpm_port *port =3D power_supply_get_drvdata(psy); int ret; =20 + /* + * All the properties below are related to USB PD. The check needs to be + * property specific when a non-pd related property is added. + */ + if (!port->pd_supported) + return -EOPNOTSUPP; + switch (psp) { case POWER_SUPPLY_PROP_ONLINE: ret =3D tcpm_psy_set_online(port, val); --=20 2.37.1.595.g718a3a8f04-goog