Skip to content

Commit b6a8f6a

Browse files
SherrySun5gregkh
authored andcommitted
tty: serial: fsl_lpuart: Use u32 and u8 for register variables
Use u32 and u8 rather than unsigned long or unsigned char for register variables for clarity and consistency. Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Link: https://lore.kernel.org/r/20250312023904.1343351-2-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f5cb528 commit b6a8f6a

File tree

1 file changed

+46
-47
lines changed

1 file changed

+46
-47
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static unsigned int lpuart_get_baud_clk_rate(struct lpuart_port *sport)
441441

442442
static void lpuart_stop_tx(struct uart_port *port)
443443
{
444-
unsigned char temp;
444+
u8 temp;
445445

446446
temp = readb(port->membase + UARTCR2);
447447
temp &= ~(UARTCR2_TIE | UARTCR2_TCIE);
@@ -450,7 +450,7 @@ static void lpuart_stop_tx(struct uart_port *port)
450450

451451
static void lpuart32_stop_tx(struct uart_port *port)
452452
{
453-
unsigned long temp;
453+
u32 temp;
454454

455455
temp = lpuart32_read(port, UARTCTRL);
456456
temp &= ~(UARTCTRL_TIE | UARTCTRL_TCIE);
@@ -459,15 +459,15 @@ static void lpuart32_stop_tx(struct uart_port *port)
459459

460460
static void lpuart_stop_rx(struct uart_port *port)
461461
{
462-
unsigned char temp;
462+
u8 temp;
463463

464464
temp = readb(port->membase + UARTCR2);
465465
writeb(temp & ~UARTCR2_RE, port->membase + UARTCR2);
466466
}
467467

468468
static void lpuart32_stop_rx(struct uart_port *port)
469469
{
470-
unsigned long temp;
470+
u32 temp;
471471

472472
temp = lpuart32_read(port, UARTCTRL);
473473
lpuart32_write(port, temp & ~UARTCTRL_RE, UARTCTRL);
@@ -642,7 +642,7 @@ static int lpuart_poll_init(struct uart_port *port)
642642
struct lpuart_port *sport = container_of(port,
643643
struct lpuart_port, port);
644644
unsigned long flags;
645-
unsigned char temp;
645+
u8 temp;
646646

647647
sport->port.fifosize = 0;
648648

@@ -752,7 +752,7 @@ static inline void lpuart_transmit_buffer(struct lpuart_port *sport)
752752
static inline void lpuart32_transmit_buffer(struct lpuart_port *sport)
753753
{
754754
struct tty_port *tport = &sport->port.state->port;
755-
unsigned long txcnt;
755+
u32 txcnt;
756756
unsigned char c;
757757

758758
if (sport->port.x_char) {
@@ -789,7 +789,7 @@ static void lpuart_start_tx(struct uart_port *port)
789789
{
790790
struct lpuart_port *sport = container_of(port,
791791
struct lpuart_port, port);
792-
unsigned char temp;
792+
u8 temp;
793793

794794
temp = readb(port->membase + UARTCR2);
795795
writeb(temp | UARTCR2_TIE, port->membase + UARTCR2);
@@ -806,7 +806,7 @@ static void lpuart_start_tx(struct uart_port *port)
806806
static void lpuart32_start_tx(struct uart_port *port)
807807
{
808808
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
809-
unsigned long temp;
809+
u32 temp;
810810

811811
if (sport->lpuart_dma_tx_use) {
812812
if (!lpuart_stopped_or_empty(port))
@@ -839,8 +839,8 @@ static unsigned int lpuart_tx_empty(struct uart_port *port)
839839
{
840840
struct lpuart_port *sport = container_of(port,
841841
struct lpuart_port, port);
842-
unsigned char sr1 = readb(port->membase + UARTSR1);
843-
unsigned char sfifo = readb(port->membase + UARTSFIFO);
842+
u8 sr1 = readb(port->membase + UARTSR1);
843+
u8 sfifo = readb(port->membase + UARTSFIFO);
844844

845845
if (sport->dma_tx_in_progress)
846846
return 0;
@@ -855,9 +855,9 @@ static unsigned int lpuart32_tx_empty(struct uart_port *port)
855855
{
856856
struct lpuart_port *sport = container_of(port,
857857
struct lpuart_port, port);
858-
unsigned long stat = lpuart32_read(port, UARTSTAT);
859-
unsigned long sfifo = lpuart32_read(port, UARTFIFO);
860-
unsigned long ctrl = lpuart32_read(port, UARTCTRL);
858+
u32 stat = lpuart32_read(port, UARTSTAT);
859+
u32 sfifo = lpuart32_read(port, UARTFIFO);
860+
u32 ctrl = lpuart32_read(port, UARTCTRL);
861861

862862
if (sport->dma_tx_in_progress)
863863
return 0;
@@ -884,7 +884,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
884884
{
885885
unsigned int flg, ignored = 0, overrun = 0;
886886
struct tty_port *port = &sport->port.state->port;
887-
unsigned char rx, sr;
887+
u8 rx, sr;
888888

889889
uart_port_lock(&sport->port);
890890

@@ -961,7 +961,7 @@ static void lpuart32_rxint(struct lpuart_port *sport)
961961
{
962962
unsigned int flg, ignored = 0;
963963
struct tty_port *port = &sport->port.state->port;
964-
unsigned long rx, sr;
964+
u32 rx, sr;
965965
bool is_break;
966966

967967
uart_port_lock(&sport->port);
@@ -1039,7 +1039,7 @@ static void lpuart32_rxint(struct lpuart_port *sport)
10391039
static irqreturn_t lpuart_int(int irq, void *dev_id)
10401040
{
10411041
struct lpuart_port *sport = dev_id;
1042-
unsigned char sts;
1042+
u8 sts;
10431043

10441044
sts = readb(sport->port.membase + UARTSR1);
10451045

@@ -1113,7 +1113,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
11131113
int count, copied;
11141114

11151115
if (lpuart_is_32(sport)) {
1116-
unsigned long sr = lpuart32_read(&sport->port, UARTSTAT);
1116+
u32 sr = lpuart32_read(&sport->port, UARTSTAT);
11171117

11181118
if (sr & (UARTSTAT_PE | UARTSTAT_FE)) {
11191119
/* Clear the error flags */
@@ -1125,10 +1125,10 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
11251125
sport->port.icount.frame++;
11261126
}
11271127
} else {
1128-
unsigned char sr = readb(sport->port.membase + UARTSR1);
1128+
u8 sr = readb(sport->port.membase + UARTSR1);
11291129

11301130
if (sr & (UARTSR1_PE | UARTSR1_FE)) {
1131-
unsigned char cr2;
1131+
u8 cr2;
11321132

11331133
/* Disable receiver during this operation... */
11341134
cr2 = readb(sport->port.membase + UARTCR2);
@@ -1279,7 +1279,7 @@ static void lpuart32_dma_idleint(struct lpuart_port *sport)
12791279
static irqreturn_t lpuart32_int(int irq, void *dev_id)
12801280
{
12811281
struct lpuart_port *sport = dev_id;
1282-
unsigned long sts, rxcount;
1282+
u32 sts, rxcount;
12831283

12841284
sts = lpuart32_read(&sport->port, UARTSTAT);
12851285
rxcount = lpuart32_read(&sport->port, UARTWATER);
@@ -1411,12 +1411,12 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
14111411
dma_async_issue_pending(chan);
14121412

14131413
if (lpuart_is_32(sport)) {
1414-
unsigned long temp = lpuart32_read(&sport->port, UARTBAUD);
1414+
u32 temp = lpuart32_read(&sport->port, UARTBAUD);
14151415

14161416
lpuart32_write(&sport->port, temp | UARTBAUD_RDMAE, UARTBAUD);
14171417

14181418
if (sport->dma_idle_int) {
1419-
unsigned long ctrl = lpuart32_read(&sport->port, UARTCTRL);
1419+
u32 ctrl = lpuart32_read(&sport->port, UARTCTRL);
14201420

14211421
lpuart32_write(&sport->port, ctrl | UARTCTRL_ILIE, UARTCTRL);
14221422
}
@@ -1482,7 +1482,7 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio
14821482
struct lpuart_port *sport = container_of(port,
14831483
struct lpuart_port, port);
14841484

1485-
unsigned long modem = lpuart32_read(&sport->port, UARTMODIR)
1485+
u32 modem = lpuart32_read(&sport->port, UARTMODIR)
14861486
& ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE);
14871487
u32 ctrl;
14881488

@@ -1577,7 +1577,7 @@ static void lpuart32_set_mctrl(struct uart_port *port, unsigned int mctrl)
15771577

15781578
static void lpuart_break_ctl(struct uart_port *port, int break_state)
15791579
{
1580-
unsigned char temp;
1580+
u8 temp;
15811581

15821582
temp = readb(port->membase + UARTCR2) & ~UARTCR2_SBK;
15831583

@@ -1589,7 +1589,7 @@ static void lpuart_break_ctl(struct uart_port *port, int break_state)
15891589

15901590
static void lpuart32_break_ctl(struct uart_port *port, int break_state)
15911591
{
1592-
unsigned long temp;
1592+
u32 temp;
15931593

15941594
temp = lpuart32_read(port, UARTCTRL);
15951595

@@ -1623,8 +1623,7 @@ static void lpuart32_break_ctl(struct uart_port *port, int break_state)
16231623

16241624
static void lpuart_setup_watermark(struct lpuart_port *sport)
16251625
{
1626-
unsigned char val, cr2;
1627-
unsigned char cr2_saved;
1626+
u8 val, cr2, cr2_saved;
16281627

16291628
cr2 = readb(sport->port.membase + UARTCR2);
16301629
cr2_saved = cr2;
@@ -1657,7 +1656,7 @@ static void lpuart_setup_watermark(struct lpuart_port *sport)
16571656

16581657
static void lpuart_setup_watermark_enable(struct lpuart_port *sport)
16591658
{
1660-
unsigned char cr2;
1659+
u8 cr2;
16611660

16621661
lpuart_setup_watermark(sport);
16631662

@@ -1668,8 +1667,7 @@ static void lpuart_setup_watermark_enable(struct lpuart_port *sport)
16681667

16691668
static void lpuart32_setup_watermark(struct lpuart_port *sport)
16701669
{
1671-
unsigned long val, ctrl;
1672-
unsigned long ctrl_saved;
1670+
u32 val, ctrl, ctrl_saved;
16731671

16741672
ctrl = lpuart32_read(&sport->port, UARTCTRL);
16751673
ctrl_saved = ctrl;
@@ -1778,7 +1776,7 @@ static void lpuart_tx_dma_startup(struct lpuart_port *sport)
17781776
static void lpuart_rx_dma_startup(struct lpuart_port *sport)
17791777
{
17801778
int ret;
1781-
unsigned char cr3;
1779+
u8 cr3;
17821780

17831781
if (uart_console(&sport->port))
17841782
goto err;
@@ -1828,7 +1826,7 @@ static void lpuart_hw_setup(struct lpuart_port *sport)
18281826
static int lpuart_startup(struct uart_port *port)
18291827
{
18301828
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
1831-
unsigned char temp;
1829+
u8 temp;
18321830

18331831
/* determine FIFO size and enable FIFO mode */
18341832
temp = readb(sport->port.membase + UARTPFIFO);
@@ -1848,7 +1846,7 @@ static int lpuart_startup(struct uart_port *port)
18481846

18491847
static void lpuart32_hw_disable(struct lpuart_port *sport)
18501848
{
1851-
unsigned long temp;
1849+
u32 temp;
18521850

18531851
temp = lpuart32_read(&sport->port, UARTCTRL);
18541852
temp &= ~(UARTCTRL_RIE | UARTCTRL_ILIE | UARTCTRL_RE |
@@ -1858,7 +1856,7 @@ static void lpuart32_hw_disable(struct lpuart_port *sport)
18581856

18591857
static void lpuart32_configure(struct lpuart_port *sport)
18601858
{
1861-
unsigned long temp;
1859+
u32 temp;
18621860

18631861
temp = lpuart32_read(&sport->port, UARTCTRL);
18641862
if (!sport->lpuart_dma_rx_use)
@@ -1888,7 +1886,7 @@ static void lpuart32_hw_setup(struct lpuart_port *sport)
18881886
static int lpuart32_startup(struct uart_port *port)
18891887
{
18901888
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
1891-
unsigned long temp;
1889+
u32 temp;
18921890

18931891
/* determine FIFO size */
18941892
temp = lpuart32_read(&sport->port, UARTFIFO);
@@ -1942,7 +1940,7 @@ static void lpuart_dma_shutdown(struct lpuart_port *sport)
19421940
static void lpuart_shutdown(struct uart_port *port)
19431941
{
19441942
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
1945-
unsigned char temp;
1943+
u8 temp;
19461944
unsigned long flags;
19471945

19481946
uart_port_lock_irqsave(port, &flags);
@@ -1962,7 +1960,7 @@ static void lpuart32_shutdown(struct uart_port *port)
19621960
{
19631961
struct lpuart_port *sport =
19641962
container_of(port, struct lpuart_port, port);
1965-
unsigned long temp;
1963+
u32 temp;
19661964
unsigned long flags;
19671965

19681966
uart_port_lock_irqsave(port, &flags);
@@ -1998,7 +1996,7 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
19981996
{
19991997
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
20001998
unsigned long flags;
2001-
unsigned char cr1, old_cr1, old_cr2, cr3, cr4, bdh, modem;
1999+
u8 cr1, old_cr1, old_cr2, cr3, cr4, bdh, modem;
20022000
unsigned int baud;
20032001
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
20042002
unsigned int sbr, brfa;
@@ -2236,7 +2234,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
22362234
{
22372235
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
22382236
unsigned long flags;
2239-
unsigned long ctrl, old_ctrl, bd, modem;
2237+
u32 ctrl, old_ctrl, bd, modem;
22402238
unsigned int baud;
22412239
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
22422240

@@ -2503,7 +2501,7 @@ static void
25032501
lpuart_console_write(struct console *co, const char *s, unsigned int count)
25042502
{
25052503
struct lpuart_port *sport = lpuart_ports[co->index];
2506-
unsigned char old_cr2, cr2;
2504+
u8 old_cr2, cr2;
25072505
unsigned long flags;
25082506
int locked = 1;
25092507

@@ -2533,7 +2531,7 @@ static void
25332531
lpuart32_console_write(struct console *co, const char *s, unsigned int count)
25342532
{
25352533
struct lpuart_port *sport = lpuart_ports[co->index];
2536-
unsigned long old_cr, cr;
2534+
u32 old_cr, cr;
25372535
unsigned long flags;
25382536
int locked = 1;
25392537

@@ -2567,7 +2565,7 @@ static void __init
25672565
lpuart_console_get_options(struct lpuart_port *sport, int *baud,
25682566
int *parity, int *bits)
25692567
{
2570-
unsigned char cr, bdh, bdl, brfa;
2568+
u8 cr, bdh, bdl, brfa;
25712569
unsigned int sbr, uartclk, baud_raw;
25722570

25732571
cr = readb(sport->port.membase + UARTCR2);
@@ -2616,7 +2614,7 @@ static void __init
26162614
lpuart32_console_get_options(struct lpuart_port *sport, int *baud,
26172615
int *parity, int *bits)
26182616
{
2619-
unsigned long cr, bd;
2617+
u32 cr, bd;
26202618
unsigned int sbr, uartclk, baud_raw;
26212619

26222620
cr = lpuart32_read(&sport->port, UARTCTRL);
@@ -2822,7 +2820,7 @@ static int lpuart_global_reset(struct lpuart_port *sport)
28222820
{
28232821
struct uart_port *port = &sport->port;
28242822
void __iomem *global_addr;
2825-
unsigned long ctrl, bd;
2823+
u32 ctrl, bd;
28262824
unsigned int val = 0;
28272825
int ret;
28282826

@@ -3028,7 +3026,7 @@ static int lpuart_runtime_resume(struct device *dev)
30283026

30293027
static void serial_lpuart_enable_wakeup(struct lpuart_port *sport, bool on)
30303028
{
3031-
unsigned int val, baud;
3029+
u32 val, baud;
30323030

30333031
if (lpuart_is_32(sport)) {
30343032
val = lpuart32_read(&sport->port, UARTCTRL);
@@ -3093,7 +3091,7 @@ static int lpuart_suspend_noirq(struct device *dev)
30933091
static int lpuart_resume_noirq(struct device *dev)
30943092
{
30953093
struct lpuart_port *sport = dev_get_drvdata(dev);
3096-
unsigned int val;
3094+
u32 val;
30973095

30983096
pinctrl_pm_select_default_state(dev);
30993097

@@ -3113,7 +3111,8 @@ static int lpuart_resume_noirq(struct device *dev)
31133111
static int lpuart_suspend(struct device *dev)
31143112
{
31153113
struct lpuart_port *sport = dev_get_drvdata(dev);
3116-
unsigned long temp, flags;
3114+
u32 temp;
3115+
unsigned long flags;
31173116

31183117
uart_suspend_port(&lpuart_reg, &sport->port);
31193118

0 commit comments

Comments
 (0)