aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/cpm_uart
diff options
context:
space:
mode:
authorFabian Frederick <fabf@skynet.be>2014-10-05 13:01:06 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-05 22:20:52 -0500
commite789d2688720dba26079aac3e008eb6e78937753 (patch)
tree3ea629ebf317d6256e92a34954d4f2aff9c06d47 /drivers/tty/serial/cpm_uart
parent22d4d44c4ce3a860377aaaeeb4a7b8b907ab66bc (diff)
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 <fabf@skynet.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/cpm_uart')
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c48
1 files 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 533852eb8778..638afd35c547 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);
80*/ 80*/
81static unsigned int cpm_uart_tx_empty(struct uart_port *port) 81static unsigned int cpm_uart_tx_empty(struct uart_port *port)
82{ 82{
83 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 83 struct uart_cpm_port *pinfo =
84 container_of(port, struct uart_cpm_port, port);
84 cbd_t __iomem *bdp = pinfo->tx_bd_base; 85 cbd_t __iomem *bdp = pinfo->tx_bd_base;
85 int ret = 0; 86 int ret = 0;
86 87
@@ -102,7 +103,8 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)
102 103
103static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 104static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
104{ 105{
105 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 106 struct uart_cpm_port *pinfo =
107 container_of(port, struct uart_cpm_port, port);
106 108
107 if (pinfo->gpios[GPIO_RTS] >= 0) 109 if (pinfo->gpios[GPIO_RTS] >= 0)
108 gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS)); 110 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)
113 115
114static unsigned int cpm_uart_get_mctrl(struct uart_port *port) 116static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
115{ 117{
116 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 118 struct uart_cpm_port *pinfo =
119 container_of(port, struct uart_cpm_port, port);
117 unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 120 unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
118 121
119 if (pinfo->gpios[GPIO_CTS] >= 0) { 122 if (pinfo->gpios[GPIO_CTS] >= 0) {
@@ -144,7 +147,8 @@ static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
144 */ 147 */
145static void cpm_uart_stop_tx(struct uart_port *port) 148static void cpm_uart_stop_tx(struct uart_port *port)
146{ 149{
147 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 150 struct uart_cpm_port *pinfo =
151 container_of(port, struct uart_cpm_port, port);
148 smc_t __iomem *smcp = pinfo->smcp; 152 smc_t __iomem *smcp = pinfo->smcp;
149 scc_t __iomem *sccp = pinfo->sccp; 153 scc_t __iomem *sccp = pinfo->sccp;
150 154
@@ -161,7 +165,8 @@ static void cpm_uart_stop_tx(struct uart_port *port)
161 */ 165 */
162static void cpm_uart_start_tx(struct uart_port *port) 166static void cpm_uart_start_tx(struct uart_port *port)
163{ 167{
164 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 168 struct uart_cpm_port *pinfo =
169 container_of(port, struct uart_cpm_port, port);
165 smc_t __iomem *smcp = pinfo->smcp; 170 smc_t __iomem *smcp = pinfo->smcp;
166 scc_t __iomem *sccp = pinfo->sccp; 171 scc_t __iomem *sccp = pinfo->sccp;
167 172
@@ -189,7 +194,8 @@ static void cpm_uart_start_tx(struct uart_port *port)
189 */ 194 */
190static void cpm_uart_stop_rx(struct uart_port *port) 195static void cpm_uart_stop_rx(struct uart_port *port)
191{ 196{
192 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 197 struct uart_cpm_port *pinfo =
198 container_of(port, struct uart_cpm_port, port);
193 smc_t __iomem *smcp = pinfo->smcp; 199 smc_t __iomem *smcp = pinfo->smcp;
194 scc_t __iomem *sccp = pinfo->sccp; 200 scc_t __iomem *sccp = pinfo->sccp;
195 201
@@ -206,7 +212,8 @@ static void cpm_uart_stop_rx(struct uart_port *port)
206 */ 212 */
207static void cpm_uart_break_ctl(struct uart_port *port, int break_state) 213static void cpm_uart_break_ctl(struct uart_port *port, int break_state)
208{ 214{
209 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 215 struct uart_cpm_port *pinfo =
216 container_of(port, struct uart_cpm_port, port);
210 217
211 pr_debug("CPM uart[%d]:break ctrl, break_state: %d\n", port->line, 218 pr_debug("CPM uart[%d]:break ctrl, break_state: %d\n", port->line,
212 break_state); 219 break_state);
@@ -240,7 +247,8 @@ static void cpm_uart_int_rx(struct uart_port *port)
240 unsigned char ch; 247 unsigned char ch;
241 u8 *cp; 248 u8 *cp;
242 struct tty_port *tport = &port->state->port; 249 struct tty_port *tport = &port->state->port;
243 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 250 struct uart_cpm_port *pinfo =
251 container_of(port, struct uart_cpm_port, port);
244 cbd_t __iomem *bdp; 252 cbd_t __iomem *bdp;
245 u16 status; 253 u16 status;
246 unsigned int flg; 254 unsigned int flg;
@@ -397,7 +405,8 @@ static irqreturn_t cpm_uart_int(int irq, void *data)
397static int cpm_uart_startup(struct uart_port *port) 405static int cpm_uart_startup(struct uart_port *port)
398{ 406{
399 int retval; 407 int retval;
400 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 408 struct uart_cpm_port *pinfo =
409 container_of(port, struct uart_cpm_port, port);
401 410
402 pr_debug("CPM uart[%d]:startup\n", port->line); 411 pr_debug("CPM uart[%d]:startup\n", port->line);
403 412
@@ -442,7 +451,8 @@ inline void cpm_uart_wait_until_send(struct uart_cpm_port *pinfo)
442 */ 451 */
443static void cpm_uart_shutdown(struct uart_port *port) 452static void cpm_uart_shutdown(struct uart_port *port)
444{ 453{
445 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 454 struct uart_cpm_port *pinfo =
455 container_of(port, struct uart_cpm_port, port);
446 456
447 pr_debug("CPM uart[%d]:shutdown\n", port->line); 457 pr_debug("CPM uart[%d]:shutdown\n", port->line);
448 458
@@ -492,7 +502,8 @@ static void cpm_uart_set_termios(struct uart_port *port,
492 unsigned long flags; 502 unsigned long flags;
493 u16 cval, scval, prev_mode; 503 u16 cval, scval, prev_mode;
494 int bits, sbits; 504 int bits, sbits;
495 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 505 struct uart_cpm_port *pinfo =
506 container_of(port, struct uart_cpm_port, port);
496 smc_t __iomem *smcp = pinfo->smcp; 507 smc_t __iomem *smcp = pinfo->smcp;
497 scc_t __iomem *sccp = pinfo->sccp; 508 scc_t __iomem *sccp = pinfo->sccp;
498 int maxidl; 509 int maxidl;
@@ -675,7 +686,8 @@ static int cpm_uart_tx_pump(struct uart_port *port)
675 cbd_t __iomem *bdp; 686 cbd_t __iomem *bdp;
676 u8 *p; 687 u8 *p;
677 int count; 688 int count;
678 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 689 struct uart_cpm_port *pinfo =
690 container_of(port, struct uart_cpm_port, port);
679 struct circ_buf *xmit = &port->state->xmit; 691 struct circ_buf *xmit = &port->state->xmit;
680 692
681 /* Handle xon/xoff */ 693 /* Handle xon/xoff */
@@ -906,7 +918,8 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
906 */ 918 */
907static int cpm_uart_request_port(struct uart_port *port) 919static int cpm_uart_request_port(struct uart_port *port)
908{ 920{
909 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 921 struct uart_cpm_port *pinfo =
922 container_of(port, struct uart_cpm_port, port);
910 int ret; 923 int ret;
911 924
912 pr_debug("CPM uart[%d]:request port\n", port->line); 925 pr_debug("CPM uart[%d]:request port\n", port->line);
@@ -938,7 +951,8 @@ static int cpm_uart_request_port(struct uart_port *port)
938 951
939static void cpm_uart_release_port(struct uart_port *port) 952static void cpm_uart_release_port(struct uart_port *port)
940{ 953{
941 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 954 struct uart_cpm_port *pinfo =
955 container_of(port, struct uart_cpm_port, port);
942 956
943 if (!(pinfo->flags & FLAG_CONSOLE)) 957 if (!(pinfo->flags & FLAG_CONSOLE))
944 cpm_uart_freebuf(pinfo); 958 cpm_uart_freebuf(pinfo);
@@ -1082,7 +1096,8 @@ static int poll_wait_key(char *obuf, struct uart_cpm_port *pinfo)
1082 1096
1083static int cpm_get_poll_char(struct uart_port *port) 1097static int cpm_get_poll_char(struct uart_port *port)
1084{ 1098{
1085 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 1099 struct uart_cpm_port *pinfo =
1100 container_of(port, struct uart_cpm_port, port);
1086 1101
1087 if (!serial_polled) { 1102 if (!serial_polled) {
1088 serial_polled = 1; 1103 serial_polled = 1;
@@ -1099,7 +1114,8 @@ static int cpm_get_poll_char(struct uart_port *port)
1099static void cpm_put_poll_char(struct uart_port *port, 1114static void cpm_put_poll_char(struct uart_port *port,
1100 unsigned char c) 1115 unsigned char c)
1101{ 1116{
1102 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 1117 struct uart_cpm_port *pinfo =
1118 container_of(port, struct uart_cpm_port, port);
1103 static char ch[2]; 1119 static char ch[2];
1104 1120
1105 ch[0] = (char)c; 1121 ch[0] = (char)c;