Skip to contentSkip to conversation

serial: 8250_mtk: make two read-only arrays static const

PATCH In review Colin Ian King 2 participants 2 messages Mar 7, 2022 – Mar 8, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8250_mtk: make two read-only arrays static const

Don't populate the read-only arrays fraction_L_mapping and fraction_M_mapping on the stack but instead make them static const. Also makes the object code a little smaller.

---
 drivers/tty/serial/8250/8250_mtk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +2 -2
index fb65dc601b23..f4a0caa56f84 100644
@@ -289,10 +289,10 @@ static void
 mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
 			struct ktermios *old)
 {
-	unsigned short fraction_L_mapping[] = {
+	static const unsigned short fraction_L_mapping[] = {
 		0, 1, 0x5, 0x15, 0x55, 0x57, 0x57, 0x77, 0x7F, 0xFF, 0xFF
 	};
-	unsigned short fraction_M_mapping[] = {
+	static const unsigned short fraction_M_mapping[] = {
 		0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3
 	};
 	struct uart_8250_port *up = up_to_u8250p(port);
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 15 lines · Colin Ian King

Don't populate the read-only arrays fraction_L_mapping and fraction_M_mapping on the stack but instead make them static const. Also makes the object code a little smaller.

---
  drivers/tty/serial/8250/8250_mtk.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +0 -0
index fb65dc601b23..f4a0caa56f84 100644
@@ -289,10 +289,10 @@ static void
  mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,

drivers/tty/serial/8250/8250_mtk.c static void · line 297

Quoted 10 lines
drivers/tty/serial/8250/8250_mtk.c +2 -2
  			struct ktermios *old)
  {
-	unsigned short fraction_L_mapping[] = {
+	static const unsigned short fraction_L_mapping[] = {
  		0, 1, 0x5, 0x15, 0x55, 0x57, 0x57, 0x77, 0x7F, 0xFF, 0xFF
  	};
-	unsigned short fraction_M_mapping[] = {
+	static const unsigned short fraction_M_mapping[] = {
  		0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3
  	};

And perhaps make them both unsigned char?

thanks,

Signature · 2 lines
js
suse labs