serial: sunsab: use container_of to resolve uart_sunsu_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Fabian Frederick 2014-10-05 19:01:10 +02:00 committed by Greg Kroah-Hartman
parent 9a6962c531
commit 726657653f

View File

@ -345,7 +345,8 @@ static irqreturn_t sunsab_interrupt(int irq, void *dev_id)
/* port->lock is not held. */ /* port->lock is not held. */
static unsigned int sunsab_tx_empty(struct uart_port *port) static unsigned int sunsab_tx_empty(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
int ret; int ret;
/* Do not need a lock for a state test like this. */ /* Do not need a lock for a state test like this. */
@ -360,7 +361,8 @@ static unsigned int sunsab_tx_empty(struct uart_port *port)
/* port->lock held by caller. */ /* port->lock held by caller. */
static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl) static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
if (mctrl & TIOCM_RTS) { if (mctrl & TIOCM_RTS) {
up->cached_mode &= ~SAB82532_MODE_FRTS; up->cached_mode &= ~SAB82532_MODE_FRTS;
@ -383,7 +385,8 @@ static void sunsab_set_mctrl(struct uart_port *port, unsigned int mctrl)
/* port->lock is held by caller and interrupts are disabled. */ /* port->lock is held by caller and interrupts are disabled. */
static unsigned int sunsab_get_mctrl(struct uart_port *port) static unsigned int sunsab_get_mctrl(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
unsigned char val; unsigned char val;
unsigned int result; unsigned int result;
@ -404,7 +407,8 @@ static unsigned int sunsab_get_mctrl(struct uart_port *port)
/* port->lock held by caller. */ /* port->lock held by caller. */
static void sunsab_stop_tx(struct uart_port *port) static void sunsab_stop_tx(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
up->interrupt_mask1 |= SAB82532_IMR1_XPR; up->interrupt_mask1 |= SAB82532_IMR1_XPR;
writeb(up->interrupt_mask1, &up->regs->w.imr1); writeb(up->interrupt_mask1, &up->regs->w.imr1);
@ -432,7 +436,8 @@ static void sunsab_tx_idle(struct uart_sunsab_port *up)
/* port->lock held by caller. */ /* port->lock held by caller. */
static void sunsab_start_tx(struct uart_port *port) static void sunsab_start_tx(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
struct circ_buf *xmit = &up->port.state->xmit; struct circ_buf *xmit = &up->port.state->xmit;
int i; int i;
@ -465,7 +470,8 @@ static void sunsab_start_tx(struct uart_port *port)
/* port->lock is not held. */ /* port->lock is not held. */
static void sunsab_send_xchar(struct uart_port *port, char ch) static void sunsab_send_xchar(struct uart_port *port, char ch)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
unsigned long flags; unsigned long flags;
if (ch == __DISABLED_CHAR) if (ch == __DISABLED_CHAR)
@ -482,7 +488,8 @@ static void sunsab_send_xchar(struct uart_port *port, char ch)
/* port->lock held by caller. */ /* port->lock held by caller. */
static void sunsab_stop_rx(struct uart_port *port) static void sunsab_stop_rx(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
up->interrupt_mask0 |= SAB82532_IMR0_TCD; up->interrupt_mask0 |= SAB82532_IMR0_TCD;
writeb(up->interrupt_mask1, &up->regs->w.imr0); writeb(up->interrupt_mask1, &up->regs->w.imr0);
@ -491,7 +498,8 @@ static void sunsab_stop_rx(struct uart_port *port)
/* port->lock is not held. */ /* port->lock is not held. */
static void sunsab_break_ctl(struct uart_port *port, int break_state) static void sunsab_break_ctl(struct uart_port *port, int break_state)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
unsigned long flags; unsigned long flags;
unsigned char val; unsigned char val;
@ -514,7 +522,8 @@ static void sunsab_break_ctl(struct uart_port *port, int break_state)
/* port->lock is not held. */ /* port->lock is not held. */
static int sunsab_startup(struct uart_port *port) static int sunsab_startup(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
unsigned long flags; unsigned long flags;
unsigned char tmp; unsigned char tmp;
int err = request_irq(up->port.irq, sunsab_interrupt, int err = request_irq(up->port.irq, sunsab_interrupt,
@ -585,7 +594,8 @@ static int sunsab_startup(struct uart_port *port)
/* port->lock is not held. */ /* port->lock is not held. */
static void sunsab_shutdown(struct uart_port *port) static void sunsab_shutdown(struct uart_port *port)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&up->port.lock, flags);
@ -771,7 +781,8 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
static void sunsab_set_termios(struct uart_port *port, struct ktermios *termios, static void sunsab_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old) struct ktermios *old)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
unsigned long flags; unsigned long flags;
unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
unsigned int quot = uart_get_divisor(port, baud); unsigned int quot = uart_get_divisor(port, baud);
@ -840,7 +851,8 @@ static struct uart_sunsab_port *sunsab_ports;
static void sunsab_console_putchar(struct uart_port *port, int c) static void sunsab_console_putchar(struct uart_port *port, int c)
{ {
struct uart_sunsab_port *up = (struct uart_sunsab_port *)port; struct uart_sunsab_port *up =
container_of(port, struct uart_sunsab_port, port);
sunsab_tec_wait(up); sunsab_tec_wait(up);
writeb(c, &up->regs->w.tic); writeb(c, &up->regs->w.tic);