public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: 8250: Use serial8250_do_set_termios for uartclk updating
@ 2024-02-22 14:50 Serge Semin
  2024-02-22 15:05 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Serge Semin @ 2024-02-22 14:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Andy Shevchenko, Andy Shevchenko, linux-kernel, linux-serial

The serial8250_update_uartclk() body was created based on the several
method calls copied from the serial8250_do_set_termios() function. Seeing
aside with some other things the later method can update the baud rate
based on the new reference clock let's just call it instead thus
simplifying the code a bit.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/linux-serial/ZczD7KPbeRnY4CFc@black.fi.intel.com
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
---
 drivers/tty/serial/8250/8250_port.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 8ca061d3bbb9..a74d39846dd4 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2714,12 +2714,8 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
  */
 void serial8250_update_uartclk(struct uart_port *port, unsigned int uartclk)
 {
-	struct uart_8250_port *up = up_to_u8250p(port);
 	struct tty_port *tport = &port->state->port;
-	unsigned int baud, quot, frac = 0;
-	struct ktermios *termios;
 	struct tty_struct *tty;
-	unsigned long flags;
 
 	tty = tty_port_tty_get(tport);
 	if (!tty) {
@@ -2740,21 +2736,7 @@ void serial8250_update_uartclk(struct uart_port *port, unsigned int uartclk)
 	if (!tty_port_initialized(tport))
 		goto out_unlock;
 
-	termios = &tty->termios;
-
-	baud = serial8250_get_baud_rate(port, termios, NULL);
-	quot = serial8250_get_divisor(port, baud, &frac);
-
-	serial8250_rpm_get(up);
-	uart_port_lock_irqsave(port, &flags);
-
-	uart_update_timeout(port, termios->c_cflag, baud);
-
-	serial8250_set_divisor(port, baud, quot, frac);
-	serial_port_out(port, UART_LCR, up->lcr);
-
-	uart_port_unlock_irqrestore(port, flags);
-	serial8250_rpm_put(up);
+	serial8250_do_set_termios(port, &tty->termios, NULL);
 
 out_unlock:
 	mutex_unlock(&tport->mutex);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: 8250: Use serial8250_do_set_termios for uartclk updating
  2024-02-22 14:50 [PATCH] serial: 8250: Use serial8250_do_set_termios for uartclk updating Serge Semin
@ 2024-02-22 15:05 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2024-02-22 15:05 UTC (permalink / raw)
  To: Serge Semin; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial

On Thu, Feb 22, 2024 at 05:50:56PM +0300, Serge Semin wrote:
> The serial8250_update_uartclk() body was created based on the several
> method calls copied from the serial8250_do_set_termios() function. Seeing
> aside with some other things the later method can update the baud rate
> based on the new reference clock let's just call it instead thus
> simplifying the code a bit.
> 
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Link: https://lore.kernel.org/linux-serial/ZczD7KPbeRnY4CFc@black.fi.intel.com
> Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

Thank you! This looks like a good simplification and turning to "one source" of
the same flow principle.

Assuming that it's working on your hardware,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-22 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22 14:50 [PATCH] serial: 8250: Use serial8250_do_set_termios for uartclk updating Serge Semin
2024-02-22 15:05 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox