diff mbox series

[v1,8/8] xen/console: introduce console_get_focus()

Message ID 20250318233617.849903-9-dmukhin@ford.com (mailing list archive)
State New
Headers show
Series xen/console: cleanup console input switch logic | expand

Commit Message

Denis Mukhin March 18, 2025, 11:37 p.m. UTC
Add console_get_focus() as a console public API to the retrieve current
console owner domain ID.

Make console_{get,put}_domain() private and simplify vpl011 code a bit.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
 xen/arch/arm/vpl011.c      | 5 +----
 xen/drivers/char/console.c | 9 +++++++--
 xen/include/xen/console.h  | 3 +--
 3 files changed, 9 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index 147958eee8..9ce6151c2a 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -78,12 +78,11 @@  static void vpl011_write_data_xen(struct domain *d, uint8_t data)
     unsigned long flags;
     struct vpl011 *vpl011 = &d->arch.vpl011;
     struct vpl011_xen_backend *intf = vpl011->backend.xen;
-    struct domain *input = console_get_domain();
 
     VPL011_LOCK(d, flags);
 
     intf->out[intf->out_prod++] = data;
-    if ( d == input )
+    if ( d->domain_id == console_get_focus() )
     {
         if ( intf->out_prod == 1 )
         {
@@ -123,8 +122,6 @@  static void vpl011_write_data_xen(struct domain *d, uint8_t data)
     vpl011_update_interrupt_status(d);
 
     VPL011_UNLOCK(d, flags);
-
-    console_put_domain(input);
 }
 
 /*
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 0e2349a868..906a0ae996 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -484,12 +484,12 @@  static struct domain *console_get_domain_by_id(domid_t domid)
     return NULL;
 }
 
-struct domain *console_get_domain(void)
+static struct domain *console_get_domain(void)
 {
     return console_get_domain_by_id(console_focus);
 }
 
-void console_put_domain(struct domain *d)
+static void console_put_domain(struct domain *d)
 {
     if ( d )
         rcu_unlock_domain(d);
@@ -523,6 +523,11 @@  static int console_set_focus(domid_t domid)
     return 0;
 }
 
+domid_t console_get_focus(void)
+{
+    return console_focus;
+}
+
 /*
  * Switch console focus.
  * Rotates input focus among Xen, dom0 and boot-time created domUs while
diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h
index 83cbc9fbda..19da2b755c 100644
--- a/xen/include/xen/console.h
+++ b/xen/include/xen/console.h
@@ -32,8 +32,7 @@  void console_end_sync(void);
 void console_start_log_everything(void);
 void console_end_log_everything(void);
 
-struct domain *console_get_domain(void);
-void console_put_domain(struct domain *d);
+domid_t console_get_focus(void);
 
 /*
  * Steal output from the console. Returns +ve identifier, else -ve error.