Linux 4.19.140
[linux/fpc-iii.git] / arch / alpha / lib / srm_printk.c
blob6276eed76276b2864cf121546c560c585a657a56
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * arch/alpha/lib/srm_printk.c
4 */
6 #include <linux/kernel.h>
7 #include <asm/console.h>
9 long
10 srm_printk(const char *fmt, ...)
12 static char buf[1024];
13 va_list args;
14 long len, num_lf;
15 char *src, *dst;
17 va_start(args, fmt);
18 len = vsprintf(buf, fmt, args);
19 va_end(args);
21 /* count number of linefeeds in string: */
23 num_lf = 0;
24 for (src = buf; *src; ++src) {
25 if (*src == '\n') {
26 ++num_lf;
30 if (num_lf) {
31 /* expand each linefeed into carriage-return/linefeed: */
32 for (dst = src + num_lf; src >= buf; ) {
33 if (*src == '\n') {
34 *dst-- = '\r';
36 *dst-- = *src--;
40 srm_puts(buf, num_lf+len);
41 return len;