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.se...@baikalelectronics.ru>
Cc: Alexey Malahov <alexey.mala...@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbog...@alpha.franken.de>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: Andy Shevchenko <andriy.shevche...@linux.intel.com>
Cc: Maxime Ripard <mrip...@kernel.org>
Cc: Will Deacon <w...@kernel.org>
Cc: Russell King <li...@armlinux.org.uk>
Cc: linux-m...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org

---

Changelog v3:
- This is a new patch.
---
 drivers/tty/serial/8250/8250_dw.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index aab3cccc6789..12866083731d 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -282,20 +282,13 @@ static void dw8250_set_termios(struct uart_port *p, 
struct ktermios *termios,
 
        clk_disable_unprepare(d->clk);
        rate = clk_round_rate(d->clk, baud * 16);
-       if (rate < 0)
-               ret = rate;
-       else if (rate == 0)
-               ret = -ENOENT;
-       else
+       if (rate > 0) {
                ret = clk_set_rate(d->clk, rate);
+               if (!ret)
+                       p->uartclk = rate;
+       }
        clk_prepare_enable(d->clk);
 
-       if (ret)
-               goto out;
-
-       p->uartclk = rate;
-
-out:
        p->status &= ~UPSTAT_AUTOCTS;
        if (termios->c_cflag & CRTSCTS)
                p->status |= UPSTAT_AUTOCTS;
-- 
2.26.2

Reply via email to