Skip to contentSkip to conversation

tty: serial: meson: small code improvements

PATCH New Martin Blumenstingl 2 participants 5 messages Nov 17, 2017 – Dec 7, 2017

Subsystems (2)
lore
Share & tools
lore

Martin Blumenstingl

author reviewer
#0 lore raw

cover tty: serial: meson: small code improvements

The goal of this series is to make some the pre-processor defines also useful for humans (like me) who want to compare register dumps. These patches should not have any functional impact (which is also why I didn't add a "Fixes" tag).

Martin Blumenstingl (3):
tty: serial: meson: remove duplicate "clear error" bit definition
tty: serial: meson: merge the two register sections for
AML_UART_CONTROL
tty: serial: meson: fix typo in the "stop bit" register definition

 drivers/tty/serial/meson_uart.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)
Signature · 1 line
2.15.0
author reviewer
#1 lore raw

PATCH 1/3 tty: serial: meson: remove duplicate "clear error" bit definition

The "clear error" bit in the AML_UART_CONTROL register is defined twice. Remove the AML_UART_CLR_ERR definition and replace it with AML_UART_CLEAR_ERR.
AML_UART_CLEAR_ERR was chosen to be kept since the datasheet's description for this bit is "Clear Error" (so developer's don't have to translate this to "CLR_ERR").
No functional changes intended.

---
 drivers/tty/serial/meson_uart.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/tty/serial/meson_uart.c +4 -5
index daafe60175da..78b5d2d15a97 100644
@@ -36,7 +36,6 @@
 #define AML_UART_RX_EN			BIT(13)
 #define AML_UART_TX_RST			BIT(22)
 #define AML_UART_RX_RST			BIT(23)
-#define AML_UART_CLR_ERR		BIT(24)
 #define AML_UART_RX_INT_EN		BIT(27)
 #define AML_UART_TX_INT_EN		BIT(28)
 #define AML_UART_DATA_LEN_MASK		(0x03 << 20)
@@ -263,10 +262,10 @@ static void meson_uart_reset(struct uart_port *port)
 	u32 val;
 
 	val = readl(port->membase + AML_UART_CONTROL);
-	val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR);
+	val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR);
 	writel(val, port->membase + AML_UART_CONTROL);
 
-	val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR);
+	val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR);
 	writel(val, port->membase + AML_UART_CONTROL);
 }
 
@@ -276,9 +275,9 @@ static int meson_uart_startup(struct uart_port *port)
 	int ret = 0;
 
 	val = readl(port->membase + AML_UART_CONTROL);
-	val |= AML_UART_CLR_ERR;
+	val |= AML_UART_CLEAR_ERR;
 	writel(val, port->membase + AML_UART_CONTROL);
-	val &= ~AML_UART_CLR_ERR;
+	val &= ~AML_UART_CLEAR_ERR;
 	writel(val, port->membase + AML_UART_CONTROL);
 
 	val |= (AML_UART_RX_EN | AML_UART_TX_EN);
Signature · 1 line
2.15.0
author reviewer
#2 lore raw

PATCH 2/3 tty: serial: meson: merge the two register sections for AML_UART_CONTROL

In reply to Martin Blumenstingl

In the code there are two separate sections which each describe some of the bits in the AML_UART_CONTROL register.
Merge these into one section to make the code easier to read. No functional changes intended.

---
 drivers/tty/serial/meson_uart.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/tty/serial/meson_uart.c +7 -9
index 78b5d2d15a97..72d425579a4d 100644
@@ -34,8 +34,15 @@
 /* AML_UART_CONTROL bits */
 #define AML_UART_TX_EN			BIT(12)
 #define AML_UART_RX_EN			BIT(13)
+#define AML_UART_TWO_WIRE_EN		BIT(15)
+#define AML_UART_STOP_BIN_LEN_MASK	(0x03 << 16)
+#define AML_UART_STOP_BIN_1SB		(0x00 << 16)
+#define AML_UART_STOP_BIN_2SB		(0x01 << 16)
+#define AML_UART_PARITY_TYPE		BIT(18)
+#define AML_UART_PARITY_EN		BIT(19)
 #define AML_UART_TX_RST			BIT(22)
 #define AML_UART_RX_RST			BIT(23)
+#define AML_UART_CLEAR_ERR		BIT(24)
 #define AML_UART_RX_INT_EN		BIT(27)
 #define AML_UART_TX_INT_EN		BIT(28)
 #define AML_UART_DATA_LEN_MASK		(0x03 << 20)
@@ -56,15 +63,6 @@
 					 AML_UART_FRAME_ERR  | \
 					 AML_UART_TX_FIFO_WERR)
 
-/* AML_UART_CONTROL bits */
-#define AML_UART_TWO_WIRE_EN		BIT(15)
-#define AML_UART_PARITY_TYPE		BIT(18)
-#define AML_UART_PARITY_EN		BIT(19)
-#define AML_UART_CLEAR_ERR		BIT(24)
-#define AML_UART_STOP_BIN_LEN_MASK	(0x03 << 16)
-#define AML_UART_STOP_BIN_1SB		(0x00 << 16)
-#define AML_UART_STOP_BIN_2SB		(0x01 << 16)
-
 /* AML_UART_MISC bits */
 #define AML_UART_XMIT_IRQ(c)		(((c) & 0xff) << 8)
 #define AML_UART_RECV_IRQ(c)		((c) & 0xff)
Signature · 1 line
2.15.0
author reviewer
#3 lore raw

PATCH 3/3 tty: serial: meson: fix typo in the "stop bit" register definition

In reply to Martin Blumenstingl

This simply fixes a typo in the preprocessor macros. No functional changes intended.

---
 drivers/tty/serial/meson_uart.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/tty/serial/meson_uart.c +6 -6
index 72d425579a4d..8a842591b37c 100644
@@ -35,9 +35,9 @@
 #define AML_UART_TX_EN			BIT(12)
 #define AML_UART_RX_EN			BIT(13)
 #define AML_UART_TWO_WIRE_EN		BIT(15)
-#define AML_UART_STOP_BIN_LEN_MASK	(0x03 << 16)
-#define AML_UART_STOP_BIN_1SB		(0x00 << 16)
-#define AML_UART_STOP_BIN_2SB		(0x01 << 16)
+#define AML_UART_STOP_BIT_LEN_MASK	(0x03 << 16)
+#define AML_UART_STOP_BIT_1SB		(0x00 << 16)
+#define AML_UART_STOP_BIT_2SB		(0x01 << 16)
 #define AML_UART_PARITY_TYPE		BIT(18)
 #define AML_UART_PARITY_EN		BIT(19)
 #define AML_UART_TX_RST			BIT(22)
@@ -351,11 +351,11 @@ static void meson_uart_set_termios(struct uart_port *port,
 	else
 		val &= ~AML_UART_PARITY_TYPE;
 
-	val &= ~AML_UART_STOP_BIN_LEN_MASK;
+	val &= ~AML_UART_STOP_BIT_LEN_MASK;
 	if (cflags & CSTOPB)
-		val |= AML_UART_STOP_BIN_2SB;
+		val |= AML_UART_STOP_BIT_2SB;
 	else
-		val |= AML_UART_STOP_BIN_1SB;
+		val |= AML_UART_STOP_BIT_1SB;
 
 	if (cflags & CRTSCTS)
 		val &= ~AML_UART_TWO_WIRE_EN;
Signature · 1 line
2.15.0
maintainer
#4 lore raw

cover tty: serial: meson: small code improvements

In reply to Martin Blumenstingl
Quoted 6 lines · Martin Blumenstingl

The goal of this series is to make some the pre-processor defines also useful for humans (like me) who want to compare register dumps. These patches should not have any functional impact (which is also why I didn't add a "Fixes" tag).

Quoted 8 lines

Martin Blumenstingl (3):
tty: serial: meson: remove duplicate "clear error" bit definition
tty: serial: meson: merge the two register sections for
AML_UART_CONTROL
tty: serial: meson: fix typo in the "stop bit" register definition

 drivers/tty/serial/meson_uart.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)