All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Fix checkpatch errors
@ 2015-12-11 10:36 Frederik Völkel
  2015-12-11 10:36 ` [PATCH 1/9] drivers: tty: 68328serial.c: Add missing spaces(checkpatch) Frederik Völkel
                   ` (11 more replies)
  0 siblings, 12 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel

This patch series fixes all checkpatch error in 68328serial.c except
5 trailing whitespace errors we are unsure how to fix.
Checkpatch warnings are unfixed. Maybe we send an patch series witch fix
these warnings later on.

Frederik Völkel (9):
  drivers: tty: 68328serial.c: Add missing spaces(checkpatch)
  drivers: tty: 68328serial.c: remove unnecessary spaces(checkpatch)
  drivers: tty: 68328serial.c: Do not initialize statics to 0
  drivers: tty: 68328serial.c: Fix "foo * bar" should be "foo *bar"
  drivers: tty: 68328serial.c: Remove parentheses after return
  drivers: tty: 68328serial.c: Use tabs for indentation
  drivers: tty: 68328serial.c: remove trailing whitespaces
  drivers: tty: 68328serial.c: Use use same indentation for switch/case
  drivers: tty: 68328serial.c: Move trailing statements to next line

 drivers/tty/serial/68328serial.c | 337 ++++++++++++++++++++-------------------
 1 file changed, 171 insertions(+), 166 deletions(-)

-- 
1.9.1


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

* [PATCH 1/9] drivers: tty: 68328serial.c: Add missing spaces(checkpatch)
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 2/9] drivers: tty: 68328serial.c: remove unnecessary spaces(checkpatch) Frederik Völkel
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch adds missing spaces reported by checkpatch.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 92 ++++++++++++++++++++--------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 0140ba4..4cdd805 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -274,8 +274,8 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
 #endif	
 		ch = GET_FIELD(rx, URX_RXDATA);
 	
-		if(info->is_cons) {
-			if(URX_BREAK & rx) { /* whee, break received */
+		if (info->is_cons) {
+			if (URX_BREAK & rx) { /* whee, break received */
 				return;
 #ifdef CONFIG_MAGIC_SYSRQ
 			} else if (ch == 0x10) { /* ^P */
@@ -302,7 +302,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
 
 		tty_insert_flip_char(&info->tport, ch, flag);
 #ifndef CONFIG_XCOPILOT_BUGS
-	} while((rx = uart->urx.w) & URX_DATA_READY);
+	} while ((rx = uart->urx.w) & URX_DATA_READY);
 #endif
 
 	tty_schedule_flip(&info->tport);
@@ -330,7 +330,7 @@ static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
 	info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
 	info->xmit_cnt--;
 
-	if(info->xmit_cnt <= 0) {
+	if (info->xmit_cnt <= 0) {
 		/* All done for now... TX ints off */
 		uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
 		goto clear_and_return;
@@ -452,45 +452,45 @@ struct {
 }
 #ifndef CONFIG_M68VZ328
  hw_baud_table[18] = {
-	{0,0}, /* 0 */
-	{0,0}, /* 50 */
-	{0,0}, /* 75 */
-	{0,0}, /* 110 */
-	{0,0}, /* 134 */
-	{0,0}, /* 150 */
-	{0,0}, /* 200 */
-	{7,0x26}, /* 300 */
-	{6,0x26}, /* 600 */
-	{5,0x26}, /* 1200 */
-	{0,0}, /* 1800 */
-	{4,0x26}, /* 2400 */
-	{3,0x26}, /* 4800 */
-	{2,0x26}, /* 9600 */
-	{1,0x26}, /* 19200 */
-	{0,0x26}, /* 38400 */
-	{1,0x38}, /* 57600 */
-	{0,0x38}, /* 115200 */
+	{0, 0}, /* 0 */
+	{0, 0}, /* 50 */
+	{0, 0}, /* 75 */
+	{0, 0}, /* 110 */
+	{0, 0}, /* 134 */
+	{0, 0}, /* 150 */
+	{0, 0}, /* 200 */
+	{7, 0x26}, /* 300 */
+	{6, 0x26}, /* 600 */
+	{5, 0x26}, /* 1200 */
+	{0, 0}, /* 1800 */
+	{4, 0x26}, /* 2400 */
+	{3, 0x26}, /* 4800 */
+	{2, 0x26}, /* 9600 */
+	{1, 0x26}, /* 19200 */
+	{0, 0x26}, /* 38400 */
+	{1, 0x38}, /* 57600 */
+	{0, 0x38}, /* 115200 */
 };
 #else
  hw_baud_table[18] = {
-                 {0,0}, /* 0 */
-                 {0,0}, /* 50 */
-                 {0,0}, /* 75 */
-                 {0,0}, /* 110 */
-                 {0,0}, /* 134 */
-                 {0,0}, /* 150 */
-                 {0,0}, /* 200 */
-                 {0,0}, /* 300 */
-                 {7,0x26}, /* 600 */
-                 {6,0x26}, /* 1200 */
-                 {0,0}, /* 1800 */
-                 {5,0x26}, /* 2400 */
-                 {4,0x26}, /* 4800 */
-                 {3,0x26}, /* 9600 */
-                 {2,0x26}, /* 19200 */
-                 {1,0x26}, /* 38400 */
-                 {0,0x26}, /* 57600 */
-                 {1,0x38}, /* 115200 */
+                 {0, 0}, /* 0 */
+                 {0, 0}, /* 50 */
+                 {0, 0}, /* 75 */
+                 {0, 0}, /* 110 */
+                 {0, 0}, /* 134 */
+                 {0, 0}, /* 150 */
+                 {0, 0}, /* 200 */
+                 {0, 0}, /* 300 */
+                 {7, 0x26}, /* 600 */
+                 {6, 0x26}, /* 1200 */
+                 {0, 0}, /* 1800 */
+                 {5, 0x26}, /* 2400 */
+                 {4, 0x26}, /* 4800 */
+                 {3, 0x26}, /* 9600 */
+                 {2, 0x26}, /* 19200 */
+                 {1, 0x26}, /* 38400 */
+                 {0, 0x26}, /* 57600 */
+                 {1, 0x38}, /* 115200 */
 }; 
 #endif
 /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
@@ -591,8 +591,8 @@ void console_print_68328(const char *p)
 {
 	char c;
 	
-	while((c=*(p++)) != 0) {
-		if(c == '\n')
+	while ((c = *(p++)) != 0) {
+		if (c == '\n')
 			rs_put_char('\r');
 		rs_put_char(c);
 	}
@@ -624,7 +624,7 @@ static void rs_flush_chars(struct tty_struct *tty)
 	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
 		return;
 #ifndef USE_INTS
-	for(;;) {
+	for (;;) {
 #endif
 
 	/* Enable transmitter */
@@ -700,7 +700,7 @@ static int rs_write(struct tty_struct * tty,
 		/* Enable transmitter */
 		local_irq_disable();		
 #ifndef USE_INTS
-		while(info->xmit_cnt) {
+		while (info->xmit_cnt) {
 #endif
 
 		uart->ustcnt |= USTCNT_TXEN;
@@ -1180,7 +1180,7 @@ rs68328_init(void)
 
 	local_irq_save(flags);
 
-	for(i=0;i<NR_PORTS;i++) {
+	for (i = 0; i < NR_PORTS; i++) {
 
 	    info = &m68k_soft[i];
 	    tty_port_init(&info->tport);
@@ -1263,7 +1263,7 @@ int m68328_console_setup(struct console *cp, char *arg)
 		return(-1);
 
 	if (arg)
-		n = simple_strtoul(arg,NULL,0);
+		n = simple_strtoul(arg, NULL, 0);
 
 	for (i = 0; i < ARRAY_SIZE(baud_table); i++)
 		if (baud_table[i] == n)
-- 
1.9.1


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

* [PATCH 2/9] drivers: tty: 68328serial.c: remove unnecessary spaces(checkpatch)
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
  2015-12-11 10:36 ` [PATCH 1/9] drivers: tty: 68328serial.c: Add missing spaces(checkpatch) Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 3/9] drivers: tty: 68328serial.c: Do not initialize statics to 0 Frederik Völkel
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch removes unnecessary spaces reported by checkpatch.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 4cdd805..b26cbae 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -538,7 +538,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 	
 #ifdef CONFIG_SERIAL_68328_RTS_CTS
 	if (cflag & CRTSCTS) {
-		uart->utx.w &= ~ UTX_NOCTS;
+		uart->utx.w &= ~UTX_NOCTS;
 	} else {
 		uart->utx.w |= UTX_NOCTS;
 	}
@@ -1198,7 +1198,7 @@ rs68328_init(void)
 	    printk(" is a builtin MC68328 UART\n");
 	    
 #ifdef CONFIG_M68VZ328
-		if (i > 0 )
+		if (i > 0)
 			PJSEL &= 0xCF;  /* PSW enable second port output */
 #endif
 
@@ -1298,7 +1298,7 @@ void m68328_console_write (struct console *co, const char *str,
     while (count--) {
         if (*str == '\n')
            rs_put_char('\r');
-        rs_put_char( *str++ );
+        rs_put_char(*str++);
     }
 }
 
-- 
1.9.1


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

* [PATCH 3/9] drivers: tty: 68328serial.c: Do not initialize statics to 0
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
  2015-12-11 10:36 ` [PATCH 1/9] drivers: tty: 68328serial.c: Add missing spaces(checkpatch) Frederik Völkel
  2015-12-11 10:36 ` [PATCH 2/9] drivers: tty: 68328serial.c: remove unnecessary spaces(checkpatch) Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 4/9] drivers: tty: 68328serial.c: Fix "foo * bar" should be "foo *bar" Frederik Völkel
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch removes an initialization of a static to 0 as checkpatch
suggests.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index b26cbae..b6d7230c 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -157,7 +157,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
 #endif
 
 
-static int m68328_console_initted = 0;
+static int m68328_console_initted;
 static int m68328_console_baud    = CONSOLE_BAUD_RATE;
 static int m68328_console_cbaud   = DEFAULT_CBAUD;
 
-- 
1.9.1


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

* [PATCH 4/9] drivers: tty: 68328serial.c: Fix "foo * bar" should be "foo *bar"
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (2 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 3/9] drivers: tty: 68328serial.c: Do not initialize statics to 0 Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 5/9] drivers: tty: 68328serial.c: Remove parentheses after return Frederik Völkel
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch fixes checkpatch errors "foo * bar" should be "foo *bar".

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index b6d7230c..8d58517 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -659,9 +659,9 @@ static void rs_flush_chars(struct tty_struct *tty)
 	local_irq_restore(flags);
 }
 
-extern void console_printn(const char * b, int count);
+extern void console_printn(const char *b, int count);
 
-static int rs_write(struct tty_struct * tty,
+static int rs_write(struct tty_struct *tty,
 		    const unsigned char *buf, int count)
 {
 	int	c, total = 0;
@@ -767,7 +767,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
  * incoming characters should be throttled.
  * ------------------------------------------------------------
  */
-static void rs_throttle(struct tty_struct * tty)
+static void rs_throttle(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 
@@ -780,7 +780,7 @@ static void rs_throttle(struct tty_struct * tty)
 	/* Turn off RTS line (do this atomic) */
 }
 
-static void rs_unthrottle(struct tty_struct * tty)
+static void rs_unthrottle(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 
@@ -803,8 +803,8 @@ static void rs_unthrottle(struct tty_struct * tty)
  * ------------------------------------------------------------
  */
 
-static int get_serial_info(struct m68k_serial * info,
-			   struct serial_struct * retinfo)
+static int get_serial_info(struct m68k_serial *info,
+			   struct serial_struct *retinfo)
 {
 	struct serial_struct tmp;
   
@@ -827,7 +827,7 @@ static int get_serial_info(struct m68k_serial * info,
 }
 
 static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
-			   struct serial_struct * new_info)
+			   struct serial_struct *new_info)
 {
 	struct tty_port *port = &info->tport;
 	struct serial_struct new_serial;
@@ -883,7 +883,7 @@ check_and_exit:
  * 	    transmit holding register is empty.  This functionality
  * 	    allows an RS485 driver to be written in user space. 
  */
-static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
+static int get_lsr_info(struct m68k_serial *info, unsigned int *value)
 {
 #ifdef CONFIG_SERIAL_68328_RTS_CTS
 	m68328_uart *uart = &uart_addr[info->line];
@@ -904,7 +904,7 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
 /*
  * This routine sends a break character out the serial port.
  */
-static void send_break(struct m68k_serial * info, unsigned int duration)
+static void send_break(struct m68k_serial *info, unsigned int duration)
 {
 	m68328_uart *uart = &uart_addr[info->line];
         unsigned long flags;
@@ -922,7 +922,7 @@ static void send_break(struct m68k_serial * info, unsigned int duration)
 static int rs_ioctl(struct tty_struct *tty,
 		    unsigned int cmd, unsigned long arg)
 {
-	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
+	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	int retval;
 
 	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
@@ -992,9 +992,9 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
  * that IRQ if nothing is left in the chain.
  * ------------------------------------------------------------
  */
-static void rs_close(struct tty_struct *tty, struct file * filp)
+static void rs_close(struct tty_struct *tty, struct file *filp)
 {
-	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
+	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	struct tty_port *port = &info->tport;
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
@@ -1079,7 +1079,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
  */
 void rs_hangup(struct tty_struct *tty)
 {
-	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
+	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	
 	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
@@ -1098,7 +1098,7 @@ void rs_hangup(struct tty_struct *tty)
  * the IRQ chain.   It also performs the serial-specific
  * initialization for the tty structure.
  */
-int rs_open(struct tty_struct *tty, struct file * filp)
+int rs_open(struct tty_struct *tty, struct file *filp)
 {
 	struct m68k_serial	*info;
 	int retval;
-- 
1.9.1


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

* [PATCH 5/9] drivers: tty: 68328serial.c: Remove parentheses after return
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (3 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 4/9] drivers: tty: 68328serial.c: Fix "foo * bar" should be "foo *bar" Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch removes parentheses after return as checkpatch suggests.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 8d58517..0982c1a 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -1279,7 +1279,7 @@ int m68328_console_setup(struct console *cp, char *arg)
 	}
 
 	m68328_set_baud(); /* make sure baud rate changes */
-	return(0);
+	return 0;
 }
 
 
-- 
1.9.1


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

* [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (4 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 5/9] drivers: tty: 68328serial.c: Remove parentheses after return Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-13  7:08   ` Greg KH
  2015-12-11 10:36 ` [PATCH 7/9] drivers: tty: 68328serial.c: remove trailing whitespaces Frederik Völkel
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

The patch replaces the spaces used for indentation at some points with
tabs.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 82 ++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 0982c1a..22f52e0 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -228,17 +228,17 @@ static int rs_put_char(char ch)
 	unsigned long flags;
 	int loops = 0;
 
-        local_irq_save(flags);
+	local_irq_save(flags);
 
 	while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
-        	loops++;
-        	udelay(5);
-        }
+		loops++;
+		udelay(5);
+	}
 
 	UTX_TXDATA = ch;
-        udelay(5);
-        local_irq_restore(flags);
-        return 1;
+	udelay(5);
+	local_irq_restore(flags);
+	return 1;
 }
 
 static void rs_start(struct tty_struct *tty)
@@ -268,7 +268,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
 
 	/*
 	 * This do { } while() loop will get ALL chars out of Rx FIFO 
-         */
+	 */
 #ifndef CONFIG_XCOPILOT_BUGS
 	do {
 #endif	
@@ -400,7 +400,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 	 */
 #ifdef USE_INTS
 	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
-                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
+		USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
 #else
 	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
 #endif
@@ -473,24 +473,24 @@ struct {
 };
 #else
  hw_baud_table[18] = {
-                 {0, 0}, /* 0 */
-                 {0, 0}, /* 50 */
-                 {0, 0}, /* 75 */
-                 {0, 0}, /* 110 */
-                 {0, 0}, /* 134 */
-                 {0, 0}, /* 150 */
-                 {0, 0}, /* 200 */
-                 {0, 0}, /* 300 */
-                 {7, 0x26}, /* 600 */
-                 {6, 0x26}, /* 1200 */
-                 {0, 0}, /* 1800 */
-                 {5, 0x26}, /* 2400 */
-                 {4, 0x26}, /* 4800 */
-                 {3, 0x26}, /* 9600 */
-                 {2, 0x26}, /* 19200 */
-                 {1, 0x26}, /* 38400 */
-                 {0, 0x26}, /* 57600 */
-                 {1, 0x38}, /* 115200 */
+	{0, 0}, /* 0 */
+	{0, 0}, /* 50 */
+	{0, 0}, /* 75 */
+	{0, 0}, /* 110 */
+	{0, 0}, /* 134 */
+	{0, 0}, /* 150 */
+	{0, 0}, /* 200 */
+	{0, 0}, /* 300 */
+	{7, 0x26}, /* 600 */
+	{6, 0x26}, /* 1200 */
+	{0, 0}, /* 1800 */
+	{5, 0x26}, /* 2400 */
+	{4, 0x26}, /* 4800 */
+	{3, 0x26}, /* 9600 */
+	{2, 0x26}, /* 19200 */
+	{1, 0x26}, /* 38400 */
+	{0, 0x26}, /* 57600 */
+	{1, 0x38}, /* 115200 */
 }; 
 #endif
 /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
@@ -516,9 +516,9 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 	uart->ustcnt = ustcnt & ~USTCNT_TXEN;
 
 	i = cflag & CBAUD;
-        if (i & CBAUDEX) {
-                i = (i & ~CBAUDEX) + B38400;
-        }
+	if (i & CBAUDEX) {
+		i = (i & ~CBAUDEX) + B38400;
+	}
 
 	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
 		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
@@ -907,16 +907,16 @@ static int get_lsr_info(struct m68k_serial *info, unsigned int *value)
 static void send_break(struct m68k_serial *info, unsigned int duration)
 {
 	m68328_uart *uart = &uart_addr[info->line];
-        unsigned long flags;
-        if (!info->port)
-                return;
-        local_irq_save(flags);
+	unsigned long flags;
+	if (!info->port)
+		return;
+	local_irq_save(flags);
 #ifdef USE_INTS	
 	uart->utx.w |= UTX_SEND_BREAK;
 	msleep_interruptible(duration);
 	uart->utx.w &= ~UTX_SEND_BREAK;
 #endif		
-        local_irq_restore(flags);
+	local_irq_restore(flags);
 }
 
 static int rs_ioctl(struct tty_struct *tty,
@@ -1206,7 +1206,7 @@ rs68328_init(void)
 			    rs_interrupt,
 			    0,
 			    "M68328_UART", info))
-                panic("Unable to attach 68328 serial interrupt\n");
+		panic("Unable to attach 68328 serial interrupt\n");
 
 	    tty_port_link_device(&info->tport, serial_driver, i);
 	}
@@ -1295,11 +1295,11 @@ void m68328_console_write (struct console *co, const char *str,
 {
 	if (!m68328_console_initted)
 		m68328_set_baud();
-    while (count--) {
-        if (*str == '\n')
-           rs_put_char('\r');
-        rs_put_char(*str++);
-    }
+	while (count--) {
+		if (*str == '\n')
+		    rs_put_char('\r');
+	rs_put_char(*str++);
+	}
 }
 
 
-- 
1.9.1


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

* [PATCH 7/9] drivers: tty: 68328serial.c: remove trailing whitespaces
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (5 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 8/9] drivers: tty: 68328serial.c: Use use same indentation for switch/case Frederik Völkel
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch removes trailing whitespaces reported by checkpatch.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
5 trailing whitespaces issues are still left. We are not sure how
to fix them.
---
 drivers/tty/serial/68328serial.c | 88 ++++++++++++++++++++--------------------
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 22f52e0..3e974d2 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -217,7 +217,7 @@ static void rs_stop(struct tty_struct *tty)
 
 	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
-	
+
 	local_irq_save(flags);
 	uart->ustcnt &= ~USTCNT_TXEN;
 	local_irq_restore(flags);
@@ -246,10 +246,10 @@ static void rs_start(struct tty_struct *tty)
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
-	
+
 	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
-	
+
 	local_irq_save(flags);
 	if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
 #ifdef USE_INTS
@@ -271,9 +271,9 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
 	 */
 #ifndef CONFIG_XCOPILOT_BUGS
 	do {
-#endif	
+#endif
 		ch = GET_FIELD(rx, URX_RXDATA);
-	
+
 		if (info->is_cons) {
 			if (URX_BREAK & rx) { /* whee, break received */
 				return;
@@ -374,7 +374,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 {
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
-	
+
 	if (info->tport.flags & ASYNC_INITIALIZED)
 		return 0;
 
@@ -399,7 +399,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 	 * Finally, enable sequencing and interrupts
 	 */
 #ifdef USE_INTS
-	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
+	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
 		USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
 #else
 	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
@@ -434,7 +434,7 @@ static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
 		return;
 
 	local_irq_save(flags);
-	
+
 	if (info->xmit_buf) {
 		free_page((unsigned long) info->xmit_buf);
 		info->xmit_buf = 0;
@@ -442,7 +442,7 @@ static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
 
 	if (tty)
 		set_bit(TTY_IO_ERROR, &tty->flags);
-	
+
 	info->tport.flags &= ~ASYNC_INITIALIZED;
 	local_irq_restore(flags);
 }
@@ -491,7 +491,7 @@ struct {
 	{1, 0x26}, /* 38400 */
 	{0, 0x26}, /* 57600 */
 	{1, 0x38}, /* 115200 */
-}; 
+};
 #endif
 /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
 
@@ -520,14 +520,14 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 		i = (i & ~CBAUDEX) + B38400;
 	}
 
-	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
+	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
 		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
 
 	ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
-	
+
 	if ((cflag & CSIZE) == CS8)
 		ustcnt |= USTCNT_8_7;
-		
+
 	if (cflag & CSTOPB)
 		ustcnt |= USTCNT_STOP;
 
@@ -535,7 +535,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 		ustcnt |= USTCNT_PARITYEN;
 	if (cflag & PARODD)
 		ustcnt |= USTCNT_ODD_EVEN;
-	
+
 #ifdef CONFIG_SERIAL_68328_RTS_CTS
 	if (cflag & CRTSCTS) {
 		uart->utx.w &= ~UTX_NOCTS;
@@ -545,7 +545,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 #endif
 
 	ustcnt |= USTCNT_TXEN;
-	
+
 	uart->ustcnt = ustcnt;
 	return;
 }
@@ -590,7 +590,7 @@ static void rs_fair_output(void)
 void console_print_68328(const char *p)
 {
 	char c;
-	
+
 	while ((c = *(p++)) != 0) {
 		if (c == '\n')
 			rs_put_char('\r');
@@ -611,7 +611,7 @@ static void rs_set_ldisc(struct tty_struct *tty)
 		return;
 
 	info->is_cons = (tty->termios.c_line == N_TTY);
-	
+
 	printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
 }
 
@@ -677,7 +677,7 @@ static int rs_write(struct tty_struct *tty,
 
 	local_save_flags(flags);
 	while (1) {
-		local_irq_disable();		
+		local_irq_disable();
 		c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
 				   SERIAL_XMIT_SIZE - info->xmit_head));
 		local_irq_restore(flags);
@@ -698,7 +698,7 @@ static int rs_write(struct tty_struct *tty,
 
 	if (info->xmit_cnt && !tty->stopped) {
 		/* Enable transmitter */
-		local_irq_disable();		
+		local_irq_disable();
 #ifndef USE_INTS
 		while (info->xmit_cnt) {
 #endif
@@ -728,7 +728,7 @@ static int rs_write_room(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	int	ret;
-				
+
 	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
@@ -740,7 +740,7 @@ static int rs_write_room(struct tty_struct *tty)
 static int rs_chars_in_buffer(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-				
+
 	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
@@ -750,7 +750,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	unsigned long flags;
-				
+
 	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	local_irq_save(flags);
@@ -773,7 +773,7 @@ static void rs_throttle(struct tty_struct *tty)
 
 	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
-	
+
 	if (I_IXOFF(tty))
 		info->x_char = STOP_CHAR(tty);
 
@@ -786,7 +786,7 @@ static void rs_unthrottle(struct tty_struct *tty)
 
 	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
-	
+
 	if (I_IXOFF(tty)) {
 		if (info->x_char)
 			info->x_char = 0;
@@ -807,7 +807,7 @@ static int get_serial_info(struct m68k_serial *info,
 			   struct serial_struct *retinfo)
 {
 	struct serial_struct tmp;
-  
+
 	if (!retinfo)
 		return -EFAULT;
 	memset(&tmp, 0, sizeof(tmp));
@@ -832,7 +832,7 @@ static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
 	struct tty_port *port = &info->tport;
 	struct serial_struct new_serial;
 	struct m68k_serial old_info;
-	int 			retval = 0;
+	int			retval = 0;
 
 	if (!new_info)
 		return -EFAULT;
@@ -911,11 +911,11 @@ static void send_break(struct m68k_serial *info, unsigned int duration)
 	if (!info->port)
 		return;
 	local_irq_save(flags);
-#ifdef USE_INTS	
+#ifdef USE_INTS
 	uart->utx.w |= UTX_SEND_BREAK;
 	msleep_interruptible(duration);
 	uart->utx.w &= ~UTX_SEND_BREAK;
-#endif		
+#endif
 	local_irq_restore(flags);
 }
 
@@ -934,7 +934,7 @@ static int rs_ioctl(struct tty_struct *tty,
 		if (tty->flags & (1 << TTY_IO_ERROR))
 		    return -EIO;
 	}
-	
+
 	switch (cmd) {
 		case TCSBRK:	/* SVID version: non-zero arg --> no break */
 			retval = tty_check_change(tty);
@@ -979,7 +979,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	if ((old_termios->c_cflag & CRTSCTS) &&
 	    !(tty->termios.c_cflag & CRTSCTS))
 		rs_start(tty);
-	
+
 }
 
 /*
@@ -1001,14 +1001,14 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 
 	if (serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
-	
+
 	local_irq_save(flags);
-	
+
 	if (tty_hung_up_p(filp)) {
 		local_irq_restore(flags);
 		return;
 	}
-	
+
 	if ((tty->count == 1) && (port->count != 1)) {
 		/*
 		 * Uh, oh.  tty->count is 1, which means that the tty
@@ -1050,11 +1050,11 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 
 	shutdown(info, tty);
 	rs_flush_buffer(tty);
-		
+
 	tty_ldisc_flush(tty);
 	tty->closing = 0;
 	tty_port_tty_set(&info->tport, NULL);
-#warning "This is not and has never been valid so fix it"	
+#warning "This is not and has never been valid so fix it"
 #if 0
 	if (tty->ldisc.num != ldiscs[N_TTY].num) {
 		if (tty->ldisc.close)
@@ -1064,7 +1064,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 		if (tty->ldisc.open)
 			(tty->ldisc.open)(tty);
 	}
-#endif	
+#endif
 	if (port->blocked_open) {
 		if (port->close_delay)
 			msleep_interruptible(jiffies_to_msecs(port->close_delay));
@@ -1080,10 +1080,10 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 void rs_hangup(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	
+
 	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
-	
+
 	rs_flush_buffer(tty);
 	shutdown(info, tty);
 	info->tport.count = 0;
@@ -1166,14 +1166,14 @@ rs68328_init(void)
 
 	/* Initialize the tty_driver structure */
 	/* SPARC: Not all of this is exactly right for us. */
-	
+
 	serial_driver->name = "ttyS";
 	serial_driver->major = TTY_MAJOR;
 	serial_driver->minor_start = 64;
 	serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
 	serial_driver->subtype = SERIAL_TYPE_NORMAL;
 	serial_driver->init_termios = tty_std_termios;
-	serial_driver->init_termios.c_cflag = 
+	serial_driver->init_termios.c_cflag =
 			m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
 	serial_driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(serial_driver, &rs_ops);
@@ -1192,11 +1192,11 @@ rs68328_init(void)
 	    info->x_char = 0;
 	    info->line = i;
 	    info->is_cons = 1; /* Means shortcuts work */
-	    
-	    printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line, 
+
+	    printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
 		   info->port, info->irq);
 	    printk(" is a builtin MC68328 UART\n");
-	    
+
 #ifdef CONFIG_M68VZ328
 		if (i > 0)
 			PJSEL &= 0xCF;  /* PSW enable second port output */
@@ -1244,7 +1244,7 @@ again:
 		goto again;
 	}
 
-	UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
+	UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
 		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
 	ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
 	ustcnt |= USTCNT_8_7;
-- 
1.9.1


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

* [PATCH 8/9] drivers: tty: 68328serial.c: Use use same indentation for switch/case
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (6 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 7/9] drivers: tty: 68328serial.c: remove trailing whitespaces Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-11 10:36 ` [PATCH 9/9] drivers: tty: 68328serial.c: Move trailing statements to next line Frederik Völkel
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch fixes an indentation checkpatch error so switch and case
have the same indentation.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 60 ++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 3e974d2..7e2e494 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -936,37 +936,37 @@ static int rs_ioctl(struct tty_struct *tty,
 	}
 
 	switch (cmd) {
-		case TCSBRK:	/* SVID version: non-zero arg --> no break */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			if (!arg)
-				send_break(info, 250);	/* 1/4 second */
-			return 0;
-		case TCSBRKP:	/* support for POSIX tcsendbreak() */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			send_break(info, arg ? arg*(100) : 250);
-			return 0;
-		case TIOCGSERIAL:
-			return get_serial_info(info,
+	case TCSBRK:	/* SVID version: non-zero arg --> no break */
+		retval = tty_check_change(tty);
+		if (retval)
+			return retval;
+		tty_wait_until_sent(tty, 0);
+		if (!arg)
+			send_break(info, 250);	/* 1/4 second */
+		return 0;
+	case TCSBRKP:	/* support for POSIX tcsendbreak() */
+		retval = tty_check_change(tty);
+		if (retval)
+			return retval;
+		tty_wait_until_sent(tty, 0);
+		send_break(info, arg ? arg*(100) : 250);
+		return 0;
+	case TIOCGSERIAL:
+		return get_serial_info(info,
+			       (struct serial_struct *) arg);
+	case TIOCSSERIAL:
+		return set_serial_info(info, tty,
 				       (struct serial_struct *) arg);
-		case TIOCSSERIAL:
-			return set_serial_info(info, tty,
-					       (struct serial_struct *) arg);
-		case TIOCSERGETLSR: /* Get line status register */
-			return get_lsr_info(info, (unsigned int *) arg);
-		case TIOCSERGSTRUCT:
-			if (copy_to_user((struct m68k_serial *) arg,
-				    info, sizeof(struct m68k_serial)))
-				return -EFAULT;
-			return 0;
-		default:
-			return -ENOIOCTLCMD;
-		}
+	case TIOCSERGETLSR: /* Get line status register */
+		return get_lsr_info(info, (unsigned int *) arg);
+	case TIOCSERGSTRUCT:
+		if (copy_to_user((struct m68k_serial *) arg,
+			    info, sizeof(struct m68k_serial)))
+			return -EFAULT;
+		return 0;
+	default:
+		return -ENOIOCTLCMD;
+	}
 	return 0;
 }
 
-- 
1.9.1


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

* [PATCH 9/9] drivers: tty: 68328serial.c: Move trailing statements to next line
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (7 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 8/9] drivers: tty: 68328serial.c: Use use same indentation for switch/case Frederik Völkel
@ 2015-12-11 10:36 ` Frederik Völkel
  2015-12-13  7:06 ` [PATCH 0/9] Fix checkpatch errors Greg KH
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-11 10:36 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: jslaby, gregkh, linux-kernel, Frederik Völkel, Lukas Braun

This patch moves trailing statements to the next line as checkpatch
suggests.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 7e2e494..d5bc7f1 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -195,7 +195,8 @@ static inline int get_baud(struct m68k_serial *ss)
 {
 	unsigned long result = 115200;
 	unsigned short int baud = uart_addr[ss->line].ubaud;
-	if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
+	if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38)
+		result = 38400;
 	result >>= GET_FIELD(baud, UBAUD_DIVIDE);
 
 	return result;
@@ -560,8 +561,10 @@ static void rs_fair_output(void)
 	struct m68k_serial *info = &m68k_soft[0];
 	char c;
 
-	if (info == NULL) return;
-	if (info->xmit_buf == NULL) return;
+	if (info == NULL)
+		return;
+	if (info->xmit_buf == NULL)
+		return;
 
 	local_irq_save(flags);
 	left = info->xmit_cnt;
@@ -653,7 +656,8 @@ static void rs_flush_chars(struct tty_struct *tty)
 	}
 
 #ifndef USE_INTS
-	while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
+	while (!(uart->utx.w & UTX_TX_AVAIL))
+		udelay(5);
 	}
 #endif
 	local_irq_restore(flags);
@@ -707,7 +711,8 @@ static int rs_write(struct tty_struct *tty,
 #ifdef USE_INTS
 		uart->ustcnt |= USTCNT_TX_INTR_MASK;
 #else
-		while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
+		while (!(uart->utx.w & UTX_TX_AVAIL))
+			udelay(5);
 #endif
 		if (uart->utx.w & UTX_TX_AVAIL) {
 			uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
-- 
1.9.1


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

* Re: [PATCH 0/9] Fix checkpatch errors
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (8 preceding siblings ...)
  2015-12-11 10:36 ` [PATCH 9/9] drivers: tty: 68328serial.c: Move trailing statements to next line Frederik Völkel
@ 2015-12-13  7:06 ` Greg KH
  2015-12-13 17:44   ` Frederik
  2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
  2015-12-18 11:28 ` [PATCH] serial: Remove 68328 driver Frederik Völkel
  11 siblings, 1 reply; 32+ messages in thread
From: Greg KH @ 2015-12-13  7:06 UTC (permalink / raw)
  To: Frederik Völkel; +Cc: linux-kernel, linux-serial, jslaby, linux-kernel

On Fri, Dec 11, 2015 at 11:36:00AM +0100, Frederik Völkel wrote:
> This patch series fixes all checkpatch error in 68328serial.c except
> 5 trailing whitespace errors we are unsure how to fix.

What are the errors you are not sure how to fix?

thanks,

greg k-h

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

* Re: [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation
  2015-12-11 10:36 ` [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
@ 2015-12-13  7:08   ` Greg KH
  2015-12-13  7:09     ` Greg KH
  0 siblings, 1 reply; 32+ messages in thread
From: Greg KH @ 2015-12-13  7:08 UTC (permalink / raw)
  To: Frederik Völkel
  Cc: linux-kernel, linux-serial, jslaby, linux-kernel, Lukas Braun

On Fri, Dec 11, 2015 at 11:36:06AM +0100, Frederik Völkel wrote:
> The patch replaces the spaces used for indentation at some points with
> tabs.
> 
> Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
> Signed-off-by: Lukas Braun <lukas.braun@fau.de>
> ---
>  drivers/tty/serial/68328serial.c | 82 ++++++++++++++++++++--------------------
>  1 file changed, 41 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
> index 0982c1a..22f52e0 100644
> --- a/drivers/tty/serial/68328serial.c
> +++ b/drivers/tty/serial/68328serial.c
> @@ -228,17 +228,17 @@ static int rs_put_char(char ch)
>  	unsigned long flags;
>  	int loops = 0;
>  
> -        local_irq_save(flags);
> +	local_irq_save(flags);
>  
>  	while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
> -        	loops++;
> -        	udelay(5);
> -        }
> +		loops++;
> +		udelay(5);
> +	}
>  
>  	UTX_TXDATA = ch;
> -        udelay(5);
> -        local_irq_restore(flags);
> -        return 1;
> +	udelay(5);
> +	local_irq_restore(flags);
> +	return 1;
>  }
>  
>  static void rs_start(struct tty_struct *tty)
> @@ -268,7 +268,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
>  
>  	/*
>  	 * This do { } while() loop will get ALL chars out of Rx FIFO 
> -         */
> +	 */
>  #ifndef CONFIG_XCOPILOT_BUGS
>  	do {
>  #endif	
> @@ -400,7 +400,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
>  	 */
>  #ifdef USE_INTS
>  	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
> -                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
> +		USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
>  #else
>  	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
>  #endif
> @@ -473,24 +473,24 @@ struct {
>  };
>  #else
>   hw_baud_table[18] = {
> -                 {0, 0}, /* 0 */
> -                 {0, 0}, /* 50 */
> -                 {0, 0}, /* 75 */
> -                 {0, 0}, /* 110 */
> -                 {0, 0}, /* 134 */
> -                 {0, 0}, /* 150 */
> -                 {0, 0}, /* 200 */
> -                 {0, 0}, /* 300 */
> -                 {7, 0x26}, /* 600 */
> -                 {6, 0x26}, /* 1200 */
> -                 {0, 0}, /* 1800 */
> -                 {5, 0x26}, /* 2400 */
> -                 {4, 0x26}, /* 4800 */
> -                 {3, 0x26}, /* 9600 */
> -                 {2, 0x26}, /* 19200 */
> -                 {1, 0x26}, /* 38400 */
> -                 {0, 0x26}, /* 57600 */
> -                 {1, 0x38}, /* 115200 */
> +	{0, 0}, /* 0 */
> +	{0, 0}, /* 50 */
> +	{0, 0}, /* 75 */
> +	{0, 0}, /* 110 */
> +	{0, 0}, /* 134 */
> +	{0, 0}, /* 150 */
> +	{0, 0}, /* 200 */
> +	{0, 0}, /* 300 */
> +	{7, 0x26}, /* 600 */
> +	{6, 0x26}, /* 1200 */
> +	{0, 0}, /* 1800 */
> +	{5, 0x26}, /* 2400 */
> +	{4, 0x26}, /* 4800 */
> +	{3, 0x26}, /* 9600 */
> +	{2, 0x26}, /* 19200 */
> +	{1, 0x26}, /* 38400 */
> +	{0, 0x26}, /* 57600 */
> +	{1, 0x38}, /* 115200 */
>  }; 
>  #endif
>  /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
> @@ -516,9 +516,9 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
>  	uart->ustcnt = ustcnt & ~USTCNT_TXEN;
>  
>  	i = cflag & CBAUD;
> -        if (i & CBAUDEX) {
> -                i = (i & ~CBAUDEX) + B38400;
> -        }
> +	if (i & CBAUDEX) {
> +		i = (i & ~CBAUDEX) + B38400;
> +	}
>  
>  	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
>  		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
> @@ -907,16 +907,16 @@ static int get_lsr_info(struct m68k_serial *info, unsigned int *value)
>  static void send_break(struct m68k_serial *info, unsigned int duration)
>  {
>  	m68328_uart *uart = &uart_addr[info->line];
> -        unsigned long flags;
> -        if (!info->port)
> -                return;
> -        local_irq_save(flags);
> +	unsigned long flags;
> +	if (!info->port)
> +		return;
> +	local_irq_save(flags);
>  #ifdef USE_INTS	
>  	uart->utx.w |= UTX_SEND_BREAK;
>  	msleep_interruptible(duration);
>  	uart->utx.w &= ~UTX_SEND_BREAK;
>  #endif		
> -        local_irq_restore(flags);
> +	local_irq_restore(flags);
>  }
>  
>  static int rs_ioctl(struct tty_struct *tty,
> @@ -1206,7 +1206,7 @@ rs68328_init(void)
>  			    rs_interrupt,
>  			    0,
>  			    "M68328_UART", info))
> -                panic("Unable to attach 68328 serial interrupt\n");
> +		panic("Unable to attach 68328 serial interrupt\n");
>  
>  	    tty_port_link_device(&info->tport, serial_driver, i);
>  	}
> @@ -1295,11 +1295,11 @@ void m68328_console_write (struct console *co, const char *str,
>  {
>  	if (!m68328_console_initted)
>  		m68328_set_baud();
> -    while (count--) {
> -        if (*str == '\n')
> -           rs_put_char('\r');
> -        rs_put_char(*str++);
> -    }
> +	while (count--) {
> +		if (*str == '\n')
> +		    rs_put_char('\r');
> +	rs_put_char(*str++);

This line should also be indented one more tab, right?

> +	}

Please fix up and resend.

thanks,

greg k-h

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

* Re: [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation
  2015-12-13  7:08   ` Greg KH
@ 2015-12-13  7:09     ` Greg KH
  0 siblings, 0 replies; 32+ messages in thread
From: Greg KH @ 2015-12-13  7:09 UTC (permalink / raw)
  To: Frederik Völkel
  Cc: linux-kernel, linux-serial, jslaby, linux-kernel, Lukas Braun

On Sat, Dec 12, 2015 at 11:08:00PM -0800, Greg KH wrote:
> On Fri, Dec 11, 2015 at 11:36:06AM +0100, Frederik Völkel wrote:
> > The patch replaces the spaces used for indentation at some points with
> > tabs.
> > 
> > Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
> > Signed-off-by: Lukas Braun <lukas.braun@fau.de>
> > ---
> >  drivers/tty/serial/68328serial.c | 82 ++++++++++++++++++++--------------------
> >  1 file changed, 41 insertions(+), 41 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
> > index 0982c1a..22f52e0 100644
> > --- a/drivers/tty/serial/68328serial.c
> > +++ b/drivers/tty/serial/68328serial.c
> > @@ -228,17 +228,17 @@ static int rs_put_char(char ch)
> >  	unsigned long flags;
> >  	int loops = 0;
> >  
> > -        local_irq_save(flags);
> > +	local_irq_save(flags);
> >  
> >  	while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
> > -        	loops++;
> > -        	udelay(5);
> > -        }
> > +		loops++;
> > +		udelay(5);
> > +	}
> >  
> >  	UTX_TXDATA = ch;
> > -        udelay(5);
> > -        local_irq_restore(flags);
> > -        return 1;
> > +	udelay(5);
> > +	local_irq_restore(flags);
> > +	return 1;
> >  }
> >  
> >  static void rs_start(struct tty_struct *tty)
> > @@ -268,7 +268,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
> >  
> >  	/*
> >  	 * This do { } while() loop will get ALL chars out of Rx FIFO 
> > -         */
> > +	 */
> >  #ifndef CONFIG_XCOPILOT_BUGS
> >  	do {
> >  #endif	
> > @@ -400,7 +400,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
> >  	 */
> >  #ifdef USE_INTS
> >  	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
> > -                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
> > +		USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
> >  #else
> >  	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
> >  #endif
> > @@ -473,24 +473,24 @@ struct {
> >  };
> >  #else
> >   hw_baud_table[18] = {
> > -                 {0, 0}, /* 0 */
> > -                 {0, 0}, /* 50 */
> > -                 {0, 0}, /* 75 */
> > -                 {0, 0}, /* 110 */
> > -                 {0, 0}, /* 134 */
> > -                 {0, 0}, /* 150 */
> > -                 {0, 0}, /* 200 */
> > -                 {0, 0}, /* 300 */
> > -                 {7, 0x26}, /* 600 */
> > -                 {6, 0x26}, /* 1200 */
> > -                 {0, 0}, /* 1800 */
> > -                 {5, 0x26}, /* 2400 */
> > -                 {4, 0x26}, /* 4800 */
> > -                 {3, 0x26}, /* 9600 */
> > -                 {2, 0x26}, /* 19200 */
> > -                 {1, 0x26}, /* 38400 */
> > -                 {0, 0x26}, /* 57600 */
> > -                 {1, 0x38}, /* 115200 */
> > +	{0, 0}, /* 0 */
> > +	{0, 0}, /* 50 */
> > +	{0, 0}, /* 75 */
> > +	{0, 0}, /* 110 */
> > +	{0, 0}, /* 134 */
> > +	{0, 0}, /* 150 */
> > +	{0, 0}, /* 200 */
> > +	{0, 0}, /* 300 */
> > +	{7, 0x26}, /* 600 */
> > +	{6, 0x26}, /* 1200 */
> > +	{0, 0}, /* 1800 */
> > +	{5, 0x26}, /* 2400 */
> > +	{4, 0x26}, /* 4800 */
> > +	{3, 0x26}, /* 9600 */
> > +	{2, 0x26}, /* 19200 */
> > +	{1, 0x26}, /* 38400 */
> > +	{0, 0x26}, /* 57600 */
> > +	{1, 0x38}, /* 115200 */
> >  }; 
> >  #endif
> >  /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
> > @@ -516,9 +516,9 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
> >  	uart->ustcnt = ustcnt & ~USTCNT_TXEN;
> >  
> >  	i = cflag & CBAUD;
> > -        if (i & CBAUDEX) {
> > -                i = (i & ~CBAUDEX) + B38400;
> > -        }
> > +	if (i & CBAUDEX) {
> > +		i = (i & ~CBAUDEX) + B38400;
> > +	}
> >  
> >  	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
> >  		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
> > @@ -907,16 +907,16 @@ static int get_lsr_info(struct m68k_serial *info, unsigned int *value)
> >  static void send_break(struct m68k_serial *info, unsigned int duration)
> >  {
> >  	m68328_uart *uart = &uart_addr[info->line];
> > -        unsigned long flags;
> > -        if (!info->port)
> > -                return;
> > -        local_irq_save(flags);
> > +	unsigned long flags;
> > +	if (!info->port)
> > +		return;
> > +	local_irq_save(flags);
> >  #ifdef USE_INTS	
> >  	uart->utx.w |= UTX_SEND_BREAK;
> >  	msleep_interruptible(duration);
> >  	uart->utx.w &= ~UTX_SEND_BREAK;
> >  #endif		
> > -        local_irq_restore(flags);
> > +	local_irq_restore(flags);
> >  }
> >  
> >  static int rs_ioctl(struct tty_struct *tty,
> > @@ -1206,7 +1206,7 @@ rs68328_init(void)
> >  			    rs_interrupt,
> >  			    0,
> >  			    "M68328_UART", info))
> > -                panic("Unable to attach 68328 serial interrupt\n");
> > +		panic("Unable to attach 68328 serial interrupt\n");
> >  
> >  	    tty_port_link_device(&info->tport, serial_driver, i);
> >  	}
> > @@ -1295,11 +1295,11 @@ void m68328_console_write (struct console *co, const char *str,
> >  {
> >  	if (!m68328_console_initted)
> >  		m68328_set_baud();
> > -    while (count--) {
> > -        if (*str == '\n')
> > -           rs_put_char('\r');
> > -        rs_put_char(*str++);
> > -    }
> > +	while (count--) {
> > +		if (*str == '\n')
> > +		    rs_put_char('\r');
> > +	rs_put_char(*str++);
> 
> This line should also be indented one more tab, right?
> 
> > +	}
> 
> Please fix up and resend.

And resend the rest of the patches in this series, I stopped applying
them here, but applied the previous ones.

thanks,

greg k-h

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

* Re: [PATCH 0/9] Fix checkpatch errors
  2015-12-13  7:06 ` [PATCH 0/9] Fix checkpatch errors Greg KH
@ 2015-12-13 17:44   ` Frederik
  2015-12-13 18:15     ` Nicolai Stange
  0 siblings, 1 reply; 32+ messages in thread
From: Frederik @ 2015-12-13 17:44 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linux-serial, jslaby, linux-kernel, lukas.braun

On Sat, 12. Dec 23:06, Greg KH wrote:
> On Fri, Dec 11, 2015 at 11:36:00AM +0100, Frederik Völkel wrote:
> > This patch series fixes all checkpatch error in 68328serial.c except
> > 5 trailing whitespace errors we are unsure how to fix.
> 
> What are the errors you are not sure how to fix?
> 
> thanks,
> 
> greg k-h

All 5 errors are at comments. It is not clear to us where exactly the
trailing whitespace is checkpatch complains(lines 271, 770, 889, 993
and 1040).

Greetings,

Lukas and Frederik

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

* Re: [PATCH 0/9] Fix checkpatch errors
  2015-12-13 17:44   ` Frederik
@ 2015-12-13 18:15     ` Nicolai Stange
  2015-12-13 18:26       ` Frederik
  0 siblings, 1 reply; 32+ messages in thread
From: Nicolai Stange @ 2015-12-13 18:15 UTC (permalink / raw)
  To: Frederik
  Cc: Greg KH, linux-kernel, linux-serial, jslaby, linux-kernel, lukas.braun

Frederik <frederik.voelkel@fau.de> writes:

> On Sat, 12. Dec 23:06, Greg KH wrote:
>> On Fri, Dec 11, 2015 at 11:36:00AM +0100, Frederik Völkel wrote:
>> > This patch series fixes all checkpatch error in 68328serial.c except
>> > 5 trailing whitespace errors we are unsure how to fix.
>> 
>> What are the errors you are not sure how to fix?
>> 
>> thanks,
>> 
>> greg k-h
>
> All 5 errors are at comments. It is not clear to us where exactly the
> trailing whitespace is checkpatch complains(lines 271, 770, 889, 993
> and 1040).

W/o your series applied (so line numbering might be slightly
different), checkpatch.pl says:

  ERROR: trailing whitespace
  #270: FILE: -:270:
  +^I * This do { } while() loop will get ALL chars out of Rx FIFO $

AFAICS, your patch [7/9] ("drivers: tty: 68328serial.c: remove trailing
whitespaces") doesn't fix this one.

In good old regexp tradition, the '$' sign denotes the end of line. So,
there is a single space after "FIFO" and before the end of line.

If you happen to be Emacs users, consider trying out whitespace-mode.
If not, try to find another way to make your editor visualize whitespace
somehow.

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

* Re: [PATCH 0/9] Fix checkpatch errors
  2015-12-13 18:15     ` Nicolai Stange
@ 2015-12-13 18:26       ` Frederik
  2015-12-13 20:31         ` Ken Moffat
  0 siblings, 1 reply; 32+ messages in thread
From: Frederik @ 2015-12-13 18:26 UTC (permalink / raw)
  To: Nicolai Stange
  Cc: Greg KH, linux-kernel, linux-serial, jslaby, linux-kernel, lukas.braun

On Sun, 13. Dec 19:15, Nicolai Stange wrote:
> Frederik <frederik.voelkel@fau.de> writes:
> 
> > On Sat, 12. Dec 23:06, Greg KH wrote:
> >> On Fri, Dec 11, 2015 at 11:36:00AM +0100, Frederik Völkel wrote:
> >> > This patch series fixes all checkpatch error in 68328serial.c except
> >> > 5 trailing whitespace errors we are unsure how to fix.
> >> 
> >> What are the errors you are not sure how to fix?
> >> 
> >> thanks,
> >> 
> >> greg k-h
> >
> > All 5 errors are at comments. It is not clear to us where exactly the
> > trailing whitespace is checkpatch complains(lines 271, 770, 889, 993
> > and 1040).
> 
> W/o your series applied (so line numbering might be slightly
> different), checkpatch.pl says:
> 
>   ERROR: trailing whitespace
>   #270: FILE: -:270:
>   +^I * This do { } while() loop will get ALL chars out of Rx FIFO $
> 
> AFAICS, your patch [7/9] ("drivers: tty: 68328serial.c: remove trailing
> whitespaces") doesn't fix this one.
> 
> In good old regexp tradition, the '$' sign denotes the end of line. So,
> there is a single space after "FIFO" and before the end of line.
> 
> If you happen to be Emacs users, consider trying out whitespace-mode.
> If not, try to find another way to make your editor visualize whitespace
> somehow.

Oh right I see. We will fix that and resend.

Thank you!

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

* Re: [PATCH 0/9] Fix checkpatch errors
  2015-12-13 18:26       ` Frederik
@ 2015-12-13 20:31         ` Ken Moffat
  0 siblings, 0 replies; 32+ messages in thread
From: Ken Moffat @ 2015-12-13 20:31 UTC (permalink / raw)
  To: Frederik
  Cc: Nicolai Stange, Greg KH, linux-kernel, linux-serial, jslaby,
	linux-kernel, lukas.braun

On Sun, Dec 13, 2015 at 07:26:04PM +0100, Frederik wrote:
> On Sun, 13. Dec 19:15, Nicolai Stange wrote:
> > Frederik <frederik.voelkel@fau.de> writes:
> > 
> > W/o your series applied (so line numbering might be slightly
> > different), checkpatch.pl says:
> > 
> >   ERROR: trailing whitespace
> >   #270: FILE: -:270:
> >   +^I * This do { } while() loop will get ALL chars out of Rx FIFO $
> > 
> > AFAICS, your patch [7/9] ("drivers: tty: 68328serial.c: remove trailing
> > whitespaces") doesn't fix this one.
> > 
> > In good old regexp tradition, the '$' sign denotes the end of line. So,
> > there is a single space after "FIFO" and before the end of line.
> > 
> > If you happen to be Emacs users, consider trying out whitespace-mode.
> > If not, try to find another way to make your editor visualize whitespace
> > somehow.
> 
> Oh right I see. We will fix that and resend.
> 
> Thank you!
If you are using vim, I have the following in my .vimrc.  It was
originally posted here many years ago.  Seems to work on all my x86
boxes, but AFAIR it didn't work on a ppc, so might not work on other
architectures.

"for redundant whitespace, from Jeremy Kerr via Olof Johanson
highlight RedundantWhitespace ctermbg=red guibg=red
match RedundantWhitespace /\s\+$\| \+\ze\t/

HTH

ĸen
-- 
This email was written using 100% recycled letters.

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

* [PATCH v2 0/4] Fix checkpatch errors
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (9 preceding siblings ...)
  2015-12-13  7:06 ` [PATCH 0/9] Fix checkpatch errors Greg KH
@ 2015-12-16 15:16 ` Frederik Völkel
  2015-12-16 15:16   ` [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
                     ` (3 more replies)
  2015-12-18 11:28 ` [PATCH] serial: Remove 68328 driver Frederik Völkel
  11 siblings, 4 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-16 15:16 UTC (permalink / raw)
  To: gregkh, jslaby
  Cc: linux-serial, linux-kernel, lukas.braun, linux-kernel,
	Frederik Völkel

This is the rest of the previous patchseries witch fixes now all of the
whitespace errors and fixes the wrong indentation.

Frederik Völkel (4):
  drivers: tty: 68328serial.c: Use tabs for indentation
  drivers: tty: 68328serial.c: remove trailing whitespaces
  drivers: tty: 68328serial.c: Use use same indentation for switch/case
  drivers: tty: 68328serial.c: Move trailing statements to next line

 drivers/tty/serial/68328serial.c | 255 ++++++++++++++++++++-------------------
 1 file changed, 130 insertions(+), 125 deletions(-)

-- 
1.9.1


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

* [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation
  2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
@ 2015-12-16 15:16   ` Frederik Völkel
  2015-12-16 15:43     ` One Thousand Gnomes
  2015-12-16 15:16   ` [PATCH v2 2/4] drivers: tty: 68328serial.c: remove trailing whitespaces Frederik Völkel
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 32+ messages in thread
From: Frederik Völkel @ 2015-12-16 15:16 UTC (permalink / raw)
  To: gregkh, jslaby
  Cc: linux-serial, linux-kernel, lukas.braun, linux-kernel,
	Frederik Völkel

The patch replaces the spaces used for indentation at some points with
tabs.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 82 ++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 0982c1a..183f6d9 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -228,17 +228,17 @@ static int rs_put_char(char ch)
 	unsigned long flags;
 	int loops = 0;
 
-        local_irq_save(flags);
+	local_irq_save(flags);
 
 	while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
-        	loops++;
-        	udelay(5);
-        }
+		loops++;
+		udelay(5);
+	}
 
 	UTX_TXDATA = ch;
-        udelay(5);
-        local_irq_restore(flags);
-        return 1;
+	udelay(5);
+	local_irq_restore(flags);
+	return 1;
 }
 
 static void rs_start(struct tty_struct *tty)
@@ -268,7 +268,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
 
 	/*
 	 * This do { } while() loop will get ALL chars out of Rx FIFO 
-         */
+	 */
 #ifndef CONFIG_XCOPILOT_BUGS
 	do {
 #endif	
@@ -400,7 +400,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 	 */
 #ifdef USE_INTS
 	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
-                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
+		USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
 #else
 	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
 #endif
@@ -473,24 +473,24 @@ struct {
 };
 #else
  hw_baud_table[18] = {
-                 {0, 0}, /* 0 */
-                 {0, 0}, /* 50 */
-                 {0, 0}, /* 75 */
-                 {0, 0}, /* 110 */
-                 {0, 0}, /* 134 */
-                 {0, 0}, /* 150 */
-                 {0, 0}, /* 200 */
-                 {0, 0}, /* 300 */
-                 {7, 0x26}, /* 600 */
-                 {6, 0x26}, /* 1200 */
-                 {0, 0}, /* 1800 */
-                 {5, 0x26}, /* 2400 */
-                 {4, 0x26}, /* 4800 */
-                 {3, 0x26}, /* 9600 */
-                 {2, 0x26}, /* 19200 */
-                 {1, 0x26}, /* 38400 */
-                 {0, 0x26}, /* 57600 */
-                 {1, 0x38}, /* 115200 */
+	{0, 0}, /* 0 */
+	{0, 0}, /* 50 */
+	{0, 0}, /* 75 */
+	{0, 0}, /* 110 */
+	{0, 0}, /* 134 */
+	{0, 0}, /* 150 */
+	{0, 0}, /* 200 */
+	{0, 0}, /* 300 */
+	{7, 0x26}, /* 600 */
+	{6, 0x26}, /* 1200 */
+	{0, 0}, /* 1800 */
+	{5, 0x26}, /* 2400 */
+	{4, 0x26}, /* 4800 */
+	{3, 0x26}, /* 9600 */
+	{2, 0x26}, /* 19200 */
+	{1, 0x26}, /* 38400 */
+	{0, 0x26}, /* 57600 */
+	{1, 0x38}, /* 115200 */
 }; 
 #endif
 /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
@@ -516,9 +516,9 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 	uart->ustcnt = ustcnt & ~USTCNT_TXEN;
 
 	i = cflag & CBAUD;
-        if (i & CBAUDEX) {
-                i = (i & ~CBAUDEX) + B38400;
-        }
+	if (i & CBAUDEX) {
+		i = (i & ~CBAUDEX) + B38400;
+	}
 
 	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
 		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
@@ -907,16 +907,16 @@ static int get_lsr_info(struct m68k_serial *info, unsigned int *value)
 static void send_break(struct m68k_serial *info, unsigned int duration)
 {
 	m68328_uart *uart = &uart_addr[info->line];
-        unsigned long flags;
-        if (!info->port)
-                return;
-        local_irq_save(flags);
+	unsigned long flags;
+	if (!info->port)
+		return;
+	local_irq_save(flags);
 #ifdef USE_INTS	
 	uart->utx.w |= UTX_SEND_BREAK;
 	msleep_interruptible(duration);
 	uart->utx.w &= ~UTX_SEND_BREAK;
 #endif		
-        local_irq_restore(flags);
+	local_irq_restore(flags);
 }
 
 static int rs_ioctl(struct tty_struct *tty,
@@ -1206,7 +1206,7 @@ rs68328_init(void)
 			    rs_interrupt,
 			    0,
 			    "M68328_UART", info))
-                panic("Unable to attach 68328 serial interrupt\n");
+		panic("Unable to attach 68328 serial interrupt\n");
 
 	    tty_port_link_device(&info->tport, serial_driver, i);
 	}
@@ -1295,11 +1295,11 @@ void m68328_console_write (struct console *co, const char *str,
 {
 	if (!m68328_console_initted)
 		m68328_set_baud();
-    while (count--) {
-        if (*str == '\n')
-           rs_put_char('\r');
-        rs_put_char(*str++);
-    }
+	while (count--) {
+		if (*str == '\n')
+			rs_put_char('\r');
+		rs_put_char(*str++);
+	}
 }
 
 
-- 
1.9.1


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

* [PATCH v2 2/4] drivers: tty: 68328serial.c: remove trailing whitespaces
  2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
  2015-12-16 15:16   ` [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
@ 2015-12-16 15:16   ` Frederik Völkel
  2015-12-16 15:17   ` [PATCH v2 3/4] drivers: tty: 68328serial.c: Use use same indentation for switch/case Frederik Völkel
  2015-12-16 15:17   ` [PATCH v2 4/4] drivers: tty: 68328serial.c: Move trailing statements to next line Frederik Völkel
  3 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-16 15:16 UTC (permalink / raw)
  To: gregkh, jslaby
  Cc: linux-serial, linux-kernel, lukas.braun, linux-kernel,
	Frederik Völkel

This patch removes trailing whitespaces reported by checkpatch.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 98 ++++++++++++++++++++--------------------
 1 file changed, 49 insertions(+), 49 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 183f6d9..f7f9b7e 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -217,7 +217,7 @@ static void rs_stop(struct tty_struct *tty)
 
 	if (serial_paranoia_check(info, tty->name, "rs_stop"))
 		return;
-	
+
 	local_irq_save(flags);
 	uart->ustcnt &= ~USTCNT_TXEN;
 	local_irq_restore(flags);
@@ -246,10 +246,10 @@ static void rs_start(struct tty_struct *tty)
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
-	
+
 	if (serial_paranoia_check(info, tty->name, "rs_start"))
 		return;
-	
+
 	local_irq_save(flags);
 	if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
 #ifdef USE_INTS
@@ -267,13 +267,13 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
 	unsigned char ch, flag;
 
 	/*
-	 * This do { } while() loop will get ALL chars out of Rx FIFO 
+	 * This do { } while() loop will get ALL chars out of Rx FIFO
 	 */
 #ifndef CONFIG_XCOPILOT_BUGS
 	do {
-#endif	
+#endif
 		ch = GET_FIELD(rx, URX_RXDATA);
-	
+
 		if (info->is_cons) {
 			if (URX_BREAK & rx) { /* whee, break received */
 				return;
@@ -374,7 +374,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 {
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
-	
+
 	if (info->tport.flags & ASYNC_INITIALIZED)
 		return 0;
 
@@ -399,7 +399,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 	 * Finally, enable sequencing and interrupts
 	 */
 #ifdef USE_INTS
-	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
+	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
 		USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
 #else
 	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
@@ -434,7 +434,7 @@ static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
 		return;
 
 	local_irq_save(flags);
-	
+
 	if (info->xmit_buf) {
 		free_page((unsigned long) info->xmit_buf);
 		info->xmit_buf = 0;
@@ -442,7 +442,7 @@ static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
 
 	if (tty)
 		set_bit(TTY_IO_ERROR, &tty->flags);
-	
+
 	info->tport.flags &= ~ASYNC_INITIALIZED;
 	local_irq_restore(flags);
 }
@@ -491,7 +491,7 @@ struct {
 	{1, 0x26}, /* 38400 */
 	{0, 0x26}, /* 57600 */
 	{1, 0x38}, /* 115200 */
-}; 
+};
 #endif
 /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
 
@@ -520,14 +520,14 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 		i = (i & ~CBAUDEX) + B38400;
 	}
 
-	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
+	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
 		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
 
 	ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
-	
+
 	if ((cflag & CSIZE) == CS8)
 		ustcnt |= USTCNT_8_7;
-		
+
 	if (cflag & CSTOPB)
 		ustcnt |= USTCNT_STOP;
 
@@ -535,7 +535,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 		ustcnt |= USTCNT_PARITYEN;
 	if (cflag & PARODD)
 		ustcnt |= USTCNT_ODD_EVEN;
-	
+
 #ifdef CONFIG_SERIAL_68328_RTS_CTS
 	if (cflag & CRTSCTS) {
 		uart->utx.w &= ~UTX_NOCTS;
@@ -545,7 +545,7 @@ static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
 #endif
 
 	ustcnt |= USTCNT_TXEN;
-	
+
 	uart->ustcnt = ustcnt;
 	return;
 }
@@ -590,7 +590,7 @@ static void rs_fair_output(void)
 void console_print_68328(const char *p)
 {
 	char c;
-	
+
 	while ((c = *(p++)) != 0) {
 		if (c == '\n')
 			rs_put_char('\r');
@@ -611,7 +611,7 @@ static void rs_set_ldisc(struct tty_struct *tty)
 		return;
 
 	info->is_cons = (tty->termios.c_line == N_TTY);
-	
+
 	printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
 }
 
@@ -677,7 +677,7 @@ static int rs_write(struct tty_struct *tty,
 
 	local_save_flags(flags);
 	while (1) {
-		local_irq_disable();		
+		local_irq_disable();
 		c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
 				   SERIAL_XMIT_SIZE - info->xmit_head));
 		local_irq_restore(flags);
@@ -698,7 +698,7 @@ static int rs_write(struct tty_struct *tty,
 
 	if (info->xmit_cnt && !tty->stopped) {
 		/* Enable transmitter */
-		local_irq_disable();		
+		local_irq_disable();
 #ifndef USE_INTS
 		while (info->xmit_cnt) {
 #endif
@@ -728,7 +728,7 @@ static int rs_write_room(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	int	ret;
-				
+
 	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
 		return 0;
 	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
@@ -740,7 +740,7 @@ static int rs_write_room(struct tty_struct *tty)
 static int rs_chars_in_buffer(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-				
+
 	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
 		return 0;
 	return info->xmit_cnt;
@@ -750,7 +750,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
 	unsigned long flags;
-				
+
 	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
 		return;
 	local_irq_save(flags);
@@ -762,7 +762,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
 /*
  * ------------------------------------------------------------
  * rs_throttle()
- * 
+ *
  * This routine is called by the upper-layer tty layer to signal that
  * incoming characters should be throttled.
  * ------------------------------------------------------------
@@ -773,7 +773,7 @@ static void rs_throttle(struct tty_struct *tty)
 
 	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
-	
+
 	if (I_IXOFF(tty))
 		info->x_char = STOP_CHAR(tty);
 
@@ -786,7 +786,7 @@ static void rs_unthrottle(struct tty_struct *tty)
 
 	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
-	
+
 	if (I_IXOFF(tty)) {
 		if (info->x_char)
 			info->x_char = 0;
@@ -807,7 +807,7 @@ static int get_serial_info(struct m68k_serial *info,
 			   struct serial_struct *retinfo)
 {
 	struct serial_struct tmp;
-  
+
 	if (!retinfo)
 		return -EFAULT;
 	memset(&tmp, 0, sizeof(tmp));
@@ -832,7 +832,7 @@ static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
 	struct tty_port *port = &info->tport;
 	struct serial_struct new_serial;
 	struct m68k_serial old_info;
-	int 			retval = 0;
+	int			retval = 0;
 
 	if (!new_info)
 		return -EFAULT;
@@ -881,7 +881,7 @@ check_and_exit:
  * 	    release the bus after transmitting. This must be done when
  * 	    the transmit shift register is empty, not be done when the
  * 	    transmit holding register is empty.  This functionality
- * 	    allows an RS485 driver to be written in user space. 
+ *	    allows an RS485 driver to be written in user space.
  */
 static int get_lsr_info(struct m68k_serial *info, unsigned int *value)
 {
@@ -911,11 +911,11 @@ static void send_break(struct m68k_serial *info, unsigned int duration)
 	if (!info->port)
 		return;
 	local_irq_save(flags);
-#ifdef USE_INTS	
+#ifdef USE_INTS
 	uart->utx.w |= UTX_SEND_BREAK;
 	msleep_interruptible(duration);
 	uart->utx.w &= ~UTX_SEND_BREAK;
-#endif		
+#endif
 	local_irq_restore(flags);
 }
 
@@ -934,7 +934,7 @@ static int rs_ioctl(struct tty_struct *tty,
 		if (tty->flags & (1 << TTY_IO_ERROR))
 		    return -EIO;
 	}
-	
+
 	switch (cmd) {
 		case TCSBRK:	/* SVID version: non-zero arg --> no break */
 			retval = tty_check_change(tty);
@@ -979,13 +979,13 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	if ((old_termios->c_cflag & CRTSCTS) &&
 	    !(tty->termios.c_cflag & CRTSCTS))
 		rs_start(tty);
-	
+
 }
 
 /*
  * ------------------------------------------------------------
  * rs_close()
- * 
+ *
  * This routine is called when the serial port gets closed.  First, we
  * wait for the last remaining data to be sent.  Then, we unlink its
  * S structure from the interrupt chain if necessary, and we free
@@ -1001,14 +1001,14 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 
 	if (serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
-	
+
 	local_irq_save(flags);
-	
+
 	if (tty_hung_up_p(filp)) {
 		local_irq_restore(flags);
 		return;
 	}
-	
+
 	if ((tty->count == 1) && (port->count != 1)) {
 		/*
 		 * Uh, oh.  tty->count is 1, which means that the tty
@@ -1032,7 +1032,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 	}
 	port->flags |= ASYNC_CLOSING;
 	/*
-	 * Now we wait for the transmit buffer to clear; and we notify 
+	 * Now we wait for the transmit buffer to clear; and we notify
 	 * the line discipline to only process XON/XOFF characters.
 	 */
 	tty->closing = 1;
@@ -1050,11 +1050,11 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 
 	shutdown(info, tty);
 	rs_flush_buffer(tty);
-		
+
 	tty_ldisc_flush(tty);
 	tty->closing = 0;
 	tty_port_tty_set(&info->tport, NULL);
-#warning "This is not and has never been valid so fix it"	
+#warning "This is not and has never been valid so fix it"
 #if 0
 	if (tty->ldisc.num != ldiscs[N_TTY].num) {
 		if (tty->ldisc.close)
@@ -1064,7 +1064,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 		if (tty->ldisc.open)
 			(tty->ldisc.open)(tty);
 	}
-#endif	
+#endif
 	if (port->blocked_open) {
 		if (port->close_delay)
 			msleep_interruptible(jiffies_to_msecs(port->close_delay));
@@ -1080,10 +1080,10 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 void rs_hangup(struct tty_struct *tty)
 {
 	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	
+
 	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
 		return;
-	
+
 	rs_flush_buffer(tty);
 	shutdown(info, tty);
 	info->tport.count = 0;
@@ -1166,14 +1166,14 @@ rs68328_init(void)
 
 	/* Initialize the tty_driver structure */
 	/* SPARC: Not all of this is exactly right for us. */
-	
+
 	serial_driver->name = "ttyS";
 	serial_driver->major = TTY_MAJOR;
 	serial_driver->minor_start = 64;
 	serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
 	serial_driver->subtype = SERIAL_TYPE_NORMAL;
 	serial_driver->init_termios = tty_std_termios;
-	serial_driver->init_termios.c_cflag = 
+	serial_driver->init_termios.c_cflag =
 			m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
 	serial_driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(serial_driver, &rs_ops);
@@ -1192,11 +1192,11 @@ rs68328_init(void)
 	    info->x_char = 0;
 	    info->line = i;
 	    info->is_cons = 1; /* Means shortcuts work */
-	    
-	    printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line, 
+
+	    printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
 		   info->port, info->irq);
 	    printk(" is a builtin MC68328 UART\n");
-	    
+
 #ifdef CONFIG_M68VZ328
 		if (i > 0)
 			PJSEL &= 0xCF;  /* PSW enable second port output */
@@ -1244,7 +1244,7 @@ again:
 		goto again;
 	}
 
-	UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
+	UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
 		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
 	ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
 	ustcnt |= USTCNT_8_7;
-- 
1.9.1


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

* [PATCH v2 3/4] drivers: tty: 68328serial.c: Use use same indentation for switch/case
  2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
  2015-12-16 15:16   ` [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
  2015-12-16 15:16   ` [PATCH v2 2/4] drivers: tty: 68328serial.c: remove trailing whitespaces Frederik Völkel
@ 2015-12-16 15:17   ` Frederik Völkel
  2015-12-16 15:17   ` [PATCH v2 4/4] drivers: tty: 68328serial.c: Move trailing statements to next line Frederik Völkel
  3 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-16 15:17 UTC (permalink / raw)
  To: gregkh, jslaby
  Cc: linux-serial, linux-kernel, lukas.braun, linux-kernel,
	Frederik Völkel

This patch fixes an indentation checkpatch error so switch and case
have the same indentation.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 60 ++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index f7f9b7e..c0bd3a6 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -936,37 +936,37 @@ static int rs_ioctl(struct tty_struct *tty,
 	}
 
 	switch (cmd) {
-		case TCSBRK:	/* SVID version: non-zero arg --> no break */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			if (!arg)
-				send_break(info, 250);	/* 1/4 second */
-			return 0;
-		case TCSBRKP:	/* support for POSIX tcsendbreak() */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			send_break(info, arg ? arg*(100) : 250);
-			return 0;
-		case TIOCGSERIAL:
-			return get_serial_info(info,
+	case TCSBRK:	/* SVID version: non-zero arg --> no break */
+		retval = tty_check_change(tty);
+		if (retval)
+			return retval;
+		tty_wait_until_sent(tty, 0);
+		if (!arg)
+			send_break(info, 250);	/* 1/4 second */
+		return 0;
+	case TCSBRKP:	/* support for POSIX tcsendbreak() */
+		retval = tty_check_change(tty);
+		if (retval)
+			return retval;
+		tty_wait_until_sent(tty, 0);
+		send_break(info, arg ? arg*(100) : 250);
+		return 0;
+	case TIOCGSERIAL:
+		return get_serial_info(info,
+			       (struct serial_struct *) arg);
+	case TIOCSSERIAL:
+		return set_serial_info(info, tty,
 				       (struct serial_struct *) arg);
-		case TIOCSSERIAL:
-			return set_serial_info(info, tty,
-					       (struct serial_struct *) arg);
-		case TIOCSERGETLSR: /* Get line status register */
-			return get_lsr_info(info, (unsigned int *) arg);
-		case TIOCSERGSTRUCT:
-			if (copy_to_user((struct m68k_serial *) arg,
-				    info, sizeof(struct m68k_serial)))
-				return -EFAULT;
-			return 0;
-		default:
-			return -ENOIOCTLCMD;
-		}
+	case TIOCSERGETLSR: /* Get line status register */
+		return get_lsr_info(info, (unsigned int *) arg);
+	case TIOCSERGSTRUCT:
+		if (copy_to_user((struct m68k_serial *) arg,
+			    info, sizeof(struct m68k_serial)))
+			return -EFAULT;
+		return 0;
+	default:
+		return -ENOIOCTLCMD;
+	}
 	return 0;
 }
 
-- 
1.9.1


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

* [PATCH v2 4/4] drivers: tty: 68328serial.c: Move trailing statements to next line
  2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
                     ` (2 preceding siblings ...)
  2015-12-16 15:17   ` [PATCH v2 3/4] drivers: tty: 68328serial.c: Use use same indentation for switch/case Frederik Völkel
@ 2015-12-16 15:17   ` Frederik Völkel
  3 siblings, 0 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-16 15:17 UTC (permalink / raw)
  To: gregkh, jslaby
  Cc: linux-serial, linux-kernel, lukas.braun, linux-kernel,
	Frederik Völkel

This patch moves trailing statements to the next line as checkpatch
suggests.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
 drivers/tty/serial/68328serial.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index c0bd3a6..f5224aa 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -195,7 +195,8 @@ static inline int get_baud(struct m68k_serial *ss)
 {
 	unsigned long result = 115200;
 	unsigned short int baud = uart_addr[ss->line].ubaud;
-	if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
+	if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38)
+		result = 38400;
 	result >>= GET_FIELD(baud, UBAUD_DIVIDE);
 
 	return result;
@@ -560,8 +561,10 @@ static void rs_fair_output(void)
 	struct m68k_serial *info = &m68k_soft[0];
 	char c;
 
-	if (info == NULL) return;
-	if (info->xmit_buf == NULL) return;
+	if (info == NULL)
+		return;
+	if (info->xmit_buf == NULL)
+		return;
 
 	local_irq_save(flags);
 	left = info->xmit_cnt;
@@ -653,7 +656,8 @@ static void rs_flush_chars(struct tty_struct *tty)
 	}
 
 #ifndef USE_INTS
-	while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
+	while (!(uart->utx.w & UTX_TX_AVAIL))
+		udelay(5);
 	}
 #endif
 	local_irq_restore(flags);
@@ -707,7 +711,8 @@ static int rs_write(struct tty_struct *tty,
 #ifdef USE_INTS
 		uart->ustcnt |= USTCNT_TX_INTR_MASK;
 #else
-		while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
+		while (!(uart->utx.w & UTX_TX_AVAIL))
+			udelay(5);
 #endif
 		if (uart->utx.w & UTX_TX_AVAIL) {
 			uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
-- 
1.9.1


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

* Re: [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation
  2015-12-16 15:16   ` [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
@ 2015-12-16 15:43     ` One Thousand Gnomes
  2015-12-16 16:25       ` Peter Hurley
  0 siblings, 1 reply; 32+ messages in thread
From: One Thousand Gnomes @ 2015-12-16 15:43 UTC (permalink / raw)
  To: Frederik Völkel
  Cc: gregkh, jslaby, linux-serial, linux-kernel, lukas.braun, linux-kernel

On Wed, 16 Dec 2015 16:16:58 +0100
Frederik Völkel <frederik.voelkel@fau.de> wrote:

> The patch replaces the spaces used for indentation at some points with
> tabs.

Are you actually still using this driver or just randomly cleaning stuff
up. If the former is the case then there are some other fairly major
things wrong with it, but otherwise I'd really suggest someone just
deletes it instead.

Alan

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

* Re: [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation
  2015-12-16 15:43     ` One Thousand Gnomes
@ 2015-12-16 16:25       ` Peter Hurley
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Hurley @ 2015-12-16 16:25 UTC (permalink / raw)
  To: One Thousand Gnomes, Frederik Völkel, gregkh
  Cc: jslaby, linux-serial, linux-kernel, lukas.braun, linux-kernel

On 12/16/2015 07:43 AM, One Thousand Gnomes wrote:
> otherwise I'd really suggest someone just deletes it instead.

Yes, please.

Or at least demote it to staging where it can languish until deleted.


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

* [PATCH] serial: Remove 68328 driver
  2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
                   ` (10 preceding siblings ...)
  2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
@ 2015-12-18 11:28 ` Frederik Völkel
  2015-12-18 14:27     ` Geert Uytterhoeven
  2016-01-11 17:53   ` Peter Hurley
  11 siblings, 2 replies; 32+ messages in thread
From: Frederik Völkel @ 2015-12-18 11:28 UTC (permalink / raw)
  To: jslaby, gregkh
  Cc: linux-serial, linux-kernel, linux-kernel, Frederik Völkel,
	Lukas Braun

It's old, messy and mostly unmaintained.
Remove it as suggested by Peter Hurley and Alan.

Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
Signed-off-by: Lukas Braun <lukas.braun@fau.de>
---
Should we remove other drivers like framebuffer as well?
It is probably useless without serial support.
---
 drivers/tty/serial/68328serial.c | 1322 --------------------------------------
 drivers/tty/serial/Kconfig       |   11 -
 drivers/tty/serial/Makefile      |    1 -
 3 files changed, 1334 deletions(-)
 delete mode 100644 drivers/tty/serial/68328serial.c

diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
deleted file mode 100644
index 0140ba4..0000000
--- a/drivers/tty/serial/68328serial.c
+++ /dev/null
@@ -1,1322 +0,0 @@
-/* 68328serial.c: Serial port driver for 68328 microcontroller
- *
- * Copyright (C) 1995       David S. Miller    <davem@caip.rutgers.edu>
- * Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
- * Copyright (C) 1998, 1999 D. Jeff Dionne     <jeff@uclinux.org>
- * Copyright (C) 1999       Vladimir Gurevich  <vgurevic@cisco.com>
- * Copyright (C) 2002-2003  David McCullough   <davidm@snapgear.com>
- * Copyright (C) 2002       Greg Ungerer       <gerg@snapgear.com>
- *
- * VZ Support/Fixes             Evan Stawnyczy <e@lineo.ca>
- * Multiple UART support        Daniel Potts <danielp@cse.unsw.edu.au>
- * Power management support     Daniel Potts <danielp@cse.unsw.edu.au>
- * VZ Second Serial Port enable Phil Wilshire
- * 2.4/2.5 port                 David McCullough
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/serial.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/mm.h>
-#include <linux/kernel.h>
-#include <linux/console.h>
-#include <linux/reboot.h>
-#include <linux/keyboard.h>
-#include <linux/init.h>
-#include <linux/pm.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
-#include <linux/gfp.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/delay.h>
-#include <asm/uaccess.h>
-
-/* (es) */
-/* note: perhaps we can murge these files, so that you can just
- * 	 define 1 of them, and they can sort that out for themselves
- */
-#if defined(CONFIG_M68EZ328)
-#include <asm/MC68EZ328.h>
-#else
-#if defined(CONFIG_M68VZ328)
-#include <asm/MC68VZ328.h>
-#else
-#include <asm/MC68328.h>
-#endif /* CONFIG_M68VZ328 */
-#endif /* CONFIG_M68EZ328 */
-
-/* Turn off usage of real serial interrupt code, to "support" Copilot */
-#ifdef CONFIG_XCOPILOT_BUGS
-#undef USE_INTS
-#else
-#define USE_INTS
-#endif
-
-/*
- * I believe this is the optimal setting that reduces the number of interrupts.
- * At high speeds the output might become a little "bursted" (use USTCNT_TXHE
- * if that bothers you), but in most cases it will not, since we try to
- * transmit characters every time rs_interrupt is called. Thus, quite often
- * you'll see that a receive interrupt occures before the transmit one.
- *                                  -- Vladimir Gurevich
- */
-#define USTCNT_TX_INTR_MASK (USTCNT_TXEE)
-
-/*
- * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special
- * "Old data interrupt" which occures whenever the data stay in the FIFO
- * longer than 30 bits time. This allows us to use FIFO without compromising
- * latency. '328 does not have this feature and without the real  328-based
- * board I would assume that RXRE is the safest setting.
- *
- * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of
- * interrupts. RXFE (receive queue full) causes the system to lose data
- * at least at 115200 baud
- *
- * If your board is busy doing other stuff, you might consider to use
- * RXRE (data ready intrrupt) instead.
- *
- * The other option is to make these INTR masks run-time configurable, so
- * that people can dynamically adapt them according to the current usage.
- *                                  -- Vladimir Gurevich
- */
-
-/* (es) */
-#if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328)
-#define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN)
-#elif defined(CONFIG_M68328)
-#define USTCNT_RX_INTR_MASK (USTCNT_RXRE)
-#else
-#error Please, define the Rx interrupt events for your CPU
-#endif
-/* (/es) */
-
-/*
- * This is our internal structure for each serial port's state.
- */
-struct m68k_serial {
-	struct tty_port		tport;
-	char			is_cons;	/* Is this our console. */
-	int			magic;
-	int			baud_base;
-	int			port;
-	int			irq;
-	int			type;		/* UART type */
-	int			custom_divisor;
-	int			x_char;		/* xon/xoff character */
-	int			line;
-	unsigned char		*xmit_buf;
-	int			xmit_head;
-	int			xmit_tail;
-	int			xmit_cnt;
-};
-
-#define SERIAL_MAGIC 0x5301
-
-/*
- * Define the number of ports supported and their irqs.
- */
-#define NR_PORTS 1
-
-static struct m68k_serial m68k_soft[NR_PORTS];
-
-static unsigned int uart_irqs[NR_PORTS] = { UART_IRQ_NUM };
-
-/* multiple ports are contiguous in memory */
-m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR;
-
-struct tty_driver *serial_driver;
-
-static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
-
-/*
- *	Setup for console. Argument comes from the boot command line.
- */
-
-/* note: this is messy, but it works, again, perhaps defined somewhere else?*/
-#ifdef CONFIG_M68VZ328
-#define CONSOLE_BAUD_RATE	19200
-#define DEFAULT_CBAUD		B19200
-#endif
-
-
-#ifndef CONSOLE_BAUD_RATE
-#define	CONSOLE_BAUD_RATE	9600
-#define	DEFAULT_CBAUD		B9600
-#endif
-
-
-static int m68328_console_initted = 0;
-static int m68328_console_baud    = CONSOLE_BAUD_RATE;
-static int m68328_console_cbaud   = DEFAULT_CBAUD;
-
-
-static inline int serial_paranoia_check(struct m68k_serial *info,
-					char *name, const char *routine)
-{
-#ifdef SERIAL_PARANOIA_CHECK
-	static const char *badmagic =
-		"Warning: bad magic number for serial struct %s in %s\n";
-	static const char *badinfo =
-		"Warning: null m68k_serial for %s in %s\n";
-
-	if (!info) {
-		printk(badinfo, name, routine);
-		return 1;
-	}
-	if (info->magic != SERIAL_MAGIC) {
-		printk(badmagic, name, routine);
-		return 1;
-	}
-#endif
-	return 0;
-}
-
-/*
- * This is used to figure out the divisor speeds and the timeouts
- */
-static int baud_table[] = {
-	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
-	9600, 19200, 38400, 57600, 115200, 0 };
-
-/* Utility routines */
-static inline int get_baud(struct m68k_serial *ss)
-{
-	unsigned long result = 115200;
-	unsigned short int baud = uart_addr[ss->line].ubaud;
-	if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
-	result >>= GET_FIELD(baud, UBAUD_DIVIDE);
-
-	return result;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_stop() and rs_start()
- *
- * This routines are called before setting or resetting tty->stopped.
- * They enable or disable transmitter interrupts, as necessary.
- * ------------------------------------------------------------
- */
-static void rs_stop(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long flags;
-
-	if (serial_paranoia_check(info, tty->name, "rs_stop"))
-		return;
-	
-	local_irq_save(flags);
-	uart->ustcnt &= ~USTCNT_TXEN;
-	local_irq_restore(flags);
-}
-
-static int rs_put_char(char ch)
-{
-	unsigned long flags;
-	int loops = 0;
-
-        local_irq_save(flags);
-
-	while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
-        	loops++;
-        	udelay(5);
-        }
-
-	UTX_TXDATA = ch;
-        udelay(5);
-        local_irq_restore(flags);
-        return 1;
-}
-
-static void rs_start(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long flags;
-	
-	if (serial_paranoia_check(info, tty->name, "rs_start"))
-		return;
-	
-	local_irq_save(flags);
-	if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
-#ifdef USE_INTS
-		uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
-#else
-		uart->ustcnt |= USTCNT_TXEN;
-#endif
-	}
-	local_irq_restore(flags);
-}
-
-static void receive_chars(struct m68k_serial *info, unsigned short rx)
-{
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned char ch, flag;
-
-	/*
-	 * This do { } while() loop will get ALL chars out of Rx FIFO 
-         */
-#ifndef CONFIG_XCOPILOT_BUGS
-	do {
-#endif	
-		ch = GET_FIELD(rx, URX_RXDATA);
-	
-		if(info->is_cons) {
-			if(URX_BREAK & rx) { /* whee, break received */
-				return;
-#ifdef CONFIG_MAGIC_SYSRQ
-			} else if (ch == 0x10) { /* ^P */
-				show_state();
-				show_free_areas(0);
-				show_buffers();
-/*				show_net_buffers(); */
-				return;
-			} else if (ch == 0x12) { /* ^R */
-				emergency_restart();
-				return;
-#endif /* CONFIG_MAGIC_SYSRQ */
-			}
-		}
-
-		flag = TTY_NORMAL;
-
-		if (rx & URX_PARITY_ERROR)
-			flag = TTY_PARITY;
-		else if (rx & URX_OVRUN)
-			flag = TTY_OVERRUN;
-		else if (rx & URX_FRAME_ERROR)
-			flag = TTY_FRAME;
-
-		tty_insert_flip_char(&info->tport, ch, flag);
-#ifndef CONFIG_XCOPILOT_BUGS
-	} while((rx = uart->urx.w) & URX_DATA_READY);
-#endif
-
-	tty_schedule_flip(&info->tport);
-}
-
-static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
-{
-	m68328_uart *uart = &uart_addr[info->line];
-
-	if (info->x_char) {
-		/* Send next char */
-		uart->utx.b.txdata = info->x_char;
-		info->x_char = 0;
-		goto clear_and_return;
-	}
-
-	if ((info->xmit_cnt <= 0) || !tty || tty->stopped) {
-		/* That's peculiar... TX ints off */
-		uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
-		goto clear_and_return;
-	}
-
-	/* Send char */
-	uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
-	info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
-	info->xmit_cnt--;
-
-	if(info->xmit_cnt <= 0) {
-		/* All done for now... TX ints off */
-		uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
-		goto clear_and_return;
-	}
-
-clear_and_return:
-	/* Clear interrupt (should be auto)*/
-	return;
-}
-
-/*
- * This is the serial driver's generic interrupt routine
- */
-irqreturn_t rs_interrupt(int irq, void *dev_id)
-{
-	struct m68k_serial *info = dev_id;
-	struct tty_struct *tty = tty_port_tty_get(&info->tport);
-	m68328_uart *uart;
-	unsigned short rx;
-	unsigned short tx;
-
-	uart = &uart_addr[info->line];
-	rx = uart->urx.w;
-
-#ifdef USE_INTS
-	tx = uart->utx.w;
-
-	if (rx & URX_DATA_READY)
-		receive_chars(info, rx);
-	if (tx & UTX_TX_AVAIL)
-		transmit_chars(info, tty);
-#else
-	receive_chars(info, rx);
-#endif
-	tty_kref_put(tty);
-
-	return IRQ_HANDLED;
-}
-
-static int startup(struct m68k_serial *info, struct tty_struct *tty)
-{
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long flags;
-	
-	if (info->tport.flags & ASYNC_INITIALIZED)
-		return 0;
-
-	if (!info->xmit_buf) {
-		info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
-		if (!info->xmit_buf)
-			return -ENOMEM;
-	}
-
-	local_irq_save(flags);
-
-	/*
-	 * Clear the FIFO buffers and disable them
-	 * (they will be reenabled in change_speed())
-	 */
-
-	uart->ustcnt = USTCNT_UEN;
-	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
-	(void)uart->urx.w;
-
-	/*
-	 * Finally, enable sequencing and interrupts
-	 */
-#ifdef USE_INTS
-	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | 
-                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
-#else
-	uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
-#endif
-
-	if (tty)
-		clear_bit(TTY_IO_ERROR, &tty->flags);
-	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-
-	/*
-	 * and set the speed of the serial port
-	 */
-
-	change_speed(info, tty);
-
-	info->tport.flags |= ASYNC_INITIALIZED;
-	local_irq_restore(flags);
-	return 0;
-}
-
-/*
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- */
-static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
-{
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long	flags;
-
-	uart->ustcnt = 0; /* All off! */
-	if (!(info->tport.flags & ASYNC_INITIALIZED))
-		return;
-
-	local_irq_save(flags);
-	
-	if (info->xmit_buf) {
-		free_page((unsigned long) info->xmit_buf);
-		info->xmit_buf = 0;
-	}
-
-	if (tty)
-		set_bit(TTY_IO_ERROR, &tty->flags);
-	
-	info->tport.flags &= ~ASYNC_INITIALIZED;
-	local_irq_restore(flags);
-}
-
-struct {
-	int divisor, prescale;
-}
-#ifndef CONFIG_M68VZ328
- hw_baud_table[18] = {
-	{0,0}, /* 0 */
-	{0,0}, /* 50 */
-	{0,0}, /* 75 */
-	{0,0}, /* 110 */
-	{0,0}, /* 134 */
-	{0,0}, /* 150 */
-	{0,0}, /* 200 */
-	{7,0x26}, /* 300 */
-	{6,0x26}, /* 600 */
-	{5,0x26}, /* 1200 */
-	{0,0}, /* 1800 */
-	{4,0x26}, /* 2400 */
-	{3,0x26}, /* 4800 */
-	{2,0x26}, /* 9600 */
-	{1,0x26}, /* 19200 */
-	{0,0x26}, /* 38400 */
-	{1,0x38}, /* 57600 */
-	{0,0x38}, /* 115200 */
-};
-#else
- hw_baud_table[18] = {
-                 {0,0}, /* 0 */
-                 {0,0}, /* 50 */
-                 {0,0}, /* 75 */
-                 {0,0}, /* 110 */
-                 {0,0}, /* 134 */
-                 {0,0}, /* 150 */
-                 {0,0}, /* 200 */
-                 {0,0}, /* 300 */
-                 {7,0x26}, /* 600 */
-                 {6,0x26}, /* 1200 */
-                 {0,0}, /* 1800 */
-                 {5,0x26}, /* 2400 */
-                 {4,0x26}, /* 4800 */
-                 {3,0x26}, /* 9600 */
-                 {2,0x26}, /* 19200 */
-                 {1,0x26}, /* 38400 */
-                 {0,0x26}, /* 57600 */
-                 {1,0x38}, /* 115200 */
-}; 
-#endif
-/* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
-
-/*
- * This routine is called to set the UART divisor registers to match
- * the specified baud rate for a serial port.
- */
-static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
-{
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned short port;
-	unsigned short ustcnt;
-	unsigned cflag;
-	int	i;
-
-	cflag = tty->termios.c_cflag;
-	port = info->port;
-	if (!port)
-		return;
-
-	ustcnt = uart->ustcnt;
-	uart->ustcnt = ustcnt & ~USTCNT_TXEN;
-
-	i = cflag & CBAUD;
-        if (i & CBAUDEX) {
-                i = (i & ~CBAUDEX) + B38400;
-        }
-
-	uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
-		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
-
-	ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
-	
-	if ((cflag & CSIZE) == CS8)
-		ustcnt |= USTCNT_8_7;
-		
-	if (cflag & CSTOPB)
-		ustcnt |= USTCNT_STOP;
-
-	if (cflag & PARENB)
-		ustcnt |= USTCNT_PARITYEN;
-	if (cflag & PARODD)
-		ustcnt |= USTCNT_ODD_EVEN;
-	
-#ifdef CONFIG_SERIAL_68328_RTS_CTS
-	if (cflag & CRTSCTS) {
-		uart->utx.w &= ~ UTX_NOCTS;
-	} else {
-		uart->utx.w |= UTX_NOCTS;
-	}
-#endif
-
-	ustcnt |= USTCNT_TXEN;
-	
-	uart->ustcnt = ustcnt;
-	return;
-}
-
-/*
- * Fair output driver allows a process to speak.
- */
-static void rs_fair_output(void)
-{
-	int left;		/* Output no more than that */
-	unsigned long flags;
-	struct m68k_serial *info = &m68k_soft[0];
-	char c;
-
-	if (info == NULL) return;
-	if (info->xmit_buf == NULL) return;
-
-	local_irq_save(flags);
-	left = info->xmit_cnt;
-	while (left != 0) {
-		c = info->xmit_buf[info->xmit_tail];
-		info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
-		info->xmit_cnt--;
-		local_irq_restore(flags);
-
-		rs_put_char(c);
-
-		local_irq_save(flags);
-		left = min(info->xmit_cnt, left-1);
-	}
-
-	/* Last character is being transmitted now (hopefully). */
-	udelay(5);
-
-	local_irq_restore(flags);
-	return;
-}
-
-/*
- * m68k_console_print is registered for printk.
- */
-void console_print_68328(const char *p)
-{
-	char c;
-	
-	while((c=*(p++)) != 0) {
-		if(c == '\n')
-			rs_put_char('\r');
-		rs_put_char(c);
-	}
-
-	/* Comment this if you want to have a strict interrupt-driven output */
-	rs_fair_output();
-
-	return;
-}
-
-static void rs_set_ldisc(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-
-	if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
-		return;
-
-	info->is_cons = (tty->termios.c_line == N_TTY);
-	
-	printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
-}
-
-static void rs_flush_chars(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long flags;
-
-	if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
-		return;
-#ifndef USE_INTS
-	for(;;) {
-#endif
-
-	/* Enable transmitter */
-	local_irq_save(flags);
-
-	if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) {
-		local_irq_restore(flags);
-		return;
-	}
-
-#ifdef USE_INTS
-	uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
-#else
-	uart->ustcnt |= USTCNT_TXEN;
-#endif
-
-#ifdef USE_INTS
-	if (uart->utx.w & UTX_TX_AVAIL) {
-#else
-	if (1) {
-#endif
-		/* Send char */
-		uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
-		info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
-		info->xmit_cnt--;
-	}
-
-#ifndef USE_INTS
-	while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
-	}
-#endif
-	local_irq_restore(flags);
-}
-
-extern void console_printn(const char * b, int count);
-
-static int rs_write(struct tty_struct * tty,
-		    const unsigned char *buf, int count)
-{
-	int	c, total = 0;
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long flags;
-
-	if (serial_paranoia_check(info, tty->name, "rs_write"))
-		return 0;
-
-	if (!tty || !info->xmit_buf)
-		return 0;
-
-	local_save_flags(flags);
-	while (1) {
-		local_irq_disable();		
-		c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
-				   SERIAL_XMIT_SIZE - info->xmit_head));
-		local_irq_restore(flags);
-
-		if (c <= 0)
-			break;
-
-		memcpy(info->xmit_buf + info->xmit_head, buf, c);
-
-		local_irq_disable();
-		info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
-		info->xmit_cnt += c;
-		local_irq_restore(flags);
-		buf += c;
-		count -= c;
-		total += c;
-	}
-
-	if (info->xmit_cnt && !tty->stopped) {
-		/* Enable transmitter */
-		local_irq_disable();		
-#ifndef USE_INTS
-		while(info->xmit_cnt) {
-#endif
-
-		uart->ustcnt |= USTCNT_TXEN;
-#ifdef USE_INTS
-		uart->ustcnt |= USTCNT_TX_INTR_MASK;
-#else
-		while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
-#endif
-		if (uart->utx.w & UTX_TX_AVAIL) {
-			uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
-			info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
-			info->xmit_cnt--;
-		}
-
-#ifndef USE_INTS
-		}
-#endif
-		local_irq_restore(flags);
-	}
-
-	return total;
-}
-
-static int rs_write_room(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	int	ret;
-				
-	if (serial_paranoia_check(info, tty->name, "rs_write_room"))
-		return 0;
-	ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
-	if (ret < 0)
-		ret = 0;
-	return ret;
-}
-
-static int rs_chars_in_buffer(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-				
-	if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
-		return 0;
-	return info->xmit_cnt;
-}
-
-static void rs_flush_buffer(struct tty_struct *tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-	unsigned long flags;
-				
-	if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
-		return;
-	local_irq_save(flags);
-	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-	local_irq_restore(flags);
-	tty_wakeup(tty);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_throttle()
- * 
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled.
- * ------------------------------------------------------------
- */
-static void rs_throttle(struct tty_struct * tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-
-	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
-		return;
-	
-	if (I_IXOFF(tty))
-		info->x_char = STOP_CHAR(tty);
-
-	/* Turn off RTS line (do this atomic) */
-}
-
-static void rs_unthrottle(struct tty_struct * tty)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-
-	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
-		return;
-	
-	if (I_IXOFF(tty)) {
-		if (info->x_char)
-			info->x_char = 0;
-		else
-			info->x_char = START_CHAR(tty);
-	}
-
-	/* Assert RTS line (do this atomic) */
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl() and friends
- * ------------------------------------------------------------
- */
-
-static int get_serial_info(struct m68k_serial * info,
-			   struct serial_struct * retinfo)
-{
-	struct serial_struct tmp;
-  
-	if (!retinfo)
-		return -EFAULT;
-	memset(&tmp, 0, sizeof(tmp));
-	tmp.type = info->type;
-	tmp.line = info->line;
-	tmp.port = info->port;
-	tmp.irq = info->irq;
-	tmp.flags = info->tport.flags;
-	tmp.baud_base = info->baud_base;
-	tmp.close_delay = info->tport.close_delay;
-	tmp.closing_wait = info->tport.closing_wait;
-	tmp.custom_divisor = info->custom_divisor;
-	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
-		return -EFAULT;
-
-	return 0;
-}
-
-static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
-			   struct serial_struct * new_info)
-{
-	struct tty_port *port = &info->tport;
-	struct serial_struct new_serial;
-	struct m68k_serial old_info;
-	int 			retval = 0;
-
-	if (!new_info)
-		return -EFAULT;
-	if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
-		return -EFAULT;
-	old_info = *info;
-
-	if (!capable(CAP_SYS_ADMIN)) {
-		if ((new_serial.baud_base != info->baud_base) ||
-		    (new_serial.type != info->type) ||
-		    (new_serial.close_delay != port->close_delay) ||
-		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
-		     (port->flags & ~ASYNC_USR_MASK)))
-			return -EPERM;
-		port->flags = ((port->flags & ~ASYNC_USR_MASK) |
-			       (new_serial.flags & ASYNC_USR_MASK));
-		info->custom_divisor = new_serial.custom_divisor;
-		goto check_and_exit;
-	}
-
-	if (port->count > 1)
-		return -EBUSY;
-
-	/*
-	 * OK, past this point, all the error checking has been done.
-	 * At this point, we start making changes.....
-	 */
-
-	info->baud_base = new_serial.baud_base;
-	port->flags = ((port->flags & ~ASYNC_FLAGS) |
-			(new_serial.flags & ASYNC_FLAGS));
-	info->type = new_serial.type;
-	port->close_delay = new_serial.close_delay;
-	port->closing_wait = new_serial.closing_wait;
-
-check_and_exit:
-	retval = startup(info, tty);
-	return retval;
-}
-
-/*
- * get_lsr_info - get line status register info
- *
- * Purpose: Let user call ioctl() to get info when the UART physically
- * 	    is emptied.  On bus types like RS485, the transmitter must
- * 	    release the bus after transmitting. This must be done when
- * 	    the transmit shift register is empty, not be done when the
- * 	    transmit holding register is empty.  This functionality
- * 	    allows an RS485 driver to be written in user space. 
- */
-static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
-{
-#ifdef CONFIG_SERIAL_68328_RTS_CTS
-	m68328_uart *uart = &uart_addr[info->line];
-#endif
-	unsigned char status;
-	unsigned long flags;
-
-	local_irq_save(flags);
-#ifdef CONFIG_SERIAL_68328_RTS_CTS
-	status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
-#else
-	status = 0;
-#endif
-	local_irq_restore(flags);
-	return put_user(status, value);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break(struct m68k_serial * info, unsigned int duration)
-{
-	m68328_uart *uart = &uart_addr[info->line];
-        unsigned long flags;
-        if (!info->port)
-                return;
-        local_irq_save(flags);
-#ifdef USE_INTS	
-	uart->utx.w |= UTX_SEND_BREAK;
-	msleep_interruptible(duration);
-	uart->utx.w &= ~UTX_SEND_BREAK;
-#endif		
-        local_irq_restore(flags);
-}
-
-static int rs_ioctl(struct tty_struct *tty,
-		    unsigned int cmd, unsigned long arg)
-{
-	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
-	int retval;
-
-	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
-		return -ENODEV;
-
-	if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
-	    (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD)  &&
-	    (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
-		if (tty->flags & (1 << TTY_IO_ERROR))
-		    return -EIO;
-	}
-	
-	switch (cmd) {
-		case TCSBRK:	/* SVID version: non-zero arg --> no break */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			if (!arg)
-				send_break(info, 250);	/* 1/4 second */
-			return 0;
-		case TCSBRKP:	/* support for POSIX tcsendbreak() */
-			retval = tty_check_change(tty);
-			if (retval)
-				return retval;
-			tty_wait_until_sent(tty, 0);
-			send_break(info, arg ? arg*(100) : 250);
-			return 0;
-		case TIOCGSERIAL:
-			return get_serial_info(info,
-				       (struct serial_struct *) arg);
-		case TIOCSSERIAL:
-			return set_serial_info(info, tty,
-					       (struct serial_struct *) arg);
-		case TIOCSERGETLSR: /* Get line status register */
-			return get_lsr_info(info, (unsigned int *) arg);
-		case TIOCSERGSTRUCT:
-			if (copy_to_user((struct m68k_serial *) arg,
-				    info, sizeof(struct m68k_serial)))
-				return -EFAULT;
-			return 0;
-		default:
-			return -ENOIOCTLCMD;
-		}
-	return 0;
-}
-
-static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
-{
-	struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
-
-	change_speed(info, tty);
-
-	if ((old_termios->c_cflag & CRTSCTS) &&
-	    !(tty->termios.c_cflag & CRTSCTS))
-		rs_start(tty);
-	
-}
-
-/*
- * ------------------------------------------------------------
- * rs_close()
- * 
- * This routine is called when the serial port gets closed.  First, we
- * wait for the last remaining data to be sent.  Then, we unlink its
- * S structure from the interrupt chain if necessary, and we free
- * that IRQ if nothing is left in the chain.
- * ------------------------------------------------------------
- */
-static void rs_close(struct tty_struct *tty, struct file * filp)
-{
-	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
-	struct tty_port *port = &info->tport;
-	m68328_uart *uart = &uart_addr[info->line];
-	unsigned long flags;
-
-	if (serial_paranoia_check(info, tty->name, "rs_close"))
-		return;
-	
-	local_irq_save(flags);
-	
-	if (tty_hung_up_p(filp)) {
-		local_irq_restore(flags);
-		return;
-	}
-	
-	if ((tty->count == 1) && (port->count != 1)) {
-		/*
-		 * Uh, oh.  tty->count is 1, which means that the tty
-		 * structure will be freed.  Info->count should always
-		 * be one in these conditions.  If it's greater than
-		 * one, we've got real problems, since it means the
-		 * serial port won't be shutdown.
-		 */
-		printk("rs_close: bad serial port count; tty->count is 1, "
-		       "port->count is %d\n", port->count);
-		port->count = 1;
-	}
-	if (--port->count < 0) {
-		printk("rs_close: bad serial port count for ttyS%d: %d\n",
-		       info->line, port->count);
-		port->count = 0;
-	}
-	if (port->count) {
-		local_irq_restore(flags);
-		return;
-	}
-	port->flags |= ASYNC_CLOSING;
-	/*
-	 * Now we wait for the transmit buffer to clear; and we notify 
-	 * the line discipline to only process XON/XOFF characters.
-	 */
-	tty->closing = 1;
-	if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, port->closing_wait);
-	/*
-	 * At this point we stop accepting input.  To do this, we
-	 * disable the receive line status interrupts, and tell the
-	 * interrupt driver to stop checking the data ready bit in the
-	 * line status register.
-	 */
-
-	uart->ustcnt &= ~USTCNT_RXEN;
-	uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
-
-	shutdown(info, tty);
-	rs_flush_buffer(tty);
-		
-	tty_ldisc_flush(tty);
-	tty->closing = 0;
-	tty_port_tty_set(&info->tport, NULL);
-#warning "This is not and has never been valid so fix it"	
-#if 0
-	if (tty->ldisc.num != ldiscs[N_TTY].num) {
-		if (tty->ldisc.close)
-			(tty->ldisc.close)(tty);
-		tty->ldisc = ldiscs[N_TTY];
-		tty->termios.c_line = N_TTY;
-		if (tty->ldisc.open)
-			(tty->ldisc.open)(tty);
-	}
-#endif	
-	if (port->blocked_open) {
-		if (port->close_delay)
-			msleep_interruptible(jiffies_to_msecs(port->close_delay));
-		wake_up_interruptible(&port->open_wait);
-	}
-	port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-	local_irq_restore(flags);
-}
-
-/*
- * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
- */
-void rs_hangup(struct tty_struct *tty)
-{
-	struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
-	
-	if (serial_paranoia_check(info, tty->name, "rs_hangup"))
-		return;
-	
-	rs_flush_buffer(tty);
-	shutdown(info, tty);
-	info->tport.count = 0;
-	info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
-	tty_port_tty_set(&info->tport, NULL);
-	wake_up_interruptible(&info->tport.open_wait);
-}
-
-/*
- * This routine is called whenever a serial port is opened.  It
- * enables interrupts for a serial port, linking in its S structure into
- * the IRQ chain.   It also performs the serial-specific
- * initialization for the tty structure.
- */
-int rs_open(struct tty_struct *tty, struct file * filp)
-{
-	struct m68k_serial	*info;
-	int retval;
-
-	info = &m68k_soft[tty->index];
-
-	if (serial_paranoia_check(info, tty->name, "rs_open"))
-		return -ENODEV;
-
-	info->tport.count++;
-	tty->driver_data = info;
-	tty_port_tty_set(&info->tport, tty);
-
-	/*
-	 * Start up serial port
-	 */
-	retval = startup(info, tty);
-	if (retval)
-		return retval;
-
-	return tty_port_block_til_ready(&info->tport, tty, filp);
-}
-
-/* Finally, routines used to initialize the serial driver. */
-
-static void show_serial_version(void)
-{
-	printk("MC68328 serial driver version 1.00\n");
-}
-
-static const struct tty_operations rs_ops = {
-	.open = rs_open,
-	.close = rs_close,
-	.write = rs_write,
-	.flush_chars = rs_flush_chars,
-	.write_room = rs_write_room,
-	.chars_in_buffer = rs_chars_in_buffer,
-	.flush_buffer = rs_flush_buffer,
-	.ioctl = rs_ioctl,
-	.throttle = rs_throttle,
-	.unthrottle = rs_unthrottle,
-	.set_termios = rs_set_termios,
-	.stop = rs_stop,
-	.start = rs_start,
-	.hangup = rs_hangup,
-	.set_ldisc = rs_set_ldisc,
-};
-
-static const struct tty_port_operations rs_port_ops = {
-};
-
-/* rs_init inits the driver */
-static int __init
-rs68328_init(void)
-{
-	unsigned long flags;
-	int i;
-	struct m68k_serial *info;
-
-	serial_driver = alloc_tty_driver(NR_PORTS);
-	if (!serial_driver)
-		return -ENOMEM;
-
-	show_serial_version();
-
-	/* Initialize the tty_driver structure */
-	/* SPARC: Not all of this is exactly right for us. */
-	
-	serial_driver->name = "ttyS";
-	serial_driver->major = TTY_MAJOR;
-	serial_driver->minor_start = 64;
-	serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
-	serial_driver->subtype = SERIAL_TYPE_NORMAL;
-	serial_driver->init_termios = tty_std_termios;
-	serial_driver->init_termios.c_cflag = 
-			m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
-	serial_driver->flags = TTY_DRIVER_REAL_RAW;
-	tty_set_operations(serial_driver, &rs_ops);
-
-	local_irq_save(flags);
-
-	for(i=0;i<NR_PORTS;i++) {
-
-	    info = &m68k_soft[i];
-	    tty_port_init(&info->tport);
-	    info->tport.ops = &rs_port_ops;
-	    info->magic = SERIAL_MAGIC;
-	    info->port = (int) &uart_addr[i];
-	    info->irq = uart_irqs[i];
-	    info->custom_divisor = 16;
-	    info->x_char = 0;
-	    info->line = i;
-	    info->is_cons = 1; /* Means shortcuts work */
-	    
-	    printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line, 
-		   info->port, info->irq);
-	    printk(" is a builtin MC68328 UART\n");
-	    
-#ifdef CONFIG_M68VZ328
-		if (i > 0 )
-			PJSEL &= 0xCF;  /* PSW enable second port output */
-#endif
-
-	    if (request_irq(uart_irqs[i],
-			    rs_interrupt,
-			    0,
-			    "M68328_UART", info))
-                panic("Unable to attach 68328 serial interrupt\n");
-
-	    tty_port_link_device(&info->tport, serial_driver, i);
-	}
-	local_irq_restore(flags);
-
-	if (tty_register_driver(serial_driver)) {
-		put_tty_driver(serial_driver);
-		for (i = 0; i < NR_PORTS; i++)
-			tty_port_destroy(&m68k_soft[i].tport);
-		printk(KERN_ERR "Couldn't register serial driver\n");
-		return -ENOMEM;
-	}
-
-	return 0;
-}
-
-module_init(rs68328_init);
-
-
-
-static void m68328_set_baud(void)
-{
-	unsigned short ustcnt;
-	int	i;
-
-	ustcnt = USTCNT;
-	USTCNT = ustcnt & ~USTCNT_TXEN;
-
-again:
-	for (i = 0; i < ARRAY_SIZE(baud_table); i++)
-		if (baud_table[i] == m68328_console_baud)
-			break;
-	if (i >= ARRAY_SIZE(baud_table)) {
-		m68328_console_baud = 9600;
-		goto again;
-	}
-
-	UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) | 
-		PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
-	ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
-	ustcnt |= USTCNT_8_7;
-	ustcnt |= USTCNT_TXEN;
-	USTCNT = ustcnt;
-	m68328_console_initted = 1;
-	return;
-}
-
-
-int m68328_console_setup(struct console *cp, char *arg)
-{
-	int		i, n = CONSOLE_BAUD_RATE;
-
-	if (!cp)
-		return(-1);
-
-	if (arg)
-		n = simple_strtoul(arg,NULL,0);
-
-	for (i = 0; i < ARRAY_SIZE(baud_table); i++)
-		if (baud_table[i] == n)
-			break;
-	if (i < ARRAY_SIZE(baud_table)) {
-		m68328_console_baud = n;
-		m68328_console_cbaud = 0;
-		if (i > 15) {
-			m68328_console_cbaud |= CBAUDEX;
-			i -= 15;
-		}
-		m68328_console_cbaud |= i;
-	}
-
-	m68328_set_baud(); /* make sure baud rate changes */
-	return(0);
-}
-
-
-static struct tty_driver *m68328_console_device(struct console *c, int *index)
-{
-	*index = c->index;
-	return serial_driver;
-}
-
-
-void m68328_console_write (struct console *co, const char *str,
-			   unsigned int count)
-{
-	if (!m68328_console_initted)
-		m68328_set_baud();
-    while (count--) {
-        if (*str == '\n')
-           rs_put_char('\r');
-        rs_put_char( *str++ );
-    }
-}
-
-
-static struct console m68328_driver = {
-	.name		= "ttyS",
-	.write		= m68328_console_write,
-	.device		= m68328_console_device,
-	.setup		= m68328_console_setup,
-	.flags		= CON_PRINTBUFFER,
-	.index		= -1,
-};
-
-
-static int __init m68328_console_init(void)
-{
-	register_console(&m68328_driver);
-	return 0;
-}
-
-console_initcall(m68328_console_init);
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index f38beb2..a261457 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -790,17 +790,6 @@ config SERIAL_CORE_CONSOLE
 config CONSOLE_POLL
 	bool
 
-config SERIAL_68328
-	bool "68328 serial support"
-	depends on M68328 || M68EZ328 || M68VZ328
-	help
-	  This driver supports the built-in serial port of the Motorola 68328
-	  (standard, EZ and VZ varieties).
-
-config SERIAL_68328_RTS_CTS
-	bool "Support RTS/CTS on 68328 serial port"
-	depends on SERIAL_68328
-
 config SERIAL_MCF
 	bool "Coldfire serial support"
 	depends on COLDFIRE
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 5ab4111..9d35387 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -34,7 +34,6 @@ obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
 obj-$(CONFIG_SERIAL_MAX310X) += max310x.o
 obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
 obj-$(CONFIG_SERIAL_MUX) += mux.o
-obj-$(CONFIG_SERIAL_68328) += 68328serial.o
 obj-$(CONFIG_SERIAL_MCF) += mcf.o
 obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
 obj-$(CONFIG_SERIAL_HS_LPC32XX) += lpc32xx_hs.o
-- 
1.9.1


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

* Re: [PATCH] serial: Remove 68328 driver
  2015-12-18 11:28 ` [PATCH] serial: Remove 68328 driver Frederik Völkel
@ 2015-12-18 14:27     ` Geert Uytterhoeven
  2016-01-11 17:53   ` Peter Hurley
  1 sibling, 0 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2015-12-18 14:27 UTC (permalink / raw)
  To: Frederik Völkel
  Cc: Jiri Slaby, Greg KH, linux-serial, linux-kernel, linux-kernel,
	Lukas Braun, Linux/m68k, uClinux development list

CC linux-m68k, uClinux-dev

On Fri, Dec 18, 2015 at 12:28 PM, Frederik Völkel
<frederik.voelkel@fau.de> wrote:
> It's old, messy and mostly unmaintained.
> Remove it as suggested by Peter Hurley and Alan.
>
> Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
> Signed-off-by: Lukas Braun <lukas.braun@fau.de>
> ---
> Should we remove other drivers like framebuffer as well?
> It is probably useless without serial support.
> ---
>  drivers/tty/serial/68328serial.c | 1322 --------------------------------------
>  drivers/tty/serial/Kconfig       |   11 -
>  drivers/tty/serial/Makefile      |    1 -
>  3 files changed, 1334 deletions(-)
>  delete mode 100644 drivers/tty/serial/68328serial.c
>
> diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
> deleted file mode 100644
> index 0140ba4..0000000
> --- a/drivers/tty/serial/68328serial.c
> +++ /dev/null
> @@ -1,1322 +0,0 @@
> -/* 68328serial.c: Serial port driver for 68328 microcontroller
> - *
> - * Copyright (C) 1995       David S. Miller    <davem@caip.rutgers.edu>
> - * Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
> - * Copyright (C) 1998, 1999 D. Jeff Dionne     <jeff@uclinux.org>
> - * Copyright (C) 1999       Vladimir Gurevich  <vgurevic@cisco.com>
> - * Copyright (C) 2002-2003  David McCullough   <davidm@snapgear.com>
> - * Copyright (C) 2002       Greg Ungerer       <gerg@snapgear.com>
> - *
> - * VZ Support/Fixes             Evan Stawnyczy <e@lineo.ca>
> - * Multiple UART support        Daniel Potts <danielp@cse.unsw.edu.au>
> - * Power management support     Daniel Potts <danielp@cse.unsw.edu.au>
> - * VZ Second Serial Port enable Phil Wilshire
> - * 2.4/2.5 port                 David McCullough
> - */
> -
> -#include <linux/module.h>
> -#include <linux/errno.h>
> -#include <linux/serial.h>
> -#include <linux/signal.h>
> -#include <linux/sched.h>
> -#include <linux/timer.h>
> -#include <linux/interrupt.h>
> -#include <linux/tty.h>
> -#include <linux/tty_flip.h>
> -#include <linux/major.h>
> -#include <linux/string.h>
> -#include <linux/fcntl.h>
> -#include <linux/mm.h>
> -#include <linux/kernel.h>
> -#include <linux/console.h>
> -#include <linux/reboot.h>
> -#include <linux/keyboard.h>
> -#include <linux/init.h>
> -#include <linux/pm.h>
> -#include <linux/bitops.h>
> -#include <linux/delay.h>
> -#include <linux/gfp.h>
> -
> -#include <asm/io.h>
> -#include <asm/irq.h>
> -#include <asm/delay.h>
> -#include <asm/uaccess.h>
> -
> -/* (es) */
> -/* note: perhaps we can murge these files, so that you can just
> - *      define 1 of them, and they can sort that out for themselves
> - */
> -#if defined(CONFIG_M68EZ328)
> -#include <asm/MC68EZ328.h>
> -#else
> -#if defined(CONFIG_M68VZ328)
> -#include <asm/MC68VZ328.h>
> -#else
> -#include <asm/MC68328.h>
> -#endif /* CONFIG_M68VZ328 */
> -#endif /* CONFIG_M68EZ328 */
> -
> -/* Turn off usage of real serial interrupt code, to "support" Copilot */
> -#ifdef CONFIG_XCOPILOT_BUGS
> -#undef USE_INTS
> -#else
> -#define USE_INTS
> -#endif
> -
> -/*
> - * I believe this is the optimal setting that reduces the number of interrupts.
> - * At high speeds the output might become a little "bursted" (use USTCNT_TXHE
> - * if that bothers you), but in most cases it will not, since we try to
> - * transmit characters every time rs_interrupt is called. Thus, quite often
> - * you'll see that a receive interrupt occures before the transmit one.
> - *                                  -- Vladimir Gurevich
> - */
> -#define USTCNT_TX_INTR_MASK (USTCNT_TXEE)
> -
> -/*
> - * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special
> - * "Old data interrupt" which occures whenever the data stay in the FIFO
> - * longer than 30 bits time. This allows us to use FIFO without compromising
> - * latency. '328 does not have this feature and without the real  328-based
> - * board I would assume that RXRE is the safest setting.
> - *
> - * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of
> - * interrupts. RXFE (receive queue full) causes the system to lose data
> - * at least at 115200 baud
> - *
> - * If your board is busy doing other stuff, you might consider to use
> - * RXRE (data ready intrrupt) instead.
> - *
> - * The other option is to make these INTR masks run-time configurable, so
> - * that people can dynamically adapt them according to the current usage.
> - *                                  -- Vladimir Gurevich
> - */
> -
> -/* (es) */
> -#if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328)
> -#define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN)
> -#elif defined(CONFIG_M68328)
> -#define USTCNT_RX_INTR_MASK (USTCNT_RXRE)
> -#else
> -#error Please, define the Rx interrupt events for your CPU
> -#endif
> -/* (/es) */
> -
> -/*
> - * This is our internal structure for each serial port's state.
> - */
> -struct m68k_serial {
> -       struct tty_port         tport;
> -       char                    is_cons;        /* Is this our console. */
> -       int                     magic;
> -       int                     baud_base;
> -       int                     port;
> -       int                     irq;
> -       int                     type;           /* UART type */
> -       int                     custom_divisor;
> -       int                     x_char;         /* xon/xoff character */
> -       int                     line;
> -       unsigned char           *xmit_buf;
> -       int                     xmit_head;
> -       int                     xmit_tail;
> -       int                     xmit_cnt;
> -};
> -
> -#define SERIAL_MAGIC 0x5301
> -
> -/*
> - * Define the number of ports supported and their irqs.
> - */
> -#define NR_PORTS 1
> -
> -static struct m68k_serial m68k_soft[NR_PORTS];
> -
> -static unsigned int uart_irqs[NR_PORTS] = { UART_IRQ_NUM };
> -
> -/* multiple ports are contiguous in memory */
> -m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR;
> -
> -struct tty_driver *serial_driver;
> -
> -static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
> -
> -/*
> - *     Setup for console. Argument comes from the boot command line.
> - */
> -
> -/* note: this is messy, but it works, again, perhaps defined somewhere else?*/
> -#ifdef CONFIG_M68VZ328
> -#define CONSOLE_BAUD_RATE      19200
> -#define DEFAULT_CBAUD          B19200
> -#endif
> -
> -
> -#ifndef CONSOLE_BAUD_RATE
> -#define        CONSOLE_BAUD_RATE       9600
> -#define        DEFAULT_CBAUD           B9600
> -#endif
> -
> -
> -static int m68328_console_initted = 0;
> -static int m68328_console_baud    = CONSOLE_BAUD_RATE;
> -static int m68328_console_cbaud   = DEFAULT_CBAUD;
> -
> -
> -static inline int serial_paranoia_check(struct m68k_serial *info,
> -                                       char *name, const char *routine)
> -{
> -#ifdef SERIAL_PARANOIA_CHECK
> -       static const char *badmagic =
> -               "Warning: bad magic number for serial struct %s in %s\n";
> -       static const char *badinfo =
> -               "Warning: null m68k_serial for %s in %s\n";
> -
> -       if (!info) {
> -               printk(badinfo, name, routine);
> -               return 1;
> -       }
> -       if (info->magic != SERIAL_MAGIC) {
> -               printk(badmagic, name, routine);
> -               return 1;
> -       }
> -#endif
> -       return 0;
> -}
> -
> -/*
> - * This is used to figure out the divisor speeds and the timeouts
> - */
> -static int baud_table[] = {
> -       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
> -       9600, 19200, 38400, 57600, 115200, 0 };
> -
> -/* Utility routines */
> -static inline int get_baud(struct m68k_serial *ss)
> -{
> -       unsigned long result = 115200;
> -       unsigned short int baud = uart_addr[ss->line].ubaud;
> -       if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
> -       result >>= GET_FIELD(baud, UBAUD_DIVIDE);
> -
> -       return result;
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_stop() and rs_start()
> - *
> - * This routines are called before setting or resetting tty->stopped.
> - * They enable or disable transmitter interrupts, as necessary.
> - * ------------------------------------------------------------
> - */
> -static void rs_stop(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_stop"))
> -               return;
> -
> -       local_irq_save(flags);
> -       uart->ustcnt &= ~USTCNT_TXEN;
> -       local_irq_restore(flags);
> -}
> -
> -static int rs_put_char(char ch)
> -{
> -       unsigned long flags;
> -       int loops = 0;
> -
> -        local_irq_save(flags);
> -
> -       while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
> -               loops++;
> -               udelay(5);
> -        }
> -
> -       UTX_TXDATA = ch;
> -        udelay(5);
> -        local_irq_restore(flags);
> -        return 1;
> -}
> -
> -static void rs_start(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_start"))
> -               return;
> -
> -       local_irq_save(flags);
> -       if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
> -#ifdef USE_INTS
> -               uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
> -#else
> -               uart->ustcnt |= USTCNT_TXEN;
> -#endif
> -       }
> -       local_irq_restore(flags);
> -}
> -
> -static void receive_chars(struct m68k_serial *info, unsigned short rx)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned char ch, flag;
> -
> -       /*
> -        * This do { } while() loop will get ALL chars out of Rx FIFO
> -         */
> -#ifndef CONFIG_XCOPILOT_BUGS
> -       do {
> -#endif
> -               ch = GET_FIELD(rx, URX_RXDATA);
> -
> -               if(info->is_cons) {
> -                       if(URX_BREAK & rx) { /* whee, break received */
> -                               return;
> -#ifdef CONFIG_MAGIC_SYSRQ
> -                       } else if (ch == 0x10) { /* ^P */
> -                               show_state();
> -                               show_free_areas(0);
> -                               show_buffers();
> -/*                             show_net_buffers(); */
> -                               return;
> -                       } else if (ch == 0x12) { /* ^R */
> -                               emergency_restart();
> -                               return;
> -#endif /* CONFIG_MAGIC_SYSRQ */
> -                       }
> -               }
> -
> -               flag = TTY_NORMAL;
> -
> -               if (rx & URX_PARITY_ERROR)
> -                       flag = TTY_PARITY;
> -               else if (rx & URX_OVRUN)
> -                       flag = TTY_OVERRUN;
> -               else if (rx & URX_FRAME_ERROR)
> -                       flag = TTY_FRAME;
> -
> -               tty_insert_flip_char(&info->tport, ch, flag);
> -#ifndef CONFIG_XCOPILOT_BUGS
> -       } while((rx = uart->urx.w) & URX_DATA_READY);
> -#endif
> -
> -       tty_schedule_flip(&info->tport);
> -}
> -
> -static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -
> -       if (info->x_char) {
> -               /* Send next char */
> -               uart->utx.b.txdata = info->x_char;
> -               info->x_char = 0;
> -               goto clear_and_return;
> -       }
> -
> -       if ((info->xmit_cnt <= 0) || !tty || tty->stopped) {
> -               /* That's peculiar... TX ints off */
> -               uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
> -               goto clear_and_return;
> -       }
> -
> -       /* Send char */
> -       uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
> -       info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
> -       info->xmit_cnt--;
> -
> -       if(info->xmit_cnt <= 0) {
> -               /* All done for now... TX ints off */
> -               uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
> -               goto clear_and_return;
> -       }
> -
> -clear_and_return:
> -       /* Clear interrupt (should be auto)*/
> -       return;
> -}
> -
> -/*
> - * This is the serial driver's generic interrupt routine
> - */
> -irqreturn_t rs_interrupt(int irq, void *dev_id)
> -{
> -       struct m68k_serial *info = dev_id;
> -       struct tty_struct *tty = tty_port_tty_get(&info->tport);
> -       m68328_uart *uart;
> -       unsigned short rx;
> -       unsigned short tx;
> -
> -       uart = &uart_addr[info->line];
> -       rx = uart->urx.w;
> -
> -#ifdef USE_INTS
> -       tx = uart->utx.w;
> -
> -       if (rx & URX_DATA_READY)
> -               receive_chars(info, rx);
> -       if (tx & UTX_TX_AVAIL)
> -               transmit_chars(info, tty);
> -#else
> -       receive_chars(info, rx);
> -#endif
> -       tty_kref_put(tty);
> -
> -       return IRQ_HANDLED;
> -}
> -
> -static int startup(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (info->tport.flags & ASYNC_INITIALIZED)
> -               return 0;
> -
> -       if (!info->xmit_buf) {
> -               info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
> -               if (!info->xmit_buf)
> -                       return -ENOMEM;
> -       }
> -
> -       local_irq_save(flags);
> -
> -       /*
> -        * Clear the FIFO buffers and disable them
> -        * (they will be reenabled in change_speed())
> -        */
> -
> -       uart->ustcnt = USTCNT_UEN;
> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
> -       (void)uart->urx.w;
> -
> -       /*
> -        * Finally, enable sequencing and interrupts
> -        */
> -#ifdef USE_INTS
> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
> -                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
> -#else
> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
> -#endif
> -
> -       if (tty)
> -               clear_bit(TTY_IO_ERROR, &tty->flags);
> -       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
> -
> -       /*
> -        * and set the speed of the serial port
> -        */
> -
> -       change_speed(info, tty);
> -
> -       info->tport.flags |= ASYNC_INITIALIZED;
> -       local_irq_restore(flags);
> -       return 0;
> -}
> -
> -/*
> - * This routine will shutdown a serial port; interrupts are disabled, and
> - * DTR is dropped if the hangup on close termio flag is on.
> - */
> -static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long   flags;
> -
> -       uart->ustcnt = 0; /* All off! */
> -       if (!(info->tport.flags & ASYNC_INITIALIZED))
> -               return;
> -
> -       local_irq_save(flags);
> -
> -       if (info->xmit_buf) {
> -               free_page((unsigned long) info->xmit_buf);
> -               info->xmit_buf = 0;
> -       }
> -
> -       if (tty)
> -               set_bit(TTY_IO_ERROR, &tty->flags);
> -
> -       info->tport.flags &= ~ASYNC_INITIALIZED;
> -       local_irq_restore(flags);
> -}
> -
> -struct {
> -       int divisor, prescale;
> -}
> -#ifndef CONFIG_M68VZ328
> - hw_baud_table[18] = {
> -       {0,0}, /* 0 */
> -       {0,0}, /* 50 */
> -       {0,0}, /* 75 */
> -       {0,0}, /* 110 */
> -       {0,0}, /* 134 */
> -       {0,0}, /* 150 */
> -       {0,0}, /* 200 */
> -       {7,0x26}, /* 300 */
> -       {6,0x26}, /* 600 */
> -       {5,0x26}, /* 1200 */
> -       {0,0}, /* 1800 */
> -       {4,0x26}, /* 2400 */
> -       {3,0x26}, /* 4800 */
> -       {2,0x26}, /* 9600 */
> -       {1,0x26}, /* 19200 */
> -       {0,0x26}, /* 38400 */
> -       {1,0x38}, /* 57600 */
> -       {0,0x38}, /* 115200 */
> -};
> -#else
> - hw_baud_table[18] = {
> -                 {0,0}, /* 0 */
> -                 {0,0}, /* 50 */
> -                 {0,0}, /* 75 */
> -                 {0,0}, /* 110 */
> -                 {0,0}, /* 134 */
> -                 {0,0}, /* 150 */
> -                 {0,0}, /* 200 */
> -                 {0,0}, /* 300 */
> -                 {7,0x26}, /* 600 */
> -                 {6,0x26}, /* 1200 */
> -                 {0,0}, /* 1800 */
> -                 {5,0x26}, /* 2400 */
> -                 {4,0x26}, /* 4800 */
> -                 {3,0x26}, /* 9600 */
> -                 {2,0x26}, /* 19200 */
> -                 {1,0x26}, /* 38400 */
> -                 {0,0x26}, /* 57600 */
> -                 {1,0x38}, /* 115200 */
> -};
> -#endif
> -/* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
> -
> -/*
> - * This routine is called to set the UART divisor registers to match
> - * the specified baud rate for a serial port.
> - */
> -static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned short port;
> -       unsigned short ustcnt;
> -       unsigned cflag;
> -       int     i;
> -
> -       cflag = tty->termios.c_cflag;
> -       port = info->port;
> -       if (!port)
> -               return;
> -
> -       ustcnt = uart->ustcnt;
> -       uart->ustcnt = ustcnt & ~USTCNT_TXEN;
> -
> -       i = cflag & CBAUD;
> -        if (i & CBAUDEX) {
> -                i = (i & ~CBAUDEX) + B38400;
> -        }
> -
> -       uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
> -               PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
> -
> -       ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
> -
> -       if ((cflag & CSIZE) == CS8)
> -               ustcnt |= USTCNT_8_7;
> -
> -       if (cflag & CSTOPB)
> -               ustcnt |= USTCNT_STOP;
> -
> -       if (cflag & PARENB)
> -               ustcnt |= USTCNT_PARITYEN;
> -       if (cflag & PARODD)
> -               ustcnt |= USTCNT_ODD_EVEN;
> -
> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
> -       if (cflag & CRTSCTS) {
> -               uart->utx.w &= ~ UTX_NOCTS;
> -       } else {
> -               uart->utx.w |= UTX_NOCTS;
> -       }
> -#endif
> -
> -       ustcnt |= USTCNT_TXEN;
> -
> -       uart->ustcnt = ustcnt;
> -       return;
> -}
> -
> -/*
> - * Fair output driver allows a process to speak.
> - */
> -static void rs_fair_output(void)
> -{
> -       int left;               /* Output no more than that */
> -       unsigned long flags;
> -       struct m68k_serial *info = &m68k_soft[0];
> -       char c;
> -
> -       if (info == NULL) return;
> -       if (info->xmit_buf == NULL) return;
> -
> -       local_irq_save(flags);
> -       left = info->xmit_cnt;
> -       while (left != 0) {
> -               c = info->xmit_buf[info->xmit_tail];
> -               info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
> -               info->xmit_cnt--;
> -               local_irq_restore(flags);
> -
> -               rs_put_char(c);
> -
> -               local_irq_save(flags);
> -               left = min(info->xmit_cnt, left-1);
> -       }
> -
> -       /* Last character is being transmitted now (hopefully). */
> -       udelay(5);
> -
> -       local_irq_restore(flags);
> -       return;
> -}
> -
> -/*
> - * m68k_console_print is registered for printk.
> - */
> -void console_print_68328(const char *p)
> -{
> -       char c;
> -
> -       while((c=*(p++)) != 0) {
> -               if(c == '\n')
> -                       rs_put_char('\r');
> -               rs_put_char(c);
> -       }
> -
> -       /* Comment this if you want to have a strict interrupt-driven output */
> -       rs_fair_output();
> -
> -       return;
> -}
> -
> -static void rs_set_ldisc(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
> -               return;
> -
> -       info->is_cons = (tty->termios.c_line == N_TTY);
> -
> -       printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
> -}
> -
> -static void rs_flush_chars(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
> -               return;
> -#ifndef USE_INTS
> -       for(;;) {
> -#endif
> -
> -       /* Enable transmitter */
> -       local_irq_save(flags);
> -
> -       if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) {
> -               local_irq_restore(flags);
> -               return;
> -       }
> -
> -#ifdef USE_INTS
> -       uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
> -#else
> -       uart->ustcnt |= USTCNT_TXEN;
> -#endif
> -
> -#ifdef USE_INTS
> -       if (uart->utx.w & UTX_TX_AVAIL) {
> -#else
> -       if (1) {
> -#endif
> -               /* Send char */
> -               uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
> -               info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
> -               info->xmit_cnt--;
> -       }
> -
> -#ifndef USE_INTS
> -       while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
> -       }
> -#endif
> -       local_irq_restore(flags);
> -}
> -
> -extern void console_printn(const char * b, int count);
> -
> -static int rs_write(struct tty_struct * tty,
> -                   const unsigned char *buf, int count)
> -{
> -       int     c, total = 0;
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_write"))
> -               return 0;
> -
> -       if (!tty || !info->xmit_buf)
> -               return 0;
> -
> -       local_save_flags(flags);
> -       while (1) {
> -               local_irq_disable();
> -               c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
> -                                  SERIAL_XMIT_SIZE - info->xmit_head));
> -               local_irq_restore(flags);
> -
> -               if (c <= 0)
> -                       break;
> -
> -               memcpy(info->xmit_buf + info->xmit_head, buf, c);
> -
> -               local_irq_disable();
> -               info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
> -               info->xmit_cnt += c;
> -               local_irq_restore(flags);
> -               buf += c;
> -               count -= c;
> -               total += c;
> -       }
> -
> -       if (info->xmit_cnt && !tty->stopped) {
> -               /* Enable transmitter */
> -               local_irq_disable();
> -#ifndef USE_INTS
> -               while(info->xmit_cnt) {
> -#endif
> -
> -               uart->ustcnt |= USTCNT_TXEN;
> -#ifdef USE_INTS
> -               uart->ustcnt |= USTCNT_TX_INTR_MASK;
> -#else
> -               while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
> -#endif
> -               if (uart->utx.w & UTX_TX_AVAIL) {
> -                       uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
> -                       info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
> -                       info->xmit_cnt--;
> -               }
> -
> -#ifndef USE_INTS
> -               }
> -#endif
> -               local_irq_restore(flags);
> -       }
> -
> -       return total;
> -}
> -
> -static int rs_write_room(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       int     ret;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_write_room"))
> -               return 0;
> -       ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
> -       if (ret < 0)
> -               ret = 0;
> -       return ret;
> -}
> -
> -static int rs_chars_in_buffer(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
> -               return 0;
> -       return info->xmit_cnt;
> -}
> -
> -static void rs_flush_buffer(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
> -               return;
> -       local_irq_save(flags);
> -       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
> -       local_irq_restore(flags);
> -       tty_wakeup(tty);
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_throttle()
> - *
> - * This routine is called by the upper-layer tty layer to signal that
> - * incoming characters should be throttled.
> - * ------------------------------------------------------------
> - */
> -static void rs_throttle(struct tty_struct * tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_throttle"))
> -               return;
> -
> -       if (I_IXOFF(tty))
> -               info->x_char = STOP_CHAR(tty);
> -
> -       /* Turn off RTS line (do this atomic) */
> -}
> -
> -static void rs_unthrottle(struct tty_struct * tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
> -               return;
> -
> -       if (I_IXOFF(tty)) {
> -               if (info->x_char)
> -                       info->x_char = 0;
> -               else
> -                       info->x_char = START_CHAR(tty);
> -       }
> -
> -       /* Assert RTS line (do this atomic) */
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_ioctl() and friends
> - * ------------------------------------------------------------
> - */
> -
> -static int get_serial_info(struct m68k_serial * info,
> -                          struct serial_struct * retinfo)
> -{
> -       struct serial_struct tmp;
> -
> -       if (!retinfo)
> -               return -EFAULT;
> -       memset(&tmp, 0, sizeof(tmp));
> -       tmp.type = info->type;
> -       tmp.line = info->line;
> -       tmp.port = info->port;
> -       tmp.irq = info->irq;
> -       tmp.flags = info->tport.flags;
> -       tmp.baud_base = info->baud_base;
> -       tmp.close_delay = info->tport.close_delay;
> -       tmp.closing_wait = info->tport.closing_wait;
> -       tmp.custom_divisor = info->custom_divisor;
> -       if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
> -               return -EFAULT;
> -
> -       return 0;
> -}
> -
> -static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
> -                          struct serial_struct * new_info)
> -{
> -       struct tty_port *port = &info->tport;
> -       struct serial_struct new_serial;
> -       struct m68k_serial old_info;
> -       int                     retval = 0;
> -
> -       if (!new_info)
> -               return -EFAULT;
> -       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
> -               return -EFAULT;
> -       old_info = *info;
> -
> -       if (!capable(CAP_SYS_ADMIN)) {
> -               if ((new_serial.baud_base != info->baud_base) ||
> -                   (new_serial.type != info->type) ||
> -                   (new_serial.close_delay != port->close_delay) ||
> -                   ((new_serial.flags & ~ASYNC_USR_MASK) !=
> -                    (port->flags & ~ASYNC_USR_MASK)))
> -                       return -EPERM;
> -               port->flags = ((port->flags & ~ASYNC_USR_MASK) |
> -                              (new_serial.flags & ASYNC_USR_MASK));
> -               info->custom_divisor = new_serial.custom_divisor;
> -               goto check_and_exit;
> -       }
> -
> -       if (port->count > 1)
> -               return -EBUSY;
> -
> -       /*
> -        * OK, past this point, all the error checking has been done.
> -        * At this point, we start making changes.....
> -        */
> -
> -       info->baud_base = new_serial.baud_base;
> -       port->flags = ((port->flags & ~ASYNC_FLAGS) |
> -                       (new_serial.flags & ASYNC_FLAGS));
> -       info->type = new_serial.type;
> -       port->close_delay = new_serial.close_delay;
> -       port->closing_wait = new_serial.closing_wait;
> -
> -check_and_exit:
> -       retval = startup(info, tty);
> -       return retval;
> -}
> -
> -/*
> - * get_lsr_info - get line status register info
> - *
> - * Purpose: Let user call ioctl() to get info when the UART physically
> - *         is emptied.  On bus types like RS485, the transmitter must
> - *         release the bus after transmitting. This must be done when
> - *         the transmit shift register is empty, not be done when the
> - *         transmit holding register is empty.  This functionality
> - *         allows an RS485 driver to be written in user space.
> - */
> -static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
> -{
> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
> -       m68328_uart *uart = &uart_addr[info->line];
> -#endif
> -       unsigned char status;
> -       unsigned long flags;
> -
> -       local_irq_save(flags);
> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
> -       status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
> -#else
> -       status = 0;
> -#endif
> -       local_irq_restore(flags);
> -       return put_user(status, value);
> -}
> -
> -/*
> - * This routine sends a break character out the serial port.
> - */
> -static void send_break(struct m68k_serial * info, unsigned int duration)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -        unsigned long flags;
> -        if (!info->port)
> -                return;
> -        local_irq_save(flags);
> -#ifdef USE_INTS
> -       uart->utx.w |= UTX_SEND_BREAK;
> -       msleep_interruptible(duration);
> -       uart->utx.w &= ~UTX_SEND_BREAK;
> -#endif
> -        local_irq_restore(flags);
> -}
> -
> -static int rs_ioctl(struct tty_struct *tty,
> -                   unsigned int cmd, unsigned long arg)
> -{
> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
> -       int retval;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
> -               return -ENODEV;
> -
> -       if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
> -           (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD)  &&
> -           (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
> -               if (tty->flags & (1 << TTY_IO_ERROR))
> -                   return -EIO;
> -       }
> -
> -       switch (cmd) {
> -               case TCSBRK:    /* SVID version: non-zero arg --> no break */
> -                       retval = tty_check_change(tty);
> -                       if (retval)
> -                               return retval;
> -                       tty_wait_until_sent(tty, 0);
> -                       if (!arg)
> -                               send_break(info, 250);  /* 1/4 second */
> -                       return 0;
> -               case TCSBRKP:   /* support for POSIX tcsendbreak() */
> -                       retval = tty_check_change(tty);
> -                       if (retval)
> -                               return retval;
> -                       tty_wait_until_sent(tty, 0);
> -                       send_break(info, arg ? arg*(100) : 250);
> -                       return 0;
> -               case TIOCGSERIAL:
> -                       return get_serial_info(info,
> -                                      (struct serial_struct *) arg);
> -               case TIOCSSERIAL:
> -                       return set_serial_info(info, tty,
> -                                              (struct serial_struct *) arg);
> -               case TIOCSERGETLSR: /* Get line status register */
> -                       return get_lsr_info(info, (unsigned int *) arg);
> -               case TIOCSERGSTRUCT:
> -                       if (copy_to_user((struct m68k_serial *) arg,
> -                                   info, sizeof(struct m68k_serial)))
> -                               return -EFAULT;
> -                       return 0;
> -               default:
> -                       return -ENOIOCTLCMD;
> -               }
> -       return 0;
> -}
> -
> -static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       change_speed(info, tty);
> -
> -       if ((old_termios->c_cflag & CRTSCTS) &&
> -           !(tty->termios.c_cflag & CRTSCTS))
> -               rs_start(tty);
> -
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_close()
> - *
> - * This routine is called when the serial port gets closed.  First, we
> - * wait for the last remaining data to be sent.  Then, we unlink its
> - * S structure from the interrupt chain if necessary, and we free
> - * that IRQ if nothing is left in the chain.
> - * ------------------------------------------------------------
> - */
> -static void rs_close(struct tty_struct *tty, struct file * filp)
> -{
> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
> -       struct tty_port *port = &info->tport;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_close"))
> -               return;
> -
> -       local_irq_save(flags);
> -
> -       if (tty_hung_up_p(filp)) {
> -               local_irq_restore(flags);
> -               return;
> -       }
> -
> -       if ((tty->count == 1) && (port->count != 1)) {
> -               /*
> -                * Uh, oh.  tty->count is 1, which means that the tty
> -                * structure will be freed.  Info->count should always
> -                * be one in these conditions.  If it's greater than
> -                * one, we've got real problems, since it means the
> -                * serial port won't be shutdown.
> -                */
> -               printk("rs_close: bad serial port count; tty->count is 1, "
> -                      "port->count is %d\n", port->count);
> -               port->count = 1;
> -       }
> -       if (--port->count < 0) {
> -               printk("rs_close: bad serial port count for ttyS%d: %d\n",
> -                      info->line, port->count);
> -               port->count = 0;
> -       }
> -       if (port->count) {
> -               local_irq_restore(flags);
> -               return;
> -       }
> -       port->flags |= ASYNC_CLOSING;
> -       /*
> -        * Now we wait for the transmit buffer to clear; and we notify
> -        * the line discipline to only process XON/XOFF characters.
> -        */
> -       tty->closing = 1;
> -       if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
> -               tty_wait_until_sent(tty, port->closing_wait);
> -       /*
> -        * At this point we stop accepting input.  To do this, we
> -        * disable the receive line status interrupts, and tell the
> -        * interrupt driver to stop checking the data ready bit in the
> -        * line status register.
> -        */
> -
> -       uart->ustcnt &= ~USTCNT_RXEN;
> -       uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
> -
> -       shutdown(info, tty);
> -       rs_flush_buffer(tty);
> -
> -       tty_ldisc_flush(tty);
> -       tty->closing = 0;
> -       tty_port_tty_set(&info->tport, NULL);
> -#warning "This is not and has never been valid so fix it"
> -#if 0
> -       if (tty->ldisc.num != ldiscs[N_TTY].num) {
> -               if (tty->ldisc.close)
> -                       (tty->ldisc.close)(tty);
> -               tty->ldisc = ldiscs[N_TTY];
> -               tty->termios.c_line = N_TTY;
> -               if (tty->ldisc.open)
> -                       (tty->ldisc.open)(tty);
> -       }
> -#endif
> -       if (port->blocked_open) {
> -               if (port->close_delay)
> -                       msleep_interruptible(jiffies_to_msecs(port->close_delay));
> -               wake_up_interruptible(&port->open_wait);
> -       }
> -       port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
> -       local_irq_restore(flags);
> -}
> -
> -/*
> - * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
> - */
> -void rs_hangup(struct tty_struct *tty)
> -{
> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_hangup"))
> -               return;
> -
> -       rs_flush_buffer(tty);
> -       shutdown(info, tty);
> -       info->tport.count = 0;
> -       info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
> -       tty_port_tty_set(&info->tport, NULL);
> -       wake_up_interruptible(&info->tport.open_wait);
> -}
> -
> -/*
> - * This routine is called whenever a serial port is opened.  It
> - * enables interrupts for a serial port, linking in its S structure into
> - * the IRQ chain.   It also performs the serial-specific
> - * initialization for the tty structure.
> - */
> -int rs_open(struct tty_struct *tty, struct file * filp)
> -{
> -       struct m68k_serial      *info;
> -       int retval;
> -
> -       info = &m68k_soft[tty->index];
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_open"))
> -               return -ENODEV;
> -
> -       info->tport.count++;
> -       tty->driver_data = info;
> -       tty_port_tty_set(&info->tport, tty);
> -
> -       /*
> -        * Start up serial port
> -        */
> -       retval = startup(info, tty);
> -       if (retval)
> -               return retval;
> -
> -       return tty_port_block_til_ready(&info->tport, tty, filp);
> -}
> -
> -/* Finally, routines used to initialize the serial driver. */
> -
> -static void show_serial_version(void)
> -{
> -       printk("MC68328 serial driver version 1.00\n");
> -}
> -
> -static const struct tty_operations rs_ops = {
> -       .open = rs_open,
> -       .close = rs_close,
> -       .write = rs_write,
> -       .flush_chars = rs_flush_chars,
> -       .write_room = rs_write_room,
> -       .chars_in_buffer = rs_chars_in_buffer,
> -       .flush_buffer = rs_flush_buffer,
> -       .ioctl = rs_ioctl,
> -       .throttle = rs_throttle,
> -       .unthrottle = rs_unthrottle,
> -       .set_termios = rs_set_termios,
> -       .stop = rs_stop,
> -       .start = rs_start,
> -       .hangup = rs_hangup,
> -       .set_ldisc = rs_set_ldisc,
> -};
> -
> -static const struct tty_port_operations rs_port_ops = {
> -};
> -
> -/* rs_init inits the driver */
> -static int __init
> -rs68328_init(void)
> -{
> -       unsigned long flags;
> -       int i;
> -       struct m68k_serial *info;
> -
> -       serial_driver = alloc_tty_driver(NR_PORTS);
> -       if (!serial_driver)
> -               return -ENOMEM;
> -
> -       show_serial_version();
> -
> -       /* Initialize the tty_driver structure */
> -       /* SPARC: Not all of this is exactly right for us. */
> -
> -       serial_driver->name = "ttyS";
> -       serial_driver->major = TTY_MAJOR;
> -       serial_driver->minor_start = 64;
> -       serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
> -       serial_driver->subtype = SERIAL_TYPE_NORMAL;
> -       serial_driver->init_termios = tty_std_termios;
> -       serial_driver->init_termios.c_cflag =
> -                       m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
> -       serial_driver->flags = TTY_DRIVER_REAL_RAW;
> -       tty_set_operations(serial_driver, &rs_ops);
> -
> -       local_irq_save(flags);
> -
> -       for(i=0;i<NR_PORTS;i++) {
> -
> -           info = &m68k_soft[i];
> -           tty_port_init(&info->tport);
> -           info->tport.ops = &rs_port_ops;
> -           info->magic = SERIAL_MAGIC;
> -           info->port = (int) &uart_addr[i];
> -           info->irq = uart_irqs[i];
> -           info->custom_divisor = 16;
> -           info->x_char = 0;
> -           info->line = i;
> -           info->is_cons = 1; /* Means shortcuts work */
> -
> -           printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
> -                  info->port, info->irq);
> -           printk(" is a builtin MC68328 UART\n");
> -
> -#ifdef CONFIG_M68VZ328
> -               if (i > 0 )
> -                       PJSEL &= 0xCF;  /* PSW enable second port output */
> -#endif
> -
> -           if (request_irq(uart_irqs[i],
> -                           rs_interrupt,
> -                           0,
> -                           "M68328_UART", info))
> -                panic("Unable to attach 68328 serial interrupt\n");
> -
> -           tty_port_link_device(&info->tport, serial_driver, i);
> -       }
> -       local_irq_restore(flags);
> -
> -       if (tty_register_driver(serial_driver)) {
> -               put_tty_driver(serial_driver);
> -               for (i = 0; i < NR_PORTS; i++)
> -                       tty_port_destroy(&m68k_soft[i].tport);
> -               printk(KERN_ERR "Couldn't register serial driver\n");
> -               return -ENOMEM;
> -       }
> -
> -       return 0;
> -}
> -
> -module_init(rs68328_init);
> -
> -
> -
> -static void m68328_set_baud(void)
> -{
> -       unsigned short ustcnt;
> -       int     i;
> -
> -       ustcnt = USTCNT;
> -       USTCNT = ustcnt & ~USTCNT_TXEN;
> -
> -again:
> -       for (i = 0; i < ARRAY_SIZE(baud_table); i++)
> -               if (baud_table[i] == m68328_console_baud)
> -                       break;
> -       if (i >= ARRAY_SIZE(baud_table)) {
> -               m68328_console_baud = 9600;
> -               goto again;
> -       }
> -
> -       UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
> -               PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
> -       ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
> -       ustcnt |= USTCNT_8_7;
> -       ustcnt |= USTCNT_TXEN;
> -       USTCNT = ustcnt;
> -       m68328_console_initted = 1;
> -       return;
> -}
> -
> -
> -int m68328_console_setup(struct console *cp, char *arg)
> -{
> -       int             i, n = CONSOLE_BAUD_RATE;
> -
> -       if (!cp)
> -               return(-1);
> -
> -       if (arg)
> -               n = simple_strtoul(arg,NULL,0);
> -
> -       for (i = 0; i < ARRAY_SIZE(baud_table); i++)
> -               if (baud_table[i] == n)
> -                       break;
> -       if (i < ARRAY_SIZE(baud_table)) {
> -               m68328_console_baud = n;
> -               m68328_console_cbaud = 0;
> -               if (i > 15) {
> -                       m68328_console_cbaud |= CBAUDEX;
> -                       i -= 15;
> -               }
> -               m68328_console_cbaud |= i;
> -       }
> -
> -       m68328_set_baud(); /* make sure baud rate changes */
> -       return(0);
> -}
> -
> -
> -static struct tty_driver *m68328_console_device(struct console *c, int *index)
> -{
> -       *index = c->index;
> -       return serial_driver;
> -}
> -
> -
> -void m68328_console_write (struct console *co, const char *str,
> -                          unsigned int count)
> -{
> -       if (!m68328_console_initted)
> -               m68328_set_baud();
> -    while (count--) {
> -        if (*str == '\n')
> -           rs_put_char('\r');
> -        rs_put_char( *str++ );
> -    }
> -}
> -
> -
> -static struct console m68328_driver = {
> -       .name           = "ttyS",
> -       .write          = m68328_console_write,
> -       .device         = m68328_console_device,
> -       .setup          = m68328_console_setup,
> -       .flags          = CON_PRINTBUFFER,
> -       .index          = -1,
> -};
> -
> -
> -static int __init m68328_console_init(void)
> -{
> -       register_console(&m68328_driver);
> -       return 0;
> -}
> -
> -console_initcall(m68328_console_init);
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index f38beb2..a261457 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -790,17 +790,6 @@ config SERIAL_CORE_CONSOLE
>  config CONSOLE_POLL
>         bool
>
> -config SERIAL_68328
> -       bool "68328 serial support"
> -       depends on M68328 || M68EZ328 || M68VZ328
> -       help
> -         This driver supports the built-in serial port of the Motorola 68328
> -         (standard, EZ and VZ varieties).
> -
> -config SERIAL_68328_RTS_CTS
> -       bool "Support RTS/CTS on 68328 serial port"
> -       depends on SERIAL_68328
> -
>  config SERIAL_MCF
>         bool "Coldfire serial support"
>         depends on COLDFIRE
> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
> index 5ab4111..9d35387 100644
> --- a/drivers/tty/serial/Makefile
> +++ b/drivers/tty/serial/Makefile
> @@ -34,7 +34,6 @@ obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
>  obj-$(CONFIG_SERIAL_MAX310X) += max310x.o
>  obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
>  obj-$(CONFIG_SERIAL_MUX) += mux.o
> -obj-$(CONFIG_SERIAL_68328) += 68328serial.o
>  obj-$(CONFIG_SERIAL_MCF) += mcf.o
>  obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
>  obj-$(CONFIG_SERIAL_HS_LPC32XX) += lpc32xx_hs.o
> --
> 1.9.1

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] serial: Remove 68328 driver
@ 2015-12-18 14:27     ` Geert Uytterhoeven
  0 siblings, 0 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2015-12-18 14:27 UTC (permalink / raw)
  To: Frederik Völkel
  Cc: Linux/m68k, uClinux development list, linux-kernel, Greg KH,
	linux-kernel, linux-serial, Jiri Slaby, Lukas Braun

CC linux-m68k, uClinux-dev

On Fri, Dec 18, 2015 at 12:28 PM, Frederik Völkel
<frederik.voelkel@fau.de> wrote:
> It's old, messy and mostly unmaintained.
> Remove it as suggested by Peter Hurley and Alan.
>
> Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
> Signed-off-by: Lukas Braun <lukas.braun@fau.de>
> ---
> Should we remove other drivers like framebuffer as well?
> It is probably useless without serial support.
> ---
>  drivers/tty/serial/68328serial.c | 1322 --------------------------------------
>  drivers/tty/serial/Kconfig       |   11 -
>  drivers/tty/serial/Makefile      |    1 -
>  3 files changed, 1334 deletions(-)
>  delete mode 100644 drivers/tty/serial/68328serial.c
>
> diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
> deleted file mode 100644
> index 0140ba4..0000000
> --- a/drivers/tty/serial/68328serial.c
> +++ /dev/null
> @@ -1,1322 +0,0 @@
> -/* 68328serial.c: Serial port driver for 68328 microcontroller
> - *
> - * Copyright (C) 1995       David S. Miller    <davem@caip.rutgers.edu>
> - * Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
> - * Copyright (C) 1998, 1999 D. Jeff Dionne     <jeff@uclinux.org>
> - * Copyright (C) 1999       Vladimir Gurevich  <vgurevic@cisco.com>
> - * Copyright (C) 2002-2003  David McCullough   <davidm@snapgear.com>
> - * Copyright (C) 2002       Greg Ungerer       <gerg@snapgear.com>
> - *
> - * VZ Support/Fixes             Evan Stawnyczy <e@lineo.ca>
> - * Multiple UART support        Daniel Potts <danielp@cse.unsw.edu.au>
> - * Power management support     Daniel Potts <danielp@cse.unsw.edu.au>
> - * VZ Second Serial Port enable Phil Wilshire
> - * 2.4/2.5 port                 David McCullough
> - */
> -
> -#include <linux/module.h>
> -#include <linux/errno.h>
> -#include <linux/serial.h>
> -#include <linux/signal.h>
> -#include <linux/sched.h>
> -#include <linux/timer.h>
> -#include <linux/interrupt.h>
> -#include <linux/tty.h>
> -#include <linux/tty_flip.h>
> -#include <linux/major.h>
> -#include <linux/string.h>
> -#include <linux/fcntl.h>
> -#include <linux/mm.h>
> -#include <linux/kernel.h>
> -#include <linux/console.h>
> -#include <linux/reboot.h>
> -#include <linux/keyboard.h>
> -#include <linux/init.h>
> -#include <linux/pm.h>
> -#include <linux/bitops.h>
> -#include <linux/delay.h>
> -#include <linux/gfp.h>
> -
> -#include <asm/io.h>
> -#include <asm/irq.h>
> -#include <asm/delay.h>
> -#include <asm/uaccess.h>
> -
> -/* (es) */
> -/* note: perhaps we can murge these files, so that you can just
> - *      define 1 of them, and they can sort that out for themselves
> - */
> -#if defined(CONFIG_M68EZ328)
> -#include <asm/MC68EZ328.h>
> -#else
> -#if defined(CONFIG_M68VZ328)
> -#include <asm/MC68VZ328.h>
> -#else
> -#include <asm/MC68328.h>
> -#endif /* CONFIG_M68VZ328 */
> -#endif /* CONFIG_M68EZ328 */
> -
> -/* Turn off usage of real serial interrupt code, to "support" Copilot */
> -#ifdef CONFIG_XCOPILOT_BUGS
> -#undef USE_INTS
> -#else
> -#define USE_INTS
> -#endif
> -
> -/*
> - * I believe this is the optimal setting that reduces the number of interrupts.
> - * At high speeds the output might become a little "bursted" (use USTCNT_TXHE
> - * if that bothers you), but in most cases it will not, since we try to
> - * transmit characters every time rs_interrupt is called. Thus, quite often
> - * you'll see that a receive interrupt occures before the transmit one.
> - *                                  -- Vladimir Gurevich
> - */
> -#define USTCNT_TX_INTR_MASK (USTCNT_TXEE)
> -
> -/*
> - * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special
> - * "Old data interrupt" which occures whenever the data stay in the FIFO
> - * longer than 30 bits time. This allows us to use FIFO without compromising
> - * latency. '328 does not have this feature and without the real  328-based
> - * board I would assume that RXRE is the safest setting.
> - *
> - * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of
> - * interrupts. RXFE (receive queue full) causes the system to lose data
> - * at least at 115200 baud
> - *
> - * If your board is busy doing other stuff, you might consider to use
> - * RXRE (data ready intrrupt) instead.
> - *
> - * The other option is to make these INTR masks run-time configurable, so
> - * that people can dynamically adapt them according to the current usage.
> - *                                  -- Vladimir Gurevich
> - */
> -
> -/* (es) */
> -#if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328)
> -#define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN)
> -#elif defined(CONFIG_M68328)
> -#define USTCNT_RX_INTR_MASK (USTCNT_RXRE)
> -#else
> -#error Please, define the Rx interrupt events for your CPU
> -#endif
> -/* (/es) */
> -
> -/*
> - * This is our internal structure for each serial port's state.
> - */
> -struct m68k_serial {
> -       struct tty_port         tport;
> -       char                    is_cons;        /* Is this our console. */
> -       int                     magic;
> -       int                     baud_base;
> -       int                     port;
> -       int                     irq;
> -       int                     type;           /* UART type */
> -       int                     custom_divisor;
> -       int                     x_char;         /* xon/xoff character */
> -       int                     line;
> -       unsigned char           *xmit_buf;
> -       int                     xmit_head;
> -       int                     xmit_tail;
> -       int                     xmit_cnt;
> -};
> -
> -#define SERIAL_MAGIC 0x5301
> -
> -/*
> - * Define the number of ports supported and their irqs.
> - */
> -#define NR_PORTS 1
> -
> -static struct m68k_serial m68k_soft[NR_PORTS];
> -
> -static unsigned int uart_irqs[NR_PORTS] = { UART_IRQ_NUM };
> -
> -/* multiple ports are contiguous in memory */
> -m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR;
> -
> -struct tty_driver *serial_driver;
> -
> -static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
> -
> -/*
> - *     Setup for console. Argument comes from the boot command line.
> - */
> -
> -/* note: this is messy, but it works, again, perhaps defined somewhere else?*/
> -#ifdef CONFIG_M68VZ328
> -#define CONSOLE_BAUD_RATE      19200
> -#define DEFAULT_CBAUD          B19200
> -#endif
> -
> -
> -#ifndef CONSOLE_BAUD_RATE
> -#define        CONSOLE_BAUD_RATE       9600
> -#define        DEFAULT_CBAUD           B9600
> -#endif
> -
> -
> -static int m68328_console_initted = 0;
> -static int m68328_console_baud    = CONSOLE_BAUD_RATE;
> -static int m68328_console_cbaud   = DEFAULT_CBAUD;
> -
> -
> -static inline int serial_paranoia_check(struct m68k_serial *info,
> -                                       char *name, const char *routine)
> -{
> -#ifdef SERIAL_PARANOIA_CHECK
> -       static const char *badmagic =
> -               "Warning: bad magic number for serial struct %s in %s\n";
> -       static const char *badinfo =
> -               "Warning: null m68k_serial for %s in %s\n";
> -
> -       if (!info) {
> -               printk(badinfo, name, routine);
> -               return 1;
> -       }
> -       if (info->magic != SERIAL_MAGIC) {
> -               printk(badmagic, name, routine);
> -               return 1;
> -       }
> -#endif
> -       return 0;
> -}
> -
> -/*
> - * This is used to figure out the divisor speeds and the timeouts
> - */
> -static int baud_table[] = {
> -       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
> -       9600, 19200, 38400, 57600, 115200, 0 };
> -
> -/* Utility routines */
> -static inline int get_baud(struct m68k_serial *ss)
> -{
> -       unsigned long result = 115200;
> -       unsigned short int baud = uart_addr[ss->line].ubaud;
> -       if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
> -       result >>= GET_FIELD(baud, UBAUD_DIVIDE);
> -
> -       return result;
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_stop() and rs_start()
> - *
> - * This routines are called before setting or resetting tty->stopped.
> - * They enable or disable transmitter interrupts, as necessary.
> - * ------------------------------------------------------------
> - */
> -static void rs_stop(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_stop"))
> -               return;
> -
> -       local_irq_save(flags);
> -       uart->ustcnt &= ~USTCNT_TXEN;
> -       local_irq_restore(flags);
> -}
> -
> -static int rs_put_char(char ch)
> -{
> -       unsigned long flags;
> -       int loops = 0;
> -
> -        local_irq_save(flags);
> -
> -       while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
> -               loops++;
> -               udelay(5);
> -        }
> -
> -       UTX_TXDATA = ch;
> -        udelay(5);
> -        local_irq_restore(flags);
> -        return 1;
> -}
> -
> -static void rs_start(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_start"))
> -               return;
> -
> -       local_irq_save(flags);
> -       if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
> -#ifdef USE_INTS
> -               uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
> -#else
> -               uart->ustcnt |= USTCNT_TXEN;
> -#endif
> -       }
> -       local_irq_restore(flags);
> -}
> -
> -static void receive_chars(struct m68k_serial *info, unsigned short rx)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned char ch, flag;
> -
> -       /*
> -        * This do { } while() loop will get ALL chars out of Rx FIFO
> -         */
> -#ifndef CONFIG_XCOPILOT_BUGS
> -       do {
> -#endif
> -               ch = GET_FIELD(rx, URX_RXDATA);
> -
> -               if(info->is_cons) {
> -                       if(URX_BREAK & rx) { /* whee, break received */
> -                               return;
> -#ifdef CONFIG_MAGIC_SYSRQ
> -                       } else if (ch == 0x10) { /* ^P */
> -                               show_state();
> -                               show_free_areas(0);
> -                               show_buffers();
> -/*                             show_net_buffers(); */
> -                               return;
> -                       } else if (ch == 0x12) { /* ^R */
> -                               emergency_restart();
> -                               return;
> -#endif /* CONFIG_MAGIC_SYSRQ */
> -                       }
> -               }
> -
> -               flag = TTY_NORMAL;
> -
> -               if (rx & URX_PARITY_ERROR)
> -                       flag = TTY_PARITY;
> -               else if (rx & URX_OVRUN)
> -                       flag = TTY_OVERRUN;
> -               else if (rx & URX_FRAME_ERROR)
> -                       flag = TTY_FRAME;
> -
> -               tty_insert_flip_char(&info->tport, ch, flag);
> -#ifndef CONFIG_XCOPILOT_BUGS
> -       } while((rx = uart->urx.w) & URX_DATA_READY);
> -#endif
> -
> -       tty_schedule_flip(&info->tport);
> -}
> -
> -static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -
> -       if (info->x_char) {
> -               /* Send next char */
> -               uart->utx.b.txdata = info->x_char;
> -               info->x_char = 0;
> -               goto clear_and_return;
> -       }
> -
> -       if ((info->xmit_cnt <= 0) || !tty || tty->stopped) {
> -               /* That's peculiar... TX ints off */
> -               uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
> -               goto clear_and_return;
> -       }
> -
> -       /* Send char */
> -       uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
> -       info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
> -       info->xmit_cnt--;
> -
> -       if(info->xmit_cnt <= 0) {
> -               /* All done for now... TX ints off */
> -               uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
> -               goto clear_and_return;
> -       }
> -
> -clear_and_return:
> -       /* Clear interrupt (should be auto)*/
> -       return;
> -}
> -
> -/*
> - * This is the serial driver's generic interrupt routine
> - */
> -irqreturn_t rs_interrupt(int irq, void *dev_id)
> -{
> -       struct m68k_serial *info = dev_id;
> -       struct tty_struct *tty = tty_port_tty_get(&info->tport);
> -       m68328_uart *uart;
> -       unsigned short rx;
> -       unsigned short tx;
> -
> -       uart = &uart_addr[info->line];
> -       rx = uart->urx.w;
> -
> -#ifdef USE_INTS
> -       tx = uart->utx.w;
> -
> -       if (rx & URX_DATA_READY)
> -               receive_chars(info, rx);
> -       if (tx & UTX_TX_AVAIL)
> -               transmit_chars(info, tty);
> -#else
> -       receive_chars(info, rx);
> -#endif
> -       tty_kref_put(tty);
> -
> -       return IRQ_HANDLED;
> -}
> -
> -static int startup(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (info->tport.flags & ASYNC_INITIALIZED)
> -               return 0;
> -
> -       if (!info->xmit_buf) {
> -               info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
> -               if (!info->xmit_buf)
> -                       return -ENOMEM;
> -       }
> -
> -       local_irq_save(flags);
> -
> -       /*
> -        * Clear the FIFO buffers and disable them
> -        * (they will be reenabled in change_speed())
> -        */
> -
> -       uart->ustcnt = USTCNT_UEN;
> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
> -       (void)uart->urx.w;
> -
> -       /*
> -        * Finally, enable sequencing and interrupts
> -        */
> -#ifdef USE_INTS
> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
> -                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
> -#else
> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
> -#endif
> -
> -       if (tty)
> -               clear_bit(TTY_IO_ERROR, &tty->flags);
> -       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
> -
> -       /*
> -        * and set the speed of the serial port
> -        */
> -
> -       change_speed(info, tty);
> -
> -       info->tport.flags |= ASYNC_INITIALIZED;
> -       local_irq_restore(flags);
> -       return 0;
> -}
> -
> -/*
> - * This routine will shutdown a serial port; interrupts are disabled, and
> - * DTR is dropped if the hangup on close termio flag is on.
> - */
> -static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long   flags;
> -
> -       uart->ustcnt = 0; /* All off! */
> -       if (!(info->tport.flags & ASYNC_INITIALIZED))
> -               return;
> -
> -       local_irq_save(flags);
> -
> -       if (info->xmit_buf) {
> -               free_page((unsigned long) info->xmit_buf);
> -               info->xmit_buf = 0;
> -       }
> -
> -       if (tty)
> -               set_bit(TTY_IO_ERROR, &tty->flags);
> -
> -       info->tport.flags &= ~ASYNC_INITIALIZED;
> -       local_irq_restore(flags);
> -}
> -
> -struct {
> -       int divisor, prescale;
> -}
> -#ifndef CONFIG_M68VZ328
> - hw_baud_table[18] = {
> -       {0,0}, /* 0 */
> -       {0,0}, /* 50 */
> -       {0,0}, /* 75 */
> -       {0,0}, /* 110 */
> -       {0,0}, /* 134 */
> -       {0,0}, /* 150 */
> -       {0,0}, /* 200 */
> -       {7,0x26}, /* 300 */
> -       {6,0x26}, /* 600 */
> -       {5,0x26}, /* 1200 */
> -       {0,0}, /* 1800 */
> -       {4,0x26}, /* 2400 */
> -       {3,0x26}, /* 4800 */
> -       {2,0x26}, /* 9600 */
> -       {1,0x26}, /* 19200 */
> -       {0,0x26}, /* 38400 */
> -       {1,0x38}, /* 57600 */
> -       {0,0x38}, /* 115200 */
> -};
> -#else
> - hw_baud_table[18] = {
> -                 {0,0}, /* 0 */
> -                 {0,0}, /* 50 */
> -                 {0,0}, /* 75 */
> -                 {0,0}, /* 110 */
> -                 {0,0}, /* 134 */
> -                 {0,0}, /* 150 */
> -                 {0,0}, /* 200 */
> -                 {0,0}, /* 300 */
> -                 {7,0x26}, /* 600 */
> -                 {6,0x26}, /* 1200 */
> -                 {0,0}, /* 1800 */
> -                 {5,0x26}, /* 2400 */
> -                 {4,0x26}, /* 4800 */
> -                 {3,0x26}, /* 9600 */
> -                 {2,0x26}, /* 19200 */
> -                 {1,0x26}, /* 38400 */
> -                 {0,0x26}, /* 57600 */
> -                 {1,0x38}, /* 115200 */
> -};
> -#endif
> -/* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
> -
> -/*
> - * This routine is called to set the UART divisor registers to match
> - * the specified baud rate for a serial port.
> - */
> -static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned short port;
> -       unsigned short ustcnt;
> -       unsigned cflag;
> -       int     i;
> -
> -       cflag = tty->termios.c_cflag;
> -       port = info->port;
> -       if (!port)
> -               return;
> -
> -       ustcnt = uart->ustcnt;
> -       uart->ustcnt = ustcnt & ~USTCNT_TXEN;
> -
> -       i = cflag & CBAUD;
> -        if (i & CBAUDEX) {
> -                i = (i & ~CBAUDEX) + B38400;
> -        }
> -
> -       uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
> -               PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
> -
> -       ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
> -
> -       if ((cflag & CSIZE) == CS8)
> -               ustcnt |= USTCNT_8_7;
> -
> -       if (cflag & CSTOPB)
> -               ustcnt |= USTCNT_STOP;
> -
> -       if (cflag & PARENB)
> -               ustcnt |= USTCNT_PARITYEN;
> -       if (cflag & PARODD)
> -               ustcnt |= USTCNT_ODD_EVEN;
> -
> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
> -       if (cflag & CRTSCTS) {
> -               uart->utx.w &= ~ UTX_NOCTS;
> -       } else {
> -               uart->utx.w |= UTX_NOCTS;
> -       }
> -#endif
> -
> -       ustcnt |= USTCNT_TXEN;
> -
> -       uart->ustcnt = ustcnt;
> -       return;
> -}
> -
> -/*
> - * Fair output driver allows a process to speak.
> - */
> -static void rs_fair_output(void)
> -{
> -       int left;               /* Output no more than that */
> -       unsigned long flags;
> -       struct m68k_serial *info = &m68k_soft[0];
> -       char c;
> -
> -       if (info == NULL) return;
> -       if (info->xmit_buf == NULL) return;
> -
> -       local_irq_save(flags);
> -       left = info->xmit_cnt;
> -       while (left != 0) {
> -               c = info->xmit_buf[info->xmit_tail];
> -               info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
> -               info->xmit_cnt--;
> -               local_irq_restore(flags);
> -
> -               rs_put_char(c);
> -
> -               local_irq_save(flags);
> -               left = min(info->xmit_cnt, left-1);
> -       }
> -
> -       /* Last character is being transmitted now (hopefully). */
> -       udelay(5);
> -
> -       local_irq_restore(flags);
> -       return;
> -}
> -
> -/*
> - * m68k_console_print is registered for printk.
> - */
> -void console_print_68328(const char *p)
> -{
> -       char c;
> -
> -       while((c=*(p++)) != 0) {
> -               if(c == '\n')
> -                       rs_put_char('\r');
> -               rs_put_char(c);
> -       }
> -
> -       /* Comment this if you want to have a strict interrupt-driven output */
> -       rs_fair_output();
> -
> -       return;
> -}
> -
> -static void rs_set_ldisc(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
> -               return;
> -
> -       info->is_cons = (tty->termios.c_line == N_TTY);
> -
> -       printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
> -}
> -
> -static void rs_flush_chars(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
> -               return;
> -#ifndef USE_INTS
> -       for(;;) {
> -#endif
> -
> -       /* Enable transmitter */
> -       local_irq_save(flags);
> -
> -       if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) {
> -               local_irq_restore(flags);
> -               return;
> -       }
> -
> -#ifdef USE_INTS
> -       uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
> -#else
> -       uart->ustcnt |= USTCNT_TXEN;
> -#endif
> -
> -#ifdef USE_INTS
> -       if (uart->utx.w & UTX_TX_AVAIL) {
> -#else
> -       if (1) {
> -#endif
> -               /* Send char */
> -               uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
> -               info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
> -               info->xmit_cnt--;
> -       }
> -
> -#ifndef USE_INTS
> -       while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
> -       }
> -#endif
> -       local_irq_restore(flags);
> -}
> -
> -extern void console_printn(const char * b, int count);
> -
> -static int rs_write(struct tty_struct * tty,
> -                   const unsigned char *buf, int count)
> -{
> -       int     c, total = 0;
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_write"))
> -               return 0;
> -
> -       if (!tty || !info->xmit_buf)
> -               return 0;
> -
> -       local_save_flags(flags);
> -       while (1) {
> -               local_irq_disable();
> -               c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
> -                                  SERIAL_XMIT_SIZE - info->xmit_head));
> -               local_irq_restore(flags);
> -
> -               if (c <= 0)
> -                       break;
> -
> -               memcpy(info->xmit_buf + info->xmit_head, buf, c);
> -
> -               local_irq_disable();
> -               info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
> -               info->xmit_cnt += c;
> -               local_irq_restore(flags);
> -               buf += c;
> -               count -= c;
> -               total += c;
> -       }
> -
> -       if (info->xmit_cnt && !tty->stopped) {
> -               /* Enable transmitter */
> -               local_irq_disable();
> -#ifndef USE_INTS
> -               while(info->xmit_cnt) {
> -#endif
> -
> -               uart->ustcnt |= USTCNT_TXEN;
> -#ifdef USE_INTS
> -               uart->ustcnt |= USTCNT_TX_INTR_MASK;
> -#else
> -               while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
> -#endif
> -               if (uart->utx.w & UTX_TX_AVAIL) {
> -                       uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
> -                       info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
> -                       info->xmit_cnt--;
> -               }
> -
> -#ifndef USE_INTS
> -               }
> -#endif
> -               local_irq_restore(flags);
> -       }
> -
> -       return total;
> -}
> -
> -static int rs_write_room(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       int     ret;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_write_room"))
> -               return 0;
> -       ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
> -       if (ret < 0)
> -               ret = 0;
> -       return ret;
> -}
> -
> -static int rs_chars_in_buffer(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
> -               return 0;
> -       return info->xmit_cnt;
> -}
> -
> -static void rs_flush_buffer(struct tty_struct *tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
> -               return;
> -       local_irq_save(flags);
> -       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
> -       local_irq_restore(flags);
> -       tty_wakeup(tty);
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_throttle()
> - *
> - * This routine is called by the upper-layer tty layer to signal that
> - * incoming characters should be throttled.
> - * ------------------------------------------------------------
> - */
> -static void rs_throttle(struct tty_struct * tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_throttle"))
> -               return;
> -
> -       if (I_IXOFF(tty))
> -               info->x_char = STOP_CHAR(tty);
> -
> -       /* Turn off RTS line (do this atomic) */
> -}
> -
> -static void rs_unthrottle(struct tty_struct * tty)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
> -               return;
> -
> -       if (I_IXOFF(tty)) {
> -               if (info->x_char)
> -                       info->x_char = 0;
> -               else
> -                       info->x_char = START_CHAR(tty);
> -       }
> -
> -       /* Assert RTS line (do this atomic) */
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_ioctl() and friends
> - * ------------------------------------------------------------
> - */
> -
> -static int get_serial_info(struct m68k_serial * info,
> -                          struct serial_struct * retinfo)
> -{
> -       struct serial_struct tmp;
> -
> -       if (!retinfo)
> -               return -EFAULT;
> -       memset(&tmp, 0, sizeof(tmp));
> -       tmp.type = info->type;
> -       tmp.line = info->line;
> -       tmp.port = info->port;
> -       tmp.irq = info->irq;
> -       tmp.flags = info->tport.flags;
> -       tmp.baud_base = info->baud_base;
> -       tmp.close_delay = info->tport.close_delay;
> -       tmp.closing_wait = info->tport.closing_wait;
> -       tmp.custom_divisor = info->custom_divisor;
> -       if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
> -               return -EFAULT;
> -
> -       return 0;
> -}
> -
> -static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
> -                          struct serial_struct * new_info)
> -{
> -       struct tty_port *port = &info->tport;
> -       struct serial_struct new_serial;
> -       struct m68k_serial old_info;
> -       int                     retval = 0;
> -
> -       if (!new_info)
> -               return -EFAULT;
> -       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
> -               return -EFAULT;
> -       old_info = *info;
> -
> -       if (!capable(CAP_SYS_ADMIN)) {
> -               if ((new_serial.baud_base != info->baud_base) ||
> -                   (new_serial.type != info->type) ||
> -                   (new_serial.close_delay != port->close_delay) ||
> -                   ((new_serial.flags & ~ASYNC_USR_MASK) !=
> -                    (port->flags & ~ASYNC_USR_MASK)))
> -                       return -EPERM;
> -               port->flags = ((port->flags & ~ASYNC_USR_MASK) |
> -                              (new_serial.flags & ASYNC_USR_MASK));
> -               info->custom_divisor = new_serial.custom_divisor;
> -               goto check_and_exit;
> -       }
> -
> -       if (port->count > 1)
> -               return -EBUSY;
> -
> -       /*
> -        * OK, past this point, all the error checking has been done.
> -        * At this point, we start making changes.....
> -        */
> -
> -       info->baud_base = new_serial.baud_base;
> -       port->flags = ((port->flags & ~ASYNC_FLAGS) |
> -                       (new_serial.flags & ASYNC_FLAGS));
> -       info->type = new_serial.type;
> -       port->close_delay = new_serial.close_delay;
> -       port->closing_wait = new_serial.closing_wait;
> -
> -check_and_exit:
> -       retval = startup(info, tty);
> -       return retval;
> -}
> -
> -/*
> - * get_lsr_info - get line status register info
> - *
> - * Purpose: Let user call ioctl() to get info when the UART physically
> - *         is emptied.  On bus types like RS485, the transmitter must
> - *         release the bus after transmitting. This must be done when
> - *         the transmit shift register is empty, not be done when the
> - *         transmit holding register is empty.  This functionality
> - *         allows an RS485 driver to be written in user space.
> - */
> -static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
> -{
> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
> -       m68328_uart *uart = &uart_addr[info->line];
> -#endif
> -       unsigned char status;
> -       unsigned long flags;
> -
> -       local_irq_save(flags);
> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
> -       status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
> -#else
> -       status = 0;
> -#endif
> -       local_irq_restore(flags);
> -       return put_user(status, value);
> -}
> -
> -/*
> - * This routine sends a break character out the serial port.
> - */
> -static void send_break(struct m68k_serial * info, unsigned int duration)
> -{
> -       m68328_uart *uart = &uart_addr[info->line];
> -        unsigned long flags;
> -        if (!info->port)
> -                return;
> -        local_irq_save(flags);
> -#ifdef USE_INTS
> -       uart->utx.w |= UTX_SEND_BREAK;
> -       msleep_interruptible(duration);
> -       uart->utx.w &= ~UTX_SEND_BREAK;
> -#endif
> -        local_irq_restore(flags);
> -}
> -
> -static int rs_ioctl(struct tty_struct *tty,
> -                   unsigned int cmd, unsigned long arg)
> -{
> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
> -       int retval;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
> -               return -ENODEV;
> -
> -       if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
> -           (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD)  &&
> -           (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
> -               if (tty->flags & (1 << TTY_IO_ERROR))
> -                   return -EIO;
> -       }
> -
> -       switch (cmd) {
> -               case TCSBRK:    /* SVID version: non-zero arg --> no break */
> -                       retval = tty_check_change(tty);
> -                       if (retval)
> -                               return retval;
> -                       tty_wait_until_sent(tty, 0);
> -                       if (!arg)
> -                               send_break(info, 250);  /* 1/4 second */
> -                       return 0;
> -               case TCSBRKP:   /* support for POSIX tcsendbreak() */
> -                       retval = tty_check_change(tty);
> -                       if (retval)
> -                               return retval;
> -                       tty_wait_until_sent(tty, 0);
> -                       send_break(info, arg ? arg*(100) : 250);
> -                       return 0;
> -               case TIOCGSERIAL:
> -                       return get_serial_info(info,
> -                                      (struct serial_struct *) arg);
> -               case TIOCSSERIAL:
> -                       return set_serial_info(info, tty,
> -                                              (struct serial_struct *) arg);
> -               case TIOCSERGETLSR: /* Get line status register */
> -                       return get_lsr_info(info, (unsigned int *) arg);
> -               case TIOCSERGSTRUCT:
> -                       if (copy_to_user((struct m68k_serial *) arg,
> -                                   info, sizeof(struct m68k_serial)))
> -                               return -EFAULT;
> -                       return 0;
> -               default:
> -                       return -ENOIOCTLCMD;
> -               }
> -       return 0;
> -}
> -
> -static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
> -{
> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
> -
> -       change_speed(info, tty);
> -
> -       if ((old_termios->c_cflag & CRTSCTS) &&
> -           !(tty->termios.c_cflag & CRTSCTS))
> -               rs_start(tty);
> -
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_close()
> - *
> - * This routine is called when the serial port gets closed.  First, we
> - * wait for the last remaining data to be sent.  Then, we unlink its
> - * S structure from the interrupt chain if necessary, and we free
> - * that IRQ if nothing is left in the chain.
> - * ------------------------------------------------------------
> - */
> -static void rs_close(struct tty_struct *tty, struct file * filp)
> -{
> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
> -       struct tty_port *port = &info->tport;
> -       m68328_uart *uart = &uart_addr[info->line];
> -       unsigned long flags;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_close"))
> -               return;
> -
> -       local_irq_save(flags);
> -
> -       if (tty_hung_up_p(filp)) {
> -               local_irq_restore(flags);
> -               return;
> -       }
> -
> -       if ((tty->count == 1) && (port->count != 1)) {
> -               /*
> -                * Uh, oh.  tty->count is 1, which means that the tty
> -                * structure will be freed.  Info->count should always
> -                * be one in these conditions.  If it's greater than
> -                * one, we've got real problems, since it means the
> -                * serial port won't be shutdown.
> -                */
> -               printk("rs_close: bad serial port count; tty->count is 1, "
> -                      "port->count is %d\n", port->count);
> -               port->count = 1;
> -       }
> -       if (--port->count < 0) {
> -               printk("rs_close: bad serial port count for ttyS%d: %d\n",
> -                      info->line, port->count);
> -               port->count = 0;
> -       }
> -       if (port->count) {
> -               local_irq_restore(flags);
> -               return;
> -       }
> -       port->flags |= ASYNC_CLOSING;
> -       /*
> -        * Now we wait for the transmit buffer to clear; and we notify
> -        * the line discipline to only process XON/XOFF characters.
> -        */
> -       tty->closing = 1;
> -       if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
> -               tty_wait_until_sent(tty, port->closing_wait);
> -       /*
> -        * At this point we stop accepting input.  To do this, we
> -        * disable the receive line status interrupts, and tell the
> -        * interrupt driver to stop checking the data ready bit in the
> -        * line status register.
> -        */
> -
> -       uart->ustcnt &= ~USTCNT_RXEN;
> -       uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
> -
> -       shutdown(info, tty);
> -       rs_flush_buffer(tty);
> -
> -       tty_ldisc_flush(tty);
> -       tty->closing = 0;
> -       tty_port_tty_set(&info->tport, NULL);
> -#warning "This is not and has never been valid so fix it"
> -#if 0
> -       if (tty->ldisc.num != ldiscs[N_TTY].num) {
> -               if (tty->ldisc.close)
> -                       (tty->ldisc.close)(tty);
> -               tty->ldisc = ldiscs[N_TTY];
> -               tty->termios.c_line = N_TTY;
> -               if (tty->ldisc.open)
> -                       (tty->ldisc.open)(tty);
> -       }
> -#endif
> -       if (port->blocked_open) {
> -               if (port->close_delay)
> -                       msleep_interruptible(jiffies_to_msecs(port->close_delay));
> -               wake_up_interruptible(&port->open_wait);
> -       }
> -       port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
> -       local_irq_restore(flags);
> -}
> -
> -/*
> - * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
> - */
> -void rs_hangup(struct tty_struct *tty)
> -{
> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_hangup"))
> -               return;
> -
> -       rs_flush_buffer(tty);
> -       shutdown(info, tty);
> -       info->tport.count = 0;
> -       info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
> -       tty_port_tty_set(&info->tport, NULL);
> -       wake_up_interruptible(&info->tport.open_wait);
> -}
> -
> -/*
> - * This routine is called whenever a serial port is opened.  It
> - * enables interrupts for a serial port, linking in its S structure into
> - * the IRQ chain.   It also performs the serial-specific
> - * initialization for the tty structure.
> - */
> -int rs_open(struct tty_struct *tty, struct file * filp)
> -{
> -       struct m68k_serial      *info;
> -       int retval;
> -
> -       info = &m68k_soft[tty->index];
> -
> -       if (serial_paranoia_check(info, tty->name, "rs_open"))
> -               return -ENODEV;
> -
> -       info->tport.count++;
> -       tty->driver_data = info;
> -       tty_port_tty_set(&info->tport, tty);
> -
> -       /*
> -        * Start up serial port
> -        */
> -       retval = startup(info, tty);
> -       if (retval)
> -               return retval;
> -
> -       return tty_port_block_til_ready(&info->tport, tty, filp);
> -}
> -
> -/* Finally, routines used to initialize the serial driver. */
> -
> -static void show_serial_version(void)
> -{
> -       printk("MC68328 serial driver version 1.00\n");
> -}
> -
> -static const struct tty_operations rs_ops = {
> -       .open = rs_open,
> -       .close = rs_close,
> -       .write = rs_write,
> -       .flush_chars = rs_flush_chars,
> -       .write_room = rs_write_room,
> -       .chars_in_buffer = rs_chars_in_buffer,
> -       .flush_buffer = rs_flush_buffer,
> -       .ioctl = rs_ioctl,
> -       .throttle = rs_throttle,
> -       .unthrottle = rs_unthrottle,
> -       .set_termios = rs_set_termios,
> -       .stop = rs_stop,
> -       .start = rs_start,
> -       .hangup = rs_hangup,
> -       .set_ldisc = rs_set_ldisc,
> -};
> -
> -static const struct tty_port_operations rs_port_ops = {
> -};
> -
> -/* rs_init inits the driver */
> -static int __init
> -rs68328_init(void)
> -{
> -       unsigned long flags;
> -       int i;
> -       struct m68k_serial *info;
> -
> -       serial_driver = alloc_tty_driver(NR_PORTS);
> -       if (!serial_driver)
> -               return -ENOMEM;
> -
> -       show_serial_version();
> -
> -       /* Initialize the tty_driver structure */
> -       /* SPARC: Not all of this is exactly right for us. */
> -
> -       serial_driver->name = "ttyS";
> -       serial_driver->major = TTY_MAJOR;
> -       serial_driver->minor_start = 64;
> -       serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
> -       serial_driver->subtype = SERIAL_TYPE_NORMAL;
> -       serial_driver->init_termios = tty_std_termios;
> -       serial_driver->init_termios.c_cflag =
> -                       m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
> -       serial_driver->flags = TTY_DRIVER_REAL_RAW;
> -       tty_set_operations(serial_driver, &rs_ops);
> -
> -       local_irq_save(flags);
> -
> -       for(i=0;i<NR_PORTS;i++) {
> -
> -           info = &m68k_soft[i];
> -           tty_port_init(&info->tport);
> -           info->tport.ops = &rs_port_ops;
> -           info->magic = SERIAL_MAGIC;
> -           info->port = (int) &uart_addr[i];
> -           info->irq = uart_irqs[i];
> -           info->custom_divisor = 16;
> -           info->x_char = 0;
> -           info->line = i;
> -           info->is_cons = 1; /* Means shortcuts work */
> -
> -           printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
> -                  info->port, info->irq);
> -           printk(" is a builtin MC68328 UART\n");
> -
> -#ifdef CONFIG_M68VZ328
> -               if (i > 0 )
> -                       PJSEL &= 0xCF;  /* PSW enable second port output */
> -#endif
> -
> -           if (request_irq(uart_irqs[i],
> -                           rs_interrupt,
> -                           0,
> -                           "M68328_UART", info))
> -                panic("Unable to attach 68328 serial interrupt\n");
> -
> -           tty_port_link_device(&info->tport, serial_driver, i);
> -       }
> -       local_irq_restore(flags);
> -
> -       if (tty_register_driver(serial_driver)) {
> -               put_tty_driver(serial_driver);
> -               for (i = 0; i < NR_PORTS; i++)
> -                       tty_port_destroy(&m68k_soft[i].tport);
> -               printk(KERN_ERR "Couldn't register serial driver\n");
> -               return -ENOMEM;
> -       }
> -
> -       return 0;
> -}
> -
> -module_init(rs68328_init);
> -
> -
> -
> -static void m68328_set_baud(void)
> -{
> -       unsigned short ustcnt;
> -       int     i;
> -
> -       ustcnt = USTCNT;
> -       USTCNT = ustcnt & ~USTCNT_TXEN;
> -
> -again:
> -       for (i = 0; i < ARRAY_SIZE(baud_table); i++)
> -               if (baud_table[i] == m68328_console_baud)
> -                       break;
> -       if (i >= ARRAY_SIZE(baud_table)) {
> -               m68328_console_baud = 9600;
> -               goto again;
> -       }
> -
> -       UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
> -               PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
> -       ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
> -       ustcnt |= USTCNT_8_7;
> -       ustcnt |= USTCNT_TXEN;
> -       USTCNT = ustcnt;
> -       m68328_console_initted = 1;
> -       return;
> -}
> -
> -
> -int m68328_console_setup(struct console *cp, char *arg)
> -{
> -       int             i, n = CONSOLE_BAUD_RATE;
> -
> -       if (!cp)
> -               return(-1);
> -
> -       if (arg)
> -               n = simple_strtoul(arg,NULL,0);
> -
> -       for (i = 0; i < ARRAY_SIZE(baud_table); i++)
> -               if (baud_table[i] == n)
> -                       break;
> -       if (i < ARRAY_SIZE(baud_table)) {
> -               m68328_console_baud = n;
> -               m68328_console_cbaud = 0;
> -               if (i > 15) {
> -                       m68328_console_cbaud |= CBAUDEX;
> -                       i -= 15;
> -               }
> -               m68328_console_cbaud |= i;
> -       }
> -
> -       m68328_set_baud(); /* make sure baud rate changes */
> -       return(0);
> -}
> -
> -
> -static struct tty_driver *m68328_console_device(struct console *c, int *index)
> -{
> -       *index = c->index;
> -       return serial_driver;
> -}
> -
> -
> -void m68328_console_write (struct console *co, const char *str,
> -                          unsigned int count)
> -{
> -       if (!m68328_console_initted)
> -               m68328_set_baud();
> -    while (count--) {
> -        if (*str == '\n')
> -           rs_put_char('\r');
> -        rs_put_char( *str++ );
> -    }
> -}
> -
> -
> -static struct console m68328_driver = {
> -       .name           = "ttyS",
> -       .write          = m68328_console_write,
> -       .device         = m68328_console_device,
> -       .setup          = m68328_console_setup,
> -       .flags          = CON_PRINTBUFFER,
> -       .index          = -1,
> -};
> -
> -
> -static int __init m68328_console_init(void)
> -{
> -       register_console(&m68328_driver);
> -       return 0;
> -}
> -
> -console_initcall(m68328_console_init);
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index f38beb2..a261457 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -790,17 +790,6 @@ config SERIAL_CORE_CONSOLE
>  config CONSOLE_POLL
>         bool
>
> -config SERIAL_68328
> -       bool "68328 serial support"
> -       depends on M68328 || M68EZ328 || M68VZ328
> -       help
> -         This driver supports the built-in serial port of the Motorola 68328
> -         (standard, EZ and VZ varieties).
> -
> -config SERIAL_68328_RTS_CTS
> -       bool "Support RTS/CTS on 68328 serial port"
> -       depends on SERIAL_68328
> -
>  config SERIAL_MCF
>         bool "Coldfire serial support"
>         depends on COLDFIRE
> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
> index 5ab4111..9d35387 100644
> --- a/drivers/tty/serial/Makefile
> +++ b/drivers/tty/serial/Makefile
> @@ -34,7 +34,6 @@ obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
>  obj-$(CONFIG_SERIAL_MAX310X) += max310x.o
>  obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
>  obj-$(CONFIG_SERIAL_MUX) += mux.o
> -obj-$(CONFIG_SERIAL_68328) += 68328serial.o
>  obj-$(CONFIG_SERIAL_MCF) += mcf.o
>  obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
>  obj-$(CONFIG_SERIAL_HS_LPC32XX) += lpc32xx_hs.o
> --
> 1.9.1

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

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

* Re: [PATCH] serial: Remove 68328 driver
  2015-12-18 14:27     ` Geert Uytterhoeven
  (?)
@ 2016-01-04  5:03     ` Greg Ungerer
  2016-01-04 10:30       ` One Thousand Gnomes
  -1 siblings, 1 reply; 32+ messages in thread
From: Greg Ungerer @ 2016-01-04  5:03 UTC (permalink / raw)
  To: Linux/m68k
  Cc: Geert Uytterhoeven, Frederik Völkel, Jiri Slaby, Greg KH,
	linux-serial, linux-kernel, linux-kernel, Lukas Braun,
	uClinux development list

If 68328serial.c is removed is there any point keeping the
architecture support for 68328 platforms?

The 68328serial.c provides pretty much the only type of console
that can be used on these devices. They are largely useless
without this.

Regards
Greg



On 19/12/15 00:27, Geert Uytterhoeven wrote:
> CC linux-m68k, uClinux-dev
> 
> On Fri, Dec 18, 2015 at 12:28 PM, Frederik Völkel
> <frederik.voelkel@fau.de> wrote:
>> It's old, messy and mostly unmaintained.
>> Remove it as suggested by Peter Hurley and Alan.
>>
>> Signed-off-by: Frederik Völkel <frederik.voelkel@fau.de>
>> Signed-off-by: Lukas Braun <lukas.braun@fau.de>
>> ---
>> Should we remove other drivers like framebuffer as well?
>> It is probably useless without serial support.
>> ---
>>  drivers/tty/serial/68328serial.c | 1322 --------------------------------------
>>  drivers/tty/serial/Kconfig       |   11 -
>>  drivers/tty/serial/Makefile      |    1 -
>>  3 files changed, 1334 deletions(-)
>>  delete mode 100644 drivers/tty/serial/68328serial.c
>>
>> diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
>> deleted file mode 100644
>> index 0140ba4..0000000
>> --- a/drivers/tty/serial/68328serial.c
>> +++ /dev/null
>> @@ -1,1322 +0,0 @@
>> -/* 68328serial.c: Serial port driver for 68328 microcontroller
>> - *
>> - * Copyright (C) 1995       David S. Miller    <davem@caip.rutgers.edu>
>> - * Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
>> - * Copyright (C) 1998, 1999 D. Jeff Dionne     <jeff@uclinux.org>
>> - * Copyright (C) 1999       Vladimir Gurevich  <vgurevic@cisco.com>
>> - * Copyright (C) 2002-2003  David McCullough   <davidm@snapgear.com>
>> - * Copyright (C) 2002       Greg Ungerer       <gerg@snapgear.com>
>> - *
>> - * VZ Support/Fixes             Evan Stawnyczy <e@lineo.ca>
>> - * Multiple UART support        Daniel Potts <danielp@cse.unsw.edu.au>
>> - * Power management support     Daniel Potts <danielp@cse.unsw.edu.au>
>> - * VZ Second Serial Port enable Phil Wilshire
>> - * 2.4/2.5 port                 David McCullough
>> - */
>> -
>> -#include <linux/module.h>
>> -#include <linux/errno.h>
>> -#include <linux/serial.h>
>> -#include <linux/signal.h>
>> -#include <linux/sched.h>
>> -#include <linux/timer.h>
>> -#include <linux/interrupt.h>
>> -#include <linux/tty.h>
>> -#include <linux/tty_flip.h>
>> -#include <linux/major.h>
>> -#include <linux/string.h>
>> -#include <linux/fcntl.h>
>> -#include <linux/mm.h>
>> -#include <linux/kernel.h>
>> -#include <linux/console.h>
>> -#include <linux/reboot.h>
>> -#include <linux/keyboard.h>
>> -#include <linux/init.h>
>> -#include <linux/pm.h>
>> -#include <linux/bitops.h>
>> -#include <linux/delay.h>
>> -#include <linux/gfp.h>
>> -
>> -#include <asm/io.h>
>> -#include <asm/irq.h>
>> -#include <asm/delay.h>
>> -#include <asm/uaccess.h>
>> -
>> -/* (es) */
>> -/* note: perhaps we can murge these files, so that you can just
>> - *      define 1 of them, and they can sort that out for themselves
>> - */
>> -#if defined(CONFIG_M68EZ328)
>> -#include <asm/MC68EZ328.h>
>> -#else
>> -#if defined(CONFIG_M68VZ328)
>> -#include <asm/MC68VZ328.h>
>> -#else
>> -#include <asm/MC68328.h>
>> -#endif /* CONFIG_M68VZ328 */
>> -#endif /* CONFIG_M68EZ328 */
>> -
>> -/* Turn off usage of real serial interrupt code, to "support" Copilot */
>> -#ifdef CONFIG_XCOPILOT_BUGS
>> -#undef USE_INTS
>> -#else
>> -#define USE_INTS
>> -#endif
>> -
>> -/*
>> - * I believe this is the optimal setting that reduces the number of interrupts.
>> - * At high speeds the output might become a little "bursted" (use USTCNT_TXHE
>> - * if that bothers you), but in most cases it will not, since we try to
>> - * transmit characters every time rs_interrupt is called. Thus, quite often
>> - * you'll see that a receive interrupt occures before the transmit one.
>> - *                                  -- Vladimir Gurevich
>> - */
>> -#define USTCNT_TX_INTR_MASK (USTCNT_TXEE)
>> -
>> -/*
>> - * 68328 and 68EZ328 UARTS are a little bit different. EZ328 has special
>> - * "Old data interrupt" which occures whenever the data stay in the FIFO
>> - * longer than 30 bits time. This allows us to use FIFO without compromising
>> - * latency. '328 does not have this feature and without the real  328-based
>> - * board I would assume that RXRE is the safest setting.
>> - *
>> - * For EZ328 I use RXHE (Half empty) interrupt to reduce the number of
>> - * interrupts. RXFE (receive queue full) causes the system to lose data
>> - * at least at 115200 baud
>> - *
>> - * If your board is busy doing other stuff, you might consider to use
>> - * RXRE (data ready intrrupt) instead.
>> - *
>> - * The other option is to make these INTR masks run-time configurable, so
>> - * that people can dynamically adapt them according to the current usage.
>> - *                                  -- Vladimir Gurevich
>> - */
>> -
>> -/* (es) */
>> -#if defined(CONFIG_M68EZ328) || defined(CONFIG_M68VZ328)
>> -#define USTCNT_RX_INTR_MASK (USTCNT_RXHE | USTCNT_ODEN)
>> -#elif defined(CONFIG_M68328)
>> -#define USTCNT_RX_INTR_MASK (USTCNT_RXRE)
>> -#else
>> -#error Please, define the Rx interrupt events for your CPU
>> -#endif
>> -/* (/es) */
>> -
>> -/*
>> - * This is our internal structure for each serial port's state.
>> - */
>> -struct m68k_serial {
>> -       struct tty_port         tport;
>> -       char                    is_cons;        /* Is this our console. */
>> -       int                     magic;
>> -       int                     baud_base;
>> -       int                     port;
>> -       int                     irq;
>> -       int                     type;           /* UART type */
>> -       int                     custom_divisor;
>> -       int                     x_char;         /* xon/xoff character */
>> -       int                     line;
>> -       unsigned char           *xmit_buf;
>> -       int                     xmit_head;
>> -       int                     xmit_tail;
>> -       int                     xmit_cnt;
>> -};
>> -
>> -#define SERIAL_MAGIC 0x5301
>> -
>> -/*
>> - * Define the number of ports supported and their irqs.
>> - */
>> -#define NR_PORTS 1
>> -
>> -static struct m68k_serial m68k_soft[NR_PORTS];
>> -
>> -static unsigned int uart_irqs[NR_PORTS] = { UART_IRQ_NUM };
>> -
>> -/* multiple ports are contiguous in memory */
>> -m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR;
>> -
>> -struct tty_driver *serial_driver;
>> -
>> -static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
>> -
>> -/*
>> - *     Setup for console. Argument comes from the boot command line.
>> - */
>> -
>> -/* note: this is messy, but it works, again, perhaps defined somewhere else?*/
>> -#ifdef CONFIG_M68VZ328
>> -#define CONSOLE_BAUD_RATE      19200
>> -#define DEFAULT_CBAUD          B19200
>> -#endif
>> -
>> -
>> -#ifndef CONSOLE_BAUD_RATE
>> -#define        CONSOLE_BAUD_RATE       9600
>> -#define        DEFAULT_CBAUD           B9600
>> -#endif
>> -
>> -
>> -static int m68328_console_initted = 0;
>> -static int m68328_console_baud    = CONSOLE_BAUD_RATE;
>> -static int m68328_console_cbaud   = DEFAULT_CBAUD;
>> -
>> -
>> -static inline int serial_paranoia_check(struct m68k_serial *info,
>> -                                       char *name, const char *routine)
>> -{
>> -#ifdef SERIAL_PARANOIA_CHECK
>> -       static const char *badmagic =
>> -               "Warning: bad magic number for serial struct %s in %s\n";
>> -       static const char *badinfo =
>> -               "Warning: null m68k_serial for %s in %s\n";
>> -
>> -       if (!info) {
>> -               printk(badinfo, name, routine);
>> -               return 1;
>> -       }
>> -       if (info->magic != SERIAL_MAGIC) {
>> -               printk(badmagic, name, routine);
>> -               return 1;
>> -       }
>> -#endif
>> -       return 0;
>> -}
>> -
>> -/*
>> - * This is used to figure out the divisor speeds and the timeouts
>> - */
>> -static int baud_table[] = {
>> -       0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
>> -       9600, 19200, 38400, 57600, 115200, 0 };
>> -
>> -/* Utility routines */
>> -static inline int get_baud(struct m68k_serial *ss)
>> -{
>> -       unsigned long result = 115200;
>> -       unsigned short int baud = uart_addr[ss->line].ubaud;
>> -       if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
>> -       result >>= GET_FIELD(baud, UBAUD_DIVIDE);
>> -
>> -       return result;
>> -}
>> -
>> -/*
>> - * ------------------------------------------------------------
>> - * rs_stop() and rs_start()
>> - *
>> - * This routines are called before setting or resetting tty->stopped.
>> - * They enable or disable transmitter interrupts, as necessary.
>> - * ------------------------------------------------------------
>> - */
>> -static void rs_stop(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long flags;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_stop"))
>> -               return;
>> -
>> -       local_irq_save(flags);
>> -       uart->ustcnt &= ~USTCNT_TXEN;
>> -       local_irq_restore(flags);
>> -}
>> -
>> -static int rs_put_char(char ch)
>> -{
>> -       unsigned long flags;
>> -       int loops = 0;
>> -
>> -        local_irq_save(flags);
>> -
>> -       while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
>> -               loops++;
>> -               udelay(5);
>> -        }
>> -
>> -       UTX_TXDATA = ch;
>> -        udelay(5);
>> -        local_irq_restore(flags);
>> -        return 1;
>> -}
>> -
>> -static void rs_start(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long flags;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_start"))
>> -               return;
>> -
>> -       local_irq_save(flags);
>> -       if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
>> -#ifdef USE_INTS
>> -               uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
>> -#else
>> -               uart->ustcnt |= USTCNT_TXEN;
>> -#endif
>> -       }
>> -       local_irq_restore(flags);
>> -}
>> -
>> -static void receive_chars(struct m68k_serial *info, unsigned short rx)
>> -{
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned char ch, flag;
>> -
>> -       /*
>> -        * This do { } while() loop will get ALL chars out of Rx FIFO
>> -         */
>> -#ifndef CONFIG_XCOPILOT_BUGS
>> -       do {
>> -#endif
>> -               ch = GET_FIELD(rx, URX_RXDATA);
>> -
>> -               if(info->is_cons) {
>> -                       if(URX_BREAK & rx) { /* whee, break received */
>> -                               return;
>> -#ifdef CONFIG_MAGIC_SYSRQ
>> -                       } else if (ch == 0x10) { /* ^P */
>> -                               show_state();
>> -                               show_free_areas(0);
>> -                               show_buffers();
>> -/*                             show_net_buffers(); */
>> -                               return;
>> -                       } else if (ch == 0x12) { /* ^R */
>> -                               emergency_restart();
>> -                               return;
>> -#endif /* CONFIG_MAGIC_SYSRQ */
>> -                       }
>> -               }
>> -
>> -               flag = TTY_NORMAL;
>> -
>> -               if (rx & URX_PARITY_ERROR)
>> -                       flag = TTY_PARITY;
>> -               else if (rx & URX_OVRUN)
>> -                       flag = TTY_OVERRUN;
>> -               else if (rx & URX_FRAME_ERROR)
>> -                       flag = TTY_FRAME;
>> -
>> -               tty_insert_flip_char(&info->tport, ch, flag);
>> -#ifndef CONFIG_XCOPILOT_BUGS
>> -       } while((rx = uart->urx.w) & URX_DATA_READY);
>> -#endif
>> -
>> -       tty_schedule_flip(&info->tport);
>> -}
>> -
>> -static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
>> -{
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -
>> -       if (info->x_char) {
>> -               /* Send next char */
>> -               uart->utx.b.txdata = info->x_char;
>> -               info->x_char = 0;
>> -               goto clear_and_return;
>> -       }
>> -
>> -       if ((info->xmit_cnt <= 0) || !tty || tty->stopped) {
>> -               /* That's peculiar... TX ints off */
>> -               uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
>> -               goto clear_and_return;
>> -       }
>> -
>> -       /* Send char */
>> -       uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
>> -       info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
>> -       info->xmit_cnt--;
>> -
>> -       if(info->xmit_cnt <= 0) {
>> -               /* All done for now... TX ints off */
>> -               uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
>> -               goto clear_and_return;
>> -       }
>> -
>> -clear_and_return:
>> -       /* Clear interrupt (should be auto)*/
>> -       return;
>> -}
>> -
>> -/*
>> - * This is the serial driver's generic interrupt routine
>> - */
>> -irqreturn_t rs_interrupt(int irq, void *dev_id)
>> -{
>> -       struct m68k_serial *info = dev_id;
>> -       struct tty_struct *tty = tty_port_tty_get(&info->tport);
>> -       m68328_uart *uart;
>> -       unsigned short rx;
>> -       unsigned short tx;
>> -
>> -       uart = &uart_addr[info->line];
>> -       rx = uart->urx.w;
>> -
>> -#ifdef USE_INTS
>> -       tx = uart->utx.w;
>> -
>> -       if (rx & URX_DATA_READY)
>> -               receive_chars(info, rx);
>> -       if (tx & UTX_TX_AVAIL)
>> -               transmit_chars(info, tty);
>> -#else
>> -       receive_chars(info, rx);
>> -#endif
>> -       tty_kref_put(tty);
>> -
>> -       return IRQ_HANDLED;
>> -}
>> -
>> -static int startup(struct m68k_serial *info, struct tty_struct *tty)
>> -{
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long flags;
>> -
>> -       if (info->tport.flags & ASYNC_INITIALIZED)
>> -               return 0;
>> -
>> -       if (!info->xmit_buf) {
>> -               info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
>> -               if (!info->xmit_buf)
>> -                       return -ENOMEM;
>> -       }
>> -
>> -       local_irq_save(flags);
>> -
>> -       /*
>> -        * Clear the FIFO buffers and disable them
>> -        * (they will be reenabled in change_speed())
>> -        */
>> -
>> -       uart->ustcnt = USTCNT_UEN;
>> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
>> -       (void)uart->urx.w;
>> -
>> -       /*
>> -        * Finally, enable sequencing and interrupts
>> -        */
>> -#ifdef USE_INTS
>> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
>> -                 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
>> -#else
>> -       uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
>> -#endif
>> -
>> -       if (tty)
>> -               clear_bit(TTY_IO_ERROR, &tty->flags);
>> -       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
>> -
>> -       /*
>> -        * and set the speed of the serial port
>> -        */
>> -
>> -       change_speed(info, tty);
>> -
>> -       info->tport.flags |= ASYNC_INITIALIZED;
>> -       local_irq_restore(flags);
>> -       return 0;
>> -}
>> -
>> -/*
>> - * This routine will shutdown a serial port; interrupts are disabled, and
>> - * DTR is dropped if the hangup on close termio flag is on.
>> - */
>> -static void shutdown(struct m68k_serial *info, struct tty_struct *tty)
>> -{
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long   flags;
>> -
>> -       uart->ustcnt = 0; /* All off! */
>> -       if (!(info->tport.flags & ASYNC_INITIALIZED))
>> -               return;
>> -
>> -       local_irq_save(flags);
>> -
>> -       if (info->xmit_buf) {
>> -               free_page((unsigned long) info->xmit_buf);
>> -               info->xmit_buf = 0;
>> -       }
>> -
>> -       if (tty)
>> -               set_bit(TTY_IO_ERROR, &tty->flags);
>> -
>> -       info->tport.flags &= ~ASYNC_INITIALIZED;
>> -       local_irq_restore(flags);
>> -}
>> -
>> -struct {
>> -       int divisor, prescale;
>> -}
>> -#ifndef CONFIG_M68VZ328
>> - hw_baud_table[18] = {
>> -       {0,0}, /* 0 */
>> -       {0,0}, /* 50 */
>> -       {0,0}, /* 75 */
>> -       {0,0}, /* 110 */
>> -       {0,0}, /* 134 */
>> -       {0,0}, /* 150 */
>> -       {0,0}, /* 200 */
>> -       {7,0x26}, /* 300 */
>> -       {6,0x26}, /* 600 */
>> -       {5,0x26}, /* 1200 */
>> -       {0,0}, /* 1800 */
>> -       {4,0x26}, /* 2400 */
>> -       {3,0x26}, /* 4800 */
>> -       {2,0x26}, /* 9600 */
>> -       {1,0x26}, /* 19200 */
>> -       {0,0x26}, /* 38400 */
>> -       {1,0x38}, /* 57600 */
>> -       {0,0x38}, /* 115200 */
>> -};
>> -#else
>> - hw_baud_table[18] = {
>> -                 {0,0}, /* 0 */
>> -                 {0,0}, /* 50 */
>> -                 {0,0}, /* 75 */
>> -                 {0,0}, /* 110 */
>> -                 {0,0}, /* 134 */
>> -                 {0,0}, /* 150 */
>> -                 {0,0}, /* 200 */
>> -                 {0,0}, /* 300 */
>> -                 {7,0x26}, /* 600 */
>> -                 {6,0x26}, /* 1200 */
>> -                 {0,0}, /* 1800 */
>> -                 {5,0x26}, /* 2400 */
>> -                 {4,0x26}, /* 4800 */
>> -                 {3,0x26}, /* 9600 */
>> -                 {2,0x26}, /* 19200 */
>> -                 {1,0x26}, /* 38400 */
>> -                 {0,0x26}, /* 57600 */
>> -                 {1,0x38}, /* 115200 */
>> -};
>> -#endif
>> -/* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
>> -
>> -/*
>> - * This routine is called to set the UART divisor registers to match
>> - * the specified baud rate for a serial port.
>> - */
>> -static void change_speed(struct m68k_serial *info, struct tty_struct *tty)
>> -{
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned short port;
>> -       unsigned short ustcnt;
>> -       unsigned cflag;
>> -       int     i;
>> -
>> -       cflag = tty->termios.c_cflag;
>> -       port = info->port;
>> -       if (!port)
>> -               return;
>> -
>> -       ustcnt = uart->ustcnt;
>> -       uart->ustcnt = ustcnt & ~USTCNT_TXEN;
>> -
>> -       i = cflag & CBAUD;
>> -        if (i & CBAUDEX) {
>> -                i = (i & ~CBAUDEX) + B38400;
>> -        }
>> -
>> -       uart->ubaud = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
>> -               PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
>> -
>> -       ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
>> -
>> -       if ((cflag & CSIZE) == CS8)
>> -               ustcnt |= USTCNT_8_7;
>> -
>> -       if (cflag & CSTOPB)
>> -               ustcnt |= USTCNT_STOP;
>> -
>> -       if (cflag & PARENB)
>> -               ustcnt |= USTCNT_PARITYEN;
>> -       if (cflag & PARODD)
>> -               ustcnt |= USTCNT_ODD_EVEN;
>> -
>> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
>> -       if (cflag & CRTSCTS) {
>> -               uart->utx.w &= ~ UTX_NOCTS;
>> -       } else {
>> -               uart->utx.w |= UTX_NOCTS;
>> -       }
>> -#endif
>> -
>> -       ustcnt |= USTCNT_TXEN;
>> -
>> -       uart->ustcnt = ustcnt;
>> -       return;
>> -}
>> -
>> -/*
>> - * Fair output driver allows a process to speak.
>> - */
>> -static void rs_fair_output(void)
>> -{
>> -       int left;               /* Output no more than that */
>> -       unsigned long flags;
>> -       struct m68k_serial *info = &m68k_soft[0];
>> -       char c;
>> -
>> -       if (info == NULL) return;
>> -       if (info->xmit_buf == NULL) return;
>> -
>> -       local_irq_save(flags);
>> -       left = info->xmit_cnt;
>> -       while (left != 0) {
>> -               c = info->xmit_buf[info->xmit_tail];
>> -               info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
>> -               info->xmit_cnt--;
>> -               local_irq_restore(flags);
>> -
>> -               rs_put_char(c);
>> -
>> -               local_irq_save(flags);
>> -               left = min(info->xmit_cnt, left-1);
>> -       }
>> -
>> -       /* Last character is being transmitted now (hopefully). */
>> -       udelay(5);
>> -
>> -       local_irq_restore(flags);
>> -       return;
>> -}
>> -
>> -/*
>> - * m68k_console_print is registered for printk.
>> - */
>> -void console_print_68328(const char *p)
>> -{
>> -       char c;
>> -
>> -       while((c=*(p++)) != 0) {
>> -               if(c == '\n')
>> -                       rs_put_char('\r');
>> -               rs_put_char(c);
>> -       }
>> -
>> -       /* Comment this if you want to have a strict interrupt-driven output */
>> -       rs_fair_output();
>> -
>> -       return;
>> -}
>> -
>> -static void rs_set_ldisc(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
>> -               return;
>> -
>> -       info->is_cons = (tty->termios.c_line == N_TTY);
>> -
>> -       printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
>> -}
>> -
>> -static void rs_flush_chars(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long flags;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
>> -               return;
>> -#ifndef USE_INTS
>> -       for(;;) {
>> -#endif
>> -
>> -       /* Enable transmitter */
>> -       local_irq_save(flags);
>> -
>> -       if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) {
>> -               local_irq_restore(flags);
>> -               return;
>> -       }
>> -
>> -#ifdef USE_INTS
>> -       uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
>> -#else
>> -       uart->ustcnt |= USTCNT_TXEN;
>> -#endif
>> -
>> -#ifdef USE_INTS
>> -       if (uart->utx.w & UTX_TX_AVAIL) {
>> -#else
>> -       if (1) {
>> -#endif
>> -               /* Send char */
>> -               uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
>> -               info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
>> -               info->xmit_cnt--;
>> -       }
>> -
>> -#ifndef USE_INTS
>> -       while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
>> -       }
>> -#endif
>> -       local_irq_restore(flags);
>> -}
>> -
>> -extern void console_printn(const char * b, int count);
>> -
>> -static int rs_write(struct tty_struct * tty,
>> -                   const unsigned char *buf, int count)
>> -{
>> -       int     c, total = 0;
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long flags;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_write"))
>> -               return 0;
>> -
>> -       if (!tty || !info->xmit_buf)
>> -               return 0;
>> -
>> -       local_save_flags(flags);
>> -       while (1) {
>> -               local_irq_disable();
>> -               c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
>> -                                  SERIAL_XMIT_SIZE - info->xmit_head));
>> -               local_irq_restore(flags);
>> -
>> -               if (c <= 0)
>> -                       break;
>> -
>> -               memcpy(info->xmit_buf + info->xmit_head, buf, c);
>> -
>> -               local_irq_disable();
>> -               info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
>> -               info->xmit_cnt += c;
>> -               local_irq_restore(flags);
>> -               buf += c;
>> -               count -= c;
>> -               total += c;
>> -       }
>> -
>> -       if (info->xmit_cnt && !tty->stopped) {
>> -               /* Enable transmitter */
>> -               local_irq_disable();
>> -#ifndef USE_INTS
>> -               while(info->xmit_cnt) {
>> -#endif
>> -
>> -               uart->ustcnt |= USTCNT_TXEN;
>> -#ifdef USE_INTS
>> -               uart->ustcnt |= USTCNT_TX_INTR_MASK;
>> -#else
>> -               while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
>> -#endif
>> -               if (uart->utx.w & UTX_TX_AVAIL) {
>> -                       uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
>> -                       info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
>> -                       info->xmit_cnt--;
>> -               }
>> -
>> -#ifndef USE_INTS
>> -               }
>> -#endif
>> -               local_irq_restore(flags);
>> -       }
>> -
>> -       return total;
>> -}
>> -
>> -static int rs_write_room(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -       int     ret;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_write_room"))
>> -               return 0;
>> -       ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
>> -       if (ret < 0)
>> -               ret = 0;
>> -       return ret;
>> -}
>> -
>> -static int rs_chars_in_buffer(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
>> -               return 0;
>> -       return info->xmit_cnt;
>> -}
>> -
>> -static void rs_flush_buffer(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -       unsigned long flags;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
>> -               return;
>> -       local_irq_save(flags);
>> -       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
>> -       local_irq_restore(flags);
>> -       tty_wakeup(tty);
>> -}
>> -
>> -/*
>> - * ------------------------------------------------------------
>> - * rs_throttle()
>> - *
>> - * This routine is called by the upper-layer tty layer to signal that
>> - * incoming characters should be throttled.
>> - * ------------------------------------------------------------
>> - */
>> -static void rs_throttle(struct tty_struct * tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_throttle"))
>> -               return;
>> -
>> -       if (I_IXOFF(tty))
>> -               info->x_char = STOP_CHAR(tty);
>> -
>> -       /* Turn off RTS line (do this atomic) */
>> -}
>> -
>> -static void rs_unthrottle(struct tty_struct * tty)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
>> -               return;
>> -
>> -       if (I_IXOFF(tty)) {
>> -               if (info->x_char)
>> -                       info->x_char = 0;
>> -               else
>> -                       info->x_char = START_CHAR(tty);
>> -       }
>> -
>> -       /* Assert RTS line (do this atomic) */
>> -}
>> -
>> -/*
>> - * ------------------------------------------------------------
>> - * rs_ioctl() and friends
>> - * ------------------------------------------------------------
>> - */
>> -
>> -static int get_serial_info(struct m68k_serial * info,
>> -                          struct serial_struct * retinfo)
>> -{
>> -       struct serial_struct tmp;
>> -
>> -       if (!retinfo)
>> -               return -EFAULT;
>> -       memset(&tmp, 0, sizeof(tmp));
>> -       tmp.type = info->type;
>> -       tmp.line = info->line;
>> -       tmp.port = info->port;
>> -       tmp.irq = info->irq;
>> -       tmp.flags = info->tport.flags;
>> -       tmp.baud_base = info->baud_base;
>> -       tmp.close_delay = info->tport.close_delay;
>> -       tmp.closing_wait = info->tport.closing_wait;
>> -       tmp.custom_divisor = info->custom_divisor;
>> -       if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
>> -               return -EFAULT;
>> -
>> -       return 0;
>> -}
>> -
>> -static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty,
>> -                          struct serial_struct * new_info)
>> -{
>> -       struct tty_port *port = &info->tport;
>> -       struct serial_struct new_serial;
>> -       struct m68k_serial old_info;
>> -       int                     retval = 0;
>> -
>> -       if (!new_info)
>> -               return -EFAULT;
>> -       if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
>> -               return -EFAULT;
>> -       old_info = *info;
>> -
>> -       if (!capable(CAP_SYS_ADMIN)) {
>> -               if ((new_serial.baud_base != info->baud_base) ||
>> -                   (new_serial.type != info->type) ||
>> -                   (new_serial.close_delay != port->close_delay) ||
>> -                   ((new_serial.flags & ~ASYNC_USR_MASK) !=
>> -                    (port->flags & ~ASYNC_USR_MASK)))
>> -                       return -EPERM;
>> -               port->flags = ((port->flags & ~ASYNC_USR_MASK) |
>> -                              (new_serial.flags & ASYNC_USR_MASK));
>> -               info->custom_divisor = new_serial.custom_divisor;
>> -               goto check_and_exit;
>> -       }
>> -
>> -       if (port->count > 1)
>> -               return -EBUSY;
>> -
>> -       /*
>> -        * OK, past this point, all the error checking has been done.
>> -        * At this point, we start making changes.....
>> -        */
>> -
>> -       info->baud_base = new_serial.baud_base;
>> -       port->flags = ((port->flags & ~ASYNC_FLAGS) |
>> -                       (new_serial.flags & ASYNC_FLAGS));
>> -       info->type = new_serial.type;
>> -       port->close_delay = new_serial.close_delay;
>> -       port->closing_wait = new_serial.closing_wait;
>> -
>> -check_and_exit:
>> -       retval = startup(info, tty);
>> -       return retval;
>> -}
>> -
>> -/*
>> - * get_lsr_info - get line status register info
>> - *
>> - * Purpose: Let user call ioctl() to get info when the UART physically
>> - *         is emptied.  On bus types like RS485, the transmitter must
>> - *         release the bus after transmitting. This must be done when
>> - *         the transmit shift register is empty, not be done when the
>> - *         transmit holding register is empty.  This functionality
>> - *         allows an RS485 driver to be written in user space.
>> - */
>> -static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
>> -{
>> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -#endif
>> -       unsigned char status;
>> -       unsigned long flags;
>> -
>> -       local_irq_save(flags);
>> -#ifdef CONFIG_SERIAL_68328_RTS_CTS
>> -       status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
>> -#else
>> -       status = 0;
>> -#endif
>> -       local_irq_restore(flags);
>> -       return put_user(status, value);
>> -}
>> -
>> -/*
>> - * This routine sends a break character out the serial port.
>> - */
>> -static void send_break(struct m68k_serial * info, unsigned int duration)
>> -{
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -        unsigned long flags;
>> -        if (!info->port)
>> -                return;
>> -        local_irq_save(flags);
>> -#ifdef USE_INTS
>> -       uart->utx.w |= UTX_SEND_BREAK;
>> -       msleep_interruptible(duration);
>> -       uart->utx.w &= ~UTX_SEND_BREAK;
>> -#endif
>> -        local_irq_restore(flags);
>> -}
>> -
>> -static int rs_ioctl(struct tty_struct *tty,
>> -                   unsigned int cmd, unsigned long arg)
>> -{
>> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
>> -       int retval;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
>> -               return -ENODEV;
>> -
>> -       if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
>> -           (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD)  &&
>> -           (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
>> -               if (tty->flags & (1 << TTY_IO_ERROR))
>> -                   return -EIO;
>> -       }
>> -
>> -       switch (cmd) {
>> -               case TCSBRK:    /* SVID version: non-zero arg --> no break */
>> -                       retval = tty_check_change(tty);
>> -                       if (retval)
>> -                               return retval;
>> -                       tty_wait_until_sent(tty, 0);
>> -                       if (!arg)
>> -                               send_break(info, 250);  /* 1/4 second */
>> -                       return 0;
>> -               case TCSBRKP:   /* support for POSIX tcsendbreak() */
>> -                       retval = tty_check_change(tty);
>> -                       if (retval)
>> -                               return retval;
>> -                       tty_wait_until_sent(tty, 0);
>> -                       send_break(info, arg ? arg*(100) : 250);
>> -                       return 0;
>> -               case TIOCGSERIAL:
>> -                       return get_serial_info(info,
>> -                                      (struct serial_struct *) arg);
>> -               case TIOCSSERIAL:
>> -                       return set_serial_info(info, tty,
>> -                                              (struct serial_struct *) arg);
>> -               case TIOCSERGETLSR: /* Get line status register */
>> -                       return get_lsr_info(info, (unsigned int *) arg);
>> -               case TIOCSERGSTRUCT:
>> -                       if (copy_to_user((struct m68k_serial *) arg,
>> -                                   info, sizeof(struct m68k_serial)))
>> -                               return -EFAULT;
>> -                       return 0;
>> -               default:
>> -                       return -ENOIOCTLCMD;
>> -               }
>> -       return 0;
>> -}
>> -
>> -static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
>> -{
>> -       struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
>> -
>> -       change_speed(info, tty);
>> -
>> -       if ((old_termios->c_cflag & CRTSCTS) &&
>> -           !(tty->termios.c_cflag & CRTSCTS))
>> -               rs_start(tty);
>> -
>> -}
>> -
>> -/*
>> - * ------------------------------------------------------------
>> - * rs_close()
>> - *
>> - * This routine is called when the serial port gets closed.  First, we
>> - * wait for the last remaining data to be sent.  Then, we unlink its
>> - * S structure from the interrupt chain if necessary, and we free
>> - * that IRQ if nothing is left in the chain.
>> - * ------------------------------------------------------------
>> - */
>> -static void rs_close(struct tty_struct *tty, struct file * filp)
>> -{
>> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
>> -       struct tty_port *port = &info->tport;
>> -       m68328_uart *uart = &uart_addr[info->line];
>> -       unsigned long flags;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_close"))
>> -               return;
>> -
>> -       local_irq_save(flags);
>> -
>> -       if (tty_hung_up_p(filp)) {
>> -               local_irq_restore(flags);
>> -               return;
>> -       }
>> -
>> -       if ((tty->count == 1) && (port->count != 1)) {
>> -               /*
>> -                * Uh, oh.  tty->count is 1, which means that the tty
>> -                * structure will be freed.  Info->count should always
>> -                * be one in these conditions.  If it's greater than
>> -                * one, we've got real problems, since it means the
>> -                * serial port won't be shutdown.
>> -                */
>> -               printk("rs_close: bad serial port count; tty->count is 1, "
>> -                      "port->count is %d\n", port->count);
>> -               port->count = 1;
>> -       }
>> -       if (--port->count < 0) {
>> -               printk("rs_close: bad serial port count for ttyS%d: %d\n",
>> -                      info->line, port->count);
>> -               port->count = 0;
>> -       }
>> -       if (port->count) {
>> -               local_irq_restore(flags);
>> -               return;
>> -       }
>> -       port->flags |= ASYNC_CLOSING;
>> -       /*
>> -        * Now we wait for the transmit buffer to clear; and we notify
>> -        * the line discipline to only process XON/XOFF characters.
>> -        */
>> -       tty->closing = 1;
>> -       if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
>> -               tty_wait_until_sent(tty, port->closing_wait);
>> -       /*
>> -        * At this point we stop accepting input.  To do this, we
>> -        * disable the receive line status interrupts, and tell the
>> -        * interrupt driver to stop checking the data ready bit in the
>> -        * line status register.
>> -        */
>> -
>> -       uart->ustcnt &= ~USTCNT_RXEN;
>> -       uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
>> -
>> -       shutdown(info, tty);
>> -       rs_flush_buffer(tty);
>> -
>> -       tty_ldisc_flush(tty);
>> -       tty->closing = 0;
>> -       tty_port_tty_set(&info->tport, NULL);
>> -#warning "This is not and has never been valid so fix it"
>> -#if 0
>> -       if (tty->ldisc.num != ldiscs[N_TTY].num) {
>> -               if (tty->ldisc.close)
>> -                       (tty->ldisc.close)(tty);
>> -               tty->ldisc = ldiscs[N_TTY];
>> -               tty->termios.c_line = N_TTY;
>> -               if (tty->ldisc.open)
>> -                       (tty->ldisc.open)(tty);
>> -       }
>> -#endif
>> -       if (port->blocked_open) {
>> -               if (port->close_delay)
>> -                       msleep_interruptible(jiffies_to_msecs(port->close_delay));
>> -               wake_up_interruptible(&port->open_wait);
>> -       }
>> -       port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
>> -       local_irq_restore(flags);
>> -}
>> -
>> -/*
>> - * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
>> - */
>> -void rs_hangup(struct tty_struct *tty)
>> -{
>> -       struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_hangup"))
>> -               return;
>> -
>> -       rs_flush_buffer(tty);
>> -       shutdown(info, tty);
>> -       info->tport.count = 0;
>> -       info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
>> -       tty_port_tty_set(&info->tport, NULL);
>> -       wake_up_interruptible(&info->tport.open_wait);
>> -}
>> -
>> -/*
>> - * This routine is called whenever a serial port is opened.  It
>> - * enables interrupts for a serial port, linking in its S structure into
>> - * the IRQ chain.   It also performs the serial-specific
>> - * initialization for the tty structure.
>> - */
>> -int rs_open(struct tty_struct *tty, struct file * filp)
>> -{
>> -       struct m68k_serial      *info;
>> -       int retval;
>> -
>> -       info = &m68k_soft[tty->index];
>> -
>> -       if (serial_paranoia_check(info, tty->name, "rs_open"))
>> -               return -ENODEV;
>> -
>> -       info->tport.count++;
>> -       tty->driver_data = info;
>> -       tty_port_tty_set(&info->tport, tty);
>> -
>> -       /*
>> -        * Start up serial port
>> -        */
>> -       retval = startup(info, tty);
>> -       if (retval)
>> -               return retval;
>> -
>> -       return tty_port_block_til_ready(&info->tport, tty, filp);
>> -}
>> -
>> -/* Finally, routines used to initialize the serial driver. */
>> -
>> -static void show_serial_version(void)
>> -{
>> -       printk("MC68328 serial driver version 1.00\n");
>> -}
>> -
>> -static const struct tty_operations rs_ops = {
>> -       .open = rs_open,
>> -       .close = rs_close,
>> -       .write = rs_write,
>> -       .flush_chars = rs_flush_chars,
>> -       .write_room = rs_write_room,
>> -       .chars_in_buffer = rs_chars_in_buffer,
>> -       .flush_buffer = rs_flush_buffer,
>> -       .ioctl = rs_ioctl,
>> -       .throttle = rs_throttle,
>> -       .unthrottle = rs_unthrottle,
>> -       .set_termios = rs_set_termios,
>> -       .stop = rs_stop,
>> -       .start = rs_start,
>> -       .hangup = rs_hangup,
>> -       .set_ldisc = rs_set_ldisc,
>> -};
>> -
>> -static const struct tty_port_operations rs_port_ops = {
>> -};
>> -
>> -/* rs_init inits the driver */
>> -static int __init
>> -rs68328_init(void)
>> -{
>> -       unsigned long flags;
>> -       int i;
>> -       struct m68k_serial *info;
>> -
>> -       serial_driver = alloc_tty_driver(NR_PORTS);
>> -       if (!serial_driver)
>> -               return -ENOMEM;
>> -
>> -       show_serial_version();
>> -
>> -       /* Initialize the tty_driver structure */
>> -       /* SPARC: Not all of this is exactly right for us. */
>> -
>> -       serial_driver->name = "ttyS";
>> -       serial_driver->major = TTY_MAJOR;
>> -       serial_driver->minor_start = 64;
>> -       serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
>> -       serial_driver->subtype = SERIAL_TYPE_NORMAL;
>> -       serial_driver->init_termios = tty_std_termios;
>> -       serial_driver->init_termios.c_cflag =
>> -                       m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
>> -       serial_driver->flags = TTY_DRIVER_REAL_RAW;
>> -       tty_set_operations(serial_driver, &rs_ops);
>> -
>> -       local_irq_save(flags);
>> -
>> -       for(i=0;i<NR_PORTS;i++) {
>> -
>> -           info = &m68k_soft[i];
>> -           tty_port_init(&info->tport);
>> -           info->tport.ops = &rs_port_ops;
>> -           info->magic = SERIAL_MAGIC;
>> -           info->port = (int) &uart_addr[i];
>> -           info->irq = uart_irqs[i];
>> -           info->custom_divisor = 16;
>> -           info->x_char = 0;
>> -           info->line = i;
>> -           info->is_cons = 1; /* Means shortcuts work */
>> -
>> -           printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
>> -                  info->port, info->irq);
>> -           printk(" is a builtin MC68328 UART\n");
>> -
>> -#ifdef CONFIG_M68VZ328
>> -               if (i > 0 )
>> -                       PJSEL &= 0xCF;  /* PSW enable second port output */
>> -#endif
>> -
>> -           if (request_irq(uart_irqs[i],
>> -                           rs_interrupt,
>> -                           0,
>> -                           "M68328_UART", info))
>> -                panic("Unable to attach 68328 serial interrupt\n");
>> -
>> -           tty_port_link_device(&info->tport, serial_driver, i);
>> -       }
>> -       local_irq_restore(flags);
>> -
>> -       if (tty_register_driver(serial_driver)) {
>> -               put_tty_driver(serial_driver);
>> -               for (i = 0; i < NR_PORTS; i++)
>> -                       tty_port_destroy(&m68k_soft[i].tport);
>> -               printk(KERN_ERR "Couldn't register serial driver\n");
>> -               return -ENOMEM;
>> -       }
>> -
>> -       return 0;
>> -}
>> -
>> -module_init(rs68328_init);
>> -
>> -
>> -
>> -static void m68328_set_baud(void)
>> -{
>> -       unsigned short ustcnt;
>> -       int     i;
>> -
>> -       ustcnt = USTCNT;
>> -       USTCNT = ustcnt & ~USTCNT_TXEN;
>> -
>> -again:
>> -       for (i = 0; i < ARRAY_SIZE(baud_table); i++)
>> -               if (baud_table[i] == m68328_console_baud)
>> -                       break;
>> -       if (i >= ARRAY_SIZE(baud_table)) {
>> -               m68328_console_baud = 9600;
>> -               goto again;
>> -       }
>> -
>> -       UBAUD = PUT_FIELD(UBAUD_DIVIDE,    hw_baud_table[i].divisor) |
>> -               PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
>> -       ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
>> -       ustcnt |= USTCNT_8_7;
>> -       ustcnt |= USTCNT_TXEN;
>> -       USTCNT = ustcnt;
>> -       m68328_console_initted = 1;
>> -       return;
>> -}
>> -
>> -
>> -int m68328_console_setup(struct console *cp, char *arg)
>> -{
>> -       int             i, n = CONSOLE_BAUD_RATE;
>> -
>> -       if (!cp)
>> -               return(-1);
>> -
>> -       if (arg)
>> -               n = simple_strtoul(arg,NULL,0);
>> -
>> -       for (i = 0; i < ARRAY_SIZE(baud_table); i++)
>> -               if (baud_table[i] == n)
>> -                       break;
>> -       if (i < ARRAY_SIZE(baud_table)) {
>> -               m68328_console_baud = n;
>> -               m68328_console_cbaud = 0;
>> -               if (i > 15) {
>> -                       m68328_console_cbaud |= CBAUDEX;
>> -                       i -= 15;
>> -               }
>> -               m68328_console_cbaud |= i;
>> -       }
>> -
>> -       m68328_set_baud(); /* make sure baud rate changes */
>> -       return(0);
>> -}
>> -
>> -
>> -static struct tty_driver *m68328_console_device(struct console *c, int *index)
>> -{
>> -       *index = c->index;
>> -       return serial_driver;
>> -}
>> -
>> -
>> -void m68328_console_write (struct console *co, const char *str,
>> -                          unsigned int count)
>> -{
>> -       if (!m68328_console_initted)
>> -               m68328_set_baud();
>> -    while (count--) {
>> -        if (*str == '\n')
>> -           rs_put_char('\r');
>> -        rs_put_char( *str++ );
>> -    }
>> -}
>> -
>> -
>> -static struct console m68328_driver = {
>> -       .name           = "ttyS",
>> -       .write          = m68328_console_write,
>> -       .device         = m68328_console_device,
>> -       .setup          = m68328_console_setup,
>> -       .flags          = CON_PRINTBUFFER,
>> -       .index          = -1,
>> -};
>> -
>> -
>> -static int __init m68328_console_init(void)
>> -{
>> -       register_console(&m68328_driver);
>> -       return 0;
>> -}
>> -
>> -console_initcall(m68328_console_init);
>> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
>> index f38beb2..a261457 100644
>> --- a/drivers/tty/serial/Kconfig
>> +++ b/drivers/tty/serial/Kconfig
>> @@ -790,17 +790,6 @@ config SERIAL_CORE_CONSOLE
>>  config CONSOLE_POLL
>>         bool
>>
>> -config SERIAL_68328
>> -       bool "68328 serial support"
>> -       depends on M68328 || M68EZ328 || M68VZ328
>> -       help
>> -         This driver supports the built-in serial port of the Motorola 68328
>> -         (standard, EZ and VZ varieties).
>> -
>> -config SERIAL_68328_RTS_CTS
>> -       bool "Support RTS/CTS on 68328 serial port"
>> -       depends on SERIAL_68328
>> -
>>  config SERIAL_MCF
>>         bool "Coldfire serial support"
>>         depends on COLDFIRE
>> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
>> index 5ab4111..9d35387 100644
>> --- a/drivers/tty/serial/Makefile
>> +++ b/drivers/tty/serial/Makefile
>> @@ -34,7 +34,6 @@ obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
>>  obj-$(CONFIG_SERIAL_MAX310X) += max310x.o
>>  obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
>>  obj-$(CONFIG_SERIAL_MUX) += mux.o
>> -obj-$(CONFIG_SERIAL_68328) += 68328serial.o
>>  obj-$(CONFIG_SERIAL_MCF) += mcf.o
>>  obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
>>  obj-$(CONFIG_SERIAL_HS_LPC32XX) += lpc32xx_hs.o
>> --
>> 1.9.1
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH] serial: Remove 68328 driver
  2016-01-04  5:03     ` Greg Ungerer
@ 2016-01-04 10:30       ` One Thousand Gnomes
  2016-01-04 11:10         ` Greg Ungerer
  0 siblings, 1 reply; 32+ messages in thread
From: One Thousand Gnomes @ 2016-01-04 10:30 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Linux/m68k, Geert Uytterhoeven, Frederik Völkel, Jiri Slaby,
	Greg KH, linux-serial, linux-kernel, linux-kernel, Lukas Braun,
	uClinux development list

On Mon, 4 Jan 2016 15:03:50 +1000
Greg Ungerer <gregungerer@westnet.com.au> wrote:

> If 68328serial.c is removed is there any point keeping the
> architecture support for 68328 platforms?
> 
> The 68328serial.c provides pretty much the only type of console
> that can be used on these devices. They are largely useless
> without this

Probably we should - unless someone wants to stand up and say "actually
I'm using this with current kernels, need it, and I'll maintain it"

Somehow I doubt anyone is.

Alan

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

* Re: [PATCH] serial: Remove 68328 driver
  2016-01-04 10:30       ` One Thousand Gnomes
@ 2016-01-04 11:10         ` Greg Ungerer
  2016-01-11 17:57           ` Peter Hurley
  0 siblings, 1 reply; 32+ messages in thread
From: Greg Ungerer @ 2016-01-04 11:10 UTC (permalink / raw)
  To: One Thousand Gnomes
  Cc: Linux/m68k, Geert Uytterhoeven, Frederik Völkel, Jiri Slaby,
	Greg KH, linux-serial, linux-kernel, linux-kernel, Lukas Braun,
	uClinux development list

On 04/01/16 20:30, One Thousand Gnomes wrote:
> On Mon, 4 Jan 2016 15:03:50 +1000
> Greg Ungerer <gregungerer@westnet.com.au> wrote:
>
>> If 68328serial.c is removed is there any point keeping the
>> architecture support for 68328 platforms?
>>
>> The 68328serial.c provides pretty much the only type of console
>> that can be used on these devices. They are largely useless
>> without this
>
> Probably we should - unless someone wants to stand up and say "actually
> I'm using this with current kernels, need it, and I'll maintain it"
>
> Somehow I doubt anyone is.

Yep, I suspect you are right.
I can't even remember the last time a patch or improvement
for 68328 came past me. Same goes for 68360 cpu/platform
as well.

Regards
Greg




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

* Re: [PATCH] serial: Remove 68328 driver
  2015-12-18 11:28 ` [PATCH] serial: Remove 68328 driver Frederik Völkel
  2015-12-18 14:27     ` Geert Uytterhoeven
@ 2016-01-11 17:53   ` Peter Hurley
  1 sibling, 0 replies; 32+ messages in thread
From: Peter Hurley @ 2016-01-11 17:53 UTC (permalink / raw)
  To: Frederik Völkel, gregkh
  Cc: jslaby, linux-serial, linux-kernel, linux-kernel, Lukas Braun,
	Geert Uytterhoeven, linux-m68k, uclinux-dev, One Thousand Gnomes,
	Greg Ungerer

On 12/18/2015 03:28 AM, Frederik Völkel wrote:
> It's old, messy and mostly unmaintained.
> Remove it as suggested by Peter Hurley and Alan.

Reviewed-by: Peter Hurley <peter@hurleysoftware.com>

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

* Re: [PATCH] serial: Remove 68328 driver
  2016-01-04 11:10         ` Greg Ungerer
@ 2016-01-11 17:57           ` Peter Hurley
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Hurley @ 2016-01-11 17:57 UTC (permalink / raw)
  To: Greg Ungerer, One Thousand Gnomes, Geert Uytterhoeven
  Cc: Linux/m68k, Frederik Völkel, Jiri Slaby, Greg KH,
	linux-serial, linux-kernel, linux-kernel, Lukas Braun,
	uClinux development list

On 01/04/2016 03:10 AM, Greg Ungerer wrote:
> On 04/01/16 20:30, One Thousand Gnomes wrote:
>> On Mon, 4 Jan 2016 15:03:50 +1000
>> Greg Ungerer <gregungerer@westnet.com.au> wrote:
>>
>>> If 68328serial.c is removed is there any point keeping the
>>> architecture support for 68328 platforms?
>>>
>>> The 68328serial.c provides pretty much the only type of console
>>> that can be used on these devices. They are largely useless
>>> without this
>>
>> Probably we should - unless someone wants to stand up and say "actually
>> I'm using this with current kernels, need it, and I'll maintain it"
>>
>> Somehow I doubt anyone is.
> 
> Yep, I suspect you are right.
> I can't even remember the last time a patch or improvement
> for 68328 came past me. Same goes for 68360 cpu/platform
> as well.

And none of it builds (and there's no build coverage in arch/m68k/configs)

Regards,
Peter Hurley

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

end of thread, other threads:[~2016-01-11 17:57 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-11 10:36 [PATCH 0/9] Fix checkpatch errors Frederik Völkel
2015-12-11 10:36 ` [PATCH 1/9] drivers: tty: 68328serial.c: Add missing spaces(checkpatch) Frederik Völkel
2015-12-11 10:36 ` [PATCH 2/9] drivers: tty: 68328serial.c: remove unnecessary spaces(checkpatch) Frederik Völkel
2015-12-11 10:36 ` [PATCH 3/9] drivers: tty: 68328serial.c: Do not initialize statics to 0 Frederik Völkel
2015-12-11 10:36 ` [PATCH 4/9] drivers: tty: 68328serial.c: Fix "foo * bar" should be "foo *bar" Frederik Völkel
2015-12-11 10:36 ` [PATCH 5/9] drivers: tty: 68328serial.c: Remove parentheses after return Frederik Völkel
2015-12-11 10:36 ` [PATCH 6/9] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
2015-12-13  7:08   ` Greg KH
2015-12-13  7:09     ` Greg KH
2015-12-11 10:36 ` [PATCH 7/9] drivers: tty: 68328serial.c: remove trailing whitespaces Frederik Völkel
2015-12-11 10:36 ` [PATCH 8/9] drivers: tty: 68328serial.c: Use use same indentation for switch/case Frederik Völkel
2015-12-11 10:36 ` [PATCH 9/9] drivers: tty: 68328serial.c: Move trailing statements to next line Frederik Völkel
2015-12-13  7:06 ` [PATCH 0/9] Fix checkpatch errors Greg KH
2015-12-13 17:44   ` Frederik
2015-12-13 18:15     ` Nicolai Stange
2015-12-13 18:26       ` Frederik
2015-12-13 20:31         ` Ken Moffat
2015-12-16 15:16 ` [PATCH v2 0/4] " Frederik Völkel
2015-12-16 15:16   ` [PATCH v2 1/4] drivers: tty: 68328serial.c: Use tabs for indentation Frederik Völkel
2015-12-16 15:43     ` One Thousand Gnomes
2015-12-16 16:25       ` Peter Hurley
2015-12-16 15:16   ` [PATCH v2 2/4] drivers: tty: 68328serial.c: remove trailing whitespaces Frederik Völkel
2015-12-16 15:17   ` [PATCH v2 3/4] drivers: tty: 68328serial.c: Use use same indentation for switch/case Frederik Völkel
2015-12-16 15:17   ` [PATCH v2 4/4] drivers: tty: 68328serial.c: Move trailing statements to next line Frederik Völkel
2015-12-18 11:28 ` [PATCH] serial: Remove 68328 driver Frederik Völkel
2015-12-18 14:27   ` Geert Uytterhoeven
2015-12-18 14:27     ` Geert Uytterhoeven
2016-01-04  5:03     ` Greg Ungerer
2016-01-04 10:30       ` One Thousand Gnomes
2016-01-04 11:10         ` Greg Ungerer
2016-01-11 17:57           ` Peter Hurley
2016-01-11 17:53   ` Peter Hurley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.