diff mbox

[U-Boot] netconsole: support packets longer than 512 bytes

Message ID 1317939818-19735-1-git-send-email-michael@walle.cc
State Changes Requested
Headers show

Commit Message

Michael Walle Oct. 6, 2011, 10:23 p.m. UTC
Esp. while printing the environment the output is usually longer than 512
bytes. Instead of cutting the message, send multiple 512 bytes packets.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/net/netconsole.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

Comments

Mike Frysinger Oct. 7, 2011, 5:26 p.m. UTC | #1
On Thursday 06 October 2011 18:23:38 Michael Walle wrote:
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> 
> -	if ((len = strlen (s)) > 512)
> -		len = 512;
> -
> -	nc_send_packet (s, len);
> +	len = strlen (s);
> +	while (1) {
> +		if (len > 512) {
> +			nc_send_packet (s, 512);
> +			len -= 512;
> +			s += 512;
> +		} else {
> +			nc_send_packet (s, len);
> +			break;
> +		}
> +	}

i know the existing code is broken, but when adding/changing lines, please use 
the correct style.  so this should be strlen(s) and such.

in terms of the actual content, this should be simpler:
	while (len) {
		int send_len = min(len, 512);
		nc_send_packet(s, send_len);
		len -= send_len;
		s += send_len;
	}
-mike
diff mbox

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e40efb8..d54bc65 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -189,10 +189,17 @@  static void nc_puts(const char *s)
 		return;
 	output_recursion = 1;
 
-	if ((len = strlen (s)) > 512)
-		len = 512;
-
-	nc_send_packet (s, len);
+	len = strlen (s);
+	while (1) {
+		if (len > 512) {
+			nc_send_packet (s, 512);
+			len -= 512;
+			s += 512;
+		} else {
+			nc_send_packet (s, len);
+			break;
+		}
+	}
 
 	output_recursion = 0;
 }