@@ -264,6 +264,11 @@ static const struct of_device_id imx_uart_dt_ids[] = {
264
264
};
265
265
MODULE_DEVICE_TABLE (of , imx_uart_dt_ids );
266
266
267
+ static inline struct imx_port * to_imx_port (struct uart_port * port )
268
+ {
269
+ return container_of (port , struct imx_port , port );
270
+ }
271
+
267
272
static inline void imx_uart_writel (struct imx_port * sport , u32 val , u32 offset )
268
273
{
269
274
writel (val , sport -> port .membase + offset );
@@ -377,7 +382,7 @@ static void imx_uart_disable_loopback_rs485(struct imx_port *sport)
377
382
/* called with port.lock taken and irqs off */
378
383
static void imx_uart_start_rx (struct uart_port * port )
379
384
{
380
- struct imx_port * sport = ( struct imx_port * ) port ;
385
+ struct imx_port * sport = to_imx_port ( port ) ;
381
386
unsigned int ucr1 , ucr2 ;
382
387
383
388
ucr1 = imx_uart_readl (sport , UCR1 );
@@ -401,7 +406,7 @@ static void imx_uart_start_rx(struct uart_port *port)
401
406
/* called with port.lock taken and irqs off */
402
407
static void imx_uart_stop_tx (struct uart_port * port )
403
408
{
404
- struct imx_port * sport = ( struct imx_port * ) port ;
409
+ struct imx_port * sport = to_imx_port ( port ) ;
405
410
u32 ucr1 , ucr4 , usr2 ;
406
411
407
412
if (sport -> tx_state == OFF )
@@ -466,7 +471,7 @@ static void imx_uart_stop_tx(struct uart_port *port)
466
471
467
472
static void imx_uart_stop_rx_with_loopback_ctrl (struct uart_port * port , bool loopback )
468
473
{
469
- struct imx_port * sport = ( struct imx_port * ) port ;
474
+ struct imx_port * sport = to_imx_port ( port ) ;
470
475
u32 ucr1 , ucr2 , ucr4 , uts ;
471
476
472
477
ucr1 = imx_uart_readl (sport , UCR1 );
@@ -511,7 +516,7 @@ static void imx_uart_stop_rx(struct uart_port *port)
511
516
/* called with port.lock taken and irqs off */
512
517
static void imx_uart_enable_ms (struct uart_port * port )
513
518
{
514
- struct imx_port * sport = ( struct imx_port * ) port ;
519
+ struct imx_port * sport = to_imx_port ( port ) ;
515
520
516
521
mod_timer (& sport -> timer , jiffies );
517
522
@@ -662,7 +667,7 @@ static void imx_uart_dma_tx(struct imx_port *sport)
662
667
/* called with port.lock taken and irqs off */
663
668
static void imx_uart_start_tx (struct uart_port * port )
664
669
{
665
- struct imx_port * sport = ( struct imx_port * ) port ;
670
+ struct imx_port * sport = to_imx_port ( port ) ;
666
671
struct tty_port * tport = & sport -> port .state -> port ;
667
672
u32 ucr1 ;
668
673
@@ -1043,7 +1048,7 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id)
1043
1048
*/
1044
1049
static unsigned int imx_uart_tx_empty (struct uart_port * port )
1045
1050
{
1046
- struct imx_port * sport = ( struct imx_port * ) port ;
1051
+ struct imx_port * sport = to_imx_port ( port ) ;
1047
1052
unsigned int ret ;
1048
1053
1049
1054
ret = (imx_uart_readl (sport , USR2 ) & USR2_TXDC ) ? TIOCSER_TEMT : 0 ;
@@ -1058,7 +1063,7 @@ static unsigned int imx_uart_tx_empty(struct uart_port *port)
1058
1063
/* called with port.lock taken and irqs off */
1059
1064
static unsigned int imx_uart_get_mctrl (struct uart_port * port )
1060
1065
{
1061
- struct imx_port * sport = ( struct imx_port * ) port ;
1066
+ struct imx_port * sport = to_imx_port ( port ) ;
1062
1067
unsigned int ret = imx_uart_get_hwmctrl (sport );
1063
1068
1064
1069
mctrl_gpio_get (sport -> gpios , & ret );
@@ -1069,7 +1074,7 @@ static unsigned int imx_uart_get_mctrl(struct uart_port *port)
1069
1074
/* called with port.lock taken and irqs off */
1070
1075
static void imx_uart_set_mctrl (struct uart_port * port , unsigned int mctrl )
1071
1076
{
1072
- struct imx_port * sport = ( struct imx_port * ) port ;
1077
+ struct imx_port * sport = to_imx_port ( port ) ;
1073
1078
u32 ucr3 , uts ;
1074
1079
1075
1080
if (!(port -> rs485 .flags & SER_RS485_ENABLED )) {
@@ -1112,7 +1117,7 @@ static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
1112
1117
*/
1113
1118
static void imx_uart_break_ctl (struct uart_port * port , int break_state )
1114
1119
{
1115
- struct imx_port * sport = ( struct imx_port * ) port ;
1120
+ struct imx_port * sport = to_imx_port ( port ) ;
1116
1121
unsigned long flags ;
1117
1122
u32 ucr1 ;
1118
1123
@@ -1434,7 +1439,7 @@ static void imx_uart_disable_dma(struct imx_port *sport)
1434
1439
1435
1440
static int imx_uart_startup (struct uart_port * port )
1436
1441
{
1437
- struct imx_port * sport = ( struct imx_port * ) port ;
1442
+ struct imx_port * sport = to_imx_port ( port ) ;
1438
1443
int retval ;
1439
1444
unsigned long flags ;
1440
1445
int dma_is_inited = 0 ;
@@ -1548,7 +1553,7 @@ static int imx_uart_startup(struct uart_port *port)
1548
1553
1549
1554
static void imx_uart_shutdown (struct uart_port * port )
1550
1555
{
1551
- struct imx_port * sport = ( struct imx_port * ) port ;
1556
+ struct imx_port * sport = to_imx_port ( port ) ;
1552
1557
unsigned long flags ;
1553
1558
u32 ucr1 , ucr2 , ucr4 , uts ;
1554
1559
@@ -1622,7 +1627,7 @@ static void imx_uart_shutdown(struct uart_port *port)
1622
1627
/* called with port.lock taken and irqs off */
1623
1628
static void imx_uart_flush_buffer (struct uart_port * port )
1624
1629
{
1625
- struct imx_port * sport = ( struct imx_port * ) port ;
1630
+ struct imx_port * sport = to_imx_port ( port ) ;
1626
1631
struct scatterlist * sgl = & sport -> tx_sgl [0 ];
1627
1632
1628
1633
if (!sport -> dma_chan_tx )
@@ -1649,7 +1654,7 @@ static void
1649
1654
imx_uart_set_termios (struct uart_port * port , struct ktermios * termios ,
1650
1655
const struct ktermios * old )
1651
1656
{
1652
- struct imx_port * sport = ( struct imx_port * ) port ;
1657
+ struct imx_port * sport = to_imx_port ( port ) ;
1653
1658
unsigned long flags ;
1654
1659
u32 ucr2 , old_ucr2 , ufcr ;
1655
1660
unsigned int baud , quot ;
@@ -1852,7 +1857,7 @@ imx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
1852
1857
1853
1858
static int imx_uart_poll_init (struct uart_port * port )
1854
1859
{
1855
- struct imx_port * sport = ( struct imx_port * ) port ;
1860
+ struct imx_port * sport = to_imx_port ( port ) ;
1856
1861
unsigned long flags ;
1857
1862
u32 ucr1 , ucr2 ;
1858
1863
int retval ;
@@ -1901,7 +1906,7 @@ static int imx_uart_poll_init(struct uart_port *port)
1901
1906
1902
1907
static int imx_uart_poll_get_char (struct uart_port * port )
1903
1908
{
1904
- struct imx_port * sport = ( struct imx_port * ) port ;
1909
+ struct imx_port * sport = to_imx_port ( port ) ;
1905
1910
if (!(imx_uart_readl (sport , USR2 ) & USR2_RDR ))
1906
1911
return NO_POLL_CHAR ;
1907
1912
@@ -1910,7 +1915,7 @@ static int imx_uart_poll_get_char(struct uart_port *port)
1910
1915
1911
1916
static void imx_uart_poll_put_char (struct uart_port * port , unsigned char c )
1912
1917
{
1913
- struct imx_port * sport = ( struct imx_port * ) port ;
1918
+ struct imx_port * sport = to_imx_port ( port ) ;
1914
1919
unsigned int status ;
1915
1920
1916
1921
/* drain */
@@ -1932,7 +1937,7 @@ static void imx_uart_poll_put_char(struct uart_port *port, unsigned char c)
1932
1937
static int imx_uart_rs485_config (struct uart_port * port , struct ktermios * termios ,
1933
1938
struct serial_rs485 * rs485conf )
1934
1939
{
1935
- struct imx_port * sport = ( struct imx_port * ) port ;
1940
+ struct imx_port * sport = to_imx_port ( port ) ;
1936
1941
u32 ucr2 ;
1937
1942
1938
1943
if (rs485conf -> flags & SER_RS485_ENABLED ) {
@@ -1986,7 +1991,7 @@ static struct imx_port *imx_uart_ports[UART_NR];
1986
1991
#if IS_ENABLED (CONFIG_SERIAL_IMX_CONSOLE )
1987
1992
static void imx_uart_console_putchar (struct uart_port * port , unsigned char ch )
1988
1993
{
1989
- struct imx_port * sport = ( struct imx_port * ) port ;
1994
+ struct imx_port * sport = to_imx_port ( port ) ;
1990
1995
1991
1996
while (imx_uart_readl (sport , imx_uart_uts_reg (sport )) & UTS_TXFULL )
1992
1997
barrier ();
0 commit comments