linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: Manivannan Sadhasivam <mani@kernel.org>,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 06/10] USB: serial: xr: clean up line-settings handling
Date: Thu, 21 Jan 2021 11:29:18 +0100	[thread overview]
Message-ID: <20210121102922.17439-8-johan@kernel.org> (raw)
In-Reply-To: <20210121102922.17439-1-johan@kernel.org>

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

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 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


  parent reply	other threads:[~2021-01-21 13:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21 10:29 [PATCH 00/10] USB: serial: xr: fix up remaining issues in new driver Johan Hovold
2021-01-21 10:29 ` [PATCH] USB: serial: cp210x: suppress modem-control error on open and close Johan Hovold
2021-01-21 10:32   ` Johan Hovold
2021-01-21 10:29 ` [PATCH 01/10] USB: serial: xr: fix NULL-deref at probe Johan Hovold
2021-01-21 10:29 ` [PATCH 02/10] USB: serial: xr: fix interface leak at disconnect Johan Hovold
2021-01-21 10:29 ` [PATCH 03/10] USB: serial: xr: use subsystem usb_device at probe Johan Hovold
2021-01-21 10:29 ` [PATCH 04/10] USB: serial: xr: use termios flag helpers Johan Hovold
2021-01-21 10:29 ` [PATCH 05/10] USB: serial: xr: document vendor-request recipient Johan Hovold
2021-01-21 10:29 ` Johan Hovold [this message]
2021-01-21 10:29 ` [PATCH 07/10] USB: serial: xr: simplify line-speed logic Johan Hovold
2021-01-21 10:29 ` [PATCH 08/10] USB: serial: xr: fix gpio-mode handling Johan Hovold
2021-01-21 10:29 ` [PATCH 09/10] USB: serial: xr: fix pin configuration Johan Hovold
2021-01-21 10:29 ` [PATCH 10/10] USB: serial: xr: fix B0 handling Johan Hovold
2021-01-26 15:26 ` [PATCH 00/10] USB: serial: xr: fix up remaining issues in new driver Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210121102922.17439-8-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mani@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).