From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
linux-kernel@vger.kernel.org, Paul Burton <paulburton@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Catalin Marinas <catalin.marinas@arm.com>,
Russell King <linux@armlinux.org.uk>,
Ralf Baechle <ralf@linux-mips.org>,
Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,
Serge Semin <Sergey.Semin@baikalelectronics.ru>,
Long Cheng <long.cheng@mediatek.com>,
linux-mediatek@lists.infradead.org,
Serge Semin <fancer.lancer@gmail.com>,
linux-serial@vger.kernel.org, linux-mips@vger.kernel.org,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 3/4] serial: 8250_dw: Simplify the ref clock rate setting procedure
Date: Thu, 7 May 2020 02:31:34 +0300 [thread overview]
Message-ID: <20200506233136.11842-4-Sergey.Semin@baikalelectronics.ru> (raw)
In-Reply-To: <20200506233136.11842-1-Sergey.Semin@baikalelectronics.ru>
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>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Long Cheng <long.cheng@mediatek.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-mips@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
---
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.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-05-06 23:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200306130231.05BBC8030795@mail.baikalelectronics.ru>
2020-03-23 2:46 ` [PATCH v2] serial: 8250_dw: Fix common clocks usage race condition Sergey.Semin
2020-03-23 9:20 ` Andy Shevchenko
2020-03-23 11:11 ` Sergey Semin
2020-03-23 11:52 ` Andy Shevchenko
2020-03-23 17:07 ` Sergey Semin
2020-03-23 10:01 ` Maxime Ripard
2020-03-23 13:50 ` Sergey Semin
2020-03-24 9:41 ` Maxime Ripard
2020-03-24 10:12 ` Andy Shevchenko
2020-03-25 17:11 ` Sergey Semin
2020-03-26 1:44 ` Stephen Boyd
2020-03-27 9:12 ` Sergey Semin
2020-05-06 23:31 ` [PATCH v3 0/4] serial: 8250_dw: Fix ref clock usage Serge Semin
2020-05-06 23:31 ` [PATCH v3 1/4] serial: 8250: Fix max baud limit in generic 8250 port Serge Semin
2020-05-15 13:48 ` Andy Shevchenko
2020-05-06 23:31 ` [PATCH v3 2/4] serial: 8250: Add 8250 port clock update method Serge Semin
2020-05-15 12:45 ` Greg Kroah-Hartman
2020-05-15 14:32 ` Serge Semin
2020-05-06 23:31 ` Serge Semin [this message]
2020-05-15 14:05 ` [PATCH v3 3/4] serial: 8250_dw: Simplify the ref clock rate setting procedure Andy Shevchenko
2020-05-15 14:50 ` Serge Semin
2020-05-15 15:05 ` Andy Shevchenko
2020-05-06 23:31 ` [PATCH v3 4/4] serial: 8250_dw: Fix common clocks usage race condition Serge Semin
2020-05-15 14:10 ` Andy Shevchenko
2020-05-15 15:19 ` Serge Semin
2020-05-07 18:29 ` [PATCH v3 0/4] serial: 8250_dw: Fix ref clock usage Andy Shevchenko
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=20200506233136.11842-4-Sergey.Semin@baikalelectronics.ru \
--to=sergey.semin@baikalelectronics.ru \
--cc=Alexey.Malahov@baikalelectronics.ru \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=fancer.lancer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jslaby@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=long.cheng@mediatek.com \
--cc=mripard@kernel.org \
--cc=paulburton@kernel.org \
--cc=ralf@linux-mips.org \
--cc=tsbogend@alpha.franken.de \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).