[PATCH 06/10] USB: serial: xr: clean up line-settings handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shift the line-setting values when defining them rather than in
set_termios() for consistency and improved readability.

Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
 drivers/usb/serial/xr_serial.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c
index 202263211ba9..2000277bacc1 100644
--- a/drivers/usb/serial/xr_serial.c
+++ b/drivers/usb/serial/xr_serial.c
@@ -71,17 +71,17 @@ struct xr_txrx_clk_mask {
 #define XR21V141X_UART_DATA_8		0x8
 
 #define XR21V141X_UART_PARITY_MASK	GENMASK(6, 4)
-#define XR21V141X_UART_PARITY_SHIFT	0x4
-#define XR21V141X_UART_PARITY_NONE	0x0
-#define XR21V141X_UART_PARITY_ODD	0x1
-#define XR21V141X_UART_PARITY_EVEN	0x2
-#define XR21V141X_UART_PARITY_MARK	0x3
-#define XR21V141X_UART_PARITY_SPACE	0x4
+#define XR21V141X_UART_PARITY_SHIFT	4
+#define XR21V141X_UART_PARITY_NONE	(0x0 << XR21V141X_UART_PARITY_SHIFT)
+#define XR21V141X_UART_PARITY_ODD	(0x1 << XR21V141X_UART_PARITY_SHIFT)
+#define XR21V141X_UART_PARITY_EVEN	(0x2 << XR21V141X_UART_PARITY_SHIFT)
+#define XR21V141X_UART_PARITY_MARK	(0x3 << XR21V141X_UART_PARITY_SHIFT)
+#define XR21V141X_UART_PARITY_SPACE	(0x4 << XR21V141X_UART_PARITY_SHIFT)
 
 #define XR21V141X_UART_STOP_MASK	BIT(7)
-#define XR21V141X_UART_STOP_SHIFT	0x7
-#define XR21V141X_UART_STOP_1		0x0
-#define XR21V141X_UART_STOP_2		0x1
+#define XR21V141X_UART_STOP_SHIFT	7
+#define XR21V141X_UART_STOP_1		(0x0 << XR21V141X_UART_STOP_SHIFT)
+#define XR21V141X_UART_STOP_2		(0x1 << XR21V141X_UART_STOP_SHIFT)
 
 #define XR21V141X_UART_FLOW_MODE_NONE	0x0
 #define XR21V141X_UART_FLOW_MODE_HW	0x1
@@ -477,25 +477,21 @@ static void xr_set_termios(struct tty_struct *tty,
 	if (C_PARENB(tty)) {
 		if (C_CMSPAR(tty)) {
 			if (C_PARODD(tty))
-				bits |= XR21V141X_UART_PARITY_MARK <<
-					XR21V141X_UART_PARITY_SHIFT;
+				bits |= XR21V141X_UART_PARITY_MARK;
 			else
-				bits |= XR21V141X_UART_PARITY_SPACE <<
-					XR21V141X_UART_PARITY_SHIFT;
+				bits |= XR21V141X_UART_PARITY_SPACE;
 		} else {
 			if (C_PARODD(tty))
-				bits |= XR21V141X_UART_PARITY_ODD <<
-					XR21V141X_UART_PARITY_SHIFT;
+				bits |= XR21V141X_UART_PARITY_ODD;
 			else
-				bits |= XR21V141X_UART_PARITY_EVEN <<
-					XR21V141X_UART_PARITY_SHIFT;
+				bits |= XR21V141X_UART_PARITY_EVEN;
 		}
 	}
 
 	if (C_CSTOPB(tty))
-		bits |= XR21V141X_UART_STOP_2 << XR21V141X_UART_STOP_SHIFT;
+		bits |= XR21V141X_UART_STOP_2;
 	else
-		bits |= XR21V141X_UART_STOP_1 << XR21V141X_UART_STOP_SHIFT;
+		bits |= XR21V141X_UART_STOP_1;
 
 	ret = xr_set_reg_uart(port, XR21V141X_REG_FORMAT, bits);
 	if (ret)
-- 
2.26.2




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux