2014-10-05 17:01:32

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 00/13 linux-next] drivers/tty: use container_of where possible

Small patchset using container_of instead of casting on first structure member address.
All patches (cross)compiled but untested.


Fabian Frederick (13):
serial: use container_of to resolve uart_sio_port from uart_port
serial: sa1100: use container_of to resolve sa1100_port from uart_port
serial: use container_of to resolve uart_ip22zilog_port from uart_port
serial: mpsc: use container_of to resolve mpsc_port_info from
uart_port
serial: cpm_uart: use container_of to resolve uart_cpm_port from
uart_port
TTY: jsm: use container_of to resolve jsm_channel from uart_port
tty: use container_of to resolve uart_pmac_port from uart_port
serial: sunsu: use container_of to resolve uart_sunsu_port from
uart_port
serial: sunsab: use container_of to resolve uart_sunsu_port from
uart_port
serial: amba-pl010: use container_of to resolve uart_amba_port from
uart_port
serial: pnx8xxx: use container_of to resolve pnx8xxx_port from
uart_port
serial: use container_of to resolve uart_sunzilog_port from uart_port
tty: ar933x_uart: use container_of to resolve ar933x_uart_port from
uart_port

drivers/tty/serial/amba-pl010.c | 36 ++++++++++++++--------
drivers/tty/serial/ar933x_uart.c | 30 ++++++++++++------
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 48 +++++++++++++++++++----------
drivers/tty/serial/ip22zilog.c | 18 +++++++----
drivers/tty/serial/jsm/jsm_tty.c | 30 ++++++++++++------
drivers/tty/serial/m32r_sio.c | 42 ++++++++++++++++---------
drivers/tty/serial/mpsc.c | 39 +++++++++++++++--------
drivers/tty/serial/pmac_zilog.c | 9 ++++--
drivers/tty/serial/pnx8xxx_uart.c | 48 +++++++++++++++++++----------
drivers/tty/serial/sa1100.c | 45 ++++++++++++++++++---------
drivers/tty/serial/sunsab.c | 36 ++++++++++++++--------
drivers/tty/serial/sunsu.c | 39 +++++++++++++++--------
drivers/tty/serial/sunzilog.c | 24 ++++++++++-----
13 files changed, 296 insertions(+), 148 deletions(-)

--
1.9.1


2014-10-05 17:03:23

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 01/13 linux-next] serial: use container_of to resolve uart_sio_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/m32r_sio.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index 5702828..8f7f83a 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -249,7 +249,8 @@ static void serial_out(struct uart_sio_port *up, int offset, int value)

static void m32r_sio_stop_tx(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

if (up->ier & UART_IER_THRI) {
up->ier &= ~UART_IER_THRI;
@@ -260,7 +261,8 @@ static void m32r_sio_stop_tx(struct uart_port *port)
static void m32r_sio_start_tx(struct uart_port *port)
{
#ifdef CONFIG_SERIAL_M32R_PLDSIO
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
struct circ_buf *xmit = &up->port.state->xmit;

if (!(up->ier & UART_IER_THRI)) {
@@ -274,7 +276,8 @@ static void m32r_sio_start_tx(struct uart_port *port)
}
while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY);
#else
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

if (!(up->ier & UART_IER_THRI)) {
up->ier |= UART_IER_THRI;
@@ -285,7 +288,8 @@ static void m32r_sio_start_tx(struct uart_port *port)

static void m32r_sio_stop_rx(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

up->ier &= ~UART_IER_RLSI;
up->port.read_status_mask &= ~UART_LSR_DR;
@@ -294,7 +298,8 @@ static void m32r_sio_stop_rx(struct uart_port *port)

static void m32r_sio_enable_ms(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

up->ier |= UART_IER_MSI;
serial_out(up, UART_IER, up->ier);
@@ -581,7 +586,8 @@ static void m32r_sio_timeout(unsigned long data)

static unsigned int m32r_sio_tx_empty(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
unsigned long flags;
unsigned int ret;

@@ -609,7 +615,8 @@ static void m32r_sio_break_ctl(struct uart_port *port, int break_state)

static int m32r_sio_startup(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
int retval;

sio_init();
@@ -652,7 +659,8 @@ static int m32r_sio_startup(struct uart_port *port)

static void m32r_sio_shutdown(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

/*
* Disable interrupts from this port
@@ -681,7 +689,8 @@ static unsigned int m32r_sio_get_divisor(struct uart_port *port,
static void m32r_sio_set_termios(struct uart_port *port,
struct ktermios *termios, struct ktermios *old)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
unsigned char cval = 0;
unsigned long flags;
unsigned int baud, quot;
@@ -780,7 +789,8 @@ static void m32r_sio_set_termios(struct uart_port *port,
static void m32r_sio_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

if (up->pm)
up->pm(port, state, oldstate);
@@ -825,7 +835,8 @@ m32r_sio_request_std_resource(struct uart_sio_port *up, struct resource **res)

static void m32r_sio_release_port(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
unsigned long start, offset = 0, size = 0;

size <<= up->port.regshift;
@@ -862,7 +873,8 @@ static void m32r_sio_release_port(struct uart_port *port)

static int m32r_sio_request_port(struct uart_port *port)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
struct resource *res = NULL;
int ret = 0;

@@ -889,7 +901,8 @@ static int m32r_sio_request_port(struct uart_port *port)

static void m32r_sio_config_port(struct uart_port *port, int unused)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);
unsigned long flags;

spin_lock_irqsave(&up->port.lock, flags);
@@ -1000,7 +1013,8 @@ static inline void wait_for_xmitr(struct uart_sio_port *up)

static void m32r_sio_console_putchar(struct uart_port *port, int ch)
{
- struct uart_sio_port *up = (struct uart_sio_port *)port;
+ struct uart_sio_port *up =
+ container_of(port, struct uart_sio_port, port);

wait_for_xmitr(up);
sio_out(up, SIOTXB, ch);
--
1.9.1

2014-10-05 17:05:13

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 02/13 linux-next] serial: sa1100: use container_of to resolve sa1100_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/sa1100.c | 45 ++++++++++++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index 753d452..4eb24fe 100644
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -142,7 +142,8 @@ static void sa1100_timeout(unsigned long data)
*/
static void sa1100_stop_tx(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
u32 utcr3;

utcr3 = UART_GET_UTCR3(sport);
@@ -155,7 +156,8 @@ static void sa1100_stop_tx(struct uart_port *port)
*/
static void sa1100_start_tx(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
u32 utcr3;

utcr3 = UART_GET_UTCR3(sport);
@@ -168,7 +170,8 @@ static void sa1100_start_tx(struct uart_port *port)
*/
static void sa1100_stop_rx(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
u32 utcr3;

utcr3 = UART_GET_UTCR3(sport);
@@ -180,7 +183,8 @@ static void sa1100_stop_rx(struct uart_port *port)
*/
static void sa1100_enable_ms(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

mod_timer(&sport->timer, jiffies);
}
@@ -323,7 +327,8 @@ static irqreturn_t sa1100_int(int irq, void *dev_id)
*/
static unsigned int sa1100_tx_empty(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

return UART_GET_UTSR1(sport) & UTSR1_TBY ? 0 : TIOCSER_TEMT;
}
@@ -342,7 +347,8 @@ static void sa1100_set_mctrl(struct uart_port *port, unsigned int mctrl)
*/
static void sa1100_break_ctl(struct uart_port *port, int break_state)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
unsigned long flags;
unsigned int utcr3;

@@ -358,7 +364,8 @@ static void sa1100_break_ctl(struct uart_port *port, int break_state)

static int sa1100_startup(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
int retval;

/*
@@ -387,7 +394,8 @@ static int sa1100_startup(struct uart_port *port)

static void sa1100_shutdown(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

/*
* Stop our timer.
@@ -409,7 +417,8 @@ static void
sa1100_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
unsigned long flags;
unsigned int utcr0, old_utcr3, baud, quot;
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
@@ -512,7 +521,8 @@ sa1100_set_termios(struct uart_port *port, struct ktermios *termios,

static const char *sa1100_type(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

return sport->port.type == PORT_SA1100 ? "SA1100" : NULL;
}
@@ -522,7 +532,8 @@ static const char *sa1100_type(struct uart_port *port)
*/
static void sa1100_release_port(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

release_mem_region(sport->port.mapbase, UART_PORT_SIZE);
}
@@ -532,7 +543,8 @@ static void sa1100_release_port(struct uart_port *port)
*/
static int sa1100_request_port(struct uart_port *port)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

return request_mem_region(sport->port.mapbase, UART_PORT_SIZE,
"sa11x0-uart") != NULL ? 0 : -EBUSY;
@@ -543,7 +555,8 @@ static int sa1100_request_port(struct uart_port *port)
*/
static void sa1100_config_port(struct uart_port *port, int flags)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

if (flags & UART_CONFIG_TYPE &&
sa1100_request_port(&sport->port) == 0)
@@ -558,7 +571,8 @@ static void sa1100_config_port(struct uart_port *port, int flags)
static int
sa1100_verify_port(struct uart_port *port, struct serial_struct *ser)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);
int ret = 0;

if (ser->type != PORT_UNKNOWN && ser->type != PORT_SA1100)
@@ -691,7 +705,8 @@ void __init sa1100_register_uart(int idx, int port)
#ifdef CONFIG_SERIAL_SA1100_CONSOLE
static void sa1100_console_putchar(struct uart_port *port, int ch)
{
- struct sa1100_port *sport = (struct sa1100_port *)port;
+ struct sa1100_port *sport =
+ container_of(port, struct sa1100_port, port);

while (!(UART_GET_UTSR1(sport) & UTSR1_TNF))
barrier();
--
1.9.1

2014-10-05 17:05:40

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 03/13 linux-next] serial: use container_of to resolve uart_ip22zilog_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/ip22zilog.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 99b7b86..991e6dc 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -544,7 +544,8 @@ static unsigned int ip22zilog_get_mctrl(struct uart_port *port)
/* The port lock is held and interrupts are disabled. */
static void ip22zilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
+ struct uart_ip22zilog_port *up =
+ container_of(port, struct uart_ip22zilog_port, port);
struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char set_bits, clear_bits;

@@ -568,7 +569,8 @@ static void ip22zilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
/* The port lock is held and interrupts are disabled. */
static void ip22zilog_stop_tx(struct uart_port *port)
{
- struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
+ struct uart_ip22zilog_port *up =
+ container_of(port, struct uart_ip22zilog_port, port);

up->flags |= IP22ZILOG_FLAG_TX_STOPPED;
}
@@ -576,7 +578,8 @@ static void ip22zilog_stop_tx(struct uart_port *port)
/* The port lock is held and interrupts are disabled. */
static void ip22zilog_start_tx(struct uart_port *port)
{
- struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
+ struct uart_ip22zilog_port *up =
+ container_of(port, struct uart_ip22zilog_port, port);
struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char status;

@@ -636,7 +639,8 @@ static void ip22zilog_stop_rx(struct uart_port *port)
/* The port lock is held. */
static void ip22zilog_enable_ms(struct uart_port *port)
{
- struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
+ struct uart_ip22zilog_port *up =
+ container_of(port, struct uart_ip22zilog_port, port);
struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char new_reg;

@@ -652,7 +656,8 @@ static void ip22zilog_enable_ms(struct uart_port *port)
/* The port lock is not held. */
static void ip22zilog_break_ctl(struct uart_port *port, int break_state)
{
- struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
+ struct uart_ip22zilog_port *up =
+ container_of(port, struct uart_ip22zilog_port, port);
struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char set_bits, clear_bits, new_reg;
unsigned long flags;
@@ -873,7 +878,8 @@ static void
ip22zilog_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct uart_ip22zilog_port *up = (struct uart_ip22zilog_port *) port;
+ struct uart_ip22zilog_port *up =
+ container_of(port, struct uart_ip22zilog_port, port);
unsigned long flags;
int baud, brg;

--
1.9.1

2014-10-05 17:06:40

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 04/13 linux-next] serial: mpsc: use container_of to resolve mpsc_port_info from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/mpsc.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index ae49856..5d5499b 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -1246,7 +1246,8 @@ static irqreturn_t mpsc_sdma_intr(int irq, void *dev_id)
*/
static uint mpsc_tx_empty(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
ulong iflags;
uint rc;

@@ -1264,7 +1265,8 @@ static void mpsc_set_mctrl(struct uart_port *port, uint mctrl)

static uint mpsc_get_mctrl(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
u32 mflags, status;

status = (pi->mirror_regs) ? pi->MPSC_CHR_10_m
@@ -1281,7 +1283,8 @@ static uint mpsc_get_mctrl(struct uart_port *port)

static void mpsc_stop_tx(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);

pr_debug("mpsc_stop_tx[%d]\n", port->line);

@@ -1290,7 +1293,8 @@ static void mpsc_stop_tx(struct uart_port *port)

static void mpsc_start_tx(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
unsigned long iflags;

spin_lock_irqsave(&pi->tx_lock, iflags);
@@ -1316,7 +1320,8 @@ static void mpsc_start_rx(struct mpsc_port_info *pi)

static void mpsc_stop_rx(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);

pr_debug("mpsc_stop_rx[%d]: Stopping...\n", port->line);

@@ -1338,7 +1343,8 @@ static void mpsc_stop_rx(struct uart_port *port)

static void mpsc_break_ctl(struct uart_port *port, int ctl)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
ulong flags;
u32 v;

@@ -1353,7 +1359,8 @@ static void mpsc_break_ctl(struct uart_port *port, int ctl)

static int mpsc_startup(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
u32 flag = 0;
int rc;

@@ -1383,7 +1390,8 @@ static int mpsc_startup(struct uart_port *port)

static void mpsc_shutdown(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);

pr_debug("mpsc_shutdown[%d]: Shutting down MPSC\n", port->line);

@@ -1394,7 +1402,8 @@ static void mpsc_shutdown(struct uart_port *port)
static void mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
u32 baud;
ulong flags;
u32 chr_bits, stop_bits, par;
@@ -1498,7 +1507,8 @@ static int mpsc_request_port(struct uart_port *port)

static void mpsc_release_port(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);

if (pi->ready) {
mpsc_uninit_rings(pi);
@@ -1513,7 +1523,8 @@ static void mpsc_config_port(struct uart_port *port, int flags)

static int mpsc_verify_port(struct uart_port *port, struct serial_struct *ser)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
int rc = 0;

pr_debug("mpsc_verify_port[%d]: Verifying port data\n", pi->port.line);
@@ -1548,7 +1559,8 @@ static void mpsc_put_poll_char(struct uart_port *port,

static int mpsc_get_poll_char(struct uart_port *port)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
struct mpsc_rx_desc *rxre;
u32 cmdstat, bytes_in, i;
u8 *bp;
@@ -1648,7 +1660,8 @@ static int mpsc_get_poll_char(struct uart_port *port)
static void mpsc_put_poll_char(struct uart_port *port,
unsigned char c)
{
- struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
+ struct mpsc_port_info *pi =
+ container_of(port, struct mpsc_port_info, port);
u32 data;

data = readl(pi->mpsc_base + MPSC_MPCR);
--
1.9.1

2014-10-05 17:07:54

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 05/13 linux-next] serial: cpm_uart: use container_of to resolve uart_cpm_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 48 +++++++++++++++++++----------
1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 533852e..638afd3 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -80,7 +80,8 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
*/
static unsigned int cpm_uart_tx_empty(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
cbd_t __iomem *bdp = pinfo->tx_bd_base;
int ret = 0;

@@ -102,7 +103,8 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)

static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);

if (pinfo->gpios[GPIO_RTS] >= 0)
gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS));
@@ -113,7 +115,8 @@ static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)

static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;

if (pinfo->gpios[GPIO_CTS] >= 0) {
@@ -144,7 +147,8 @@ static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
*/
static void cpm_uart_stop_tx(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
smc_t __iomem *smcp = pinfo->smcp;
scc_t __iomem *sccp = pinfo->sccp;

@@ -161,7 +165,8 @@ static void cpm_uart_stop_tx(struct uart_port *port)
*/
static void cpm_uart_start_tx(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
smc_t __iomem *smcp = pinfo->smcp;
scc_t __iomem *sccp = pinfo->sccp;

@@ -189,7 +194,8 @@ static void cpm_uart_start_tx(struct uart_port *port)
*/
static void cpm_uart_stop_rx(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
smc_t __iomem *smcp = pinfo->smcp;
scc_t __iomem *sccp = pinfo->sccp;

@@ -206,7 +212,8 @@ static void cpm_uart_stop_rx(struct uart_port *port)
*/
static void cpm_uart_break_ctl(struct uart_port *port, int break_state)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);

pr_debug("CPM uart[%d]:break ctrl, break_state: %d\n", port->line,
break_state);
@@ -240,7 +247,8 @@ static void cpm_uart_int_rx(struct uart_port *port)
unsigned char ch;
u8 *cp;
struct tty_port *tport = &port->state->port;
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
cbd_t __iomem *bdp;
u16 status;
unsigned int flg;
@@ -397,7 +405,8 @@ static irqreturn_t cpm_uart_int(int irq, void *data)
static int cpm_uart_startup(struct uart_port *port)
{
int retval;
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);

pr_debug("CPM uart[%d]:startup\n", port->line);

@@ -442,7 +451,8 @@ inline void cpm_uart_wait_until_send(struct uart_cpm_port *pinfo)
*/
static void cpm_uart_shutdown(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);

pr_debug("CPM uart[%d]:shutdown\n", port->line);

@@ -492,7 +502,8 @@ static void cpm_uart_set_termios(struct uart_port *port,
unsigned long flags;
u16 cval, scval, prev_mode;
int bits, sbits;
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
smc_t __iomem *smcp = pinfo->smcp;
scc_t __iomem *sccp = pinfo->sccp;
int maxidl;
@@ -675,7 +686,8 @@ static int cpm_uart_tx_pump(struct uart_port *port)
cbd_t __iomem *bdp;
u8 *p;
int count;
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
struct circ_buf *xmit = &port->state->xmit;

/* Handle xon/xoff */
@@ -906,7 +918,8 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
*/
static int cpm_uart_request_port(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
int ret;

pr_debug("CPM uart[%d]:request port\n", port->line);
@@ -938,7 +951,8 @@ static int cpm_uart_request_port(struct uart_port *port)

static void cpm_uart_release_port(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);

if (!(pinfo->flags & FLAG_CONSOLE))
cpm_uart_freebuf(pinfo);
@@ -1082,7 +1096,8 @@ static int poll_wait_key(char *obuf, struct uart_cpm_port *pinfo)

static int cpm_get_poll_char(struct uart_port *port)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);

if (!serial_polled) {
serial_polled = 1;
@@ -1099,7 +1114,8 @@ static int cpm_get_poll_char(struct uart_port *port)
static void cpm_put_poll_char(struct uart_port *port,
unsigned char c)
{
- struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+ struct uart_cpm_port *pinfo =
+ container_of(port, struct uart_cpm_port, port);
static char ch[2];

ch[0] = (char)c;
--
1.9.1

2014-10-05 17:10:34

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 06/13 linux-next] TTY: jsm: use container_of to resolve jsm_channel from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/jsm/jsm_tty.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 3e5c156..8814680 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -77,7 +77,8 @@ static unsigned int jsm_tty_tx_empty(struct uart_port *port)
static unsigned int jsm_tty_get_mctrl(struct uart_port *port)
{
int result;
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");

@@ -98,7 +99,8 @@ static unsigned int jsm_tty_get_mctrl(struct uart_port *port)
*/
static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");

@@ -133,7 +135,8 @@ static void jsm_tty_write(struct uart_port *port)

static void jsm_tty_start_tx(struct uart_port *port)
{
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");

@@ -145,7 +148,8 @@ static void jsm_tty_start_tx(struct uart_port *port)

static void jsm_tty_stop_tx(struct uart_port *port)
{
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");

@@ -157,7 +161,8 @@ static void jsm_tty_stop_tx(struct uart_port *port)
static void jsm_tty_send_xchar(struct uart_port *port, char ch)
{
unsigned long lock_flags;
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);
struct ktermios *termios;

spin_lock_irqsave(&port->lock, lock_flags);
@@ -172,7 +177,8 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)

static void jsm_tty_stop_rx(struct uart_port *port)
{
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

channel->ch_bd->bd_ops->disable_receiver(channel);
}
@@ -180,7 +186,8 @@ static void jsm_tty_stop_rx(struct uart_port *port)
static void jsm_tty_break(struct uart_port *port, int break_state)
{
unsigned long lock_flags;
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

spin_lock_irqsave(&port->lock, lock_flags);
if (break_state == -1)
@@ -194,7 +201,8 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
static int jsm_tty_open(struct uart_port *port)
{
struct jsm_board *brd;
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);
struct ktermios *termios;

/* Get board pointer from our array of majors we have allocated */
@@ -273,7 +281,8 @@ static void jsm_tty_close(struct uart_port *port)
{
struct jsm_board *bd;
struct ktermios *ts;
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "start\n");

@@ -307,7 +316,8 @@ static void jsm_tty_set_termios(struct uart_port *port,
struct ktermios *old_termios)
{
unsigned long lock_flags;
- struct jsm_channel *channel = (struct jsm_channel *)port;
+ struct jsm_channel *channel =
+ container_of(port, struct jsm_channel, uart_port);

spin_lock_irqsave(&port->lock, lock_flags);
channel->ch_c_cflag = termios->c_cflag;
--
1.9.1

2014-10-05 17:11:16

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 07/13 linux-next] tty: use container_of to resolve uart_pmac_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/pmac_zilog.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index abbfedb..4aca322 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1352,7 +1352,8 @@ static int pmz_verify_port(struct uart_port *port, struct serial_struct *ser)

static int pmz_poll_get_char(struct uart_port *port)
{
- struct uart_pmac_port *uap = (struct uart_pmac_port *)port;
+ struct uart_pmac_port *uap =
+ container_of(port, struct uart_pmac_port, port);
int tries = 2;

while (tries) {
@@ -1367,7 +1368,8 @@ static int pmz_poll_get_char(struct uart_port *port)

static void pmz_poll_put_char(struct uart_port *port, unsigned char c)
{
- struct uart_pmac_port *uap = (struct uart_pmac_port *)port;
+ struct uart_pmac_port *uap =
+ container_of(port, struct uart_pmac_port, port);

/* Wait for the transmit buffer to empty. */
while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
@@ -1954,7 +1956,8 @@ static void __exit exit_pmz(void)

static void pmz_console_putchar(struct uart_port *port, int ch)
{
- struct uart_pmac_port *uap = (struct uart_pmac_port *)port;
+ struct uart_pmac_port *uap =
+ container_of(port, struct uart_pmac_port, port);

/* Wait for the transmit buffer to empty. */
while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
--
1.9.1

2014-10-05 17:13:12

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 08/13 linux-next] serial: sunsu: 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 <[email protected]>
---
drivers/tty/serial/sunsu.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 5326ae1..be010f8 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -264,7 +264,8 @@ static inline void __stop_tx(struct uart_sunsu_port *p)

static void sunsu_stop_tx(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);

__stop_tx(up);

@@ -279,7 +280,8 @@ static void sunsu_stop_tx(struct uart_port *port)

static void sunsu_start_tx(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);

if (!(up->ier & UART_IER_THRI)) {
up->ier |= UART_IER_THRI;
@@ -297,7 +299,8 @@ static void sunsu_start_tx(struct uart_port *port)

static void sunsu_stop_rx(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);

up->ier &= ~UART_IER_RLSI;
up->port.read_status_mask &= ~UART_LSR_DR;
@@ -306,7 +309,8 @@ static void sunsu_stop_rx(struct uart_port *port)

static void sunsu_enable_ms(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned long flags;

spin_lock_irqsave(&up->port.lock, flags);
@@ -543,7 +547,8 @@ static irqreturn_t sunsu_kbd_ms_interrupt(int irq, void *dev_id)

static unsigned int sunsu_tx_empty(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned long flags;
unsigned int ret;

@@ -556,7 +561,8 @@ static unsigned int sunsu_tx_empty(struct uart_port *port)

static unsigned int sunsu_get_mctrl(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned char status;
unsigned int ret;

@@ -576,7 +582,8 @@ static unsigned int sunsu_get_mctrl(struct uart_port *port)

static void sunsu_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned char mcr = 0;

if (mctrl & TIOCM_RTS)
@@ -595,7 +602,8 @@ static void sunsu_set_mctrl(struct uart_port *port, unsigned int mctrl)

static void sunsu_break_ctl(struct uart_port *port, int break_state)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned long flags;

spin_lock_irqsave(&up->port.lock, flags);
@@ -609,7 +617,8 @@ static void sunsu_break_ctl(struct uart_port *port, int break_state)

static int sunsu_startup(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned long flags;
int retval;

@@ -719,7 +728,8 @@ static int sunsu_startup(struct uart_port *port)

static void sunsu_shutdown(struct uart_port *port)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned long flags;

/*
@@ -767,7 +777,8 @@ static void
sunsu_change_speed(struct uart_port *port, unsigned int cflag,
unsigned int iflag, unsigned int quot)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);
unsigned char cval, fcr = 0;
unsigned long flags;

@@ -918,7 +929,8 @@ static int sunsu_request_port(struct uart_port *port)

static void sunsu_config_port(struct uart_port *port, int flags)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);

if (flags & UART_CONFIG_TYPE) {
/*
@@ -1277,7 +1289,8 @@ static __inline__ void wait_for_xmitr(struct uart_sunsu_port *up)

static void sunsu_console_putchar(struct uart_port *port, int ch)
{
- struct uart_sunsu_port *up = (struct uart_sunsu_port *)port;
+ struct uart_sunsu_port *up =
+ container_of(port, struct uart_sunsu_port, port);

wait_for_xmitr(up);
serial_out(up, UART_TX, ch);
--
1.9.1

2014-10-05 17:14:07

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 09/13 linux-next] 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 <[email protected]>
---
drivers/tty/serial/sunsab.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index b339fe4..e3b43a4 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -345,7 +345,8 @@ static irqreturn_t sunsab_interrupt(int irq, void *dev_id)
/* port->lock is not held. */
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;

/* 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. */
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) {
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. */
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 int result;

@@ -404,7 +407,8 @@ static unsigned int sunsab_get_mctrl(struct uart_port *port)
/* port->lock held by caller. */
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;
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. */
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;
int i;

@@ -465,7 +470,8 @@ static void sunsab_start_tx(struct uart_port *port)
/* port->lock is not held. */
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;

if (ch == __DISABLED_CHAR)
@@ -482,7 +488,8 @@ static void sunsab_send_xchar(struct uart_port *port, char ch)
/* port->lock held by caller. */
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;
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. */
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 char val;

@@ -514,7 +522,8 @@ static void sunsab_break_ctl(struct uart_port *port, int break_state)
/* port->lock is not held. */
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 char tmp;
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. */
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;

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,
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 int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
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)
{
- 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);
writeb(c, &up->regs->w.tic);
--
1.9.1

2014-10-05 17:20:17

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 10/13 linux-next] serial: amba-pl010: use container_of to resolve uart_amba_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/amba-pl010.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 2064d31..00ae8dc 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -75,7 +75,8 @@ struct uart_amba_port {

static void pl010_stop_tx(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int cr;

cr = readb(uap->port.membase + UART010_CR);
@@ -85,7 +86,8 @@ static void pl010_stop_tx(struct uart_port *port)

static void pl010_start_tx(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int cr;

cr = readb(uap->port.membase + UART010_CR);
@@ -95,7 +97,8 @@ static void pl010_start_tx(struct uart_port *port)

static void pl010_stop_rx(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int cr;

cr = readb(uap->port.membase + UART010_CR);
@@ -105,7 +108,8 @@ static void pl010_stop_rx(struct uart_port *port)

static void pl010_enable_ms(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int cr;

cr = readb(uap->port.membase + UART010_CR);
@@ -259,14 +263,16 @@ static irqreturn_t pl010_int(int irq, void *dev_id)

static unsigned int pl010_tx_empty(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int status = readb(uap->port.membase + UART01x_FR);
return status & UART01x_FR_BUSY ? 0 : TIOCSER_TEMT;
}

static unsigned int pl010_get_mctrl(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int result = 0;
unsigned int status;

@@ -283,7 +289,8 @@ static unsigned int pl010_get_mctrl(struct uart_port *port)

static void pl010_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);

if (uap->data)
uap->data->set_mctrl(uap->dev, uap->port.membase, mctrl);
@@ -291,7 +298,8 @@ static void pl010_set_mctrl(struct uart_port *port, unsigned int mctrl)

static void pl010_break_ctl(struct uart_port *port, int break_state)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned long flags;
unsigned int lcr_h;

@@ -307,7 +315,8 @@ static void pl010_break_ctl(struct uart_port *port, int break_state)

static int pl010_startup(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
int retval;

/*
@@ -347,7 +356,8 @@ static int pl010_startup(struct uart_port *port)

static void pl010_shutdown(struct uart_port *port)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);

/*
* Free the interrupt
@@ -374,7 +384,8 @@ static void
pl010_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int lcr_h, old_cr;
unsigned long flags;
unsigned int baud, quot;
@@ -551,7 +562,8 @@ static struct uart_amba_port *amba_ports[UART_NR];

static void pl010_console_putchar(struct uart_port *port, int ch)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ struct uart_amba_port *uap =
+ container_of(port, struct uart_amba_port, port);
unsigned int status;

do {
--
1.9.1

2014-10-05 17:20:38

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 11/13 linux-next] serial: pnx8xxx: use container_of to resolve pnx8xxx_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/pnx8xxx_uart.c | 48 ++++++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c
index 2ba24a4..9fd9414 100644
--- a/drivers/tty/serial/pnx8xxx_uart.c
+++ b/drivers/tty/serial/pnx8xxx_uart.c
@@ -126,7 +126,8 @@ static void pnx8xxx_timeout(unsigned long data)
*/
static void pnx8xxx_stop_tx(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
u32 ien;

/* Disable TX intr */
@@ -142,7 +143,8 @@ static void pnx8xxx_stop_tx(struct uart_port *port)
*/
static void pnx8xxx_start_tx(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
u32 ien;

/* Clear all pending TX intr */
@@ -158,7 +160,8 @@ static void pnx8xxx_start_tx(struct uart_port *port)
*/
static void pnx8xxx_stop_rx(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
u32 ien;

/* Disable RX intr */
@@ -174,7 +177,8 @@ static void pnx8xxx_stop_rx(struct uart_port *port)
*/
static void pnx8xxx_enable_ms(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);

mod_timer(&sport->timer, jiffies);
}
@@ -313,14 +317,16 @@ static irqreturn_t pnx8xxx_int(int irq, void *dev_id)
*/
static unsigned int pnx8xxx_tx_empty(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);

return serial_in(sport, PNX8XXX_FIFO) & PNX8XXX_UART_FIFO_TXFIFO_STA ? 0 : TIOCSER_TEMT;
}

static unsigned int pnx8xxx_get_mctrl(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
unsigned int mctrl = TIOCM_DSR;
unsigned int msr;

@@ -347,7 +353,8 @@ static void pnx8xxx_set_mctrl(struct uart_port *port, unsigned int mctrl)
*/
static void pnx8xxx_break_ctl(struct uart_port *port, int break_state)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
unsigned long flags;
unsigned int lcr;

@@ -363,7 +370,8 @@ static void pnx8xxx_break_ctl(struct uart_port *port, int break_state)

static int pnx8xxx_startup(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
int retval;

/*
@@ -397,7 +405,8 @@ static int pnx8xxx_startup(struct uart_port *port)

static void pnx8xxx_shutdown(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
int lcr;

/*
@@ -434,7 +443,8 @@ static void
pnx8xxx_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
unsigned long flags;
unsigned int lcr_fcr, old_ien, baud, quot;
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
@@ -551,7 +561,8 @@ pnx8xxx_set_termios(struct uart_port *port, struct ktermios *termios,

static const char *pnx8xxx_type(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);

return sport->port.type == PORT_PNX8XXX ? "PNX8XXX" : NULL;
}
@@ -561,7 +572,8 @@ static const char *pnx8xxx_type(struct uart_port *port)
*/
static void pnx8xxx_release_port(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);

release_mem_region(sport->port.mapbase, UART_PORT_SIZE);
}
@@ -571,7 +583,8 @@ static void pnx8xxx_release_port(struct uart_port *port)
*/
static int pnx8xxx_request_port(struct uart_port *port)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
return request_mem_region(sport->port.mapbase, UART_PORT_SIZE,
"pnx8xxx-uart") != NULL ? 0 : -EBUSY;
}
@@ -581,7 +594,8 @@ static int pnx8xxx_request_port(struct uart_port *port)
*/
static void pnx8xxx_config_port(struct uart_port *port, int flags)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);

if (flags & UART_CONFIG_TYPE &&
pnx8xxx_request_port(&sport->port) == 0)
@@ -596,7 +610,8 @@ static void pnx8xxx_config_port(struct uart_port *port, int flags)
static int
pnx8xxx_verify_port(struct uart_port *port, struct serial_struct *ser)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
int ret = 0;

if (ser->type != PORT_UNKNOWN && ser->type != PORT_PNX8XXX)
@@ -662,7 +677,8 @@ static void __init pnx8xxx_init_ports(void)

static void pnx8xxx_console_putchar(struct uart_port *port, int ch)
{
- struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port;
+ struct pnx8xxx_port *sport =
+ container_of(port, struct pnx8xxx_port, port);
int status;

do {
--
1.9.1

2014-10-05 17:21:10

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 12/13 linux-next] serial: use container_of to resolve uart_sunzilog_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/sunzilog.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index 02df394..844aae7 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -644,7 +644,8 @@ static unsigned int sunzilog_get_mctrl(struct uart_port *port)
/* The port lock is held and interrupts are disabled. */
static void sunzilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);
struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char set_bits, clear_bits;

@@ -668,7 +669,8 @@ static void sunzilog_set_mctrl(struct uart_port *port, unsigned int mctrl)
/* The port lock is held and interrupts are disabled. */
static void sunzilog_stop_tx(struct uart_port *port)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);

up->flags |= SUNZILOG_FLAG_TX_STOPPED;
}
@@ -676,7 +678,8 @@ static void sunzilog_stop_tx(struct uart_port *port)
/* The port lock is held and interrupts are disabled. */
static void sunzilog_start_tx(struct uart_port *port)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);
struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char status;

@@ -736,7 +739,8 @@ static void sunzilog_stop_rx(struct uart_port *port)
/* The port lock is held. */
static void sunzilog_enable_ms(struct uart_port *port)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);
struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char new_reg;

@@ -752,7 +756,8 @@ static void sunzilog_enable_ms(struct uart_port *port)
/* The port lock is not held. */
static void sunzilog_break_ctl(struct uart_port *port, int break_state)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);
struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port);
unsigned char set_bits, clear_bits, new_reg;
unsigned long flags;
@@ -938,7 +943,8 @@ static void
sunzilog_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);
unsigned long flags;
int baud, brg;

@@ -998,7 +1004,8 @@ static int sunzilog_verify_port(struct uart_port *port, struct serial_struct *se
static int sunzilog_get_poll_char(struct uart_port *port)
{
unsigned char ch, r1;
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *) port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);
struct zilog_channel __iomem *channel
= ZILOG_CHANNEL_FROM_PORT(&up->port);

@@ -1032,7 +1039,8 @@ static int sunzilog_get_poll_char(struct uart_port *port)
static void sunzilog_put_poll_char(struct uart_port *port,
unsigned char ch)
{
- struct uart_sunzilog_port *up = (struct uart_sunzilog_port *)port;
+ struct uart_sunzilog_port *up =
+ container_of(port, struct uart_sunzilog_port, port);

sunzilog_putchar(&up->port, ch);
}
--
1.9.1

2014-10-05 17:21:45

by Fabian Frédérick

[permalink] [raw]
Subject: [PATCH 13/13 linux-next] tty: ar933x_uart: use container_of to resolve ar933x_uart_port from uart_port

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <[email protected]>
---
drivers/tty/serial/ar933x_uart.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 0be1c45..2739361 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -119,7 +119,8 @@ static inline void ar933x_uart_putc(struct ar933x_uart_port *up, int ch)

static unsigned int ar933x_uart_tx_empty(struct uart_port *port)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);
unsigned long flags;
unsigned int rdata;

@@ -141,21 +142,24 @@ static void ar933x_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)

static void ar933x_uart_start_tx(struct uart_port *port)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);

ar933x_uart_start_tx_interrupt(up);
}

static void ar933x_uart_stop_tx(struct uart_port *port)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);

ar933x_uart_stop_tx_interrupt(up);
}

static void ar933x_uart_stop_rx(struct uart_port *port)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);

up->ier &= ~AR933X_UART_INT_RX_VALID;
ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
@@ -163,7 +167,8 @@ static void ar933x_uart_stop_rx(struct uart_port *port)

static void ar933x_uart_break_ctl(struct uart_port *port, int break_state)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);
unsigned long flags;

spin_lock_irqsave(&up->port.lock, flags);
@@ -231,7 +236,8 @@ static void ar933x_uart_set_termios(struct uart_port *port,
struct ktermios *new,
struct ktermios *old)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);
unsigned int cs;
unsigned long flags;
unsigned int baud, scale, step;
@@ -404,7 +410,8 @@ static irqreturn_t ar933x_uart_interrupt(int irq, void *dev_id)

static int ar933x_uart_startup(struct uart_port *port)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);
unsigned long flags;
int ret;

@@ -430,7 +437,8 @@ static int ar933x_uart_startup(struct uart_port *port)

static void ar933x_uart_shutdown(struct uart_port *port)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);

/* Disable all interrupts */
up->ier = 0;
@@ -468,7 +476,8 @@ static void ar933x_uart_config_port(struct uart_port *port, int flags)
static int ar933x_uart_verify_port(struct uart_port *port,
struct serial_struct *ser)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);

if (ser->type != PORT_UNKNOWN &&
ser->type != PORT_AR933X)
@@ -521,7 +530,8 @@ static void ar933x_uart_wait_xmitr(struct ar933x_uart_port *up)

static void ar933x_uart_console_putchar(struct uart_port *port, int ch)
{
- struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
+ struct ar933x_uart_port *up =
+ container_of(port, struct ar933x_uart_port, port);

ar933x_uart_wait_xmitr(up);
ar933x_uart_putc(up, ch);
--
1.9.1

2014-10-05 20:57:55

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 08/13 linux-next] serial: sunsu: use container_of to resolve uart_sunsu_port from uart_port

From: Fabian Frederick <[email protected]>
Date: Sun, 5 Oct 2014 19:01:09 +0200

> Use container_of instead of casting first structure member.
>
> Signed-off-by: Fabian Frederick <[email protected]>

Acked-by: David S. Miller <[email protected]>

2014-10-05 20:58:11

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 09/13 linux-next] serial: sunsab: use container_of to resolve uart_sunsu_port from uart_port

From: Fabian Frederick <[email protected]>
Date: Sun, 5 Oct 2014 19:01:10 +0200

> Use container_of instead of casting first structure member.
>
> Signed-off-by: Fabian Frederick <[email protected]>

Acked-by: David S. Miller <[email protected]>

2014-10-05 20:58:17

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 12/13 linux-next] serial: use container_of to resolve uart_sunzilog_port from uart_port

From: Fabian Frederick <[email protected]>
Date: Sun, 5 Oct 2014 19:19:48 +0200

> Use container_of instead of casting first structure member.
>
> Signed-off-by: Fabian Frederick <[email protected]>

Acked-by: David S. Miller <[email protected]>