aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2012-08-23 06:32:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-05 16:26:10 -0400
commitc990f3510357586be63bbe9faf7972212a0dc78f (patch)
treef31e6ce4928c549a80637c968f1b3924de981339
parentbe282059acebcecd789fad1b3d17d826db3d5608 (diff)
serial: omap: define and use to_uart_omap_port()
current code only works because struct uart_port is the first member on the uart_omap_port structure. If, for whatever reason, someone puts another member as the first of the structure, that cast won't work anymore. In order to be safe, let's use a container_of() which, for now, gets optimized into a cast anyway. Tested-by: Shubhrajyoti D <shubhrajyoti@ti.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/arm/plat-omap/include/plat/omap-serial.h2
-rw-r--r--drivers/tty/serial/omap-serial.c36
2 files changed, 20 insertions, 18 deletions
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h b/arch/arm/plat-omap/include/plat/omap-serial.h
index 52d3de45745f..5cc062620719 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -144,4 +144,6 @@ struct uart_omap_port {
144 struct work_struct qos_work; 144 struct work_struct qos_work;
145}; 145};
146 146
147#define to_uart_omap_port(p) ((container_of((p), struct uart_omap_port, port)))
148
147#endif /* __OMAP_SERIAL_H__ */ 149#endif /* __OMAP_SERIAL_H__ */
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index aa603f221c6a..8d7a18ab045e 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -142,7 +142,7 @@ static void serial_omap_stop_rxdma(struct uart_omap_port *up)
142 142
143static void serial_omap_enable_ms(struct uart_port *port) 143static void serial_omap_enable_ms(struct uart_port *port)
144{ 144{
145 struct uart_omap_port *up = (struct uart_omap_port *)port; 145 struct uart_omap_port *up = to_uart_omap_port(port);
146 146
147 dev_dbg(up->port.dev, "serial_omap_enable_ms+%d\n", up->port.line); 147 dev_dbg(up->port.dev, "serial_omap_enable_ms+%d\n", up->port.line);
148 148
@@ -154,7 +154,7 @@ static void serial_omap_enable_ms(struct uart_port *port)
154 154
155static void serial_omap_stop_tx(struct uart_port *port) 155static void serial_omap_stop_tx(struct uart_port *port)
156{ 156{
157 struct uart_omap_port *up = (struct uart_omap_port *)port; 157 struct uart_omap_port *up = to_uart_omap_port(port);
158 struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; 158 struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
159 159
160 if (up->use_dma && 160 if (up->use_dma &&
@@ -187,7 +187,7 @@ static void serial_omap_stop_tx(struct uart_port *port)
187 187
188static void serial_omap_stop_rx(struct uart_port *port) 188static void serial_omap_stop_rx(struct uart_port *port)
189{ 189{
190 struct uart_omap_port *up = (struct uart_omap_port *)port; 190 struct uart_omap_port *up = to_uart_omap_port(port);
191 191
192 pm_runtime_get_sync(&up->pdev->dev); 192 pm_runtime_get_sync(&up->pdev->dev);
193 if (up->use_dma) 193 if (up->use_dma)
@@ -308,7 +308,7 @@ static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up)
308 308
309static void serial_omap_start_tx(struct uart_port *port) 309static void serial_omap_start_tx(struct uart_port *port)
310{ 310{
311 struct uart_omap_port *up = (struct uart_omap_port *)port; 311 struct uart_omap_port *up = to_uart_omap_port(port);
312 struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; 312 struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
313 struct circ_buf *xmit; 313 struct circ_buf *xmit;
314 unsigned int start; 314 unsigned int start;
@@ -450,7 +450,7 @@ static inline irqreturn_t serial_omap_irq(int irq, void *dev_id)
450 450
451static unsigned int serial_omap_tx_empty(struct uart_port *port) 451static unsigned int serial_omap_tx_empty(struct uart_port *port)
452{ 452{
453 struct uart_omap_port *up = (struct uart_omap_port *)port; 453 struct uart_omap_port *up = to_uart_omap_port(port);
454 unsigned long flags = 0; 454 unsigned long flags = 0;
455 unsigned int ret = 0; 455 unsigned int ret = 0;
456 456
@@ -465,7 +465,7 @@ static unsigned int serial_omap_tx_empty(struct uart_port *port)
465 465
466static unsigned int serial_omap_get_mctrl(struct uart_port *port) 466static unsigned int serial_omap_get_mctrl(struct uart_port *port)
467{ 467{
468 struct uart_omap_port *up = (struct uart_omap_port *)port; 468 struct uart_omap_port *up = to_uart_omap_port(port);
469 unsigned int status; 469 unsigned int status;
470 unsigned int ret = 0; 470 unsigned int ret = 0;
471 471
@@ -488,7 +488,7 @@ static unsigned int serial_omap_get_mctrl(struct uart_port *port)
488 488
489static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl) 489static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl)
490{ 490{
491 struct uart_omap_port *up = (struct uart_omap_port *)port; 491 struct uart_omap_port *up = to_uart_omap_port(port);
492 unsigned char mcr = 0; 492 unsigned char mcr = 0;
493 493
494 dev_dbg(up->port.dev, "serial_omap_set_mctrl+%d\n", up->port.line); 494 dev_dbg(up->port.dev, "serial_omap_set_mctrl+%d\n", up->port.line);
@@ -522,7 +522,7 @@ static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl)
522 522
523static void serial_omap_break_ctl(struct uart_port *port, int break_state) 523static void serial_omap_break_ctl(struct uart_port *port, int break_state)
524{ 524{
525 struct uart_omap_port *up = (struct uart_omap_port *)port; 525 struct uart_omap_port *up = to_uart_omap_port(port);
526 unsigned long flags = 0; 526 unsigned long flags = 0;
527 527
528 dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line); 528 dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line);
@@ -539,7 +539,7 @@ static void serial_omap_break_ctl(struct uart_port *port, int break_state)
539 539
540static int serial_omap_startup(struct uart_port *port) 540static int serial_omap_startup(struct uart_port *port)
541{ 541{
542 struct uart_omap_port *up = (struct uart_omap_port *)port; 542 struct uart_omap_port *up = to_uart_omap_port(port);
543 unsigned long flags = 0; 543 unsigned long flags = 0;
544 int retval; 544 int retval;
545 545
@@ -617,7 +617,7 @@ static int serial_omap_startup(struct uart_port *port)
617 617
618static void serial_omap_shutdown(struct uart_port *port) 618static void serial_omap_shutdown(struct uart_port *port)
619{ 619{
620 struct uart_omap_port *up = (struct uart_omap_port *)port; 620 struct uart_omap_port *up = to_uart_omap_port(port);
621 unsigned long flags = 0; 621 unsigned long flags = 0;
622 622
623 dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line); 623 dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line);
@@ -735,7 +735,7 @@ static void
735serial_omap_set_termios(struct uart_port *port, struct ktermios *termios, 735serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
736 struct ktermios *old) 736 struct ktermios *old)
737{ 737{
738 struct uart_omap_port *up = (struct uart_omap_port *)port; 738 struct uart_omap_port *up = to_uart_omap_port(port);
739 unsigned char cval = 0; 739 unsigned char cval = 0;
740 unsigned char efr = 0; 740 unsigned char efr = 0;
741 unsigned long flags = 0; 741 unsigned long flags = 0;
@@ -946,7 +946,7 @@ static void
946serial_omap_pm(struct uart_port *port, unsigned int state, 946serial_omap_pm(struct uart_port *port, unsigned int state,
947 unsigned int oldstate) 947 unsigned int oldstate)
948{ 948{
949 struct uart_omap_port *up = (struct uart_omap_port *)port; 949 struct uart_omap_port *up = to_uart_omap_port(port);
950 unsigned char efr; 950 unsigned char efr;
951 951
952 dev_dbg(up->port.dev, "serial_omap_pm+%d\n", up->port.line); 952 dev_dbg(up->port.dev, "serial_omap_pm+%d\n", up->port.line);
@@ -985,7 +985,7 @@ static int serial_omap_request_port(struct uart_port *port)
985 985
986static void serial_omap_config_port(struct uart_port *port, int flags) 986static void serial_omap_config_port(struct uart_port *port, int flags)
987{ 987{
988 struct uart_omap_port *up = (struct uart_omap_port *)port; 988 struct uart_omap_port *up = to_uart_omap_port(port);
989 989
990 dev_dbg(up->port.dev, "serial_omap_config_port+%d\n", 990 dev_dbg(up->port.dev, "serial_omap_config_port+%d\n",
991 up->port.line); 991 up->port.line);
@@ -1003,7 +1003,7 @@ serial_omap_verify_port(struct uart_port *port, struct serial_struct *ser)
1003static const char * 1003static const char *
1004serial_omap_type(struct uart_port *port) 1004serial_omap_type(struct uart_port *port)
1005{ 1005{
1006 struct uart_omap_port *up = (struct uart_omap_port *)port; 1006 struct uart_omap_port *up = to_uart_omap_port(port);
1007 1007
1008 dev_dbg(up->port.dev, "serial_omap_type+%d\n", up->port.line); 1008 dev_dbg(up->port.dev, "serial_omap_type+%d\n", up->port.line);
1009 return up->name; 1009 return up->name;
@@ -1046,7 +1046,7 @@ static inline void wait_for_xmitr(struct uart_omap_port *up)
1046 1046
1047static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch) 1047static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
1048{ 1048{
1049 struct uart_omap_port *up = (struct uart_omap_port *)port; 1049 struct uart_omap_port *up = to_uart_omap_port(port);
1050 1050
1051 pm_runtime_get_sync(&up->pdev->dev); 1051 pm_runtime_get_sync(&up->pdev->dev);
1052 wait_for_xmitr(up); 1052 wait_for_xmitr(up);
@@ -1056,7 +1056,7 @@ static void serial_omap_poll_put_char(struct uart_port *port, unsigned char ch)
1056 1056
1057static int serial_omap_poll_get_char(struct uart_port *port) 1057static int serial_omap_poll_get_char(struct uart_port *port)
1058{ 1058{
1059 struct uart_omap_port *up = (struct uart_omap_port *)port; 1059 struct uart_omap_port *up = to_uart_omap_port(port);
1060 unsigned int status; 1060 unsigned int status;
1061 1061
1062 pm_runtime_get_sync(&up->pdev->dev); 1062 pm_runtime_get_sync(&up->pdev->dev);
@@ -1079,7 +1079,7 @@ static struct uart_driver serial_omap_reg;
1079 1079
1080static void serial_omap_console_putchar(struct uart_port *port, int ch) 1080static void serial_omap_console_putchar(struct uart_port *port, int ch)
1081{ 1081{
1082 struct uart_omap_port *up = (struct uart_omap_port *)port; 1082 struct uart_omap_port *up = to_uart_omap_port(port);
1083 1083
1084 wait_for_xmitr(up); 1084 wait_for_xmitr(up);
1085 serial_out(up, UART_TX, ch); 1085 serial_out(up, UART_TX, ch);
@@ -1355,7 +1355,7 @@ static void serial_omap_continue_tx(struct uart_omap_port *up)
1355 1355
1356static void uart_tx_dma_callback(int lch, u16 ch_status, void *data) 1356static void uart_tx_dma_callback(int lch, u16 ch_status, void *data)
1357{ 1357{
1358 struct uart_omap_port *up = (struct uart_omap_port *)data; 1358 struct uart_omap_port *up = data;
1359 struct circ_buf *xmit = &up->port.state->xmit; 1359 struct circ_buf *xmit = &up->port.state->xmit;
1360 1360
1361 xmit->tail = (xmit->tail + up->uart_dma.tx_buf_size) & \ 1361 xmit->tail = (xmit->tail + up->uart_dma.tx_buf_size) & \