Skip to contentSkip to conversation

lib: utils/serial: Remove unused baudrate/frequency globals

PATCH Applied Khem Raj 2 participants 2 messages Oct 15 – Nov 2 SiFive drivers

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 lib: utils/serial: Remove unused baudrate/frequency globals

From: Khem Raj <[email protected]>

The sifive-uart and cadence-uart drivers store the input clock frequency and baudrate into file-static globals during init, but never read them back; the divisor is computed directly from the function arguments. Clang 23 adds -Wunused-but-set-global, which is enabled by -Wall, so the build fails with -Werror:

sifive-uart.c:34:12: error: variable 'uart_in_freq' set but not used [-Werror,-Wunused-but-set-global] sifive-uart.c:35:12: error: variable 'uart_baudrate' set but not used [-Werror,-Wunused-but-set-global]

Drop the dead variables.

---
 lib/utils/serial/cadence-uart.c | 4 ----
 lib/utils/serial/sifive-uart.c  | 4 ----
 2 files changed, 8 deletions(-)
lib/utils/serial/cadence-uart.c +0 -4
index 30fbb95..80dc429 100644
@@ -39,8 +39,6 @@
 /* clang-format on */
 
 static volatile void *uart_base;
-static u32 uart_in_freq;
-static u32 uart_baudrate;
 
 /*
  * Find minimum divisor divides in_freq to max_target_hz;
@@ -95,8 +93,6 @@ static struct sbi_console_device cadence_console = {
 int cadence_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
 {
 	uart_base     = (volatile void *)base;
-	uart_in_freq  = in_freq;
-	uart_baudrate = baudrate;
 
 	/* Disable interrupts */
 	set_reg(UART_REG_IDR, 0xFFFFFFFF);
lib/utils/serial/sifive-uart.c +0 -4
index 5563713..235976e 100644
@@ -31,8 +31,6 @@
 /* clang-format on */
 
 static volatile char *uart_base;
-static u32 uart_in_freq;
-static u32 uart_baudrate;
 
 /**
  * Find minimum divisor divides in_freq to max_target_hz;
@@ -94,8 +92,6 @@ static struct sbi_console_device sifive_console = {
 int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
 {
 	uart_base     = (volatile char *)base;
-	uart_in_freq  = in_freq;
-	uart_baudrate = baudrate;
 
 	/* Configure baudrate */
 	if (in_freq && baudrate)
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 9 lines · Khem Raj

From: Khem Raj <[email protected]>

The sifive-uart and cadence-uart drivers store the input clock frequency and baudrate into file-static globals during init, but never read them back; the divisor is computed directly from the function arguments. Clang 23 adds -Wunused-but-set-global, which is enabled by -Wall, so the build fails with -Werror:

Quoted 6 lines

sifive-uart.c:34:12: error: variable 'uart_in_freq' set but not used [-Werror,-Wunused-but-set-global] sifive-uart.c:35:12: error: variable 'uart_baudrate' set but not used [-Werror,-Wunused-but-set-global]

Drop the dead variables.

LGTM.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 49 lines
---
 lib/utils/serial/cadence-uart.c | 4 ----
 lib/utils/serial/sifive-uart.c  | 4 ----
 2 files changed, 8 deletions(-)
lib/utils/serial/cadence-uart.c +0 -4
index 30fbb95..80dc429 100644
@@ -39,8 +39,6 @@
 /* clang-format on */
 
 static volatile void *uart_base;
-static u32 uart_in_freq;
-static u32 uart_baudrate;
 
 /*
  * Find minimum divisor divides in_freq to max_target_hz;
@@ -95,8 +93,6 @@ static struct sbi_console_device cadence_console = {
 int cadence_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
 {
        uart_base     = (volatile void *)base;
-       uart_in_freq  = in_freq;
-       uart_baudrate = baudrate;
 
        /* Disable interrupts */
        set_reg(UART_REG_IDR, 0xFFFFFFFF);
lib/utils/serial/sifive-uart.c +0 -4
index 5563713..235976e 100644
@@ -31,8 +31,6 @@
 /* clang-format on */
 
 static volatile char *uart_base;
-static u32 uart_in_freq;
-static u32 uart_baudrate;
 
 /**
  * Find minimum divisor divides in_freq to max_target_hz;
@@ -94,8 +92,6 @@ static struct sbi_console_device sifive_console = {
 int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
 {
        uart_base     = (volatile char *)base;
-       uart_in_freq  = in_freq;
-       uart_baudrate = baudrate;
 
        /* Configure baudrate */
        if (in_freq && baudrate)
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi