[PATCH 6/9] s3c2410 serial: move divisor calculation to separate function

Cesar Eduardo Barros cesarb at cesarb.net
Wed Feb 13 02:24:34 CET 2008


The cpufreq notifier for the S3C2410 serial driver has to recalculate the
baud rate divisor. The code which does the calculation is currently part of
s3c24xx_serial_set_termios. Split it off to a separate function.

Code movement only, no functional changes.

Signed-off-by: Cesar Eduardo Barros <cesarb at cesarb.net>
---
 drivers/serial/s3c2410.c |   51 ++++++++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index b566f42..c9857d9 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -729,30 +729,13 @@ static unsigned int s3c24xx_serial_getclk(struct uart_port *port,
 	return best->quot;
 }
 
-static void s3c24xx_serial_set_termios(struct uart_port *port,
-				       struct ktermios *termios,
-				       struct ktermios *old)
+static unsigned int s3c24xx_serial_calc_ubrdiv(struct uart_port *port,
+					       unsigned int baud)
 {
-	struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
 	struct s3c24xx_uart_port *ourport = to_ourport(port);
 	struct s3c24xx_uart_clksrc *clksrc = NULL;
 	struct clk *clk = NULL;
-	unsigned long flags;
-	unsigned int baud, quot;
-	unsigned int ulcon;
-	unsigned int umcon;
-
-	/*
-	 * We don't support modem control lines.
-	 */
-	termios->c_cflag &= ~(HUPCL | CMSPAR);
-	termios->c_cflag |= CLOCAL;
-
-	/*
-	 * Ask the core to calculate the divisor for us.
-	 */
-
-	baud = uart_get_baud_rate(port, termios, old, 0, 115200*8);
+	unsigned int quot;
 
 	if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST)
 		quot = port->custom_divisor;
@@ -775,6 +758,34 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
 		ourport->baudclk = clk;
 	}
 
+	return quot;
+}
+
+static void s3c24xx_serial_set_termios(struct uart_port *port,
+				       struct ktermios *termios,
+				       struct ktermios *old)
+{
+	struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
+	struct s3c24xx_uart_port *ourport = to_ourport(port);
+	unsigned long flags;
+	unsigned int baud, quot;
+	unsigned int ulcon;
+	unsigned int umcon;
+
+	/*
+	 * We don't support modem control lines.
+	 */
+	termios->c_cflag &= ~(HUPCL | CMSPAR);
+	termios->c_cflag |= CLOCAL;
+
+	/*
+	 * Ask the core to calculate the divisor for us.
+	 */
+
+	baud = uart_get_baud_rate(port, termios, old, 0, 115200*8);
+
+	quot = s3c24xx_serial_calc_ubrdiv(port, baud);
+
 	switch (termios->c_cflag & CSIZE) {
 	case CS5:
 		dbg("config: 5bits/char\n");
-- 
1.5.4





More information about the openmoko-kernel mailing list