From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Bakker <xc-racer2@live.ca>, Krzysztof Kozlowski <krzk@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 100/127] tty: serial: samsung: Correct clock selection logic Date: Thu, 17 Sep 2020 22:11:53 -0400 Message-ID: <20200918021220.2066485-100-sashal@kernel.org> (raw) In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> From: Jonathan Bakker <xc-racer2@live.ca> [ Upstream commit 7d31676a8d91dd18e08853efd1cb26961a38c6a6 ] Some variants of the samsung tty driver can pick which clock to use for their baud rate generation. In the DT conversion, a default clock was selected to be used if a specific one wasn't assigned and then a comparison of which clock rate worked better was done. Unfortunately, the comparison was implemented in such a way that only the default clock was ever actually compared. Fix this by iterating through all possible clocks, except when a specific clock has already been picked via clk_sel (which is only possible via board files). Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Link: https://lore.kernel.org/r/BN6PR04MB06604E63833EA41837EBF77BA3A30@BN6PR04MB0660.namprd04.prod.outlook.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/tty/serial/samsung.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index c67d39fea74ca..70d29b697e822 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1165,14 +1165,14 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, struct s3c24xx_uart_info *info = ourport->info; struct clk *clk; unsigned long rate; - unsigned int cnt, baud, quot, clk_sel, best_quot = 0; + unsigned int cnt, baud, quot, best_quot = 0; char clkname[MAX_CLK_NAME_LENGTH]; int calc_deviation, deviation = (1 << 30) - 1; - clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : - ourport->info->def_clk_sel; for (cnt = 0; cnt < info->num_clks; cnt++) { - if (!(clk_sel & (1 << cnt))) + /* Keep selected clock if provided */ + if (ourport->cfg->clk_sel && + !(ourport->cfg->clk_sel & (1 << cnt))) continue; sprintf(clkname, "clk_uart_baud%d", cnt); -- 2.25.1
prev parent reply index Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20200918021220.2066485-1-sashal@kernel.org> 2020-09-18 2:11 ` [PATCH AUTOSEL 4.14 069/127] serial: 8250_port: Don't service RX FIFO if throttled Sasha Levin 2020-09-18 2:11 ` [PATCH AUTOSEL 4.14 070/127] serial: 8250_omap: Fix sleeping function called from invalid context during probe Sasha Levin 2020-09-18 2:11 ` [PATCH AUTOSEL 4.14 071/127] serial: 8250: 8250_omap: Terminate DMA before pushing data on RX timeout Sasha Levin 2020-09-18 2:11 ` [PATCH AUTOSEL 4.14 086/127] serial: uartps: Wait for tx_empty in console setup Sasha Levin 2020-09-18 2:11 ` Sasha Levin [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200918021220.2066485-100-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=gregkh@linuxfoundation.org \ --cc=krzk@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-serial@vger.kernel.org \ --cc=stable@vger.kernel.org \ --cc=xc-racer2@live.ca \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-Serial Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-serial/0 linux-serial/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-serial linux-serial/ https://lore.kernel.org/linux-serial \ linux-serial@vger.kernel.org public-inbox-index linux-serial Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-serial AGPL code for this site: git clone https://public-inbox.org/public-inbox.git