Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3760749rwa; Tue, 23 Aug 2022 09:39:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7SL6YqTgjikTWm1sQiPIQuhWUvfnf5x++pImWKQQFkpBmCc0pzQ6styy02RIiv6FRYE1le X-Received: by 2002:a05:6402:447:b0:440:d482:495f with SMTP id p7-20020a056402044700b00440d482495fmr4551113edw.264.1661272751808; Tue, 23 Aug 2022 09:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661272751; cv=none; d=google.com; s=arc-20160816; b=mJYAhe/13nscxgqkMV2Z086dykDCAzdxzpRNB+QJuH9eUqJDZrtAip3aGvyQVbpuj3 QFjqnskrV8tv0PVA1D4hljislwrOAF6qSbQ5aDdq926lNwBSL6SR9QSFMW1XdltldPk9 2zdcCi0pxup0o0phgdKr5e8kLJedPeNjNsqJKeG5E1gjncus9HJOpiNwhjDe5OYFbIg1 RokHsi63gatsUKFJ7TKn7X8iUARXwBMkm6MJEZTMZ7udrPwIpyR0vjVDvzi6hdlzO7Qk f8q+3iWBEC4HJ/TxJ5MY/OuWZrLqjdkoVXyi+ihmNviPqRSSsS4LsVy+LYZZdXo/zJoX fOAg== 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=b8EYUe3JugOX0krlcI4SIAy+UPYGVeLR4PxCSdVOZKA=; b=h3iAV7GGpdhIskVgSwCnuyx1NN6xYc6s+bub0DE/0VN9FnFxAQtqPxKmkgAPiONd8v xuJ1cGNTFD9rogajVIiY8qyN2+xUJjEccfLrP6WXbqREx5V5v3Rty+GdfWqDDblxZZAt 4URooXauCtjiCXVBIRCywwoO8u2a7fDpU3jd9x1FilmB80w255Wt74NAVuXEFqZmH/q2 cddij6RF3DOs27yxyWdgux4Zg7epZ4DCJh29DkAOpq+kritFJaHlJLhoAaBWmTwJALst /0zphdpO8pEZ5w54oQJ91p52s2YXXTnirOoDZ+YcyPJJEjza1nZWovdZeQbzYFcgmK+u r2DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="kds/eg8K"; 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 m13-20020a056402510d00b0044347b22b2bsi2765528edd.354.2022.08.23.09.38.45; Tue, 23 Aug 2022 09:39:11 -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="kds/eg8K"; 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 S244948AbiHWQgv (ORCPT + 99 others); Tue, 23 Aug 2022 12:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244939AbiHWQgb (ORCPT ); Tue, 23 Aug 2022 12:36:31 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE01DF4D6 for ; Tue, 23 Aug 2022 07:47:33 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id h22so10522447qtu.2 for ; Tue, 23 Aug 2022 07:47:33 -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; bh=b8EYUe3JugOX0krlcI4SIAy+UPYGVeLR4PxCSdVOZKA=; b=kds/eg8K8iDSgVtBJnyCXPYIJMTjIe4TyWFlnVvOJk99djqYpAvmv2YGgDbvzOJPeA cE2QB/DTRvulIqdttMXeB9CLHfx2bIc2bsNRauw5PA0xGRIeStBVoAoHKLlT6RPuGZuV qFHH/TY6hqKpwWuWFIjJ5jikWkkWE4fBYdn+eyxk5YbSy7FNs9SK0jNuni93x7hSD0vs kQIqtSBLS3ML00Sq65XA8Ax7JZBDQriWvnPMN0ME5oOoRi/EZWOhMBsxT4kCByC5E9Qt PNM2JAFW7DafoTylAIZxeFPmkjhy3JFfkDuIgwzcQPEch9CAFRi7E4qa/uqBiOaS3J3v PYBA== 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; bh=b8EYUe3JugOX0krlcI4SIAy+UPYGVeLR4PxCSdVOZKA=; b=mS07gWvCF9xqR1lAPQNfvDRfl1qSguFXl2im/f0tPILcoh4TdPgMh0ZIkLs3gC+vj/ hc59S4n0P+Wwjq6gPwtVtUknsQtkf+XMliflfRJsS4aKjX4ymZbipMQ7XUhaZp52ymra 9Nt2/leFvbr+HuHPGfssN7hcYQGmwClIC5j1Z6KYSKZKdghdGz0AfOvqbP7QTtvcYBeO dkXcYWiuNbzRe1o9HdaYUIOe5s+9zEzS9PcfFYfeWmBvyav7fIkIl/SKgPPxbEjGWI40 3/wPbjtdQ9Yxz2rKTiSaSj7BBdTTjyNMrhkvZStSZd9eZOVJ0tjsh5TEbgQGSMqBkBA7 gk6g== X-Gm-Message-State: ACgBeo3k7Ot8PIpEaSXSIU3P5Qu0ZRFqBVP2yfT/hFNx9jLZa/yXeomT cfiIXQj9eOBZbI0J5bSLdMw= X-Received: by 2002:ac8:7f83:0:b0:343:869a:7db9 with SMTP id z3-20020ac87f83000000b00343869a7db9mr19705477qtj.46.1661266052867; Tue, 23 Aug 2022 07:47:32 -0700 (PDT) Received: from master-x64.sparksnet ([2601:153:901:9131::10]) by smtp.gmail.com with ESMTPSA id y9-20020a05620a25c900b006bb83c2be40sm13304284qko.59.2022.08.23.07.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 07:47:32 -0700 (PDT) From: Peter Geis To: Heiko Stuebner , Kishon Vijay Abraham I , Vinod Koul , Peter Geis , Samuel Holland 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 v2] phy: rockchip-inno-usb2: Return zero after otg sync Date: Tue, 23 Aug 2022 10:47:28 -0400 Message-Id: <20220823144728.47068-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 --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 0b1e9337ee8e..d579a22c61df 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]; @@ -1164,11 +1164,12 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, EXTCON_USB_HOST, &rport->event_nb); 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