mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 01:22:07 +00:00
serial: 8250_dw: Simplify the ref clock rate setting procedure
Really instead of twice checking the clk_round_rate() return value we could do it once, and if it isn't error the clock rate can be changed. By doing so we decrease a number of ret-value tests and remove a weird goto-based construction implemented in the dw8250_set_termios() method. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Link: https://lore.kernel.org/r/20200723003357.26897-3-Sergey.Semin@baikalelectronics.ru Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
868f3ee6e4
commit
442fdef1b9
@ -282,20 +282,13 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
|
|||||||
|
|
||||||
clk_disable_unprepare(d->clk);
|
clk_disable_unprepare(d->clk);
|
||||||
rate = clk_round_rate(d->clk, baud * 16);
|
rate = clk_round_rate(d->clk, baud * 16);
|
||||||
if (rate < 0)
|
if (rate > 0) {
|
||||||
ret = rate;
|
|
||||||
else if (rate == 0)
|
|
||||||
ret = -ENOENT;
|
|
||||||
else
|
|
||||||
ret = clk_set_rate(d->clk, rate);
|
ret = clk_set_rate(d->clk, rate);
|
||||||
|
if (!ret)
|
||||||
|
p->uartclk = rate;
|
||||||
|
}
|
||||||
clk_prepare_enable(d->clk);
|
clk_prepare_enable(d->clk);
|
||||||
|
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
p->uartclk = rate;
|
|
||||||
|
|
||||||
out:
|
|
||||||
p->status &= ~UPSTAT_AUTOCTS;
|
p->status &= ~UPSTAT_AUTOCTS;
|
||||||
if (termios->c_cflag & CRTSCTS)
|
if (termios->c_cflag & CRTSCTS)
|
||||||
p->status |= UPSTAT_AUTOCTS;
|
p->status |= UPSTAT_AUTOCTS;
|
||||||
|
Loading…
Reference in New Issue
Block a user