From patchwork Sun Dec 12 20:18:42 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: 12672635 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 D6013C433F5 for ; Sun, 12 Dec 2021 20:19:18 +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=MdBgm7beWtmqVqxWWo865T0Q0lVZmsOylyLmy1NUW44=; b=MjbTgUoyI5/CAE C+6fgTY/pLmzYHUEeex4zZdNl8HaATE0TElnZ0NDoKQ/71cklS0gh0+fGz9fDzd8hlC3Gqkvy0nrU Id7dgqa24Amj+hXcqW4lgSc+FWfN1nA8j67DhWQrhDZ6EtkSJ39mUVzkzxlQctBaoFf5Msnm+YqLn ujBMAyUcAGVuD+upU/knMdhkgubHHNS3QnyZR+wQ/jObP28BG9rKZ+v1VgG6ESGjmORME1IPrJ0x0 XKsEKjJ8W8/J6NGLBQl84VYbFI44b5tskLaJyPIK3guzSORyBMW7IydsGHS9ZJbjIBuFn7GBHTgCz 5FsZ0iVLaYTbiOclO/OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwVJR-007BcC-NN; Sun, 12 Dec 2021 20:19:13 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwVJ9-007BVa-QW for linux-amlogic@lists.infradead.org; Sun, 12 Dec 2021 20:18:58 +0000 Received: by mail-wr1-x42a.google.com with SMTP id c4so23836608wrd.9 for ; Sun, 12 Dec 2021 12:18:53 -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=DEqcYQHdC1ee15LjGbKeJnBTc82RghuCYEwGrhqwf58=; b=6QCZInTlhtGHs38K6PWllebPY8PZ+XsQY7+py5EcxK/xQEWqo2ZYxwOMD1TGr7kglD Wt/Ncm7hC9ZiYci4RWw/ubJhzWkzrFZd3HEwq7xF0LOLLJ2CXHmB1xmTVYN4cdEMfdBi lo6KEWy8FCtr3vgpXkTF3zx4hgEBZpnQny//4xw/HEf5C6k653SPMPPqjRSJby0LwOZ7 oCyJxOaCy9IiFeKR68HBGnf7vx+ViNCe0U7TD/LpXfRNx02cfKrN8/0T/Z42mWX/q9G9 TLa8lon0OVJUJnuaKqVr+deYpHj35k8GdoafyjFs/Exf2notApgT2P0/MEPy0+amvdUc aLFw== 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=DEqcYQHdC1ee15LjGbKeJnBTc82RghuCYEwGrhqwf58=; b=oTP0dWlh68eH7YdTX2AoKu7FQ9HC0svtZDVw3iCnIMVFQ31yNrbuR2qP2Vznbv8hgS HUNLoDNV4y46IhjPNlbG4C1k63NgTmBHvrnz8w3iJjm1hgWVQDQU83k0l9Rtcx6EVOa1 4/Fs/Z3pvIQvzZDKvGU+cpBx7SiI5ZKyoubkt02FqtJCYjVxfNJucZdXeOd5o4kupiyM RzQEXwCU9xPlZq3Uwm3H7X9zWwv1/C0caWzxFbe/KvnyglYu2KBXUw/7f45nmc0RxtMg 8qjqRfCoQRNKrbhB14UbnWkjZ4v1fWYM5ymlKob2AerxKtbK5mksgyO2QthmUVb7Q6wX qs8w== X-Gm-Message-State: AOAM5304UA72FJIqxf6SGWd6osf349zmfm6TxfpnkSRGioKd5TQMBD0u wDh6SAb1zkJ6b2JsZqr60j3fPg== X-Google-Smtp-Source: ABdhPJzStHaYQvzjekJD0BKEjsvQ9ILU/QVO4EtStIMs6xGVZ5obEqnflRGFG/O+HRqSNlE3tT/vzw== X-Received: by 2002:adf:a389:: with SMTP id l9mr27656312wrb.121.1639340332397; Sun, 12 Dec 2021 12:18:52 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id p5sm9092710wrd.13.2021.12.12.12.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 12:18:52 -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 v5 1/3] phy: amlogic: phy-meson-gxl-usb2: fix shared reset controller use Date: Sun, 12 Dec 2021 21:18:42 +0100 Message-Id: <20211212201844.114949-2-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211212201844.114949-1-aouledameur@baylibre.com> References: <20211212201844.114949-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211212_121855_938437_78B010C6 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 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 --- changes since v4: - Call reset_control_rearm() after clk_prepare_enable() fails 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 Sun Dec 12 20:18:43 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: 12672631 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 29B24C433EF for ; Sun, 12 Dec 2021 20:19: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=4SlSET5PedHnpstld6kkJLvU13igXV4pNCjp70QpL3o=; b=Ig9WPk+TjpLq0O 9++bpMfksUIQesNa60xxUrxmXxMi6oCdW5ERwx8UmSToDd23y2L5bfyz9Z2IRMZFMP4ANegz8yruN dLvvsN/dSi1L56BzaH8ivYZloJjFk904q/x4LOMlpxG0RZ3OqhmxeWmFIR0P/9io3rP87Nn21d+8I lqJe9v8SXWogak0LIoRxwOvjGfJ291Eg9if4qAU+zJdsHT2nKhsXK5dxV8Q1iklFImzc3eaZxEzBL xSlK0cRzss+nRGRiZlz3zMRC6ZACGjaqjbXQF4Xbjcpfjp6GZTeKc+ePc2kxYzAsNasI8nxSrfgIU EOxn4qWeCfdNJh7+SSEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwVJF-007BY4-6P; Sun, 12 Dec 2021 20:19:01 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwVJ9-007BVp-Ql for linux-amlogic@lists.infradead.org; Sun, 12 Dec 2021 20:18:57 +0000 Received: by mail-wr1-x42a.google.com with SMTP id o13so23802150wrs.12 for ; Sun, 12 Dec 2021 12:18:54 -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=KOjWC5DgtgOF3XopqQeDoC4MVI2YzCCJsJn8/SGztamIk/lV+JZzFLMjwvUek/C2ZM ndDa0DMlr49uRS9eqfUBYj92kbhkfjFObEG+DRifDkxdoBYEB7gRSZckSVQAGGFcawno RE8Bj4wJ63PdPyxMLUnd/xr0tiIADoDIRmI74SBLwB6JpcY+HM3hqnWw1yWG9+JaZsuc GYwJrxl1P8rOrMdxdpEL9pHK78VsdvHIneYLUsNdWmsIHSoRl63RP/4Nduknj9YE41Oj oLgEQCXOPnnBmlIeR+17DENRftJWrm5+h1WQ1IA3G8ePsuJi9eIh6KF9iSoXeRZMmBke q7XQ== 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=bg32pxY6PFtzvedl3CGds4/DVn+IvTRB1tl4ezviU2q0uudkNhSItnmIc0ZtDfF/6o 7vtFUP9vsORYNkto7IBKpNNSy0UBLI5CAIydCFZ2Yu8+O8uWTqfS5UnvcWyWPwTEBLUI 8U7En8nv+MDIpGZ8BcMUpHehcZ2oXNQKFLNwr/tWqHE3NyoxC10saTJpoY/enMBfczy1 eYXT4fSySY+FI2X9nBtnOOQ7YDpONuqIyWiOHyYTcN5HZ84FTfvaeUC1P3fGimD4rVgT 7WAoCMP0/nBFdOZj8zJ6TekJQAxpW+Ougz/mVSX4T1Ru/uMR4OpAPiiVSIS7KDCwdmdT 5p0Q== X-Gm-Message-State: AOAM532xD11yU+CXWt6G8MhzkDYipQUtsXx6rbU3ovPoFCsY3v1Nstgw t4MWqDgYoCjm93k0vL/fOb5btg== X-Google-Smtp-Source: ABdhPJy0qTqHTrXdybd8Z/alToU7dWXX4j89dgDjRwcQXHgR+4kefRJlnJxM84Ub3lrX7YqunzPnCg== X-Received: by 2002:adf:ee04:: with SMTP id y4mr28043885wrn.0.1639340333104; Sun, 12 Dec 2021 12:18:53 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id p5sm9092710wrd.13.2021.12.12.12.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 12:18:52 -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 v5 2/3] phy: amlogic: meson8b-usb2: Use dev_err_probe() Date: Sun, 12 Dec 2021 21:18:43 +0100 Message-Id: <20211212201844.114949-3-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211212201844.114949-1-aouledameur@baylibre.com> References: <20211212201844.114949-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211212_121855_946059_88C669C0 X-CRM114-Status: GOOD ( 10.70 ) 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 12 20:18: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: 12672637 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 936F3C433EF for ; Sun, 12 Dec 2021 20:19:28 +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=bYudcPg2/ai7hj klB4RiPjn+MBXQxdXQnbPppM7MMhRCJPhFUoUFUi1rADxCHVnuvrd9Q1Wy+maPPuAGi3a0QbHbLC3 9QzbHEMjMvfgQ4KD94YDzkI9+UWsUocr+f/TIl3vnfv0Bdb7O8LF+oCceHrNlztltZlOOlDwC8a5t ltf3sxqsmkDrTB8pXfS+JbKSTdkMGqBov4220WdWNqU9A9sIh7nQntIRugzfzJul3BA5McBM2U1oc 55PenKSY5xf0XYL3QLWMh7aoGNDf8bUGg7xE6WWMcKJvwnQ3WWadNs9p69SLSAALga+/rrmejdHof PgJ/fa0cxCJdVFPCO8Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwVJb-007Bg8-JE; Sun, 12 Dec 2021 20:19:23 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwVJJ-007BVw-HZ for linux-amlogic@lists.infradead.org; Sun, 12 Dec 2021 20:19:06 +0000 Received: by mail-wm1-x32d.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so10360446wme.4 for ; Sun, 12 Dec 2021 12:18:54 -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=pcjNcXo7dFjKe9b3PBWARFRWZr4FFcHxkOlewPzmHYW8JxHjngMhrx0q+knnJqVDab QNJvLN85AfBHFPP8BiSpZQ6oXra++aByHtSUTJT43ycUaBS8gvZWDOhelrbn8xCY9vBl F+QBryo0cuQttHFEApUNveZJ2lGksjVT7MKTBvtqHFuMqxj2lFyREZkUPQfug759skRx TPXKV8Rky63hnwLWIYcZR3ULPibkwz7wUzgX0SNVR6KUJ/NL59u/Gnj5siakM1H3RX18 mCmT9FYecMGk6isn6Lh1oDJPLBs56QfP2a+l/z2GQRpDo0Ao6lONSzrj3JBxGe1VWqqg wfug== 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=LEVCMTRr9zYKGwvRMuTDcdCCsX81utOVOkgryxDfYDIjsH+iEeEiromg9A1iuJfMYD O2PoNMDQucXSVaNmV64cX82J7y0yzE8I06Ajh9+0f9INK7UcXwIWcxMNJAm0u3+ZRJQY 0sXbsVT5PnfWaof5hxVxrH8BrpuzO/AqN09+Ew7XUsW23LV+9N0jwkUL8tPb/zGE5JR4 dDoPNasu1N7U0eJfrcbGcfczshuxfM5+GytJgfUC4g2urdQ406LPIo0nulxHzWXlpADx SkK7wXKwaoNmBJRhznK5LlvDJg06faySWMVOyacuc1t9jxqh/ukLlUsHnAQjPAysYS3U L4gg== X-Gm-Message-State: AOAM531XzpXqCPcf6W2sXLVcr3PmQOMzV/aDzcL+weEew82CSbHQ4EOt +vldv3j+L0oyUQtOti0LuJvttA== X-Google-Smtp-Source: ABdhPJwgdpYCgr0z0RkhIAAroY4dPi0MQtlkklljD6krZXWkI9iwaVuD8lv9C9Q0BP7oIqg6Dm7GiQ== X-Received: by 2002:a7b:c197:: with SMTP id y23mr32689470wmi.44.1639340333806; Sun, 12 Dec 2021 12:18:53 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id p5sm9092710wrd.13.2021.12.12.12.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Dec 2021 12:18:53 -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 v5 3/3] phy: amlogic: meson8b-usb2: fix shared reset control use Date: Sun, 12 Dec 2021 21:18:44 +0100 Message-Id: <20211212201844.114949-4-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211212201844.114949-1-aouledameur@baylibre.com> References: <20211212201844.114949-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211212_121905_644258_D13008D5 X-CRM114-Status: UNSURE ( 9.32 ) 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,