From patchwork Sun Dec 5 21:58:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 12657343 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5692C433EF for ; Sun, 5 Dec 2021 21:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UUg1TcuqXElz7n6dGZZoRyvsdDJP/7RVpZq/LxUnqf8=; b=FAR7y1c41ZKZz4 2wrsz3oceHe0RhfxYPrwyXwgzStPGRn94QbCkjaulgDWNZ1502NdGTXWSMtAdfKpWMf3TkfnH+H9M LeatqdovnVsUuTOziC9/9/cZJU1tail0HV49we8u23S3yNvUCCYsEm5MG+QpU69xnjoC0L8PAw9sG UBOt23iF7slq6AIteQ1/LsHPF8LfQF042hhy+jN9rRidZ5a6RvjaupYo13LdqumVjIqt3ygPVzh2Z E3ozq9410E+c1fPJ89zn8hGGzw2nxu1wdVKNhvkEhEhGUBMBn9WIz+u9KlncaEL+/ERTfQidw/MMO yyWnK3mmjGYiU1rNlRiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtzXD-0021TB-0d; Sun, 05 Dec 2021 21:59:03 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtzXA-0021RQ-0R for linux-amlogic@lists.infradead.org; Sun, 05 Dec 2021 21:59:01 +0000 Received: by mail-ed1-x531.google.com with SMTP id w1so35083469edc.6 for ; Sun, 05 Dec 2021 13:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3AnWy+mVImsPoWfiIuMG6Au3yFCtHwQVYr21g6LIJdc=; b=2vQAzbnneWi/dJ7qVHsqvynEsRlHsmojxV6FboORhzrOWZLH+vfu4GDPLq1cbeBaVN 597eGNxXtDjhk4Go6uu35rJg5WRDQwGQJQbn4h6N2bJ64tjkcpp1e09jsEm0FEyOIyNQ 1xW1Rrehd1HzLpvaOUTd08Xpbvp+GlGjgL8/kjWQerOUPd4HLoTaEdRvLlLXZronEowZ h5qDzo9PttQPpVBsbdby6OTY5KsF4nzqx6DFD0nnkHa1d09Qc/euvYym+lqZ3yfQenhp p3gjQ8BMJztow6DjkQgwaRtyl699HwZt07eOTSecxJkC2OeinP6hiwTEDHnQTVB8LaIa 3izA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3AnWy+mVImsPoWfiIuMG6Au3yFCtHwQVYr21g6LIJdc=; b=HlNLJbGvWMZs/88jlC62LSNauBeIA1Q490W2+E67lnOpZUMvodVX+ohEYN8tJ+jhlf ygEHaWUuOkLaTx9MGEnUmBahpCj09GqPwDi1TPgZwjsYNpbjU9vRxyVdKeGBSJA2srxj BI9WtwLqErARs7ZZ/onfhnmPpZjKKrITsxCnYSFj8e/9m2MZYmGUIUabTRaCZ81vvsod MRYzb3/L2yq1oCeE2mhW1UgjC4jJQFyW3ud4sFxiyYBbK3Had7pzl7PBFSfkTOvun+pQ UbKUGjtSWnXSH7D5XgCHz1O4uOCDWPW1LuTU2shmZxeAqmxJO+FZp93d3MSaU5aIl4DK HuRQ== X-Gm-Message-State: AOAM531pG/XctUBQmW5l1DXCdDEFBBhrWxsK7Qxx+N0YbT/asEXKJRCW 4nBxWCKXpDhvUY6L8ke5ywNnJQ== X-Google-Smtp-Source: ABdhPJyrdhlAej+Y0j7bVwl22/TJv/4bsr28Ql2eGHPiPqD/W7PyF7tQAjNVsjJ+K+DEkbjNOQWvVA== X-Received: by 2002:a17:906:dbef:: with SMTP id yd15mr39336054ejb.354.1638741538543; Sun, 05 Dec 2021 13:58:58 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id nc29sm5724291ejc.3.2021.12.05.13.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 13:58:58 -0800 (PST) From: Amjad Ouled-Ameur To: khilman@baylibre.com Cc: Amjad Ouled-Ameur , p.zabel@pengutronix.de, balbi@kernel.org, jbrunet@baylibre.com, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v4 1/3] phy: amlogic: phy-meson-gxl-usb2: fix shared reset controller use Date: Sun, 5 Dec 2021 22:58:44 +0100 Message-Id: <20211205215846.153703-2-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205215846.153703-1-aouledameur@baylibre.com> References: <20211205215846.153703-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_135900_071265_3A284AE8 X-CRM114-Status: UNSURE ( 8.90 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Use reset_control_rearm() call if an error occurs in case phy_meson_gxl_usb2_init() fails after reset() has been called ; or in case phy_meson_gxl_usb2_exit() is called i.e the resource is no longer used and the reset line may be triggered again by other devices. reset_control_rearm() keeps use of triggered_count sane in the reset framework. Therefore, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm(). Signed-off-by: Amjad Ouled-Ameur Reported-by: Jerome Brunet --- changes since v3: - Remove unnecessary reset_control_rearm() after reset_control_reset() failure. drivers/phy/amlogic/phy-meson-gxl-usb2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/amlogic/phy-meson-gxl-usb2.c b/drivers/phy/amlogic/phy-meson-gxl-usb2.c index 2b3c0d730f20..d2f56075dc57 100644 --- a/drivers/phy/amlogic/phy-meson-gxl-usb2.c +++ b/drivers/phy/amlogic/phy-meson-gxl-usb2.c @@ -125,6 +125,7 @@ static int phy_meson_gxl_usb2_exit(struct phy *phy) struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); clk_disable_unprepare(priv->clk); + reset_control_rearm(priv->reset); return 0; } From patchwork Sun Dec 5 21:58:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 12657345 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 578E8C433F5 for ; Sun, 5 Dec 2021 21:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4SlSET5PedHnpstld6kkJLvU13igXV4pNCjp70QpL3o=; b=W2qrSlA2dvPOfO RxjcM3mlE4gzb7N8DZ+zAqP2nGlH/bnPqYGYxgvIsPx5Ro0ozWQUtSMcik8qfId6xpx1oI90LC0Zv rc7TK4ogtH+4NeUhb2gBzRS7s9D4v5xnvD47ySMfMmWpDgCX/NYOp+a9Q6otGeoSn1giUnXn2n8qw OpAxZOByKcMkM4yTBKHhijBpQjeS/AChRkmofycDDDA5YDYmSWoBM3y1YS/mG1ygNTizWqusCPi8a MKVquuAhy4aSwWl9foqHoZnrA7UygfoU6r0ylf3YAH95pua8OAHZn0sUl5OKr8bGHVuklueopiYkf mfTmf5rRv6+eKchtm89A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtzXD-0021TS-My; Sun, 05 Dec 2021 21:59:03 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtzXA-0021Rh-TZ for linux-amlogic@lists.infradead.org; Sun, 05 Dec 2021 21:59:02 +0000 Received: by mail-ed1-x533.google.com with SMTP id t5so35115083edd.0 for ; Sun, 05 Dec 2021 13:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lo3UsCaMaL5NAfBrYJDUAK0+9C+4ooYh+4fLJsKdab0=; b=ASw01r3PIJQON4NAGFYQKnXd2+BbWbCIcdAkLRviUUlHdvDyyOB4WiDEkudhci7DYF cfV32SihvIVCO6CuNoIquwRh3jlN5IIRJqpW2n6cQmEsuO/9a2WSGilXYJwxKJUyhXrr zSTl5Ok59h5DJIWpZnupzFisj1HXYXEdRdfg63cgswcdH1QbwneMOc9wbBcdGKDi1jH6 vZh3u/9HEEBjvEk5KodBy0S/JjnWbXeKtHHXXLyeSlDCkPGNeHjrPSl4ixLBdgDIPRJT U/Tdpn58UaOwnTvfg5Y9kp+O6xashRxBjnMl/kfel2W+egtVFz4h30jQpE7q0bvvQI2Q KIdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lo3UsCaMaL5NAfBrYJDUAK0+9C+4ooYh+4fLJsKdab0=; b=x+T+6RfCvnTeIa5SALM0KfmfS+D7+D57Tg9Dq6I9rviYaHHAxmCZh3LVbi+IYDeQxu k7xl67BDzL5EZWysDGdFTU5wtiTOb5qgXyLjJY907xJZyjxrp9wM2cFu1fd1nSO5im+Z qSgxBk1lPJjXF/A9SbmnJLyuMcRhTnCBTLzgcyEnBM1bl+jirArpXhnYzkyLq5iC78l9 UWPJfeEWGCeNTx5Uoef6s6gXPFwRTiqyL1VNBtMyxVEN6yjF85jH+bNVSu2hpsVsCpLx +vmrZsc49fvgUFaV5ASGgCuh+LeJ9RpmiJEWeaKHXFZ35p7ER4iafieLvgfUpjcM/GSv +Ivg== X-Gm-Message-State: AOAM531FMCErcCBAEQY5XmsvVh76asYiCsYipnC6V5kkKuHPe3hL0n6R vZfwJb6a7vkpEAijq+Twst81uA== X-Google-Smtp-Source: ABdhPJxDW08rqxgjmev9uudRq1hMRU3rZw9W5A9cElENKHZZWg2qg6bvfqw0CJ9j156uWmJpH8XTjg== X-Received: by 2002:a50:d68e:: with SMTP id r14mr48757026edi.5.1638741539361; Sun, 05 Dec 2021 13:58:59 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id nc29sm5724291ejc.3.2021.12.05.13.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 13:58:59 -0800 (PST) From: Amjad Ouled-Ameur To: khilman@baylibre.com Cc: Amjad Ouled-Ameur , p.zabel@pengutronix.de, balbi@kernel.org, jbrunet@baylibre.com, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, martin.blumenstingl@googlemail.com Subject: [PATCH v4 2/3] phy: amlogic: meson8b-usb2: Use dev_err_probe() Date: Sun, 5 Dec 2021 22:58:45 +0100 Message-Id: <20211205215846.153703-3-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205215846.153703-1-aouledameur@baylibre.com> References: <20211205215846.153703-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_135900_976097_16AFF80D X-CRM114-Status: GOOD ( 10.64 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Use the existing dev_err_probe() helper instead of open-coding the same operation. Signed-off-by: Amjad Ouled-Ameur Reported-by: Martin Blumenstingl Reviewed-by: Martin Blumenstingl --- drivers/phy/amlogic/phy-meson8b-usb2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c index cf10bed40528..77e7e9b1428c 100644 --- a/drivers/phy/amlogic/phy-meson8b-usb2.c +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c @@ -265,8 +265,9 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev) return PTR_ERR(priv->clk_usb); priv->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL); - if (PTR_ERR(priv->reset) == -EPROBE_DEFER) - return PTR_ERR(priv->reset); + if (IS_ERR(priv->reset)) + return dev_err_probe(&pdev->dev, PTR_ERR(priv->reset), + "Failed to get the reset line"); priv->dr_mode = of_usb_get_dr_mode_by_phy(pdev->dev.of_node, -1); if (priv->dr_mode == USB_DR_MODE_UNKNOWN) { From patchwork Sun Dec 5 21:58:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 12657349 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82B4FC4167D for ; Sun, 5 Dec 2021 21:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vqNK3/JKdmBbvAlz2+gefCckZyigp1/fsgvzGH36Mzs=; b=gRmgSm5Nylyuci PznuapGBjMB042OUrnRi8Oln3WfqtjerZ7BxgY9ZIEH7BVZgnmVzNHBfr0yXgoaU7RIRxNrgtOEyO VoUkvFrNkYylhad4yXmDegCEJViESG7lx0uJxs5IbHJdcSJRfxLROkM45YkXDuzSxMJdf+TUewOz0 0Cfsn4vNDh+i0WINivm/nhb4DkcP/Yk/qXLhS1UYnkv1egBgQbGPYfctD1gBAchkMb7/ZFTwRLLQX 07gZZJ0D/ZpvSiT3es+kX1tUPisuZfeedxlKDg2dO2zH1sKJOrSTZxHyMLhsxFY0DSXlFHLvUZAAH /fvwHgh5yGxjEmYSje1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtzXE-0021Tq-L5; Sun, 05 Dec 2021 21:59:04 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtzXB-0021Rx-KD for linux-amlogic@lists.infradead.org; Sun, 05 Dec 2021 21:59:02 +0000 Received: by mail-ed1-x534.google.com with SMTP id o20so35093467eds.10 for ; Sun, 05 Dec 2021 13:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kg/EoUTvtJCV0eIOzDDw+a6fO7fnDbKWvif2j9QvU1k=; b=0jJjPzSB7Fr9IOmpAWko2usGi6G/gq1tsZf77t3EBt/V8TebTy+bB3tuuQ67tI9A8J W2JmJ5Q+UGzJkQggad7OqTJyJlgGYKegNGa74yG++PRfpu/NbxsjoVCB82YNi6EY9TbI E86uK3wKF4jnatmn7I+qmIXvxkWOJQtWco/OAXUQ1m3HynXc8A1g3s4YUgexmdjy+2Kh G3KNUNGkwm59fvzUsnBSeWaH//I1RwkSSPWI7lS/RuC1Z6HsCYia2tfAj0px6VGxhouM 0CVi/KJf2cYmon2jgQ6SahAQrjXsDef7xzqTJzh1wYhiC7h2jxB+hd0kjNx4h12bnPBk vFHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kg/EoUTvtJCV0eIOzDDw+a6fO7fnDbKWvif2j9QvU1k=; b=Hku1EvGAKdCOS+zJQBvKT2+eHBWA6eEF1vYXWy3gty5Gt2/2JZgU60DLzURGTwnQ12 XmsX3qjHm/wDF6nPWdC13u+F2LYxNk4SMg5IZ3MjgjLbhRRWs7gZIU9k+xLrt6PLifIL CP2bcx+3taHn/DENURm2vlQPWknnlfV8+cYdeFiETlyK9gp6x+u6XyqYcFhZYNxbCnj0 WEhsCWHMYiHB65McVd4kTnbtA5bv6qbV5lmP8PB1jAdI7zwOH0DgaotkXfYfK0rMdGUz E3rxjA3axsrx5aKJvg6RL+Ce/w7q1U2jjVGrbcRSKvCFUgLJ3qSyVE5fszG7QjvSjg3p fuAQ== X-Gm-Message-State: AOAM533U4oHYzmPbwZm78L5x9i7pb94nVvdhMrDAuvB3uM3x3wE/TDVM 1Vz+J+Ir4Rm4nfpgCnms79h2sQ== X-Google-Smtp-Source: ABdhPJwMycCNqTJai4Fogj0S3vU9tnOWsCUMPXRynIPwKaqrJ8Vk7a5yVoJu72xQZYkFI2xyE7u5aQ== X-Received: by 2002:a17:907:a0d4:: with SMTP id hw20mr41300607ejc.16.1638741540143; Sun, 05 Dec 2021 13:59:00 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id nc29sm5724291ejc.3.2021.12.05.13.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 13:58:59 -0800 (PST) From: Amjad Ouled-Ameur To: khilman@baylibre.com Cc: Amjad Ouled-Ameur , p.zabel@pengutronix.de, balbi@kernel.org, jbrunet@baylibre.com, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v4 3/3] phy: amlogic: meson8b-usb2: fix shared reset control use Date: Sun, 5 Dec 2021 22:58:46 +0100 Message-Id: <20211205215846.153703-4-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205215846.153703-1-aouledameur@baylibre.com> References: <20211205215846.153703-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_135901_686096_EF50ABEA X-CRM114-Status: UNSURE ( 9.26 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Use reset_control_rearm() call if an error occurs in case phy_meson8b_usb2_power_on() fails after reset() has been called, or in case phy_meson8b_usb2_power_off() is called i.e the resource is no longer used and the reset line may be triggered again by other devices. reset_control_rearm() keeps use of triggered_count sane in the reset framework, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm(). Signed-off-by: Amjad Ouled-Ameur Reported-by: Jerome Brunet Reviewed-by: Martin Blumenstingl --- drivers/phy/amlogic/phy-meson8b-usb2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c index 77e7e9b1428c..dd96763911b8 100644 --- a/drivers/phy/amlogic/phy-meson8b-usb2.c +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c @@ -154,6 +154,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) ret = clk_prepare_enable(priv->clk_usb_general); if (ret) { dev_err(&phy->dev, "Failed to enable USB general clock\n"); + reset_control_rearm(priv->reset); return ret; } @@ -161,6 +162,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) if (ret) { dev_err(&phy->dev, "Failed to enable USB DDR clock\n"); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return ret; } @@ -199,6 +201,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) dev_warn(&phy->dev, "USB ID detect failed!\n"); clk_disable_unprepare(priv->clk_usb); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return -EINVAL; } } @@ -218,6 +221,7 @@ static int phy_meson8b_usb2_power_off(struct phy *phy) clk_disable_unprepare(priv->clk_usb); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); /* power off the PHY by putting it into reset mode */ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,