From patchwork Tue Jan 11 09:52:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 12709660 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 0AC9EC433EF for ; Tue, 11 Jan 2022 09:53:30 +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=Xm5afr1Bw8FgrrGrMnTou5iWjHOn1MbZ31yIdzWCYbM=; b=uvVE7IrOeGIxV6 SoKAjD8cVnfpc4GB8wp9x9UrXhMLxWF5h6/xVP+A2BOU2ckxnIw2juH2I8KEvbbMOoU/s7ZfmZ7/M UbizAt++CtbFp4bzRLw5JREV0woPDyiqQYjyGhW4qZVY89c4emiFe7Zz/IybEdN4ECaTxWAxSskyz glyWc1+X/ao+PytL91l59W0nNUP9kTaa+d/uZ1+01mxqhrxk/kWWvewPweZfsXRbQiZB7LdlMYtFD zpJ5AOAfX+aioWwtHXhOuE5UKrG8xfENk9VdpKjxSjncAas4Y4dXRP50VOrKXC13/4XFoRo5h5fbQ TNN/n9UOglG2y+IRW3rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7DqI-00FfZT-Ru; Tue, 11 Jan 2022 09:53:26 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7DqF-00FfW2-Bc for linux-amlogic@lists.infradead.org; Tue, 11 Jan 2022 09:53:24 +0000 Received: by mail-wr1-x429.google.com with SMTP id t28so25099978wrb.4 for ; Tue, 11 Jan 2022 01:53:22 -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=Z6Yer5+RWHiyObPhotCHoiFwGst2nUMplE/Hr1jBYzE=; b=MtHy2/o5zHgO8+sJV/wnvVbtlrq1TJ91C7S2Svaj8kMIvVs/fN8SgftynhA8fdVzLM GuscKOjixI81rAfR4+bdBfTJVpp8eccZWs7tsA9l7NUUQDWrbY0WbRlYg/lOeeVet4oR QfAywxQOQ7Xzo6FVTOrZS0vguVruguSqgJI7mzxloZt6qozPyPJ+4q5LZlP4FZTvwpL8 aqzPDd97RJPgMG3lGiOYYe5wm1YwumO7NSXgW7q3oXdvPJTCRu4OY48k1jQgyD5fePnD lDhFEHApicdmD8oN3Yb+nDk2xxWK4WMFMbzuMDyqXz5lSLSYxCfEfo597HgtFYFVBv/i v/0w== 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=Z6Yer5+RWHiyObPhotCHoiFwGst2nUMplE/Hr1jBYzE=; b=m0WzjTFbAqam808Am1hkR+3E/lozJP0t6fi8ekThbsqtDwrDbDEKetjH47H2q9op5o BzzXyXgaHQp/jAFEEvaO6DkT69/yzWSSM+IuXEoJOv1vloZhKReN/2OKHApfDpReBc2O Yrf//2WW41/O+REZfA2RP35MEDs7avaqEO7tm4NTK7sGKZl/SFTAXwXBvRndmBJUEDeM TfHLIps5C1G5d6V/1FD263WL6d04aGGKpZZQ8j9240RCErS7D+HxsCH0Aq/qLWCjwkk+ IaM+bO4TatcuP0Jb+XLnWpHkNFj5lW4sSEFuETkzemXh6XOTc+ttRsKuRR7k1s3GJeJW Gr6g== X-Gm-Message-State: AOAM53088BsaGrWhHKNawhsmXkKM1tPdimQh07WvomTpYZ6CdL9+tB4G 6EVN8l56EaEQkksLUpApyTFVvA== X-Google-Smtp-Source: ABdhPJxc5sOJVxSZJOZnTg+H3RQ07fBd5zkYR0tA00iUMUXkJkJDgdj9028tmtOW7O5yrH5JXHg8RQ== X-Received: by 2002:a5d:6b8e:: with SMTP id n14mr3122306wrx.537.1641894801554; Tue, 11 Jan 2022 01:53:21 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id l18sm1248916wms.24.2022.01.11.01.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 01:53:21 -0800 (PST) From: Amjad Ouled-Ameur To: kishon@ti.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, khilman@baylibre.com, vkoul@kernel.org, linux-phy@lists.infradead.org, Martin Blumenstingl , Neil Armstrong Subject: [PATCH v6 1/3] phy: amlogic: phy-meson-gxl-usb2: fix shared reset controller use Date: Tue, 11 Jan 2022 10:52:53 +0100 Message-Id: <20220111095255.176141-2-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220111095255.176141-1-aouledameur@baylibre.com> References: <20220111095255.176141-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220111_015323_422297_0BCD9E3A X-CRM114-Status: GOOD ( 12.21 ) 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 Reviewed-by: Martin Blumenstingl Reviewed-by: Philipp Zabel Acked-by: Neil Armstrong --- drivers/phy/amlogic/phy-meson-gxl-usb2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/phy/amlogic/phy-meson-gxl-usb2.c b/drivers/phy/amlogic/phy-meson-gxl-usb2.c index 2b3c0d730f20..db17c3448bfe 100644 --- a/drivers/phy/amlogic/phy-meson-gxl-usb2.c +++ b/drivers/phy/amlogic/phy-meson-gxl-usb2.c @@ -114,8 +114,10 @@ static int phy_meson_gxl_usb2_init(struct phy *phy) return ret; ret = clk_prepare_enable(priv->clk); - if (ret) + if (ret) { + reset_control_rearm(priv->reset); return ret; + } return 0; } @@ -125,6 +127,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 Tue Jan 11 09:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 12709661 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 D8D7DC433F5 for ; Tue, 11 Jan 2022 09:53:35 +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=UjpFQZajigqLGll/10A7ZjCoZ6IwBDrAdvPT6AEAzoo=; b=vMIhxzZDEDoCjl rI1tW4pZeCNZzJ24zWtQ1XE94us33NSgK/5LOoeklDEmDIpuVP6yK5hH4EZ+fvY26qMKbT63+viQa iB0GlWim8EkR3Lzwic46OrTXkxgM/c2CzZ3Xlcg70eTSK+yxGr48/0iSbNSqwVNGqi8Ot0Mqk0HFQ qvAQ6oUNmozt13U2j3Jc9rjjMX3SMW7hcuLs9ByQxcARstgQzfKlNroAuyXomsh5HbhUxXAv5/keJ PigGAgFk2/7DM9BoLLlAW/+AfiEdtQZ9um78dInaepTDJn8Ri7dhXNQEV72Op9kxaNvlHifAGgI3x paC4/8ELm8gjxLtxzaPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7DqO-00FfdH-0i; Tue, 11 Jan 2022 09:53:32 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7DqK-00FfZn-Nl for linux-amlogic@lists.infradead.org; Tue, 11 Jan 2022 09:53:30 +0000 Received: by mail-wr1-x436.google.com with SMTP id o3so31828376wrh.10 for ; Tue, 11 Jan 2022 01:53:28 -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=A+i9WMf7INTV7WCiMlaX+eZZQolId/EOXyuyr4T+wZU=; b=X/P92XWcAUFvR3YEqhxSTn9r+eVg0V0NdBO5apYmzV/a7t25cEbaojIT38kHdrpG5O ZvKQCC+gg0RrRpkxbOTwei1qDh3oDHZ9wh9CzqQBvngfvUKTmt+dNSVL1oHFZRhlgI1I T4nVsQ8iPQJSsW1UY4HR6I4e7wQIAGMRRJ9YT2c779CbPuwsz/hc+2vtnKTtbRCO5DQt 2igqhJqekzn1rAwGdqWMW26X6EdJx2BGy9EkTbhax9IzB2MIa1ceUpkWRBBx3OzpZuU8 bT05pVhBMmE7RqUK3B+VsexoV8eBa+ENdsknN555IDZY0qcseTdv+Ulx0AmEbkQqRAsv ClGw== 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=A+i9WMf7INTV7WCiMlaX+eZZQolId/EOXyuyr4T+wZU=; b=SSWF5Q1W9zuwomvqM0iZzdGpck/UeDcEPnip4L68GFSd3Caqhx+36rxzIDby+OU0rh vzAO8P6C+AtlUpN7ZV633IEyno0Myj+LwrOw7HfrBhmmOD+IRB3XFVzmNk8lyi1MQ1mN DbQutb/1wtsHihGtc6L05sABtWpjzFSe1Zfdh2swIKEIk8JIk7IuONWzCAQeI+MC8PT+ tXT97EwPEPw7duJCIDYVpGbYFM1P3adGmndZx+ANIP3iXMtTVhPZRuU5k2Pf7wMrCBso Q9cMUV4coCYwk6vijWiphi7Q4k3vRsUrnT51zOsNeLcLiz5qkjyCUY00uACvhbtFMtzF SQDA== X-Gm-Message-State: AOAM5316H5lZ6KLJWCbc/ZdQx5NX4n+wFd/j38BIcapP5gWpZFNCeO4d xaEahCO9bCPsWx+A9GtYXylNvw== X-Google-Smtp-Source: ABdhPJwh7rSklXagPFgtG7DKSa9/4llHAcDXK4XwiB5AjfRTsyZsnMgjJY7WB4LdEMyqAuoUtnxN3Q== X-Received: by 2002:adf:e3c9:: with SMTP id k9mr3064155wrm.193.1641894806884; Tue, 11 Jan 2022 01:53:26 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id l18sm1248916wms.24.2022.01.11.01.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 01:53:26 -0800 (PST) From: Amjad Ouled-Ameur To: kishon@ti.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, khilman@baylibre.com, linux-phy@lists.infradead.org, vkoul@kernel.org, martin.blumenstingl@googlemail.com, Neil Armstrong Subject: [PATCH v6 2/3] phy: amlogic: meson8b-usb2: Use dev_err_probe() Date: Tue, 11 Jan 2022 10:52:54 +0100 Message-Id: <20220111095255.176141-3-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220111095255.176141-1-aouledameur@baylibre.com> References: <20220111095255.176141-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220111_015328_831698_FD97AD5E X-CRM114-Status: GOOD ( 11.60 ) 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 Acked-by: Neil Armstrong --- 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 Tue Jan 11 09:52:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 12709662 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 1ECD1C433EF for ; Tue, 11 Jan 2022 09:53:38 +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=ZXKwyz8JNSAatph7MLfeiydCcpDI3EEKPznxROdcymw=; b=EAHwPFQournN7X ds0NMqAacarqGhcUDfsF1r6Y1VNkQdrWO9XHGtW5GKK8eFOZECi+3CoQBnyKeVQCj9fnNMATWoNDJ PeX3NVrvLBjL+X9ZkzXewtIHgla6M9ZCB4txiN/KbwKQFUNkffKC1qtiAbPrdYETGrWiyotC61uA8 DH1SoudOiz1jaUVmMf+L02xVpufoOhnQQIO41SWQVHOYJbDATQoI3T/DY3LWh7TV0MX65egC1Kw3/ gLIqNf+skbAnc7ffhEhhyQVqknpTH2HQn7fSgFwgkSj/XQofUUo4ZrIkwwKAXPHiZ+LzPRYMN1kw/ HyKUm2DxInrF6eSTEK0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7DqQ-00FfhK-7q; Tue, 11 Jan 2022 09:53:34 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7DqO-00Ffd4-FY for linux-amlogic@lists.infradead.org; Tue, 11 Jan 2022 09:53:33 +0000 Received: by mail-wm1-x32b.google.com with SMTP id d187-20020a1c1dc4000000b003474b4b7ebcso1448428wmd.5 for ; Tue, 11 Jan 2022 01:53:32 -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=bVh5nRmY/laQhXrJmZ8gLshP64K+NMdNAMHCgvzKe+U=; b=6sSuM/3s50L4vZ3q/tD7Z88/0gOxnko+TEETOKMcYK0cz7E3XMCiSyZcHcbtxNmSIg YW7hmCNasCfQs6VaJ5DK59epYQ1PdwwPQ+zIvAJFU6OvzhavqpLWmWE8bCa79TkTQgNV /CoQ8R5cgwTaVWgusSQBbGXmT5kjNqcHhpFPu68Tf1jeHbkREoDg75Kmj0GeF8ZdqrG8 jqOxrtolkcjfBhN3+UFYs3IYXs95/d4epNrgZpmPVayBHXPWJPqTWeBlz8yk5cnGTLSL z7YL3dQNbIYM0AV8RTmPRPUlz6a/Kdjk6tQMuEeittcRceBEkVYLcvRZPzLI8302rbke o37Q== 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=bVh5nRmY/laQhXrJmZ8gLshP64K+NMdNAMHCgvzKe+U=; b=MPybDsiB8AzerdOg/Lw79yDRGS1hDFI1Kpug+9psFZvl2MGoXsJK1uSiRctmvmH7yA C7jXYswXJK2IRZdUtGExpBkpgXpCB6qopyCM67W62mPTz6WdRtXmKDOmgvy3/fCZhDQ9 o1vMoqjBCnm9gALoej30pi1OvWQyNniaO1OrTqxP+T4GAztPTSFk8CsvI9mGl111MqSD FIU3dyTyMfnpvHHkYwtV1xn3Jkdof9clv3sVWm/MOShTP/3wRQsUJPVxa765RdmhwN2E rOmaMmzYai0PtJiMpLtiRRT0xr1VFiITZzR71MShBpVCc2Jzvhn1MyzM4e2msW0kOMdl ZleQ== X-Gm-Message-State: AOAM531IR/sY9rDyJBwif7wvKdK78Jh+IhThgMuBSITdtL02EBl8m1E8 z7KjfEvlK1TnBmGjDoqPwGAu7w== X-Google-Smtp-Source: ABdhPJwc1I2GFw4Edw3Pe2DmYcavGYaYA9rtbMrUDdxBE5NcWt8EiDMa+1O+zf3FSo416HYOiZvXFA== X-Received: by 2002:a05:600c:1c22:: with SMTP id j34mr1757958wms.1.1641894811138; Tue, 11 Jan 2022 01:53:31 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id l18sm1248916wms.24.2022.01.11.01.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 01:53:30 -0800 (PST) From: Amjad Ouled-Ameur To: kishon@ti.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, khilman@baylibre.com, linux-phy@lists.infradead.org, vkoul@kernel.org, linux-usb@vger.kernel.org, Martin Blumenstingl , Neil Armstrong Subject: [PATCH v6 3/3] phy: amlogic: meson8b-usb2: fix shared reset control use Date: Tue, 11 Jan 2022 10:52:55 +0100 Message-Id: <20220111095255.176141-4-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220111095255.176141-1-aouledameur@baylibre.com> References: <20220111095255.176141-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220111_015332_563699_456851D5 X-CRM114-Status: GOOD ( 10.09 ) 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 Acked-by: Neil Armstrong --- 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,