提交 b1261c86 编写于 作者: A Andy Shevchenko 提交者: Greg Kroah-Hartman

serial: 8250: introduce up_to_u8250p() helper

It helps to cast struct uart_port to struct uart_8250_port at runtime.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 380c966c
...@@ -439,8 +439,7 @@ static int exar_handle_irq(struct uart_port *port); ...@@ -439,8 +439,7 @@ static int exar_handle_irq(struct uart_port *port);
static void set_io_from_upio(struct uart_port *p) static void set_io_from_upio(struct uart_port *p)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(p);
container_of(p, struct uart_8250_port, port);
up->dl_read = default_serial_dl_read; up->dl_read = default_serial_dl_read;
up->dl_write = default_serial_dl_write; up->dl_write = default_serial_dl_write;
...@@ -1277,8 +1276,7 @@ static inline void __stop_tx(struct uart_8250_port *p) ...@@ -1277,8 +1276,7 @@ static inline void __stop_tx(struct uart_8250_port *p)
static void serial8250_stop_tx(struct uart_port *port) static void serial8250_stop_tx(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
__stop_tx(up); __stop_tx(up);
...@@ -1293,8 +1291,7 @@ static void serial8250_stop_tx(struct uart_port *port) ...@@ -1293,8 +1291,7 @@ static void serial8250_stop_tx(struct uart_port *port)
static void serial8250_start_tx(struct uart_port *port) static void serial8250_start_tx(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
if (up->dma && !serial8250_tx_dma(up)) { if (up->dma && !serial8250_tx_dma(up)) {
return; return;
...@@ -1322,8 +1319,7 @@ static void serial8250_start_tx(struct uart_port *port) ...@@ -1322,8 +1319,7 @@ static void serial8250_start_tx(struct uart_port *port)
static void serial8250_stop_rx(struct uart_port *port) static void serial8250_stop_rx(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
up->ier &= ~UART_IER_RLSI; up->ier &= ~UART_IER_RLSI;
up->port.read_status_mask &= ~UART_LSR_DR; up->port.read_status_mask &= ~UART_LSR_DR;
...@@ -1332,8 +1328,7 @@ static void serial8250_stop_rx(struct uart_port *port) ...@@ -1332,8 +1328,7 @@ static void serial8250_stop_rx(struct uart_port *port)
static void serial8250_enable_ms(struct uart_port *port) static void serial8250_enable_ms(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
/* no MSR capabilities */ /* no MSR capabilities */
if (up->bugs & UART_BUG_NOMSR) if (up->bugs & UART_BUG_NOMSR)
...@@ -1499,8 +1494,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) ...@@ -1499,8 +1494,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
{ {
unsigned char status; unsigned char status;
unsigned long flags; unsigned long flags;
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
int dma_err = 0; int dma_err = 0;
if (iir & UART_IIR_NO_INT) if (iir & UART_IIR_NO_INT)
...@@ -1785,8 +1779,7 @@ static void serial8250_backup_timeout(unsigned long data) ...@@ -1785,8 +1779,7 @@ static void serial8250_backup_timeout(unsigned long data)
static unsigned int serial8250_tx_empty(struct uart_port *port) static unsigned int serial8250_tx_empty(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned long flags; unsigned long flags;
unsigned int lsr; unsigned int lsr;
...@@ -1800,8 +1793,7 @@ static unsigned int serial8250_tx_empty(struct uart_port *port) ...@@ -1800,8 +1793,7 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
static unsigned int serial8250_get_mctrl(struct uart_port *port) static unsigned int serial8250_get_mctrl(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned int status; unsigned int status;
unsigned int ret; unsigned int ret;
...@@ -1821,8 +1813,7 @@ static unsigned int serial8250_get_mctrl(struct uart_port *port) ...@@ -1821,8 +1813,7 @@ static unsigned int serial8250_get_mctrl(struct uart_port *port)
static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl) static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned char mcr = 0; unsigned char mcr = 0;
if (mctrl & TIOCM_RTS) if (mctrl & TIOCM_RTS)
...@@ -1843,8 +1834,7 @@ static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl) ...@@ -1843,8 +1834,7 @@ static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
static void serial8250_break_ctl(struct uart_port *port, int break_state) static void serial8250_break_ctl(struct uart_port *port, int break_state)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
...@@ -1911,8 +1901,7 @@ static void serial8250_put_poll_char(struct uart_port *port, ...@@ -1911,8 +1901,7 @@ static void serial8250_put_poll_char(struct uart_port *port,
unsigned char c) unsigned char c)
{ {
unsigned int ier; unsigned int ier;
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
/* /*
* First save the IER then disable the interrupts * First save the IER then disable the interrupts
...@@ -1941,8 +1930,7 @@ static void serial8250_put_poll_char(struct uart_port *port, ...@@ -1941,8 +1930,7 @@ static void serial8250_put_poll_char(struct uart_port *port,
static int serial8250_startup(struct uart_port *port) static int serial8250_startup(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned long flags; unsigned long flags;
unsigned char lsr, iir; unsigned char lsr, iir;
int retval; int retval;
...@@ -2194,8 +2182,7 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2194,8 +2182,7 @@ static int serial8250_startup(struct uart_port *port)
static void serial8250_shutdown(struct uart_port *port) static void serial8250_shutdown(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned long flags; unsigned long flags;
/* /*
...@@ -2268,8 +2255,7 @@ void ...@@ -2268,8 +2255,7 @@ void
serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old) struct ktermios *old)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
unsigned char cval, fcr = 0; unsigned char cval, fcr = 0;
unsigned long flags; unsigned long flags;
unsigned int baud, quot; unsigned int baud, quot;
...@@ -2498,8 +2484,7 @@ serial8250_set_ldisc(struct uart_port *port, int new) ...@@ -2498,8 +2484,7 @@ serial8250_set_ldisc(struct uart_port *port, int new)
void serial8250_do_pm(struct uart_port *port, unsigned int state, void serial8250_do_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate) unsigned int oldstate)
{ {
struct uart_8250_port *p = struct uart_8250_port *p = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
serial8250_set_sleep(p, state != 0); serial8250_set_sleep(p, state != 0);
} }
...@@ -2630,8 +2615,7 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up) ...@@ -2630,8 +2615,7 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up)
static void serial8250_release_port(struct uart_port *port) static void serial8250_release_port(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
serial8250_release_std_resource(up); serial8250_release_std_resource(up);
if (port->type == PORT_RSA) if (port->type == PORT_RSA)
...@@ -2640,8 +2624,7 @@ static void serial8250_release_port(struct uart_port *port) ...@@ -2640,8 +2624,7 @@ static void serial8250_release_port(struct uart_port *port)
static int serial8250_request_port(struct uart_port *port) static int serial8250_request_port(struct uart_port *port)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
int ret; int ret;
if (port->type == PORT_8250_CIR) if (port->type == PORT_8250_CIR)
...@@ -2659,8 +2642,7 @@ static int serial8250_request_port(struct uart_port *port) ...@@ -2659,8 +2642,7 @@ static int serial8250_request_port(struct uart_port *port)
static void serial8250_config_port(struct uart_port *port, int flags) static void serial8250_config_port(struct uart_port *port, int flags)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
int probeflags = PROBE_ANY; int probeflags = PROBE_ANY;
int ret; int ret;
...@@ -2859,8 +2841,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) ...@@ -2859,8 +2841,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
static void serial8250_console_putchar(struct uart_port *port, int ch) static void serial8250_console_putchar(struct uart_port *port, int ch)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
wait_for_xmitr(up, UART_LSR_THRE); wait_for_xmitr(up, UART_LSR_THRE);
serial_port_out(port, UART_TX, ch); serial_port_out(port, UART_TX, ch);
......
...@@ -84,8 +84,9 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value) ...@@ -84,8 +84,9 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
static void dw8250_force_idle(struct uart_port *p) static void dw8250_force_idle(struct uart_port *p)
{ {
serial8250_clear_and_reinit_fifos(container_of struct uart_8250_port *up = up_to_u8250p(p);
(p, struct uart_8250_port, port));
serial8250_clear_and_reinit_fifos(up);
(void)p->serial_in(p, UART_RX); (void)p->serial_in(p, UART_RX);
} }
...@@ -255,6 +256,7 @@ static int dw8250_probe_of(struct uart_port *p, ...@@ -255,6 +256,7 @@ static int dw8250_probe_of(struct uart_port *p,
struct dw8250_data *data) struct dw8250_data *data)
{ {
struct device_node *np = p->dev->of_node; struct device_node *np = p->dev->of_node;
struct uart_8250_port *up = up_to_u8250p(p);
u32 val; u32 val;
bool has_ucv = true; bool has_ucv = true;
...@@ -287,7 +289,7 @@ static int dw8250_probe_of(struct uart_port *p, ...@@ -287,7 +289,7 @@ static int dw8250_probe_of(struct uart_port *p,
} }
} }
if (has_ucv) if (has_ucv)
dw8250_setup_port(container_of(p, struct uart_8250_port, port)); dw8250_setup_port(up);
if (!of_property_read_u32(np, "reg-shift", &val)) if (!of_property_read_u32(np, "reg-shift", &val))
p->regshift = val; p->regshift = val;
......
...@@ -28,8 +28,7 @@ int fsl8250_handle_irq(struct uart_port *port) ...@@ -28,8 +28,7 @@ int fsl8250_handle_irq(struct uart_port *port)
unsigned char lsr, orig_lsr; unsigned char lsr, orig_lsr;
unsigned long flags; unsigned long flags;
unsigned int iir; unsigned int iir;
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(port);
container_of(port, struct uart_8250_port, port);
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&up->port.lock, flags);
......
...@@ -1581,8 +1581,7 @@ static int skip_tx_en_setup(struct serial_private *priv, ...@@ -1581,8 +1581,7 @@ static int skip_tx_en_setup(struct serial_private *priv,
static void kt_handle_break(struct uart_port *p) static void kt_handle_break(struct uart_port *p)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(p);
container_of(p, struct uart_8250_port, port);
/* /*
* On receipt of a BI, serial device in Intel ME (Intel * On receipt of a BI, serial device in Intel ME (Intel
* management engine) needs to have its fifos cleared for sane * management engine) needs to have its fifos cleared for sane
...@@ -1593,8 +1592,7 @@ static void kt_handle_break(struct uart_port *p) ...@@ -1593,8 +1592,7 @@ static void kt_handle_break(struct uart_port *p)
static unsigned int kt_serial_in(struct uart_port *p, int offset) static unsigned int kt_serial_in(struct uart_port *p, int offset)
{ {
struct uart_8250_port *up = struct uart_8250_port *up = up_to_u8250p(p);
container_of(p, struct uart_8250_port, port);
unsigned int val; unsigned int val;
/* /*
......
...@@ -100,6 +100,11 @@ struct uart_8250_port { ...@@ -100,6 +100,11 @@ struct uart_8250_port {
void (*dl_write)(struct uart_8250_port *, int); void (*dl_write)(struct uart_8250_port *, int);
}; };
static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
{
return container_of(up, struct uart_8250_port, port);
}
int serial8250_register_8250_port(struct uart_8250_port *); int serial8250_register_8250_port(struct uart_8250_port *);
void serial8250_unregister_port(int line); void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line); void serial8250_suspend_port(int line);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册