diff mbox series

serial: stm32: make info structs static to avoid sparse warnings

Message ID 20220721212430.453192-1-ben-linux@fluff.org (mailing list archive)
State New, archived
Headers show
Series serial: stm32: make info structs static to avoid sparse warnings | expand

Commit Message

Ben Dooks July 21, 2022, 9:24 p.m. UTC
The info structs are local only to the stm32-usart.c driver and are
triggering sparse warnings about being undecalred. Move these into
the main driver code and make them static to avoid the following
warnings:

drivers/tty/serial/stm32-usart.h:42:25: warning: symbol 'stm32f4_info' was not declared. Should it be static?
drivers/tty/serial/stm32-usart.h:63:25: warning: symbol 'stm32f7_info' was not declared. Should it be static?
drivers/tty/serial/stm32-usart.h:85:25: warning: symbol 'stm32h7_info' was not declared. Should it be static?

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 drivers/tty/serial/stm32-usart.c | 69 ++++++++++++++++++++++++++++++++
 drivers/tty/serial/stm32-usart.h | 68 -------------------------------
 2 files changed, 69 insertions(+), 68 deletions(-)

Comments

Jiri Slaby Aug. 11, 2022, 10:48 a.m. UTC | #1
On 21. 07. 22, 23:24, Ben Dooks wrote:
> The info structs are local only to the stm32-usart.c driver and are
> triggering sparse warnings about being undecalred. Move these into
> the main driver code and make them static to avoid the following
> warnings:
> 
> drivers/tty/serial/stm32-usart.h:42:25: warning: symbol 'stm32f4_info' was not declared. Should it be static?
> drivers/tty/serial/stm32-usart.h:63:25: warning: symbol 'stm32f7_info' was not declared. Should it be static?
> drivers/tty/serial/stm32-usart.h:85:25: warning: symbol 'stm32h7_info' was not declared. Should it be static?

Right, I would go even further. There is no point in having a separate 
header. So could you move the whole content to .c?

> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
> ---
>   drivers/tty/serial/stm32-usart.c | 69 ++++++++++++++++++++++++++++++++
>   drivers/tty/serial/stm32-usart.h | 68 -------------------------------
>   2 files changed, 69 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
> index 0973b03eeeaa..01f1ab2c18c0 100644
> --- a/drivers/tty/serial/stm32-usart.c
> +++ b/drivers/tty/serial/stm32-usart.c
> @@ -35,6 +35,75 @@
>   #include "serial_mctrl_gpio.h"
>   #include "stm32-usart.h"
>   
> +
> +/* Register offsets */
> +static struct stm32_usart_info stm32f4_info = {
> +	.ofs = {
> +		.isr	= 0x00,
> +		.rdr	= 0x04,
> +		.tdr	= 0x04,
> +		.brr	= 0x08,
> +		.cr1	= 0x0c,
> +		.cr2	= 0x10,
> +		.cr3	= 0x14,
> +		.gtpr	= 0x18,
> +		.rtor	= UNDEF_REG,
> +		.rqr	= UNDEF_REG,
> +		.icr	= UNDEF_REG,
> +	},
> +	.cfg = {
> +		.uart_enable_bit = 13,
> +		.has_7bits_data = false,
> +		.fifosize = 1,
> +	}
> +};
> +
> +static struct stm32_usart_info stm32f7_info = {
> +	.ofs = {
> +		.cr1	= 0x00,
> +		.cr2	= 0x04,
> +		.cr3	= 0x08,
> +		.brr	= 0x0c,
> +		.gtpr	= 0x10,
> +		.rtor	= 0x14,
> +		.rqr	= 0x18,
> +		.isr	= 0x1c,
> +		.icr	= 0x20,
> +		.rdr	= 0x24,
> +		.tdr	= 0x28,
> +	},
> +	.cfg = {
> +		.uart_enable_bit = 0,
> +		.has_7bits_data = true,
> +		.has_swap = true,
> +		.fifosize = 1,
> +	}
> +};
> +
> +static struct stm32_usart_info stm32h7_info = {
> +	.ofs = {
> +		.cr1	= 0x00,
> +		.cr2	= 0x04,
> +		.cr3	= 0x08,
> +		.brr	= 0x0c,
> +		.gtpr	= 0x10,
> +		.rtor	= 0x14,
> +		.rqr	= 0x18,
> +		.isr	= 0x1c,
> +		.icr	= 0x20,
> +		.rdr	= 0x24,
> +		.tdr	= 0x28,
> +	},
> +	.cfg = {
> +		.uart_enable_bit = 0,
> +		.has_7bits_data = true,
> +		.has_swap = true,
> +		.has_wakeup = true,
> +		.has_fifo = true,
> +		.fifosize = 16,
> +	}
> +};
> +
>   static void stm32_usart_stop_tx(struct uart_port *port);
>   static void stm32_usart_transmit_chars(struct uart_port *port);
>   static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch);
> diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
> index ee69c203b926..0ec41a732c88 100644
> --- a/drivers/tty/serial/stm32-usart.h
> +++ b/drivers/tty/serial/stm32-usart.h
> @@ -38,74 +38,6 @@ struct stm32_usart_info {
>   
>   #define UNDEF_REG 0xff
>   
> -/* Register offsets */
> -struct stm32_usart_info stm32f4_info = {
> -	.ofs = {
> -		.isr	= 0x00,
> -		.rdr	= 0x04,
> -		.tdr	= 0x04,
> -		.brr	= 0x08,
> -		.cr1	= 0x0c,
> -		.cr2	= 0x10,
> -		.cr3	= 0x14,
> -		.gtpr	= 0x18,
> -		.rtor	= UNDEF_REG,
> -		.rqr	= UNDEF_REG,
> -		.icr	= UNDEF_REG,
> -	},
> -	.cfg = {
> -		.uart_enable_bit = 13,
> -		.has_7bits_data = false,
> -		.fifosize = 1,
> -	}
> -};
> -
> -struct stm32_usart_info stm32f7_info = {
> -	.ofs = {
> -		.cr1	= 0x00,
> -		.cr2	= 0x04,
> -		.cr3	= 0x08,
> -		.brr	= 0x0c,
> -		.gtpr	= 0x10,
> -		.rtor	= 0x14,
> -		.rqr	= 0x18,
> -		.isr	= 0x1c,
> -		.icr	= 0x20,
> -		.rdr	= 0x24,
> -		.tdr	= 0x28,
> -	},
> -	.cfg = {
> -		.uart_enable_bit = 0,
> -		.has_7bits_data = true,
> -		.has_swap = true,
> -		.fifosize = 1,
> -	}
> -};
> -
> -struct stm32_usart_info stm32h7_info = {
> -	.ofs = {
> -		.cr1	= 0x00,
> -		.cr2	= 0x04,
> -		.cr3	= 0x08,
> -		.brr	= 0x0c,
> -		.gtpr	= 0x10,
> -		.rtor	= 0x14,
> -		.rqr	= 0x18,
> -		.isr	= 0x1c,
> -		.icr	= 0x20,
> -		.rdr	= 0x24,
> -		.tdr	= 0x28,
> -	},
> -	.cfg = {
> -		.uart_enable_bit = 0,
> -		.has_7bits_data = true,
> -		.has_swap = true,
> -		.has_wakeup = true,
> -		.has_fifo = true,
> -		.fifosize = 16,
> -	}
> -};
> -
>   /* USART_SR (F4) / USART_ISR (F7) */
>   #define USART_SR_PE		BIT(0)
>   #define USART_SR_FE		BIT(1)

thanks,
diff mbox series

Patch

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 0973b03eeeaa..01f1ab2c18c0 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -35,6 +35,75 @@ 
 #include "serial_mctrl_gpio.h"
 #include "stm32-usart.h"
 
+
+/* Register offsets */
+static struct stm32_usart_info stm32f4_info = {
+	.ofs = {
+		.isr	= 0x00,
+		.rdr	= 0x04,
+		.tdr	= 0x04,
+		.brr	= 0x08,
+		.cr1	= 0x0c,
+		.cr2	= 0x10,
+		.cr3	= 0x14,
+		.gtpr	= 0x18,
+		.rtor	= UNDEF_REG,
+		.rqr	= UNDEF_REG,
+		.icr	= UNDEF_REG,
+	},
+	.cfg = {
+		.uart_enable_bit = 13,
+		.has_7bits_data = false,
+		.fifosize = 1,
+	}
+};
+
+static struct stm32_usart_info stm32f7_info = {
+	.ofs = {
+		.cr1	= 0x00,
+		.cr2	= 0x04,
+		.cr3	= 0x08,
+		.brr	= 0x0c,
+		.gtpr	= 0x10,
+		.rtor	= 0x14,
+		.rqr	= 0x18,
+		.isr	= 0x1c,
+		.icr	= 0x20,
+		.rdr	= 0x24,
+		.tdr	= 0x28,
+	},
+	.cfg = {
+		.uart_enable_bit = 0,
+		.has_7bits_data = true,
+		.has_swap = true,
+		.fifosize = 1,
+	}
+};
+
+static struct stm32_usart_info stm32h7_info = {
+	.ofs = {
+		.cr1	= 0x00,
+		.cr2	= 0x04,
+		.cr3	= 0x08,
+		.brr	= 0x0c,
+		.gtpr	= 0x10,
+		.rtor	= 0x14,
+		.rqr	= 0x18,
+		.isr	= 0x1c,
+		.icr	= 0x20,
+		.rdr	= 0x24,
+		.tdr	= 0x28,
+	},
+	.cfg = {
+		.uart_enable_bit = 0,
+		.has_7bits_data = true,
+		.has_swap = true,
+		.has_wakeup = true,
+		.has_fifo = true,
+		.fifosize = 16,
+	}
+};
+
 static void stm32_usart_stop_tx(struct uart_port *port);
 static void stm32_usart_transmit_chars(struct uart_port *port);
 static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch);
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h
index ee69c203b926..0ec41a732c88 100644
--- a/drivers/tty/serial/stm32-usart.h
+++ b/drivers/tty/serial/stm32-usart.h
@@ -38,74 +38,6 @@  struct stm32_usart_info {
 
 #define UNDEF_REG 0xff
 
-/* Register offsets */
-struct stm32_usart_info stm32f4_info = {
-	.ofs = {
-		.isr	= 0x00,
-		.rdr	= 0x04,
-		.tdr	= 0x04,
-		.brr	= 0x08,
-		.cr1	= 0x0c,
-		.cr2	= 0x10,
-		.cr3	= 0x14,
-		.gtpr	= 0x18,
-		.rtor	= UNDEF_REG,
-		.rqr	= UNDEF_REG,
-		.icr	= UNDEF_REG,
-	},
-	.cfg = {
-		.uart_enable_bit = 13,
-		.has_7bits_data = false,
-		.fifosize = 1,
-	}
-};
-
-struct stm32_usart_info stm32f7_info = {
-	.ofs = {
-		.cr1	= 0x00,
-		.cr2	= 0x04,
-		.cr3	= 0x08,
-		.brr	= 0x0c,
-		.gtpr	= 0x10,
-		.rtor	= 0x14,
-		.rqr	= 0x18,
-		.isr	= 0x1c,
-		.icr	= 0x20,
-		.rdr	= 0x24,
-		.tdr	= 0x28,
-	},
-	.cfg = {
-		.uart_enable_bit = 0,
-		.has_7bits_data = true,
-		.has_swap = true,
-		.fifosize = 1,
-	}
-};
-
-struct stm32_usart_info stm32h7_info = {
-	.ofs = {
-		.cr1	= 0x00,
-		.cr2	= 0x04,
-		.cr3	= 0x08,
-		.brr	= 0x0c,
-		.gtpr	= 0x10,
-		.rtor	= 0x14,
-		.rqr	= 0x18,
-		.isr	= 0x1c,
-		.icr	= 0x20,
-		.rdr	= 0x24,
-		.tdr	= 0x28,
-	},
-	.cfg = {
-		.uart_enable_bit = 0,
-		.has_7bits_data = true,
-		.has_swap = true,
-		.has_wakeup = true,
-		.has_fifo = true,
-		.fifosize = 16,
-	}
-};
-
 /* USART_SR (F4) / USART_ISR (F7) */
 #define USART_SR_PE		BIT(0)
 #define USART_SR_FE		BIT(1)