[PATCH v1 3/5] drivers/char: make dbc_uart_dump() a bit more useful

Marek Marczykowski-Górecki posted 5 patches 5 months, 1 week ago
[PATCH v1 3/5] drivers/char: make dbc_uart_dump() a bit more useful
Posted by Marek Marczykowski-Górecki 5 months, 1 week ago
Make it safe to call also if xhci console is not enabled. And make it
non-static, to require one less modification when actually using it.
When using it, one still needs to add its declaration in some header
(or just next to the call site).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
IIUC Misra would not be happy about a declaration of an usused function.
And I'd rather avoid extending DBC_DEBUG scope beyond that single file.
---
 xen/drivers/char/xhci-dbc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index c4bb371ff78f..ced28cae0a29 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -1498,11 +1498,14 @@ static void dbc_dump(struct dbc *dbc)
               readq(&r->cp) == virt_to_maddr(dbc->dbc_ctx));
 }
 
-static void dbc_uart_dump(void)
+void dbc_uart_dump(void)
 {
     struct dbc_uart *uart = &dbc_uart;
     struct dbc *dbc = &uart->dbc;
 
+    if ( !dbc->enable )
+        return;
+
     dbc_dump(dbc);
 }
 #endif
-- 
git-series 0.9.1

Re: [PATCH v1 3/5] drivers/char: make dbc_uart_dump() a bit more useful
Posted by Jan Beulich 4 months, 3 weeks ago
On 25.05.2025 16:15, Marek Marczykowski-Górecki wrote:
> Make it safe to call also if xhci console is not enabled. And make it
> non-static, to require one less modification when actually using it.
> When using it, one still needs to add its declaration in some header
> (or just next to the call site).
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> ---
> IIUC Misra would not be happy about a declaration of an usused function.
> And I'd rather avoid extending DBC_DEBUG scope beyond that single file.

It's not going to be happy about a non-static one without declaration
either. Misra-wise this is pretty much a no-go.

Jan

> --- a/xen/drivers/char/xhci-dbc.c
> +++ b/xen/drivers/char/xhci-dbc.c
> @@ -1498,11 +1498,14 @@ static void dbc_dump(struct dbc *dbc)
>                readq(&r->cp) == virt_to_maddr(dbc->dbc_ctx));
>  }
>  
> -static void dbc_uart_dump(void)
> +void dbc_uart_dump(void)
>  {
>      struct dbc_uart *uart = &dbc_uart;
>      struct dbc *dbc = &uart->dbc;
>  
> +    if ( !dbc->enable )
> +        return;
> +
>      dbc_dump(dbc);
>  }
>  #endif