aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2014-07-14 07:26:14 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-17 21:16:23 -0400
commitb1261c86fe238cc0da3f5dc837a38a0c39f3e7c4 (patch)
tree4a62c30754e5aca7cf5c665efeabf545b69d52da /drivers/tty
parent380c966c093e7239e42a81f165b20b2bad2658bc (diff)
serial: 8250: introduce up_to_u8250p() helper
It helps to cast struct uart_port to struct uart_8250_port at runtime. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_core.c57
-rw-r--r--drivers/tty/serial/8250/8250_dw.c8
-rw-r--r--drivers/tty/serial/8250/8250_fsl.c3
-rw-r--r--drivers/tty/serial/8250/8250_pci.c6
4 files changed, 27 insertions, 47 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 7a91c6d1eb7d..0da01458816e 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -439,8 +439,7 @@ static int exar_handle_irq(struct uart_port *port);
439 439
440static void set_io_from_upio(struct uart_port *p) 440static void set_io_from_upio(struct uart_port *p)
441{ 441{
442 struct uart_8250_port *up = 442 struct uart_8250_port *up = up_to_u8250p(p);
443 container_of(p, struct uart_8250_port, port);
444 443
445 up->dl_read = default_serial_dl_read; 444 up->dl_read = default_serial_dl_read;
446 up->dl_write = default_serial_dl_write; 445 up->dl_write = default_serial_dl_write;
@@ -1277,8 +1276,7 @@ static inline void __stop_tx(struct uart_8250_port *p)
1277 1276
1278static void serial8250_stop_tx(struct uart_port *port) 1277static void serial8250_stop_tx(struct uart_port *port)
1279{ 1278{
1280 struct uart_8250_port *up = 1279 struct uart_8250_port *up = up_to_u8250p(port);
1281 container_of(port, struct uart_8250_port, port);
1282 1280
1283 __stop_tx(up); 1281 __stop_tx(up);
1284 1282
@@ -1293,8 +1291,7 @@ static void serial8250_stop_tx(struct uart_port *port)
1293 1291
1294static void serial8250_start_tx(struct uart_port *port) 1292static void serial8250_start_tx(struct uart_port *port)
1295{ 1293{
1296 struct uart_8250_port *up = 1294 struct uart_8250_port *up = up_to_u8250p(port);
1297 container_of(port, struct uart_8250_port, port);
1298 1295
1299 if (up->dma && !serial8250_tx_dma(up)) { 1296 if (up->dma && !serial8250_tx_dma(up)) {
1300 return; 1297 return;
@@ -1322,8 +1319,7 @@ static void serial8250_start_tx(struct uart_port *port)
1322 1319
1323static void serial8250_stop_rx(struct uart_port *port) 1320static void serial8250_stop_rx(struct uart_port *port)
1324{ 1321{
1325 struct uart_8250_port *up = 1322 struct uart_8250_port *up = up_to_u8250p(port);
1326 container_of(port, struct uart_8250_port, port);
1327 1323
1328 up->ier &= ~UART_IER_RLSI; 1324 up->ier &= ~UART_IER_RLSI;
1329 up->port.read_status_mask &= ~UART_LSR_DR; 1325 up->port.read_status_mask &= ~UART_LSR_DR;
@@ -1332,8 +1328,7 @@ static void serial8250_stop_rx(struct uart_port *port)
1332 1328
1333static void serial8250_enable_ms(struct uart_port *port) 1329static void serial8250_enable_ms(struct uart_port *port)
1334{ 1330{
1335 struct uart_8250_port *up = 1331 struct uart_8250_port *up = up_to_u8250p(port);
1336 container_of(port, struct uart_8250_port, port);
1337 1332
1338 /* no MSR capabilities */ 1333 /* no MSR capabilities */
1339 if (up->bugs & UART_BUG_NOMSR) 1334 if (up->bugs & UART_BUG_NOMSR)
@@ -1499,8 +1494,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1499{ 1494{
1500 unsigned char status; 1495 unsigned char status;
1501 unsigned long flags; 1496 unsigned long flags;
1502 struct uart_8250_port *up = 1497 struct uart_8250_port *up = up_to_u8250p(port);
1503 container_of(port, struct uart_8250_port, port);
1504 int dma_err = 0; 1498 int dma_err = 0;
1505 1499
1506 if (iir & UART_IIR_NO_INT) 1500 if (iir & UART_IIR_NO_INT)
@@ -1785,8 +1779,7 @@ static void serial8250_backup_timeout(unsigned long data)
1785 1779
1786static unsigned int serial8250_tx_empty(struct uart_port *port) 1780static unsigned int serial8250_tx_empty(struct uart_port *port)
1787{ 1781{
1788 struct uart_8250_port *up = 1782 struct uart_8250_port *up = up_to_u8250p(port);
1789 container_of(port, struct uart_8250_port, port);
1790 unsigned long flags; 1783 unsigned long flags;
1791 unsigned int lsr; 1784 unsigned int lsr;
1792 1785
@@ -1800,8 +1793,7 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
1800 1793
1801static unsigned int serial8250_get_mctrl(struct uart_port *port) 1794static unsigned int serial8250_get_mctrl(struct uart_port *port)
1802{ 1795{
1803 struct uart_8250_port *up = 1796 struct uart_8250_port *up = up_to_u8250p(port);
1804 container_of(port, struct uart_8250_port, port);
1805 unsigned int status; 1797 unsigned int status;
1806 unsigned int ret; 1798 unsigned int ret;
1807 1799
@@ -1821,8 +1813,7 @@ static unsigned int serial8250_get_mctrl(struct uart_port *port)
1821 1813
1822static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl) 1814static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
1823{ 1815{
1824 struct uart_8250_port *up = 1816 struct uart_8250_port *up = up_to_u8250p(port);
1825 container_of(port, struct uart_8250_port, port);
1826 unsigned char mcr = 0; 1817 unsigned char mcr = 0;
1827 1818
1828 if (mctrl & TIOCM_RTS) 1819 if (mctrl & TIOCM_RTS)
@@ -1843,8 +1834,7 @@ static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
1843 1834
1844static void serial8250_break_ctl(struct uart_port *port, int break_state) 1835static void serial8250_break_ctl(struct uart_port *port, int break_state)
1845{ 1836{
1846 struct uart_8250_port *up = 1837 struct uart_8250_port *up = up_to_u8250p(port);
1847 container_of(port, struct uart_8250_port, port);
1848 unsigned long flags; 1838 unsigned long flags;
1849 1839
1850 spin_lock_irqsave(&port->lock, flags); 1840 spin_lock_irqsave(&port->lock, flags);
@@ -1911,8 +1901,7 @@ static void serial8250_put_poll_char(struct uart_port *port,
1911 unsigned char c) 1901 unsigned char c)
1912{ 1902{
1913 unsigned int ier; 1903 unsigned int ier;
1914 struct uart_8250_port *up = 1904 struct uart_8250_port *up = up_to_u8250p(port);
1915 container_of(port, struct uart_8250_port, port);
1916 1905
1917 /* 1906 /*
1918 * First save the IER then disable the interrupts 1907 * First save the IER then disable the interrupts
@@ -1941,8 +1930,7 @@ static void serial8250_put_poll_char(struct uart_port *port,
1941 1930
1942static int serial8250_startup(struct uart_port *port) 1931static int serial8250_startup(struct uart_port *port)
1943{ 1932{
1944 struct uart_8250_port *up = 1933 struct uart_8250_port *up = up_to_u8250p(port);
1945 container_of(port, struct uart_8250_port, port);
1946 unsigned long flags; 1934 unsigned long flags;
1947 unsigned char lsr, iir; 1935 unsigned char lsr, iir;
1948 int retval; 1936 int retval;
@@ -2194,8 +2182,7 @@ dont_test_tx_en:
2194 2182
2195static void serial8250_shutdown(struct uart_port *port) 2183static void serial8250_shutdown(struct uart_port *port)
2196{ 2184{
2197 struct uart_8250_port *up = 2185 struct uart_8250_port *up = up_to_u8250p(port);
2198 container_of(port, struct uart_8250_port, port);
2199 unsigned long flags; 2186 unsigned long flags;
2200 2187
2201 /* 2188 /*
@@ -2268,8 +2255,7 @@ void
2268serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, 2255serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2269 struct ktermios *old) 2256 struct ktermios *old)
2270{ 2257{
2271 struct uart_8250_port *up = 2258 struct uart_8250_port *up = up_to_u8250p(port);
2272 container_of(port, struct uart_8250_port, port);
2273 unsigned char cval, fcr = 0; 2259 unsigned char cval, fcr = 0;
2274 unsigned long flags; 2260 unsigned long flags;
2275 unsigned int baud, quot; 2261 unsigned int baud, quot;
@@ -2498,8 +2484,7 @@ serial8250_set_ldisc(struct uart_port *port, int new)
2498void serial8250_do_pm(struct uart_port *port, unsigned int state, 2484void serial8250_do_pm(struct uart_port *port, unsigned int state,
2499 unsigned int oldstate) 2485 unsigned int oldstate)
2500{ 2486{
2501 struct uart_8250_port *p = 2487 struct uart_8250_port *p = up_to_u8250p(port);
2502 container_of(port, struct uart_8250_port, port);
2503 2488
2504 serial8250_set_sleep(p, state != 0); 2489 serial8250_set_sleep(p, state != 0);
2505} 2490}
@@ -2630,8 +2615,7 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up)
2630 2615
2631static void serial8250_release_port(struct uart_port *port) 2616static void serial8250_release_port(struct uart_port *port)
2632{ 2617{
2633 struct uart_8250_port *up = 2618 struct uart_8250_port *up = up_to_u8250p(port);
2634 container_of(port, struct uart_8250_port, port);
2635 2619
2636 serial8250_release_std_resource(up); 2620 serial8250_release_std_resource(up);
2637 if (port->type == PORT_RSA) 2621 if (port->type == PORT_RSA)
@@ -2640,8 +2624,7 @@ static void serial8250_release_port(struct uart_port *port)
2640 2624
2641static int serial8250_request_port(struct uart_port *port) 2625static int serial8250_request_port(struct uart_port *port)
2642{ 2626{
2643 struct uart_8250_port *up = 2627 struct uart_8250_port *up = up_to_u8250p(port);
2644 container_of(port, struct uart_8250_port, port);
2645 int ret; 2628 int ret;
2646 2629
2647 if (port->type == PORT_8250_CIR) 2630 if (port->type == PORT_8250_CIR)
@@ -2659,8 +2642,7 @@ static int serial8250_request_port(struct uart_port *port)
2659 2642
2660static void serial8250_config_port(struct uart_port *port, int flags) 2643static void serial8250_config_port(struct uart_port *port, int flags)
2661{ 2644{
2662 struct uart_8250_port *up = 2645 struct uart_8250_port *up = up_to_u8250p(port);
2663 container_of(port, struct uart_8250_port, port);
2664 int probeflags = PROBE_ANY; 2646 int probeflags = PROBE_ANY;
2665 int ret; 2647 int ret;
2666 2648
@@ -2859,8 +2841,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
2859 2841
2860static void serial8250_console_putchar(struct uart_port *port, int ch) 2842static void serial8250_console_putchar(struct uart_port *port, int ch)
2861{ 2843{
2862 struct uart_8250_port *up = 2844 struct uart_8250_port *up = up_to_u8250p(port);
2863 container_of(port, struct uart_8250_port, port);
2864 2845
2865 wait_for_xmitr(up, UART_LSR_THRE); 2846 wait_for_xmitr(up, UART_LSR_THRE);
2866 serial_port_out(port, UART_TX, ch); 2847 serial_port_out(port, UART_TX, ch);
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index c531fa42f838..affdcb192aed 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -84,8 +84,9 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
84 84
85static void dw8250_force_idle(struct uart_port *p) 85static void dw8250_force_idle(struct uart_port *p)
86{ 86{
87 serial8250_clear_and_reinit_fifos(container_of 87 struct uart_8250_port *up = up_to_u8250p(p);
88 (p, struct uart_8250_port, port)); 88
89 serial8250_clear_and_reinit_fifos(up);
89 (void)p->serial_in(p, UART_RX); 90 (void)p->serial_in(p, UART_RX);
90} 91}
91 92
@@ -255,6 +256,7 @@ static int dw8250_probe_of(struct uart_port *p,
255 struct dw8250_data *data) 256 struct dw8250_data *data)
256{ 257{
257 struct device_node *np = p->dev->of_node; 258 struct device_node *np = p->dev->of_node;
259 struct uart_8250_port *up = up_to_u8250p(p);
258 u32 val; 260 u32 val;
259 bool has_ucv = true; 261 bool has_ucv = true;
260 262
@@ -287,7 +289,7 @@ static int dw8250_probe_of(struct uart_port *p,
287 } 289 }
288 } 290 }
289 if (has_ucv) 291 if (has_ucv)
290 dw8250_setup_port(container_of(p, struct uart_8250_port, port)); 292 dw8250_setup_port(up);
291 293
292 if (!of_property_read_u32(np, "reg-shift", &val)) 294 if (!of_property_read_u32(np, "reg-shift", &val))
293 p->regshift = val; 295 p->regshift = val;
diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
index f4d3c47b88e8..c0533a57ec53 100644
--- a/drivers/tty/serial/8250/8250_fsl.c
+++ b/drivers/tty/serial/8250/8250_fsl.c
@@ -28,8 +28,7 @@ int fsl8250_handle_irq(struct uart_port *port)
28 unsigned char lsr, orig_lsr; 28 unsigned char lsr, orig_lsr;
29 unsigned long flags; 29 unsigned long flags;
30 unsigned int iir; 30 unsigned int iir;
31 struct uart_8250_port *up = 31 struct uart_8250_port *up = up_to_u8250p(port);
32 container_of(port, struct uart_8250_port, port);
33 32
34 spin_lock_irqsave(&up->port.lock, flags); 33 spin_lock_irqsave(&up->port.lock, flags);
35 34
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 33137b3ba94d..61830b1792eb 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -1581,8 +1581,7 @@ static int skip_tx_en_setup(struct serial_private *priv,
1581 1581
1582static void kt_handle_break(struct uart_port *p) 1582static void kt_handle_break(struct uart_port *p)
1583{ 1583{
1584 struct uart_8250_port *up = 1584 struct uart_8250_port *up = up_to_u8250p(p);
1585 container_of(p, struct uart_8250_port, port);
1586 /* 1585 /*
1587 * On receipt of a BI, serial device in Intel ME (Intel 1586 * On receipt of a BI, serial device in Intel ME (Intel
1588 * management engine) needs to have its fifos cleared for sane 1587 * management engine) needs to have its fifos cleared for sane
@@ -1593,8 +1592,7 @@ static void kt_handle_break(struct uart_port *p)
1593 1592
1594static unsigned int kt_serial_in(struct uart_port *p, int offset) 1593static unsigned int kt_serial_in(struct uart_port *p, int offset)
1595{ 1594{
1596 struct uart_8250_port *up = 1595 struct uart_8250_port *up = up_to_u8250p(p);
1597 container_of(p, struct uart_8250_port, port);
1598 unsigned int val; 1596 unsigned int val;
1599 1597
1600 /* 1598 /*