Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp166713rwb; Fri, 2 Sep 2022 12:01:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CIl9HaZWRliw1t7G8y0bI/kyEzJ696+7rZ9B72TTaCqgzKBAShMMzOStdAhikpFiRxVcm X-Received: by 2002:a17:903:230b:b0:173:86a:50ea with SMTP id d11-20020a170903230b00b00173086a50eamr35877136plh.52.1662145315824; Fri, 02 Sep 2022 12:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662145315; cv=none; d=google.com; s=arc-20160816; b=Vk8HnHGgWEYXnq5w/pvAQo/N5g7G4rWxzDZWQ0epGp9aWe4W/sYzSGfLeC05DOBwm4 ph5ksFhOV3xP1+a2OB/8JIWbSMWbujB8/jthWC6yuEVekfaEuxbRnrHRwlfJBnULpeiT 11uAjlmq4Y1+fQ50zkF1B9b3QnYG3pUCJxpe1Wr5keVHfOByFveVTiIKYKECg0ft8pgm DVdb5X1pH2YkARaSe9Qwhq3Nie/O7BFGx6MnSpPmTikDi5mFp35PGQXrCk/WQekTA5V7 2i+2wY1MHi1ZlAqbm0eStGCJhhrphU7blmRzxLf0S4ND+yu+L8D6599IN3xQRgYxaHHD 0oWg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=l8lXRjJOTwa1pdbI6AHOCcVerD9joOqdaqD9HG8JOnk=; b=cJFXoaHWyvx9x190tdBbwd5D7sI2tGi6yw4Q2aaP14JheilBx/cWXiG2V1DfEMofs5 3fkPeGSIUrIGvPmtt77DeT1EOoLEV7MrqYEFpHLxJTFvVRiBS1Uz1F2i3tOgO1Atv66M JxHNXjkr4/e2vxsjWRlNAW1N18Y//Vl+DQgT9E1P+AwYA0UgEL5fdRuD87r1HaCPYi5o a8260dneG3dIMoe03YpuIyNNhJ0+RpLXQJeTL8qxeHovRPA0O/t9ngRB73+AzHvSl9mg 0UDx2XuDqemP4fw06fa0ksCMZR79hvPQRWPMQdsXuWqnkZPgVG2r06nM8iujq//n0qJv pnFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="JT/5wswX"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h130-20020a636c88000000b004301e6b2ec3si2432659pgc.607.2022.09.02.12.01.42; Fri, 02 Sep 2022 12:01:55 -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=@gmail.com header.s=20210112 header.b="JT/5wswX"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbiIBSpw (ORCPT + 99 others); Fri, 2 Sep 2022 14:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbiIBSpu (ORCPT ); Fri, 2 Sep 2022 14:45:50 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 503BE28E2F for ; Fri, 2 Sep 2022 11:45:49 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id j6so2071386qvu.10 for ; Fri, 02 Sep 2022 11:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=l8lXRjJOTwa1pdbI6AHOCcVerD9joOqdaqD9HG8JOnk=; b=JT/5wswXZeLkBTP7NJmehoUSznJrZkjGyuGX1VZeMQR87I5/I/NvC9NhtkHkHevMSL 5paJSt0K5hZEpDRgeCxtFxnTKXpFoCEV5uLmC/RZa8nU/JMLoii/ODoudvh4JSNPln9r flyLLR6wueAYBsGUk77HDDs8p+nAmTgUWFfhoFCyFIqr7XLImMfoEFRtCs1YTxbSlbin TMdomDl3vxaGu21qX/p1bUgflUS3QboZZAC8Zyc6O/qyjTSOXXu1b7Z73pYtVziaRZxz ZZJyGa4LwaeeHT8W4jwcUJgY238hFy1EK660+OjBPTyX+qcLKcGymUVM2WQSDdOVKze8 BBNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=l8lXRjJOTwa1pdbI6AHOCcVerD9joOqdaqD9HG8JOnk=; b=lL/nHFQ8MhINPMnGg7jaVjeo4PZyQq5SVBabJFVc9FXbuZvOaeGPQG70Hesz+SnMy7 ZkxRmZ8PpoQ2g7k6vjLqi9wvWKsc/cnRcjbXja1YnrTqQ/nUos+oTSiXYcw7uk7v5Irl cx0mKyAXw+hS/7WlmuG+MME7syMGkBVIMxKHCIBTFdHPNaBDi5u0XnyaRySu4Kod4TXT H/1LO7x2wsNAkkZHNvYGMwtEcUR5sO3HuQZABrmSEc+Bz7/14mMFoEU0lVEyAtU/W9CJ sQFNhGCImPIOpHn8iY2AVy/M2Tt1iZS1vHAIznCHDwRQGjKYrljihshwAFPniyG6TEnB ZV5Q== X-Gm-Message-State: ACgBeo3XjIQYTu8OVYmbeMMS+Zs0N65zpRrSVQoKDR8+64/zfE6qs06f EoPPlo9V+9KzECiZYsT73Yc= X-Received: by 2002:a05:6214:1a43:b0:49a:f1ea:d8e1 with SMTP id fi3-20020a0562141a4300b0049af1ead8e1mr2795452qvb.103.1662144348356; Fri, 02 Sep 2022 11:45:48 -0700 (PDT) Received: from master-x64.sparksnet ([2601:153:901:9131::10]) by smtp.gmail.com with ESMTPSA id a2-20020a05622a02c200b003447ee0a6bfsm884723qtx.17.2022.09.02.11.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 11:45:47 -0700 (PDT) From: Peter Geis To: Heiko Stuebner , Kishon Vijay Abraham I , Vinod Koul , Samuel Holland , Peter Geis Cc: Markus Reichl , Michael Riesch , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] phy: rockchip-inno-usb2: Return zero after otg sync Date: Fri, 2 Sep 2022 14:45:42 -0400 Message-Id: <20220902184543.1234835-1-pgwipeout@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 The otg sync state patch reuses the ret variable, but fails to set it to zero after use. This leads to a situation when the otg port is in peripheral mode where the otg phy aborts halfway through setup. It also fails to account for a failure to register the extcon notifier. Fix this by using our own variable and skipping otg sync in case of failure. Fixes: 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state") Reported-by: Markus Reichl Reported-by: Michael Riesch Signed-off-by: Peter Geis Tested-by: Michael Riesch Tested-by: Markus Reichl --- Changelog: v4 - fix a checkpatch style error (thanks Vinod) v3 - add missing brackets around new goto v2 - switch to using our own variable - add missing goto to skip sync in case of registration failure --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 0b1e9337ee8e..e6ededc51523 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, struct rockchip_usb2phy_port *rport, struct device_node *child_np) { - int ret; + int ret, id; rport->port_id = USB2PHY_PORT_OTG; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; @@ -1162,13 +1162,15 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, ret = devm_extcon_register_notifier(rphy->dev, rphy->edev, EXTCON_USB_HOST, &rport->event_nb); - if (ret) + if (ret) { dev_err(rphy->dev, "register USB HOST notifier failed\n"); + goto out; + } if (!of_property_read_bool(rphy->dev->of_node, "extcon")) { /* do initial sync of usb state */ - ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id); - extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret); + id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id); + extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id); } } -- 2.25.1