From patchwork Thu Jun 24 22:49:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12343331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C173C49EA5 for ; Thu, 24 Jun 2021 22:52:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6538F60FEA for ; Thu, 24 Jun 2021 22:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6538F60FEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=p1zOTTwn58A7dm7HUa2/C3OhQM4ihAyGPkKM/Vnr6vc=; b=Qu4zR1ADBs7d35 zHdExqE/4Q4NMA9DfTYpZPmxz9ogYUz6ZWsVL+zJoHY24jOurtuJczW78G2Y0DXsqliICpLg2Ra/U u+FQqsGGTJW7cNmKqUK9lYLaQU9MKafhjprZjQDJdqSuAgJOFr3HHEyKaqkkFaWF2EEoxEae48Xuc RafLFHDh190C4exzrS5Cct1sCq17bMsT+5G4KGYDWPgYTLNDeeLi36HjyNrZUZ+7BIn3DytpJG4hc UXniEPZ3SeFeIlYkSiONxvGmpbEhGluQ04mv2l+YR26qEE6uyY2vfA0c4Eru9+Sacai9CYMYRP2/c MAkMX2SwIc/vyk0e530A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwYBC-00GcuF-8a; Thu, 24 Jun 2021 22:50:38 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwYAU-00Gck0-Un for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 22:49:57 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 70380613C1; Thu, 24 Jun 2021 22:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624574994; bh=TY3iBQKER6Z5ph8zWEWZU/pK1GZsZOyt08z1Cvndgwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejK/fnKjQ/O4Pjsb2S5Y2uMIa3P9h5tOCV7V+GC5VTG1CrPP0MCXEnJHMCmEQDPFI 57Mn6q1Gc+p0gSUHttDkZmgtruixOPQ/TX/cAzAOPq3dX7sn4nIo3srL0cKH1NsoVm xIm/tQpq1c8tFs/6bNzo6rYSc4w3IaAl4/e7a/8xyv5VvAd9xaEQrDt/E4qRIT2TuQ MUoPRrJ8MzzvK6YYLuDdxV7QeNKPPt4sDawMvcnYQIR+l0KLEw8152sNKuToSERz9/ WXeiJa8iYuPIU0QRAZWj7hmAgIXTZMBLgt9hoEBiBc+hwOQdMYxUp+N2PX+4F5PexH A7PhJifWCgPdg== Received: by pali.im (Postfix) id 9FB21BFC; Fri, 25 Jun 2021 00:49:52 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Michael Turquette , Stephen Boyd , Rob Herring , Greg Kroah-Hartman Cc: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Vladimir Vid , =?utf-8?q?Marek_Beh=C3=BAn?= , linux-clk@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/10] serial: mvebu-uart: do not allow changing baudrate when uartclk is not available Date: Fri, 25 Jun 2021 00:49:01 +0200 Message-Id: <20210624224909.6350-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210624224909.6350-1-pali@kernel.org> References: <20210624224909.6350-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_154955_090419_1F2D3A95 X-CRM114-Status: GOOD ( 13.76 ) 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 Testing mvuart->clk for non-error is not enough as mvuart->clk may contain valid clk pointer but when clk_prepare_enable(mvuart->clk) failed then port->uartclk is zero. When mvuart->clk is not available then port->uartclk is zero too. Parent clock rate port->uartclk is needed to calculate UART clock divisor and without it is not possible to change baudrate. So fix test condition when it is possible to change baudrate. Signed-off-by: Pali Rohár Fixes: 68a0db1d7da2 ("serial: mvebu-uart: add function to change baudrate") --- drivers/tty/serial/mvebu-uart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c index f81bfdaa608c..dc0c26824ddb 100644 --- a/drivers/tty/serial/mvebu-uart.c +++ b/drivers/tty/serial/mvebu-uart.c @@ -445,12 +445,11 @@ static void mvebu_uart_shutdown(struct uart_port *port) static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) { - struct mvebu_uart *mvuart = to_mvuart(port); unsigned int d_divisor, m_divisor; u32 brdv, osamp; - if (IS_ERR(mvuart->clk)) - return -PTR_ERR(mvuart->clk); + if (!port->uartclk) + return -EOPNOTSUPP; /* * The baudrate is derived from the UART clock thanks to two divisors: