[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 10/16] arm/vuart: merge vuart_print_char() with vuart_mmio_write()



From: Denis Mukhin <dmukhin@xxxxxxxx> 

Simplify code a bit since there's only one user of vuart_print_char().

No functional change.

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
 xen/arch/arm/vuart.c | 45 ++++++++++++++++++--------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
index d2f90ab0c64f..66fac6c994ce 100644
--- a/xen/arch/arm/vuart.c
+++ b/xen/arch/arm/vuart.c
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
- * xen/arch/arm/vuart.c
- *
  * Virtual UART Emulator.
  *
  * This emulator uses the information from dtuart. This is not intended to be
@@ -21,6 +19,7 @@
  * Ian Campbell <ian.campbell@xxxxxxxxxx>
  * Copyright (c) 2012 Citrix Systems.
  */
+
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/errno.h>
@@ -99,27 +98,6 @@ void domain_vuart_free(struct domain *d)
     }
 }
 
-static void vuart_print_char(struct vcpu *v, char c)
-{
-    struct domain *d = v->domain;
-    struct vuart *uart = d->arch.vuart;
-
-    if ( !is_console_printable(c) )
-        return ;
-
-    spin_lock(&uart->lock);
-    uart->buf[uart->idx++] = c;
-    if ( (uart->idx == (VUART_BUF_SIZE - 2)) || (c == '\n') )
-    {
-        if ( c != '\n' )
-            uart->buf[uart->idx++] = '\n';
-        uart->buf[uart->idx] = '\0';
-        printk(XENLOG_G_DEBUG "DOM%u: %s", d->domain_id, uart->buf);
-        uart->idx = 0;
-    }
-    spin_unlock(&uart->lock);
-}
-
 static int vuart_mmio_read(struct vcpu *v, mmio_info_t *info,
                            register_t *r, void *priv)
 {
@@ -145,12 +123,26 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t 
*info,
     struct domain *d = v->domain;
     struct vuart *vdev = d->arch.vuart;
     paddr_t offset = info->gpa - vdev->info->base_addr;
+    char ch = r & 0xFF; /* ignore any status bits */
 
     perfc_incr(vuart_writes);
 
-    if ( offset == vdev->info->data_off )
-        /* ignore any status bits */
-        vuart_print_char(v, r & 0xFF);
+    if ( !vdev || offset != vdev->info->data_off || !is_console_printable(ch) )
+        return 1;
+
+    spin_lock(&vdev->lock);
+
+    vdev->buf[vdev->idx++] = ch;
+    if ( (vdev->idx == (VUART_BUF_SIZE - 2)) || (ch == '\n') )
+    {
+        if ( ch != '\n' )
+            vdev->buf[vdev->idx++] = '\n';
+        vdev->buf[vdev->idx] = '\0';
+        printk(XENLOG_G_DEBUG "DOM%u: %s", d->domain_id, vdev->buf);
+        vdev->idx = 0;
+    }
+
+    spin_unlock(&vdev->lock);
 
     return 1;
 }
@@ -163,4 +155,3 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t 
*info,
  * indent-tabs-mode: nil
  * End:
  */
-
-- 
2.34.1





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.