From patchwork Tue Dec 5 00:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13479244 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 39F8FC4167B for ; Tue, 5 Dec 2023 00:51:54 +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: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:In-Reply-To:References: List-Owner; bh=nN+QRUDFtryiJ51X+SF+jWZEJm4ZlvHwXgw1twyu6ZE=; b=sasNlAsLLqp6sx Gb0YTou7wP+fKqdUiKnwY24zo0cFwDSQCXnNIv8J6Chxb8fy7sfYg2JTE5Pzh+4iOEM9hZ0kzMiRP pUFjv2dAYa/ra1i1qRjQCDbRqzN3sueJLEPDASfgzMx2ikpAhVk+n8AxV7vvCk45w+6mEDiBnDRbO /ILcceI+FSiBGP8ruzvFtPQJB8ljSdyGhLYW5OT020jP/rbgqbXvOyw+c7tZRKATYnv1zY8hySp5v RfIEnxdWe0HKq12nqw+comkPtrOqSU1UGSTZ4rCkZc5UtLZGX/cbQc8BfE11n/yiz2+qiAYhIKKsv MUov4j/RGKlzpmjf/Y2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAJes-005uuE-36; Tue, 05 Dec 2023 00:51:30 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAJep-005utE-1i for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 00:51:29 +0000 Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 153B887239; Tue, 5 Dec 2023 01:51:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1701737480; bh=5v8+9UPXzKTD4EbtZS10D+tczM83LXSeK3tSgL2cKbw=; h=From:To:Cc:Subject:Date:From; b=HvaqQjcgHH9ZVjG9FQJ/jmw615LGV4OrfCeSBlFfrQUcj+/Mjgc47/4KQTy3Od+l5 9KxLAzJxxddD0DVSxaM4xiNvNDjHRQhIS9nZXGnjRgeFUHPJxjGe6s820yAABTyZkA OYsGIj6l2LSn9yLiR0TD49CvftaBtofbYAnpAt/Zkn7B8vuw+HWxizaoO5CoEs+m8i IDAvMb0P3c86TRyI3JMHMOTvWPk2e47Ys7PMoNIpiSyZp0ZlY4jJY4XqFY3sVf+1Yb 8CFiW3wgprrNaQiKGS3C6C3uKPMHxhAEi6kPXLx3Ng9ur3luhqhCWqnvvHsx+2IEWR C7OoBv3/MtIjA== From: Marek Vasut To: linux-serial@vger.kernel.org Cc: Marek Vasut , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Fabio Estevam , Greg Kroah-Hartman , Jiri Slaby , NXP Linux Team , Pengutronix Kernel Team , Rob Herring , Sascha Hauer , Sergey Organov , Shawn Guo , Thomas Gleixner , Tom Rix , linux-arm-kernel@lists.infradead.org Subject: [PATCH] serial: imx: Fix clock imbalance Date: Tue, 5 Dec 2023 01:50:57 +0100 Message-ID: <20231205005108.79782-1-marex@denx.de> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231204_165127_901618_6737A48F X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Disable and unprepare the clock on every exit from probe function after the clock were prepared and enabled to avoid enable/disable imbalance. Signed-off-by: Marek Vasut Reviewed-by: Fabio Estevam Reviewed-by: Christoph Niedermaier --- Cc: "Ilpo Järvinen" Cc: "Uwe Kleine-König" Cc: Fabio Estevam Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: NXP Linux Team Cc: Pengutronix Kernel Team Cc: Rob Herring Cc: Sascha Hauer Cc: Sergey Organov Cc: Shawn Guo Cc: Thomas Gleixner Cc: Tom Rix Cc: linux-arm-kernel@lists.infradead.org Cc: linux-serial@vger.kernel.org --- drivers/tty/serial/imx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 52dd8a6b87603..1cce66e5d05d8 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2332,10 +2332,8 @@ static int imx_uart_probe(struct platform_device *pdev) } ret = uart_get_rs485_mode(&sport->port); - if (ret) { - clk_disable_unprepare(sport->clk_ipg); - return ret; - } + if (ret) + goto err_clk; if (sport->port.rs485.flags & SER_RS485_ENABLED && (!sport->have_rtscts && !sport->have_rtsgpio)) @@ -2436,7 +2434,7 @@ static int imx_uart_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "failed to request rx irq: %d\n", ret); - return ret; + goto err_clk; } ret = devm_request_irq(&pdev->dev, txirq, imx_uart_txint, 0, @@ -2444,7 +2442,7 @@ static int imx_uart_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "failed to request tx irq: %d\n", ret); - return ret; + goto err_clk; } ret = devm_request_irq(&pdev->dev, rtsirq, imx_uart_rtsint, 0, @@ -2452,14 +2450,14 @@ static int imx_uart_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "failed to request rts irq: %d\n", ret); - return ret; + goto err_clk; } } else { ret = devm_request_irq(&pdev->dev, rxirq, imx_uart_int, 0, dev_name(&pdev->dev), sport); if (ret) { dev_err(&pdev->dev, "failed to request irq: %d\n", ret); - return ret; + goto err_clk; } } @@ -2468,6 +2466,10 @@ static int imx_uart_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sport); return uart_add_one_port(&imx_uart_uart_driver, &sport->port); + +err_clk: + clk_disable_unprepare(sport->clk_ipg); + return ret; } static void imx_uart_remove(struct platform_device *pdev)