Thu Mar 5 14:02:55 2015 UTC ()
Fix strange kernel output sequence "\n\r" observed in serial
consoles.  Output '\r' before '\n' in conversion.


(nakayama)
diff -r1.73 -r1.74 src/sys/dev/cons.c

cvs diff -r1.73 -r1.74 src/sys/dev/cons.c (expand / switch to unified diff)

--- src/sys/dev/cons.c 2015/02/23 06:54:12 1.73
+++ src/sys/dev/cons.c 2015/03/05 14:02:55 1.74
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cons.c,v 1.73 2015/02/23 06:54:12 mlelstv Exp $ */ 1/* $NetBSD: cons.c,v 1.74 2015/03/05 14:02:55 nakayama Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990, 1993 5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department. 10 * Science Department.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * from: Utah $Hdr: cons.c 1.7 92/01/21$ 36 * from: Utah $Hdr: cons.c 1.7 92/01/21$
37 * 37 *
38 * @(#)cons.c 8.2 (Berkeley) 1/12/94 38 * @(#)cons.c 8.2 (Berkeley) 1/12/94
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.73 2015/02/23 06:54:12 mlelstv Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.74 2015/03/05 14:02:55 nakayama Exp $");
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46#include <sys/systm.h> 46#include <sys/systm.h>
47#include <sys/buf.h> 47#include <sys/buf.h>
48#include <sys/ioctl.h> 48#include <sys/ioctl.h>
49#include <sys/poll.h> 49#include <sys/poll.h>
50#include <sys/tty.h> 50#include <sys/tty.h>
51#include <sys/file.h> 51#include <sys/file.h>
52#include <sys/conf.h> 52#include <sys/conf.h>
53#include <sys/vnode.h> 53#include <sys/vnode.h>
54#include <sys/kauth.h> 54#include <sys/kauth.h>
55#include <sys/mutex.h> 55#include <sys/mutex.h>
@@ -312,31 +312,31 @@ cngetsn(char *cp, int size) @@ -312,31 +312,31 @@ cngetsn(char *cp, int size)
312 *lp++ = c; 312 *lp++ = c;
313 } 313 }
314 } 314 }
315} 315}
316 316
317void 317void
318cnputc(int c) 318cnputc(int c)
319{ 319{
320 320
321 if (cn_tab == NULL) 321 if (cn_tab == NULL)
322 return; 322 return;
323 323
324 if (c) { 324 if (c) {
325 (*cn_tab->cn_putc)(cn_tab->cn_dev, c); 
326 if (c == '\n') { 325 if (c == '\n') {
327 docritpollhooks(); 
328 (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r'); 326 (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r');
 327 docritpollhooks();
329 } 328 }
 329 (*cn_tab->cn_putc)(cn_tab->cn_dev, c);
330 } 330 }
331} 331}
332 332
333void 333void
334cnpollc(int on) 334cnpollc(int on)
335{ 335{
336 static int refcount = 0; 336 static int refcount = 0;
337 337
338 if (cn_tab == NULL) 338 if (cn_tab == NULL)
339 return; 339 return;
340 if (!on) 340 if (!on)
341 --refcount; 341 --refcount;
342 if (refcount == 0) 342 if (refcount == 0)