From patchwork Tue Mar 1 05:37:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12764136 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 BA07AC433F5 for ; Tue, 1 Mar 2022 05:38:59 +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=SIH8a69kpjB+ye04/FUlY03m0ztuH/BQeXaJOIab15U=; b=p+QAi5KbXIbxFF /ldvEmM4fjtYrbjdefbIarU/JtMBmrmfKuSYxHxKtTTFpXuJZWvkteyy4gzbeaShV1opf1sLY6qZu kaEyxRRk858MknNEg0/3KCazHHd5hgh0m3zbf35cgS718OjrRvX8wpRjFxmLGlyHO48SJRgo2uFt0 g7xouuLJKNesCQj+ldl43+rlZSZY/UMTlAY37Y/RwWqjkddyR5ybfsyEEIYyp3762fk1bz2zjriMj CmlSn9NZgXc0uipwriIa4Bkm6caIbCoc5n0sYOJrzLQSyzr4ZE0v9zeVlFXz1LPqR0TEtvY9iTvoa 4FOu34CKlgqgexJXgl5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOvDr-00F1S0-Bd; Tue, 01 Mar 2022 05:38:55 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOvDZ-00F1Is-P4; Tue, 01 Mar 2022 05:38:39 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Tue, 1 Mar 2022 13:38:35 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu , kernel test robot , Dan Carpenter Subject: [PATCH] tty: serial: meson: Fixed an issue where pclk was turned on on probe but should be turned off on subsequent errors. Date: Tue, 1 Mar 2022 13:37:38 +0800 Message-ID: <20220301053738.21163-1-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_213837_857769_EECC8F58 X-CRM114-Status: GOOD ( 11.47 ) 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 Call clk_prepare_enable in the probe function to enable pclk. If you exit the probe function later in an error, call clk_disable_unprepare to disable pclk. Fixes: 44023b8e1f14 ("tty: serial:meson: Describes the calculation of the UART baud rate clock using a clock frameā€œ) Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 37 +++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) base-commit: d4ab5487cc77a4053dc9070c5761ad94bf397825 diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index bf6be5468aaf..972f210f3492 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -780,28 +780,37 @@ static int meson_uart_probe(struct platform_device *pdev) return ret; irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + if (irq < 0) { + ret = irq; + goto err_out_clk_disable; + } of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); if (meson_ports[pdev->id]) { dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); - return -EBUSY; + ret = -EBUSY; + goto err_out_clk_disable; } port = devm_kzalloc(&pdev->dev, sizeof(struct uart_port), GFP_KERNEL); - if (!port) - return -ENOMEM; + if (!port) { + ret = -ENOMEM; + goto err_out_clk_disable; + } port->membase = devm_ioremap_resource(&pdev->dev, res_mem); - if (IS_ERR(port->membase)) - return PTR_ERR(port->membase); + if (IS_ERR(port->membase)) { + ret = PTR_ERR(port->membase); + goto err_out_clk_disable; + } private_data = devm_kzalloc(&pdev->dev, sizeof(*private_data), GFP_KERNEL); - if (!private_data) - return -ENOMEM; + if (!private_data) { + ret = -ENOMEM; + goto err_out_clk_disable; + } if (device_get_match_data(&pdev->dev)) private_data->use_xtal_clk = true; @@ -822,7 +831,7 @@ static int meson_uart_probe(struct platform_device *pdev) ret = meson_uart_probe_clocks(port); if (ret) - return ret; + goto err_out_clk_disable; meson_ports[pdev->id] = port; platform_set_drvdata(pdev, port); @@ -831,9 +840,15 @@ static int meson_uart_probe(struct platform_device *pdev) meson_uart_reset(port); ret = uart_add_one_port(&meson_uart_driver, port); - if (ret) + if (ret) { meson_ports[pdev->id] = NULL; + goto err_out_clk_disable; + } + + return 0; +err_out_clk_disable: + clk_disable_unprepare(pclk); return ret; }