Skip to content

Commit 442fdef

Browse files
fancergregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 868f3ee commit 442fdef

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,20 +282,13 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
282282

283283
clk_disable_unprepare(d->clk);
284284
rate = clk_round_rate(d->clk, baud * 16);
285-
if (rate < 0)
286-
ret = rate;
287-
else if (rate == 0)
288-
ret = -ENOENT;
289-
else
285+
if (rate > 0) {
290286
ret = clk_set_rate(d->clk, rate);
287+
if (!ret)
288+
p->uartclk = rate;
289+
}
291290
clk_prepare_enable(d->clk);
292291

293-
if (ret)
294-
goto out;
295-
296-
p->uartclk = rate;
297-
298-
out:
299292
p->status &= ~UPSTAT_AUTOCTS;
300293
if (termios->c_cflag & CRTSCTS)
301294
p->status |= UPSTAT_AUTOCTS;

0 commit comments

Comments
 (0)