Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5307055rwb; Wed, 17 Aug 2022 15:18:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR72HYO6TEh4v/uBUYK9P98lcurFycHvdqaf5lhsdVHPdAEFTL7d2cos3DLTUuJ98xRT4Phf X-Received: by 2002:a62:1a14:0:b0:52d:daae:b289 with SMTP id a20-20020a621a14000000b0052ddaaeb289mr204637pfa.55.1660774717783; Wed, 17 Aug 2022 15:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660774717; cv=none; d=google.com; s=arc-20160816; b=J3NXdFEnjJKU4WcPZHNM1TJRgDS7SNaSTD6GyNYeA+LbFjBPhBthD2fU+3Fv6Os+/s 6v7L89ciVOvhtoqLmT2UdPXJtjD7JDJmVYuATmCN3AkJblxvZKwa7k/JqKZ5JVbBHJ2V CRPTArZvfdAuIOUY2F4+N2A4p8dIPo76OmswqEzTCd8/dEgeZBgB1Hzr/vtlL/IQhKLL 6o72e97AkWokULVnqYK33kDCLo7Kq77DLeHUtsEMNuGKoL/z+XIYYSP60WrhvfdhCdVE GuE+OblfRnujp1dzyLHVTxo6fH9i+8ggISLYM9kP9bAU12PFZPdkQB9e5oSC0nw5JsJN Iq1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=C/QKypOIvJ6Rce8xT4vH1Np43b9AyTIhn63zh/KI2uM=; b=y9jKQCoKR8kHDQXv+mmlORQ8M10I4BIU1+95cPwW7UJtut2YPltQxTDA4oWRtZPKpm iaZQBHVn7a+xVAi+HIDZYxzEqCZqbtpCk96gYuFNW/Nkl9kB7IN1KIbkhJsYwRa9vThS eSCF0CdEAtvO4+J4GDMsC19mPAvaK7y6+LXhiRUFnbpeR6dxpQCSbH0J4A3i3pgITTgE X9OpADIn9UVAqS3+mBuSQ40H7K4bckfGoiEOT5Z2ozao71jIM7QdGH1K6hCxhw/HT/8g sbH4e5rp1Ryqs72y19EUdcba71YLV0jc/5QuW9ZAq3Qpwzu1R/mAC/qYsFVMk2kSuM0q 2xcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VMEaNRZn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v37-20020a634665000000b00429ead9bda6si1083567pgk.86.2022.08.17.15.18.25; Wed, 17 Aug 2022 15:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VMEaNRZn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242406AbiHQVyQ (ORCPT + 99 others); Wed, 17 Aug 2022 17:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241796AbiHQVyP (ORCPT ); Wed, 17 Aug 2022 17:54:15 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2246FA5C5E for ; Wed, 17 Aug 2022 14:54:14 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-3345ad926f2so74044927b3.12 for ; Wed, 17 Aug 2022 14:54:14 -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=C/QKypOIvJ6Rce8xT4vH1Np43b9AyTIhn63zh/KI2uM=; b=VMEaNRZngel6522Od5siI1fX5FQlaLPJ5eZSmEoVCRfDDEuooUEG2MlNxbK0XM+Oxe gkB+JyBVX5uwSyxu5ohjWipw+ykU+IcxIcVTeEKIUzxvzb9KusCmHGJ9/h+wHCA2ZQpJ lMTsRhV+DeHyGk4HAGUahcDkTjZuoFWOwGEvwCF4AfPoPhRRj6J6frntbreYNk6dtSUm Wd4Lr3kXYUOIONYHN+BCuVYVXmZ9cMLBwitZDNVIc6QB89B2FMQ5Hxlpzulgg9uzo/1f HwqRvpM86RUaQh9Yj/3gHmj/DCPR8Ke8uyj0lbhmyEW7BjuPHhstj5sAx2atFAC88LyZ sdkA== 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=C/QKypOIvJ6Rce8xT4vH1Np43b9AyTIhn63zh/KI2uM=; b=Wj7WeCzcZY31H1AGQ6B05u+rNILBvaAwm8wJYq+4kcEUIR7iiFs5Bn8n2TOPcMP0pt xrwfhE7k/VvJOlb9FVk/Qe8UlXPzdklZYxVnRewiY6/3Qu2hocchQ3rIzZ7PZNALnYuf +OXk9qkQsVTFMHjwOcpPlNyk7wddkIuMOgYegZnz5SWGayNtPAfHRC1F1XEAEEaKm3Yx 5clug6NvuykmZ/zS7hnUENqfT2XLi4jfjkfu9Iqzr5fXY8LWQDS0y9x+hcDPxYhWcuas O1lROdcX8s/8P5vUv4L8JMcrFvzxqmYrdFdS5WtnC2G7p7qbJXLbavF20FiM57QMJzbA LMzA== X-Gm-Message-State: ACgBeo3iGSkj26wgUzh0dTJ6tPBrApoC9Gc2v2jSxH11cfrd1DV2cRnG wGYHs7djXmRD8KSwWYavJ4dWOsDwsd0= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:5faa:9f1a:38b4:b859]) (user=badhri job=sendgmr) by 2002:a81:83cf:0:b0:334:fe5:b2fe with SMTP id t198-20020a8183cf000000b003340fe5b2femr167207ywf.402.1660773253404; Wed, 17 Aug 2022 14:54:13 -0700 (PDT) Date: Wed, 17 Aug 2022 14:54:10 -0700 Message-Id: <20220817215410.1807477-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH v3] 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 NONE_AMS] [ 84.308335] Setting usb_comm capable false [ 84.323367] set_auto_vbus_discharge_threshold mode:3 pps_active:n vbus:5000 ret:0 [ 84.323376] state change SNK_NEGOTIATE_CAPABILITIES -> SNK_WAIT_CAPABILITIES [rev3 NONE_AMS] Fixes: e9e6e164ed8f6 ("usb: typec: tcpm: Support non-PD mode") Cc: stable@vger.kernel.org Signed-off-by: Badhri Jagan Sridharan --- Changes since v1: - Add Fixes tag. Changes since v2: - CCed stable --- 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 *psy, struct tcpm_port *port = power_supply_get_drvdata(psy); int ret; + /* + * 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 = tcpm_psy_set_online(port, val); -- 2.37.1.595.g718a3a8f04-goog