public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Altix console mod
@ 2004-07-27 19:53 Pat Gefre
  2004-07-27 20:10 ` Andreas Schwab
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Pat Gefre @ 2004-07-27 19:53 UTC (permalink / raw)
  To: linux-ia64

David/Tony,

Here's a small mod to make the early printk code in the Altix console
driver carriage return aware, also moves sn_debug_printf to only
compile if DEBUG is true.


Signed-off-by: Pat Gefre <pfg@sgi.com>

Thanks,
-- Pat


# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/07/27 11:17:44-05:00 pfg@sgi.com 
#   drivers/serial/sn_console.c
#       move sn_debug_printf to only compile for DEBUG
#       early printk needs to handle missing carriage returns
# 
# drivers/serial/sn_console.c
#   2004/07/27 11:17:35-05:00 pfg@sgi.com +17 -12
#   move sn_debug_printf to only compile for DEBUG
#   early printk needs to handle missing carriage returns
# 
diff -Nru a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
--- a/drivers/serial/sn_console.c	2004-07-27 11:20:23 -05:00
+++ b/drivers/serial/sn_console.c	2004-07-27 11:20:23 -05:00
@@ -105,10 +105,9 @@
 extern u64 master_node_bedrock_address;
 extern void early_sn_setup(void);
 
-static int sn_debug_printf(const char *fmt, ...);
-
 #undef DEBUG
 #ifdef DEBUG
+static int sn_debug_printf(const char *fmt, ...);
 #define DPRINTF(x...) sn_debug_printf(x)
 #else
 #define DPRINTF(x...) do { } while (0)
@@ -489,6 +488,8 @@
 
 /* End of uart struct functions and defines */
 
+#ifdef DEBUG
+
 /**
  * sn_debug_printf - close to hardware debugging printf
  * @fmt: printf format
@@ -520,6 +521,7 @@
 	va_end(args);
 	return printed_len;
 }
+#endif	/* DEBUG */
 
 /*
  * Interrupt handling routines.
@@ -654,7 +656,7 @@
 				    port->sc_ops->sal_puts(start, xmit_count);
 #ifdef DEBUG
 			if (!result)
-				sn_debug_printf("`");
+				DPRINTF("`");
 #endif
 			if (result > 0) {
 				xmit_count -= result;
@@ -971,6 +973,7 @@
 
 /**
  * puts_raw_fixed - sn_sal_console_write helper for adding \r's as required
+ * @puts_raw : puts function to do the writing
  * @s: input string
  * @count: length
  *
@@ -978,19 +981,21 @@
  * ia64_sn_console_putb (what sal_puts_raw below actually does).
  *
  */
-static void puts_raw_fixed(const char *s, int count)
+
+static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
 {
 	const char *s1;
-	struct sn_cons_port *port = &sal_console_port;
 
 	/* Output '\r' before each '\n' */
 	while ((s1 = memchr(s, '\n', count)) != NULL) {
-		port->sc_ops->sal_puts_raw(s, s1 - s);
-		port->sc_ops->sal_puts_raw("\r\n", 2);
+		if ( (*(s1 - 1) != '\r') && (*(s1 + 1) != '\r') ) {
+			puts_raw(s, s1 - s);
+			puts_raw("\r\n", 2);
+		}
 		count -= s1 + 1 - s;
 		s = s1 + 1;
 	}
-	port->sc_ops->sal_puts_raw(s, count);
+	puts_raw(s, count);
 }
 
 /**
@@ -1072,7 +1077,7 @@
 				/* fell thru */
 				stole_lock = 1;
 			}
-			puts_raw_fixed(s, count);
+			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 		}
 		else {
 			stole_lock = 0;
@@ -1081,12 +1086,12 @@
 			sn_transmit_chars(port, 1);
 			spin_unlock_irqrestore(&port->sc_port.lock, flags);
 
-			puts_raw_fixed(s, count);
+			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 		}
 	}
 	else {
 		/* Not yet registered with serial core - simple case */
-		puts_raw_fixed(s, count);
+		puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 	}
 }
 
@@ -1123,7 +1128,7 @@
 static void __init
 sn_sal_console_write_early(struct console *co, const char *s, unsigned count)
 {
-	sal_console_port.sc_ops->sal_puts(s, count);
+	puts_raw_fixed(sal_console_port.sc_ops->sal_puts_raw, s, count);
 }
 
 /* Used for very early console printing - again, before

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

* Re: [PATCH] Altix console mod
  2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
@ 2004-07-27 20:10 ` Andreas Schwab
  2004-07-27 20:29 ` Patrick Gefre
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2004-07-27 20:10 UTC (permalink / raw)
  To: linux-ia64

Pat Gefre <pfg@sgi.com> writes:

> @@ -978,19 +981,21 @@
>   * ia64_sn_console_putb (what sal_puts_raw below actually does).
>   *
>   */
> -static void puts_raw_fixed(const char *s, int count)
> +
> +static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
>  {
>  	const char *s1;
> -	struct sn_cons_port *port = &sal_console_port;
>  
>  	/* Output '\r' before each '\n' */
>  	while ((s1 = memchr(s, '\n', count)) != NULL) {
> -		port->sc_ops->sal_puts_raw(s, s1 - s);
> -		port->sc_ops->sal_puts_raw("\r\n", 2);
> +		if ( (*(s1 - 1) != '\r') && (*(s1 + 1) != '\r') ) {
> +			puts_raw(s, s1 - s);
> +			puts_raw("\r\n", 2);
> +		}

You have now broken output when a CR actually appears in the string.
What's wrong with unconditionally writing a CR before each LF?  That's
what every other console print function is doing.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH] Altix console mod
  2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
  2004-07-27 20:10 ` Andreas Schwab
@ 2004-07-27 20:29 ` Patrick Gefre
  2004-07-27 20:42 ` Andreas Schwab
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Patrick Gefre @ 2004-07-27 20:29 UTC (permalink / raw)
  To: linux-ia64

Andreas Schwab wrote:
> Pat Gefre <pfg@sgi.com> writes:
> 
> 
>>@@ -978,19 +981,21 @@
>>  * ia64_sn_console_putb (what sal_puts_raw below actually does).
>>  *
>>  */
>>-static void puts_raw_fixed(const char *s, int count)
>>+
>>+static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
>> {
>> 	const char *s1;
>>-	struct sn_cons_port *port = &sal_console_port;
>> 
>> 	/* Output '\r' before each '\n' */
>> 	while ((s1 = memchr(s, '\n', count)) != NULL) {
>>-		port->sc_ops->sal_puts_raw(s, s1 - s);
>>-		port->sc_ops->sal_puts_raw("\r\n", 2);
>>+		if ( (*(s1 - 1) != '\r') && (*(s1 + 1) != '\r') ) {
>>+			puts_raw(s, s1 - s);
>>+			puts_raw("\r\n", 2);
>>+		}
> 
> 
> You have now broken output when a CR actually appears in the string.
> What's wrong with unconditionally writing a CR before each LF?  That's
> what every other console print function is doing.
> 
> Andreas.
> 

You're right, I forgot the else on the if (to write out the lf) ....
So send the cr even if one is already there - guess it doesn't hurt ?

-- Pat

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

* Re: [PATCH] Altix console mod
  2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
  2004-07-27 20:10 ` Andreas Schwab
  2004-07-27 20:29 ` Patrick Gefre
@ 2004-07-27 20:42 ` Andreas Schwab
  2004-07-28 18:10 ` Pat Gefre
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2004-07-27 20:42 UTC (permalink / raw)
  To: linux-ia64

Patrick Gefre <pfg@sgi.com> writes:

> You're right, I forgot the else on the if (to write out the lf) ....
> So send the cr even if one is already there - guess it doesn't hurt ?

The kernel normally does not output CRs anyway, since it's just using \n
for EOL.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH] Altix console mod
  2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
                   ` (2 preceding siblings ...)
  2004-07-27 20:42 ` Andreas Schwab
@ 2004-07-28 18:10 ` Pat Gefre
  2004-07-28 18:18 ` Jesse Barnes
  2004-07-29 15:15 ` Pat Gefre
  5 siblings, 0 replies; 7+ messages in thread
From: Pat Gefre @ 2004-07-28 18:10 UTC (permalink / raw)
  To: linux-ia64

On Tue, 27 Jul 2004, Andreas Schwab wrote:

+ Patrick Gefre <pfg@sgi.com> writes:
+ 
+ > You're right, I forgot the else on the if (to write out the lf) ....
+ > So send the cr even if one is already there - guess it doesn't hurt ?
+ 
+ The kernel normally does not output CRs anyway, since it's just using \n
+ for EOL.
+ 
+ Andreas.
+ 



Here's a better version:


# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/07/28 10:51:32-05:00 pfg@sgi.com 
#   drivers/serial/sn_console.c
#       move sn_debug_printf to only compile for DEBUG
#       early printk needs to handle missing carriage returns
# 
# drivers/serial/sn_console.c
#   2004/07/28 10:51:13-05:00 pfg@sgi.com +15 -12
#   move sn_debug_printf to only compile for DEBUG
#   early printk needs to handle missing carriage returns
# 
diff -Nru a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
--- a/drivers/serial/sn_console.c	2004-07-28 11:41:46 -05:00
+++ b/drivers/serial/sn_console.c	2004-07-28 11:41:46 -05:00
@@ -105,10 +105,9 @@
 extern u64 master_node_bedrock_address;
 extern void early_sn_setup(void);
 
-static int sn_debug_printf(const char *fmt, ...);
-
 #undef DEBUG
 #ifdef DEBUG
+static int sn_debug_printf(const char *fmt, ...);
 #define DPRINTF(x...) sn_debug_printf(x)
 #else
 #define DPRINTF(x...) do { } while (0)
@@ -489,6 +488,8 @@
 
 /* End of uart struct functions and defines */
 
+#ifdef DEBUG
+
 /**
  * sn_debug_printf - close to hardware debugging printf
  * @fmt: printf format
@@ -520,6 +521,7 @@
 	va_end(args);
 	return printed_len;
 }
+#endif	/* DEBUG */
 
 /*
  * Interrupt handling routines.
@@ -654,7 +656,7 @@
 				    port->sc_ops->sal_puts(start, xmit_count);
 #ifdef DEBUG
 			if (!result)
-				sn_debug_printf("`");
+				DPRINTF("`");
 #endif
 			if (result > 0) {
 				xmit_count -= result;
@@ -971,6 +973,7 @@
 
 /**
  * puts_raw_fixed - sn_sal_console_write helper for adding \r's as required
+ * @puts_raw : puts function to do the writing
  * @s: input string
  * @count: length
  *
@@ -978,19 +981,19 @@
  * ia64_sn_console_putb (what sal_puts_raw below actually does).
  *
  */
-static void puts_raw_fixed(const char *s, int count)
+
+static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
 {
 	const char *s1;
-	struct sn_cons_port *port = &sal_console_port;
 
 	/* Output '\r' before each '\n' */
 	while ((s1 = memchr(s, '\n', count)) != NULL) {
-		port->sc_ops->sal_puts_raw(s, s1 - s);
-		port->sc_ops->sal_puts_raw("\r\n", 2);
+		puts_raw(s, s1 - s);
+		puts_raw("\r\n", 2);
 		count -= s1 + 1 - s;
 		s = s1 + 1;
 	}
-	port->sc_ops->sal_puts_raw(s, count);
+	puts_raw(s, count);
 }
 
 /**
@@ -1072,7 +1075,7 @@
 				/* fell thru */
 				stole_lock = 1;
 			}
-			puts_raw_fixed(s, count);
+			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 		}
 		else {
 			stole_lock = 0;
@@ -1081,12 +1084,12 @@
 			sn_transmit_chars(port, 1);
 			spin_unlock_irqrestore(&port->sc_port.lock, flags);
 
-			puts_raw_fixed(s, count);
+			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 		}
 	}
 	else {
 		/* Not yet registered with serial core - simple case */
-		puts_raw_fixed(s, count);
+		puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 	}
 }
 
@@ -1123,7 +1126,7 @@
 static void __init
 sn_sal_console_write_early(struct console *co, const char *s, unsigned count)
 {
-	sal_console_port.sc_ops->sal_puts(s, count);
+	puts_raw_fixed(sal_console_port.sc_ops->sal_puts_raw, s, count);
 }
 
 /* Used for very early console printing - again, before


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

* Re: [PATCH] Altix console mod
  2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
                   ` (3 preceding siblings ...)
  2004-07-28 18:10 ` Pat Gefre
@ 2004-07-28 18:18 ` Jesse Barnes
  2004-07-29 15:15 ` Pat Gefre
  5 siblings, 0 replies; 7+ messages in thread
From: Jesse Barnes @ 2004-07-28 18:18 UTC (permalink / raw)
  To: linux-ia64

On Wednesday, July 28, 2004 11:10 am, Pat Gefre wrote:
> Here's a better version:

We should send this on to Andrew (or have Tony do it) and ask him to include 
it in 2.6.8.

Jesse

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

* Re: [PATCH] Altix console mod
  2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
                   ` (4 preceding siblings ...)
  2004-07-28 18:18 ` Jesse Barnes
@ 2004-07-29 15:15 ` Pat Gefre
  5 siblings, 0 replies; 7+ messages in thread
From: Pat Gefre @ 2004-07-29 15:15 UTC (permalink / raw)
  To: tony.luck, linux-ia64; +Cc: akpm, davidm, linux-kernel

Here's a better version WITH the Signed off line - Andrew can you pick
this up for 2.6.8 ?


Signed-off-by: Pat Gefre <pfg@sgi.com>


Thanks,
-- Pat


e This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/07/28 10:51:32-05:00 pfg@sgi.com 
#   drivers/serial/sn_console.c
#       move sn_debug_printf to only compile for DEBUG
#       early printk needs to handle missing carriage returns
# 
# drivers/serial/sn_console.c
#   2004/07/28 10:51:13-05:00 pfg@sgi.com +15 -12
#   move sn_debug_printf to only compile for DEBUG
#   early printk needs to handle missing carriage returns
# 
diff -Nru a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
--- a/drivers/serial/sn_console.c	2004-07-28 11:41:46 -05:00
+++ b/drivers/serial/sn_console.c	2004-07-28 11:41:46 -05:00
@@ -105,10 +105,9 @@
 extern u64 master_node_bedrock_address;
 extern void early_sn_setup(void);
 
-static int sn_debug_printf(const char *fmt, ...);
-
 #undef DEBUG
 #ifdef DEBUG
+static int sn_debug_printf(const char *fmt, ...);
 #define DPRINTF(x...) sn_debug_printf(x)
 #else
 #define DPRINTF(x...) do { } while (0)
@@ -489,6 +488,8 @@
 
 /* End of uart struct functions and defines */
 
+#ifdef DEBUG
+
 /**
  * sn_debug_printf - close to hardware debugging printf
  * @fmt: printf format
@@ -520,6 +521,7 @@
 	va_end(args);
 	return printed_len;
 }
+#endif	/* DEBUG */
 
 /*
  * Interrupt handling routines.
@@ -654,7 +656,7 @@
 				    port->sc_ops->sal_puts(start, xmit_count);
 #ifdef DEBUG
 			if (!result)
-				sn_debug_printf("`");
+				DPRINTF("`");
 #endif
 			if (result > 0) {
 				xmit_count -= result;
@@ -971,6 +973,7 @@
 
 /**
  * puts_raw_fixed - sn_sal_console_write helper for adding \r's as required
+ * @puts_raw : puts function to do the writing
  * @s: input string
  * @count: length
  *
@@ -978,19 +981,19 @@
  * ia64_sn_console_putb (what sal_puts_raw below actually does).
  *
  */
-static void puts_raw_fixed(const char *s, int count)
+
+static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
 {
 	const char *s1;
-	struct sn_cons_port *port = &sal_console_port;
 
 	/* Output '\r' before each '\n' */
 	while ((s1 = memchr(s, '\n', count)) != NULL) {
-		port->sc_ops->sal_puts_raw(s, s1 - s);
-		port->sc_ops->sal_puts_raw("\r\n", 2);
+		puts_raw(s, s1 - s);
+		puts_raw("\r\n", 2);
 		count -= s1 + 1 - s;
 		s = s1 + 1;
 	}
-	port->sc_ops->sal_puts_raw(s, count);
+	puts_raw(s, count);
 }
 
 /**
@@ -1072,7 +1075,7 @@
 				/* fell thru */
 				stole_lock = 1;
 			}
-			puts_raw_fixed(s, count);
+			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 		}
 		else {
 			stole_lock = 0;
@@ -1081,12 +1084,12 @@
 			sn_transmit_chars(port, 1);
 			spin_unlock_irqrestore(&port->sc_port.lock, flags);
 
-			puts_raw_fixed(s, count);
+			puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 		}
 	}
 	else {
 		/* Not yet registered with serial core - simple case */
-		puts_raw_fixed(s, count);
+		puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
 	}
 }
 
@@ -1123,7 +1126,7 @@
 static void __init
 sn_sal_console_write_early(struct console *co, const char *s, unsigned count)
 {
-	sal_console_port.sc_ops->sal_puts(s, count);
+	puts_raw_fixed(sal_console_port.sc_ops->sal_puts_raw, s, count);
 }
 
 /* Used for very early console printing - again, before

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

end of thread, other threads:[~2004-07-29 15:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-27 19:53 [PATCH] Altix console mod Pat Gefre
2004-07-27 20:10 ` Andreas Schwab
2004-07-27 20:29 ` Patrick Gefre
2004-07-27 20:42 ` Andreas Schwab
2004-07-28 18:10 ` Pat Gefre
2004-07-28 18:18 ` Jesse Barnes
2004-07-29 15:15 ` Pat Gefre

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