Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4498887rwb; Tue, 6 Sep 2022 08:19:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Em0bWhwXT9tDCmOVdvUFeVQP8zWkeIOzmoMtV4nvHWoeXMKgOyZHM+sj4LPJoJE68PSXu X-Received: by 2002:a05:6402:2b98:b0:43e:107:183d with SMTP id fj24-20020a0564022b9800b0043e0107183dmr47769718edb.366.1662477575879; Tue, 06 Sep 2022 08:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477575; cv=none; d=google.com; s=arc-20160816; b=q08a1R/3spD2WXL7O2PkVOItQKVw76xVltQa5j3blsUDK/IFroEnwJUTUveliUTLpk ccspbTG6+BgGe+iizzpM0N3lmCsCVFSbSVKL3RvUBSkqeCe0og118nFpFED2qbL3mRil XtE2KO7kgX5YNwF6tD5r9o2gIHMEd1IXqaAcakcMcVjDJQJi09QeZbtkKi1cy1CK2ati 9Kpx1IQNkW0qtVmNRkg96e6hl2GHUW8IfBYsZQrZOVy0HMnDQyH6nknasKl9golBurSm YsYLhDqy3yx/Ov1Dci095RMklQ1Stx2ZIfnk6UafjnV2gGaOFwdDCyhsaVmDOviW8CYD ts9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+3Wh3UMQ7hyj2qWBdLrGh6O7QrRJ1RWJEOVatNF4lh8=; b=u+p+nH8MplPaKuJOHHSKEEb53mfdL3ciR0FC8NqoCVvsppfUdC1PcHaBa8Fx/Gge/c 63Yv9dZ9AjxqovMXQMlBQ5I9YoqCRAO2u8glAP0hoEAUZUB5XZbKJPAK/aNovH1OYQyd qwK6LO4nhsMqucfm/PuGw3/BmPdZBAkoRQ39Vyehbjw2HMpz3BMoeLRNeW0b6HayY6qo +kXOltqcW5gWov3aM0dU7OB+ljJa+NaH9kh6yEmwuFasV2NM4c947b3/VEXn2+vwGSOj vDBsA6dakEdzfacAFR5HWTAI99dRa9Ss6P2Mu3b5AJIzmCXlwwHkyb2WJkSdOAs03GHi qAtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lgtlrH/T"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb30-20020a1709076d9e00b007417040d1c5si10635509ejc.823.2022.09.06.08.19.09; Tue, 06 Sep 2022 08:19:35 -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=@linuxfoundation.org header.s=korg header.b="lgtlrH/T"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242196AbiIFOkM (ORCPT + 99 others); Tue, 6 Sep 2022 10:40:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbiIFOje (ORCPT ); Tue, 6 Sep 2022 10:39:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FA09A9F5; Tue, 6 Sep 2022 07:01:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3E776B818D2; Tue, 6 Sep 2022 13:47:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C82EC433C1; Tue, 6 Sep 2022 13:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662472028; bh=JKmsXg/xZkBd+xL8TngKylXy2C6YDDsp8ZYqyG+miC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lgtlrH/T8gRWxIMqhi77z+WimfR8nRek/B00zydDogen4YlU6F8Uy36WFtyvY33R4 n0BFwEUX1786//EFPH/uxBhGlJiMAOMiTrXxo0tFFMPSTCzWQCwEHcF/p5uuO4HT2Q swTmD53zIz9gZ8uia0y4bcEkAb5g3RJYSd8/XDq0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heikki Krogerus , Badhri Jagan Sridharan Subject: [PATCH 5.19 122/155] usb: typec: tcpm: Return ENOTSUPP for power supply prop writes Date: Tue, 6 Sep 2022 15:31:10 +0200 Message-Id: <20220906132834.608913555@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Badhri Jagan Sridharan commit f2d38edc5e3375e56b4a30d5b66cefd385a2b38c upstream. 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 Reviewed-by: Heikki Krogerus Signed-off-by: Badhri Jagan Sridharan Link: https://lore.kernel.org/r/20220817215410.1807477-1-badhri@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -6191,6 +6191,13 @@ static int tcpm_psy_set_prop(struct powe 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);