Skip to content

Commit d2e8590

Browse files
Leo-PLgregkh
authored andcommitted
serial: sc16is7xx: convert bitmask definitions to use BIT() macro
Now that bit definition comments were cleaned up, convert bitmask definitions to use BIT() macro for clarity. Convert SC16IS7XX_IIR_ID_MASK to use GENMASK() macro - - while at that, realign comments. Compose SC16IS7XX_LSR_BRK_ERROR_MASK using aforementioned constants, instead of open-coding it, and remove now unneeded comments. Signed-off-by: Lech Perczak <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eccdb0f commit d2e8590

File tree

1 file changed

+91
-85
lines changed

1 file changed

+91
-85
lines changed

drivers/tty/serial/sc16is7xx.c

Lines changed: 91 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#undef DEFAULT_SYMBOL_NAMESPACE
1111
#define DEFAULT_SYMBOL_NAMESPACE SERIAL_NXP_SC16IS7XX
1212

13+
#include <linux/bits.h>
1314
#include <linux/clk.h>
1415
#include <linux/delay.h>
1516
#include <linux/device.h>
@@ -78,72 +79,72 @@
7879
#define SC16IS7XX_XOFF2_REG (0x07) /* Xoff2 word */
7980

8081
/* IER register bits */
81-
#define SC16IS7XX_IER_RDI_BIT (1 << 0) /* Enable RX data interrupt */
82-
#define SC16IS7XX_IER_THRI_BIT (1 << 1) /* Enable TX holding register
82+
#define SC16IS7XX_IER_RDI_BIT BIT(0) /* Enable RX data interrupt */
83+
#define SC16IS7XX_IER_THRI_BIT BIT(1) /* Enable TX holding register
8384
* interrupt */
84-
#define SC16IS7XX_IER_RLSI_BIT (1 << 2) /* Enable RX line status
85+
#define SC16IS7XX_IER_RLSI_BIT BIT(2) /* Enable RX line status
8586
* interrupt */
86-
#define SC16IS7XX_IER_MSI_BIT (1 << 3) /* Enable Modem status
87+
#define SC16IS7XX_IER_MSI_BIT BIT(3) /* Enable Modem status
8788
* interrupt */
8889

8990
/* IER register bits - write only if (EFR[4] == 1) */
90-
#define SC16IS7XX_IER_SLEEP_BIT (1 << 4) /* Enable Sleep mode */
91-
#define SC16IS7XX_IER_XOFFI_BIT (1 << 5) /* Enable Xoff interrupt */
92-
#define SC16IS7XX_IER_RTSI_BIT (1 << 6) /* Enable nRTS interrupt */
93-
#define SC16IS7XX_IER_CTSI_BIT (1 << 7) /* Enable nCTS interrupt */
91+
#define SC16IS7XX_IER_SLEEP_BIT BIT(4) /* Enable Sleep mode */
92+
#define SC16IS7XX_IER_XOFFI_BIT BIT(5) /* Enable Xoff interrupt */
93+
#define SC16IS7XX_IER_RTSI_BIT BIT(6) /* Enable nRTS interrupt */
94+
#define SC16IS7XX_IER_CTSI_BIT BIT(7) /* Enable nCTS interrupt */
9495

9596
/* FCR register bits */
96-
#define SC16IS7XX_FCR_FIFO_BIT (1 << 0) /* Enable FIFO */
97-
#define SC16IS7XX_FCR_RXRESET_BIT (1 << 1) /* Reset RX FIFO */
98-
#define SC16IS7XX_FCR_TXRESET_BIT (1 << 2) /* Reset TX FIFO */
99-
#define SC16IS7XX_FCR_RXLVLL_BIT (1 << 6) /* RX Trigger level LSB */
100-
#define SC16IS7XX_FCR_RXLVLH_BIT (1 << 7) /* RX Trigger level MSB */
97+
#define SC16IS7XX_FCR_FIFO_BIT BIT(0) /* Enable FIFO */
98+
#define SC16IS7XX_FCR_RXRESET_BIT BIT(1) /* Reset RX FIFO */
99+
#define SC16IS7XX_FCR_TXRESET_BIT BIT(2) /* Reset TX FIFO */
100+
#define SC16IS7XX_FCR_RXLVLL_BIT BIT(6) /* RX Trigger level LSB */
101+
#define SC16IS7XX_FCR_RXLVLH_BIT BIT(7) /* RX Trigger level MSB */
101102

102103
/* FCR register bits - write only if (EFR[4] == 1) */
103-
#define SC16IS7XX_FCR_TXLVLL_BIT (1 << 4) /* TX Trigger level LSB */
104-
#define SC16IS7XX_FCR_TXLVLH_BIT (1 << 5) /* TX Trigger level MSB */
104+
#define SC16IS7XX_FCR_TXLVLL_BIT BIT(4) /* TX Trigger level LSB */
105+
#define SC16IS7XX_FCR_TXLVLH_BIT BIT(5) /* TX Trigger level MSB */
105106

106107
/* IIR register bits */
107-
#define SC16IS7XX_IIR_NO_INT_BIT (1 << 0) /* No interrupts pending */
108-
#define SC16IS7XX_IIR_ID_MASK 0x3e /* Mask for the interrupt ID */
109-
#define SC16IS7XX_IIR_THRI_SRC 0x02 /* TX holding register empty */
110-
#define SC16IS7XX_IIR_RDI_SRC 0x04 /* RX data interrupt */
111-
#define SC16IS7XX_IIR_RLSE_SRC 0x06 /* RX line status error */
112-
#define SC16IS7XX_IIR_RTOI_SRC 0x0c /* RX time-out interrupt */
113-
#define SC16IS7XX_IIR_MSI_SRC 0x00 /* Modem status interrupt
114-
* - only on 75x/76x
115-
*/
116-
#define SC16IS7XX_IIR_INPIN_SRC 0x30 /* Input pin change of state
117-
* - only on 75x/76x
118-
*/
119-
#define SC16IS7XX_IIR_XOFFI_SRC 0x10 /* Received Xoff */
120-
#define SC16IS7XX_IIR_CTSRTS_SRC 0x20 /* nCTS,nRTS change of state
121-
* from active (LOW)
122-
* to inactive (HIGH)
123-
*/
108+
#define SC16IS7XX_IIR_NO_INT_BIT 0x01 /* No interrupts pending */
109+
#define SC16IS7XX_IIR_ID_MASK GENMASK(5, 1) /* Mask for the interrupt ID */
110+
#define SC16IS7XX_IIR_THRI_SRC 0x02 /* TX holding register empty */
111+
#define SC16IS7XX_IIR_RDI_SRC 0x04 /* RX data interrupt */
112+
#define SC16IS7XX_IIR_RLSE_SRC 0x06 /* RX line status error */
113+
#define SC16IS7XX_IIR_RTOI_SRC 0x0c /* RX time-out interrupt */
114+
#define SC16IS7XX_IIR_MSI_SRC 0x00 /* Modem status interrupt
115+
* - only on 75x/76x
116+
*/
117+
#define SC16IS7XX_IIR_INPIN_SRC 0x30 /* Input pin change of state
118+
* - only on 75x/76x
119+
*/
120+
#define SC16IS7XX_IIR_XOFFI_SRC 0x10 /* Received Xoff */
121+
#define SC16IS7XX_IIR_CTSRTS_SRC 0x20 /* nCTS,nRTS change of state
122+
* from active (LOW)
123+
* to inactive (HIGH)
124+
*/
124125
/* LCR register bits */
125-
#define SC16IS7XX_LCR_LENGTH0_BIT (1 << 0) /* Word length bit 0 */
126-
#define SC16IS7XX_LCR_LENGTH1_BIT (1 << 1) /* Word length bit 1
126+
#define SC16IS7XX_LCR_LENGTH0_BIT BIT(0) /* Word length bit 0 */
127+
#define SC16IS7XX_LCR_LENGTH1_BIT BIT(1) /* Word length bit 1
127128
*
128129
* Word length bits table:
129130
* 00 -> 5 bit words
130131
* 01 -> 6 bit words
131132
* 10 -> 7 bit words
132133
* 11 -> 8 bit words
133134
*/
134-
#define SC16IS7XX_LCR_STOPLEN_BIT (1 << 2) /* STOP length bit
135+
#define SC16IS7XX_LCR_STOPLEN_BIT BIT(2) /* STOP length bit
135136
*
136137
* STOP length bit table:
137138
* 0 -> 1 stop bit
138139
* 1 -> 1-1.5 stop bits if
139140
* word length is 5,
140141
* 2 stop bits otherwise
141142
*/
142-
#define SC16IS7XX_LCR_PARITY_BIT (1 << 3) /* Parity bit enable */
143-
#define SC16IS7XX_LCR_EVENPARITY_BIT (1 << 4) /* Even parity bit enable */
144-
#define SC16IS7XX_LCR_FORCEPARITY_BIT (1 << 5) /* 9-bit multidrop parity */
145-
#define SC16IS7XX_LCR_TXBREAK_BIT (1 << 6) /* TX break enable */
146-
#define SC16IS7XX_LCR_DLAB_BIT (1 << 7) /* Divisor Latch enable */
143+
#define SC16IS7XX_LCR_PARITY_BIT BIT(3) /* Parity bit enable */
144+
#define SC16IS7XX_LCR_EVENPARITY_BIT BIT(4) /* Even parity bit enable */
145+
#define SC16IS7XX_LCR_FORCEPARITY_BIT BIT(5) /* 9-bit multidrop parity */
146+
#define SC16IS7XX_LCR_TXBREAK_BIT BIT(6) /* TX break enable */
147+
#define SC16IS7XX_LCR_DLAB_BIT BIT(7) /* Divisor Latch enable */
147148
#define SC16IS7XX_LCR_WORD_LEN_5 (0x00)
148149
#define SC16IS7XX_LCR_WORD_LEN_6 (0x01)
149150
#define SC16IS7XX_LCR_WORD_LEN_7 (0x02)
@@ -154,58 +155,63 @@
154155
* reg set */
155156

156157
/* MCR register bits */
157-
#define SC16IS7XX_MCR_DTR_BIT (1 << 0) /* DTR complement
158+
#define SC16IS7XX_MCR_DTR_BIT BIT(0) /* DTR complement
158159
* - only on 75x/76x
159160
*/
160-
#define SC16IS7XX_MCR_RTS_BIT (1 << 1) /* RTS complement */
161-
#define SC16IS7XX_MCR_TCRTLR_BIT (1 << 2) /* TCR/TLR register enable */
162-
#define SC16IS7XX_MCR_LOOP_BIT (1 << 4) /* Enable loopback test mode */
163-
#define SC16IS7XX_MCR_XONANY_BIT (1 << 5) /* Enable Xon Any
161+
#define SC16IS7XX_MCR_RTS_BIT BIT(1) /* RTS complement */
162+
#define SC16IS7XX_MCR_TCRTLR_BIT BIT(2) /* TCR/TLR register enable */
163+
#define SC16IS7XX_MCR_LOOP_BIT BIT(4) /* Enable loopback test mode */
164+
#define SC16IS7XX_MCR_XONANY_BIT BIT(5) /* Enable Xon Any
164165
* - write enabled
165166
* if (EFR[4] == 1)
166167
*/
167-
#define SC16IS7XX_MCR_IRDA_BIT (1 << 6) /* Enable IrDA mode
168+
#define SC16IS7XX_MCR_IRDA_BIT BIT(6) /* Enable IrDA mode
168169
* - write enabled
169170
* if (EFR[4] == 1)
170171
*/
171-
#define SC16IS7XX_MCR_CLKSEL_BIT (1 << 7) /* Divide clock by 4
172+
#define SC16IS7XX_MCR_CLKSEL_BIT BIT(7) /* Divide clock by 4
172173
* - write enabled
173174
* if (EFR[4] == 1)
174175
*/
175176

176177
/* LSR register bits */
177-
#define SC16IS7XX_LSR_DR_BIT (1 << 0) /* Receiver data ready */
178-
#define SC16IS7XX_LSR_OE_BIT (1 << 1) /* Overrun Error */
179-
#define SC16IS7XX_LSR_PE_BIT (1 << 2) /* Parity Error */
180-
#define SC16IS7XX_LSR_FE_BIT (1 << 3) /* Frame Error */
181-
#define SC16IS7XX_LSR_BI_BIT (1 << 4) /* Break Interrupt */
182-
#define SC16IS7XX_LSR_BRK_ERROR_MASK 0x1E /* BI, FE, PE, OE bits */
183-
#define SC16IS7XX_LSR_THRE_BIT (1 << 5) /* TX holding register empty */
184-
#define SC16IS7XX_LSR_TEMT_BIT (1 << 6) /* Transmitter empty */
185-
#define SC16IS7XX_LSR_FIFOE_BIT (1 << 7) /* Fifo Error */
178+
#define SC16IS7XX_LSR_DR_BIT BIT(0) /* Receiver data ready */
179+
#define SC16IS7XX_LSR_OE_BIT BIT(1) /* Overrun Error */
180+
#define SC16IS7XX_LSR_PE_BIT BIT(2) /* Parity Error */
181+
#define SC16IS7XX_LSR_FE_BIT BIT(3) /* Frame Error */
182+
#define SC16IS7XX_LSR_BI_BIT BIT(4) /* Break Interrupt */
183+
#define SC16IS7XX_LSR_BRK_ERROR_MASK \
184+
(SC16IS7XX_LSR_OE_BIT | \
185+
SC16IS7XX_LSR_PE_BIT | \
186+
SC16IS7XX_LSR_FE_BIT | \
187+
SC16IS7XX_LSR_BI_BIT)
188+
189+
#define SC16IS7XX_LSR_THRE_BIT BIT(5) /* TX holding register empty */
190+
#define SC16IS7XX_LSR_TEMT_BIT BIT(6) /* Transmitter empty */
191+
#define SC16IS7XX_LSR_FIFOE_BIT BIT(7) /* Fifo Error */
186192

187193
/* MSR register bits */
188-
#define SC16IS7XX_MSR_DCTS_BIT (1 << 0) /* Delta CTS Clear To Send */
189-
#define SC16IS7XX_MSR_DDSR_BIT (1 << 1) /* Delta DSR Data Set Ready
194+
#define SC16IS7XX_MSR_DCTS_BIT BIT(0) /* Delta CTS Clear To Send */
195+
#define SC16IS7XX_MSR_DDSR_BIT BIT(1) /* Delta DSR Data Set Ready
190196
* or (IO4)
191197
* - only on 75x/76x
192198
*/
193-
#define SC16IS7XX_MSR_DRI_BIT (1 << 2) /* Delta RI Ring Indicator
199+
#define SC16IS7XX_MSR_DRI_BIT BIT(2) /* Delta RI Ring Indicator
194200
* or (IO7)
195201
* - only on 75x/76x
196202
*/
197-
#define SC16IS7XX_MSR_DCD_BIT (1 << 3) /* Delta CD Carrier Detect
203+
#define SC16IS7XX_MSR_DCD_BIT BIT(3) /* Delta CD Carrier Detect
198204
* or (IO6)
199205
* - only on 75x/76x
200206
*/
201-
#define SC16IS7XX_MSR_CTS_BIT (1 << 4) /* CTS */
202-
#define SC16IS7XX_MSR_DSR_BIT (1 << 5) /* DSR (IO4)
207+
#define SC16IS7XX_MSR_CTS_BIT BIT(4) /* CTS */
208+
#define SC16IS7XX_MSR_DSR_BIT BIT(5) /* DSR (IO4)
203209
* - only on 75x/76x
204210
*/
205-
#define SC16IS7XX_MSR_RI_BIT (1 << 6) /* RI (IO7)
211+
#define SC16IS7XX_MSR_RI_BIT BIT(6) /* RI (IO7)
206212
* - only on 75x/76x
207213
*/
208-
#define SC16IS7XX_MSR_CD_BIT (1 << 7) /* CD (IO6)
214+
#define SC16IS7XX_MSR_CD_BIT BIT(7) /* CD (IO6)
209215
* - only on 75x/76x
210216
*/
211217

@@ -240,35 +246,35 @@
240246
#define SC16IS7XX_TLR_RX_TRIGGER(words) ((((words) / 4) & 0x0f) << 4)
241247

242248
/* IOControl register bits (Only 75x/76x) */
243-
#define SC16IS7XX_IOCONTROL_LATCH_BIT (1 << 0) /* Enable input latching */
244-
#define SC16IS7XX_IOCONTROL_MODEM_A_BIT (1 << 1) /* Enable GPIO[7:4] as modem A pins */
245-
#define SC16IS7XX_IOCONTROL_MODEM_B_BIT (1 << 2) /* Enable GPIO[3:0] as modem B pins */
246-
#define SC16IS7XX_IOCONTROL_SRESET_BIT (1 << 3) /* Software Reset */
249+
#define SC16IS7XX_IOCONTROL_LATCH_BIT BIT(0) /* Enable input latching */
250+
#define SC16IS7XX_IOCONTROL_MODEM_A_BIT BIT(1) /* Enable GPIO[7:4] as modem A pins */
251+
#define SC16IS7XX_IOCONTROL_MODEM_B_BIT BIT(2) /* Enable GPIO[3:0] as modem B pins */
252+
#define SC16IS7XX_IOCONTROL_SRESET_BIT BIT(3) /* Software Reset */
247253

248254
/* EFCR register bits */
249-
#define SC16IS7XX_EFCR_9BIT_MODE_BIT (1 << 0) /* Enable 9-bit or Multidrop
255+
#define SC16IS7XX_EFCR_9BIT_MODE_BIT BIT(0) /* Enable 9-bit or Multidrop
250256
* mode (RS485) */
251-
#define SC16IS7XX_EFCR_RXDISABLE_BIT (1 << 1) /* Disable receiver */
252-
#define SC16IS7XX_EFCR_TXDISABLE_BIT (1 << 2) /* Disable transmitter */
253-
#define SC16IS7XX_EFCR_AUTO_RS485_BIT (1 << 4) /* Auto RS485 RTS direction */
254-
#define SC16IS7XX_EFCR_RTS_INVERT_BIT (1 << 5) /* RTS output inversion */
255-
#define SC16IS7XX_EFCR_IRDA_MODE_BIT (1 << 7) /* IrDA mode
257+
#define SC16IS7XX_EFCR_RXDISABLE_BIT BIT(1) /* Disable receiver */
258+
#define SC16IS7XX_EFCR_TXDISABLE_BIT BIT(2) /* Disable transmitter */
259+
#define SC16IS7XX_EFCR_AUTO_RS485_BIT BIT(4) /* Auto RS485 RTS direction */
260+
#define SC16IS7XX_EFCR_RTS_INVERT_BIT BIT(5) /* RTS output inversion */
261+
#define SC16IS7XX_EFCR_IRDA_MODE_BIT BIT(7) /* IrDA mode
256262
* 0 = rate upto 115.2 kbit/s
257263
* - Only 75x/76x
258264
* 1 = rate upto 1.152 Mbit/s
259265
* - Only 76x
260266
*/
261267

262268
/* EFR register bits */
263-
#define SC16IS7XX_EFR_AUTORTS_BIT (1 << 6) /* Auto RTS flow ctrl enable */
264-
#define SC16IS7XX_EFR_AUTOCTS_BIT (1 << 7) /* Auto CTS flow ctrl enable */
265-
#define SC16IS7XX_EFR_XOFF2_DETECT_BIT (1 << 5) /* Enable Xoff2 detection */
266-
#define SC16IS7XX_EFR_ENABLE_BIT (1 << 4) /* Enable enhanced functions
269+
#define SC16IS7XX_EFR_AUTORTS_BIT BIT(6) /* Auto RTS flow ctrl enable */
270+
#define SC16IS7XX_EFR_AUTOCTS_BIT BIT(7) /* Auto CTS flow ctrl enable */
271+
#define SC16IS7XX_EFR_XOFF2_DETECT_BIT BIT(5) /* Enable Xoff2 detection */
272+
#define SC16IS7XX_EFR_ENABLE_BIT BIT(4) /* Enable enhanced functions
267273
* and writing to IER[7:4],
268274
* FCR[5:4], MCR[7:5]
269275
*/
270-
#define SC16IS7XX_EFR_SWFLOW3_BIT (1 << 3)
271-
#define SC16IS7XX_EFR_SWFLOW2_BIT (1 << 2)
276+
#define SC16IS7XX_EFR_SWFLOW3_BIT BIT(3)
277+
#define SC16IS7XX_EFR_SWFLOW2_BIT BIT(2)
272278
/*
273279
* SWFLOW bits 3 & 2 table:
274280
* 00 -> no transmitter flow
@@ -281,8 +287,8 @@
281287
* XON1, XON2, XOFF1 and
282288
* XOFF2
283289
*/
284-
#define SC16IS7XX_EFR_SWFLOW1_BIT (1 << 1)
285-
#define SC16IS7XX_EFR_SWFLOW0_BIT (1 << 0)
290+
#define SC16IS7XX_EFR_SWFLOW1_BIT BIT(1)
291+
#define SC16IS7XX_EFR_SWFLOW0_BIT BIT(0)
286292
/*
287293
* SWFLOW bits 1 & 0 table:
288294
* 00 -> no received flow
@@ -308,9 +314,9 @@
308314
#define SC16IS7XX_FIFO_SIZE (64)
309315
#define SC16IS7XX_GPIOS_PER_BANK 4
310316

311-
#define SC16IS7XX_RECONF_MD (1 << 0)
312-
#define SC16IS7XX_RECONF_IER (1 << 1)
313-
#define SC16IS7XX_RECONF_RS485 (1 << 2)
317+
#define SC16IS7XX_RECONF_MD BIT(0)
318+
#define SC16IS7XX_RECONF_IER BIT(1)
319+
#define SC16IS7XX_RECONF_RS485 BIT(2)
314320

315321
struct sc16is7xx_one_config {
316322
unsigned int flags;

0 commit comments

Comments
 (0)