1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * arch/alpha/lib/srm_printk.c 41da177e4SLinus Torvalds */ 51da177e4SLinus Torvalds 61da177e4SLinus Torvalds #include <linux/kernel.h> 71da177e4SLinus Torvalds #include <asm/console.h> 81da177e4SLinus Torvalds 91da177e4SLinus Torvalds long srm_printk(const char * fmt,...)101da177e4SLinus Torvaldssrm_printk(const char *fmt, ...) 111da177e4SLinus Torvalds { 121da177e4SLinus Torvalds static char buf[1024]; 131da177e4SLinus Torvalds va_list args; 141da177e4SLinus Torvalds long len, num_lf; 151da177e4SLinus Torvalds char *src, *dst; 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds va_start(args, fmt); 181da177e4SLinus Torvalds len = vsprintf(buf, fmt, args); 191da177e4SLinus Torvalds va_end(args); 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds /* count number of linefeeds in string: */ 221da177e4SLinus Torvalds 231da177e4SLinus Torvalds num_lf = 0; 241da177e4SLinus Torvalds for (src = buf; *src; ++src) { 251da177e4SLinus Torvalds if (*src == '\n') { 261da177e4SLinus Torvalds ++num_lf; 271da177e4SLinus Torvalds } 281da177e4SLinus Torvalds } 291da177e4SLinus Torvalds 301da177e4SLinus Torvalds if (num_lf) { 311da177e4SLinus Torvalds /* expand each linefeed into carriage-return/linefeed: */ 321da177e4SLinus Torvalds for (dst = src + num_lf; src >= buf; ) { 331da177e4SLinus Torvalds if (*src == '\n') { 341da177e4SLinus Torvalds *dst-- = '\r'; 351da177e4SLinus Torvalds } 361da177e4SLinus Torvalds *dst-- = *src--; 371da177e4SLinus Torvalds } 381da177e4SLinus Torvalds } 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds srm_puts(buf, num_lf+len); 411da177e4SLinus Torvalds return len; 421da177e4SLinus Torvalds } 43