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

[PATCH] xen/char: wrap suspend/resume console callbacks with CONFIG_SYSTEM_SUSPEND



From: Mykola Kvach <mykola_kvach@xxxxxxxx>

This patch wraps the suspend/resume console callbacks and related code within
CONFIG_SYSTEM_SUSPEND blocks. This ensures that these functions and their
calls are only included in the build when CONFIG_SYSTEM_SUSPEND is enabled.

This addresses Misra Rule 2.1 violations.

Suggested-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
---
 xen/drivers/char/console.c   |  4 ++++
 xen/drivers/char/ehci-dbgp.c |  6 ++++++
 xen/drivers/char/ns16550.c   | 12 ++++++++++++
 xen/drivers/char/serial.c    |  4 ++++
 xen/drivers/char/xhci-dbc.c  |  6 ++++++
 xen/include/xen/console.h    |  2 ++
 xen/include/xen/serial.h     |  4 ++++
 7 files changed, 38 insertions(+)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 5879e31786..ba5a809a99 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1365,6 +1365,8 @@ void panic(const char *fmt, ...)
         machine_restart(5000);
 }
 
+#ifdef CONFIG_SYSTEM_SUSPEND
+
 /*
  * **************************************************************
  * ****************** Console suspend/resume ********************
@@ -1388,6 +1390,8 @@ int console_resume(void)
     return 0;
 }
 
+#endif /* CONFIG_SYSTEM_SUSPEND */
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index e9cd59b254..a5c79f56fc 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1419,6 +1419,8 @@ static void __init cf_check ehci_dbgp_endboot(struct 
serial_port *port)
     ehci_dbgp_check_release(port->uart);
 }
 
+#ifdef CONFIG_SYSTEM_SUSPEND
+
 static void cf_check ehci_dbgp_suspend(struct serial_port *port)
 {
     struct ehci_dbgp *dbgp = port->uart;
@@ -1452,12 +1454,16 @@ static void cf_check ehci_dbgp_resume(struct 
serial_port *port)
     ehci_dbgp_setup_postirq(dbgp);
 }
 
+#endif /* CONFIG_SYSTEM_SUSPEND */
+
 static struct uart_driver __read_mostly ehci_dbgp_driver = {
     .init_preirq  = ehci_dbgp_init_preirq,
     .init_postirq = ehci_dbgp_init_postirq,
     .endboot      = ehci_dbgp_endboot,
+#ifdef CONFIG_SYSTEM_SUSPEND
     .suspend      = ehci_dbgp_suspend,
     .resume       = ehci_dbgp_resume,
+#endif
     .tx_ready     = ehci_dbgp_tx_ready,
     .putc         = ehci_dbgp_putc,
     .flush        = ehci_dbgp_flush,
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index eaeb0e09d0..6b4fb4ad31 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -57,7 +57,9 @@ static struct ns16550 {
 #endif
     /* UART with no IRQ line: periodically-polled I/O. */
     struct timer timer;
+#ifdef CONFIG_SYSTEM_SUSPEND
     struct timer resume_timer;
+#endif
     unsigned int timeout_ms;
     bool intr_works;
     bool dw_usr_bsy;
@@ -113,7 +115,9 @@ struct ns16550_config_param {
 static void enable_exar_enhanced_bits(const struct ns16550 *uart);
 #endif
 
+#ifdef CONFIG_SYSTEM_SUSPEND
 static void cf_check ns16550_delayed_resume(void *data);
+#endif
 
 static u8 ns_read_reg(const struct ns16550 *uart, unsigned int reg)
 {
@@ -420,7 +424,9 @@ static void __init cf_check ns16550_init_postirq(struct 
serial_port *port)
     serial_async_transmit(port);
 
     init_timer(&uart->timer, ns16550_poll, port, 0);
+#ifdef CONFIG_SYSTEM_SUSPEND
     init_timer(&uart->resume_timer, ns16550_delayed_resume, port, 0);
+#endif
 
     /* Calculate time to fill RX FIFO and/or empty TX FIFO for polling. */
     bits = uart->data_bits + uart->stop_bits + !!uart->parity;
@@ -506,6 +512,8 @@ static void __init cf_check ns16550_init_postirq(struct 
serial_port *port)
     ns16550_setup_postirq(uart);
 }
 
+#ifdef CONFIG_SYSTEM_SUSPEND
+
 static void cf_check ns16550_suspend(struct serial_port *port)
 {
     struct ns16550 *uart = port->uart;
@@ -584,6 +592,8 @@ static void cf_check ns16550_resume(struct serial_port 
*port)
         _ns16550_resume(port);
 }
 
+#endif /* CONFIG_SYSTEM_SUSPEND */
+
 static void __init cf_check ns16550_endboot(struct serial_port *port)
 {
 #ifdef CONFIG_HAS_IOPORTS
@@ -638,8 +648,10 @@ static struct uart_driver __read_mostly ns16550_driver = {
     .init_irq     = ns16550_init_irq,
     .init_postirq = ns16550_init_postirq,
     .endboot      = ns16550_endboot,
+#ifdef CONFIG_SYSTEM_SUSPEND
     .suspend      = ns16550_suspend,
     .resume       = ns16550_resume,
+#endif
     .tx_ready     = ns16550_tx_ready,
     .putc         = ns16550_putc,
     .getc         = ns16550_getc,
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 591a009008..adb312d796 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -495,6 +495,8 @@ const struct vuart_info *serial_vuart_info(int idx)
     return NULL;
 }
 
+#ifdef CONFIG_SYSTEM_SUSPEND
+
 void serial_suspend(void)
 {
     int i;
@@ -511,6 +513,8 @@ void serial_resume(void)
             com[i].driver->resume(&com[i]);
 }
 
+#endif /* CONFIG_SYSTEM_SUSPEND */
+
 void __init serial_register_uart(int idx, struct uart_driver *driver,
                                  void *uart)
 {
diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index d011159d18..1f7d4395dc 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -1271,6 +1271,8 @@ static void cf_check dbc_uart_flush(struct serial_port 
*port)
         set_timer(&uart->timer, goal);
 }
 
+#ifdef CONFIG_SYSTEM_SUSPEND
+
 static void cf_check dbc_uart_suspend(struct serial_port *port)
 {
     struct dbc_uart *uart = port->uart;
@@ -1303,6 +1305,8 @@ static void cf_check dbc_uart_resume(struct serial_port 
*port)
     set_timer(&uart->timer, NOW() + MICROSECS(DBC_POLL_INTERVAL));
 }
 
+#endif /* CONFIG_SYSTEM_SUSPEND */
+
 static struct uart_driver dbc_uart_driver = {
     .init_preirq = dbc_uart_init_preirq,
     .init_postirq = dbc_uart_init_postirq,
@@ -1310,8 +1314,10 @@ static struct uart_driver dbc_uart_driver = {
     .putc = dbc_uart_putc,
     .getc = dbc_uart_getc,
     .flush = dbc_uart_flush,
+#ifdef CONFIG_SYSTEM_SUSPEND
     .suspend = dbc_uart_suspend,
     .resume = dbc_uart_resume,
+#endif
 };
 
 /* Those are accessed via DMA. */
diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h
index 83cbc9fbda..feb57f92f1 100644
--- a/xen/include/xen/console.h
+++ b/xen/include/xen/console.h
@@ -44,8 +44,10 @@ int console_steal(int handle, void (*fn)(const char *str, 
size_t nr));
 /* Give back stolen console. Takes the identifier returned by console_steal. */
 void console_giveback(int id);
 
+#ifdef CONFIG_SYSTEM_SUSPEND
 int console_suspend(void);
 int console_resume(void);
+#endif
 
 /* Emit a string via the serial console. */
 void console_serial_puts(const char *s, size_t nr);
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 63a82b032d..8e18445552 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -66,9 +66,11 @@ struct uart_driver {
     void (*init_postirq)(struct serial_port *port);
     /* Hook to clean up after Xen bootstrap (before domain 0 runs). */
     void (*endboot)(struct serial_port *port);
+#ifdef CONFIG_SYSTEM_SUSPEND
     /* Driver suspend/resume. */
     void (*suspend)(struct serial_port *port);
     void (*resume)(struct serial_port *port);
+#endif
     /* Return number of characters the port can hold for transmit,
      * or -EIO if port is inaccesible */
     int (*tx_ready)(struct serial_port *port);
@@ -131,9 +133,11 @@ int serial_irq(int idx);
 /* Retrieve basic UART information to emulate it (base address, size...) */
 const struct vuart_info* serial_vuart_info(int idx);
 
+#ifdef CONFIG_SYSTEM_SUSPEND
 /* Serial suspend/resume. */
 void serial_suspend(void);
 void serial_resume(void);
+#endif
 
 /*
  * Initialisation and helper functions for uart drivers.
-- 
2.48.1




 


Rackspace

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