From 655ae931548f09ab6d583474097893a482eb4d61 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Tue, 30 Aug 2022 15:03:07 +0200 Subject: [PATCH] s390/con3215: Simplify console write operation The functions con3215_write() and tty3215_write() have nearly identical function bodies and a slightly different function prototype. Create function handle_write() to handle the common function body and maintain the function prototypes. Signed-off-by: Thomas Richter Reviewed-by: Peter Oberparleiter Signed-off-by: Vasily Gorbik --- drivers/s390/char/con3215.c | 40 +++++++++++-------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c index 4ae07c7e2175..03e2d3d14c6d 100644 --- a/drivers/s390/char/con3215.c +++ b/drivers/s390/char/con3215.c @@ -736,19 +736,10 @@ static struct ccw_driver raw3215_ccw_driver = { .int_class = IRQIO_C15, }; -#ifdef CONFIG_TN3215_CONSOLE -/* - * Write a string to the 3215 console - */ -static void con3215_write(struct console *co, const char *str, - unsigned int count) +static void handle_write(struct raw3215_info *raw, const char *str, int count) { - struct raw3215_info *raw; int i; - if (count <= 0) - return; - raw = raw3215[0]; /* console 3215 is the first one */ while (count > 0) { for (i = 0; i < count; i++) if (str[i] == '\t' || str[i] == '\n') @@ -764,6 +755,15 @@ static void con3215_write(struct console *co, const char *str, } } +#ifdef CONFIG_TN3215_CONSOLE +/* + * Write a string to the 3215 console + */ +static void con3215_write(struct console *co, const char *str, unsigned int count) +{ + handle_write(raw3215[0], str, count); +} + static struct tty_driver *con3215_device(struct console *c, int *index) { *index = c->index; @@ -943,24 +943,8 @@ static unsigned int tty3215_write_room(struct tty_struct *tty) static int tty3215_write(struct tty_struct * tty, const unsigned char *buf, int count) { - struct raw3215_info *raw = tty->driver_data; - int i, written; - - written = count; - while (count > 0) { - for (i = 0; i < count; i++) - if (buf[i] == '\t' || buf[i] == '\n') - break; - raw3215_write(raw, buf, i); - count -= i; - buf += i; - if (count > 0) { - raw3215_putchar(raw, *buf); - count--; - buf++; - } - } - return written; + handle_write(tty->driver_data, buf, count); + return count; } /* -- 2.25.1