summaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorThomas Richter <tmricht@linux.ibm.com>2022-08-30 15:03:07 +0200
committerVasily Gorbik <gor@linux.ibm.com>2022-10-26 14:46:51 +0200
commit655ae931548f09ab6d583474097893a482eb4d61 (patch)
tree54ae349c973d112fa540039bf9d234900232f4a8 /drivers/s390
parent247f34f7b80357943234f93f247a1ae6b6c3a740 (diff)
downloadlinux-655ae931548f09ab6d583474097893a482eb4d61.tar.gz
linux-655ae931548f09ab6d583474097893a482eb4d61.tar.bz2
linux-655ae931548f09ab6d583474097893a482eb4d61.zip
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 <tmricht@linux.ibm.com> Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/char/con3215.c40
1 files 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;
}
/*