aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/atmel_serial.c
diff options
context:
space:
mode:
authorHaavard Skinnemoen <hskinnemoen@atmel.com>2008-02-08 07:21:08 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:37 -0500
commitc811ab8c2daf6bc2b5761937929a62fa84b18b32 (patch)
tree2a3d5be5b449bc470a170efa771b404d06f5d17d /drivers/serial/atmel_serial.c
parent6433471d33c09d69d029b1c4b7bdd1612c492587 (diff)
atmel_serial: use container_of instead of direct cast
As pointed out by David Brownell, we really ought to be using container_of when converting from "struct uart_port *" to "struct atmel_uart_port *". Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: Andrew Victor <linux@maxim.org.za> Tested-by: Marc Pignat <marc.pignat@hevs.ch> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/serial/atmel_serial.c')
-rw-r--r--drivers/serial/atmel_serial.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index e08fe64e4466..8cea6068f03e 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -153,17 +153,23 @@ static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
153static struct console atmel_console; 153static struct console atmel_console;
154#endif 154#endif
155 155
156static inline struct atmel_uart_port *
157to_atmel_uart_port(struct uart_port *uart)
158{
159 return container_of(uart, struct atmel_uart_port, uart);
160}
161
156#ifdef CONFIG_SERIAL_ATMEL_PDC 162#ifdef CONFIG_SERIAL_ATMEL_PDC
157static bool atmel_use_dma_rx(struct uart_port *port) 163static bool atmel_use_dma_rx(struct uart_port *port)
158{ 164{
159 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 165 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
160 166
161 return atmel_port->use_dma_rx; 167 return atmel_port->use_dma_rx;
162} 168}
163 169
164static bool atmel_use_dma_tx(struct uart_port *port) 170static bool atmel_use_dma_tx(struct uart_port *port)
165{ 171{
166 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 172 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
167 173
168 return atmel_port->use_dma_tx; 174 return atmel_port->use_dma_tx;
169} 175}
@@ -326,7 +332,7 @@ static void
326atmel_buffer_rx_char(struct uart_port *port, unsigned int status, 332atmel_buffer_rx_char(struct uart_port *port, unsigned int status,
327 unsigned int ch) 333 unsigned int ch)
328{ 334{
329 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 335 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
330 struct circ_buf *ring = &atmel_port->rx_ring; 336 struct circ_buf *ring = &atmel_port->rx_ring;
331 struct atmel_uart_char *c; 337 struct atmel_uart_char *c;
332 338
@@ -370,7 +376,7 @@ static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status)
370 */ 376 */
371static void atmel_rx_chars(struct uart_port *port) 377static void atmel_rx_chars(struct uart_port *port)
372{ 378{
373 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 379 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
374 unsigned int status, ch; 380 unsigned int status, ch;
375 381
376 status = UART_GET_CSR(port); 382 status = UART_GET_CSR(port);
@@ -450,7 +456,7 @@ static void atmel_tx_chars(struct uart_port *port)
450static void 456static void
451atmel_handle_receive(struct uart_port *port, unsigned int pending) 457atmel_handle_receive(struct uart_port *port, unsigned int pending)
452{ 458{
453 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 459 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
454 460
455 if (atmel_use_dma_rx(port)) { 461 if (atmel_use_dma_rx(port)) {
456 /* 462 /*
@@ -491,7 +497,7 @@ atmel_handle_receive(struct uart_port *port, unsigned int pending)
491static void 497static void
492atmel_handle_transmit(struct uart_port *port, unsigned int pending) 498atmel_handle_transmit(struct uart_port *port, unsigned int pending)
493{ 499{
494 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 500 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
495 501
496 if (atmel_use_dma_tx(port)) { 502 if (atmel_use_dma_tx(port)) {
497 /* PDC transmit */ 503 /* PDC transmit */
@@ -515,7 +521,7 @@ static void
515atmel_handle_status(struct uart_port *port, unsigned int pending, 521atmel_handle_status(struct uart_port *port, unsigned int pending,
516 unsigned int status) 522 unsigned int status)
517{ 523{
518 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 524 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
519 525
520 if (pending & (ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC 526 if (pending & (ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC
521 | ATMEL_US_CTSIC)) { 527 | ATMEL_US_CTSIC)) {
@@ -551,7 +557,7 @@ static irqreturn_t atmel_interrupt(int irq, void *dev_id)
551 */ 557 */
552static void atmel_tx_dma(struct uart_port *port) 558static void atmel_tx_dma(struct uart_port *port)
553{ 559{
554 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 560 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
555 struct circ_buf *xmit = &port->info->xmit; 561 struct circ_buf *xmit = &port->info->xmit;
556 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; 562 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
557 int count; 563 int count;
@@ -593,7 +599,7 @@ static void atmel_tx_dma(struct uart_port *port)
593 599
594static void atmel_rx_from_ring(struct uart_port *port) 600static void atmel_rx_from_ring(struct uart_port *port)
595{ 601{
596 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 602 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
597 struct circ_buf *ring = &atmel_port->rx_ring; 603 struct circ_buf *ring = &atmel_port->rx_ring;
598 unsigned int flg; 604 unsigned int flg;
599 unsigned int status; 605 unsigned int status;
@@ -661,7 +667,7 @@ static void atmel_rx_from_ring(struct uart_port *port)
661 667
662static void atmel_rx_from_dma(struct uart_port *port) 668static void atmel_rx_from_dma(struct uart_port *port)
663{ 669{
664 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 670 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
665 struct tty_struct *tty = port->info->tty; 671 struct tty_struct *tty = port->info->tty;
666 struct atmel_dma_buffer *pdc; 672 struct atmel_dma_buffer *pdc;
667 int rx_idx = atmel_port->pdc_rx_idx; 673 int rx_idx = atmel_port->pdc_rx_idx;
@@ -741,7 +747,7 @@ static void atmel_rx_from_dma(struct uart_port *port)
741static void atmel_tasklet_func(unsigned long data) 747static void atmel_tasklet_func(unsigned long data)
742{ 748{
743 struct uart_port *port = (struct uart_port *)data; 749 struct uart_port *port = (struct uart_port *)data;
744 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 750 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
745 unsigned int status; 751 unsigned int status;
746 unsigned int status_change; 752 unsigned int status_change;
747 753
@@ -786,7 +792,7 @@ static void atmel_tasklet_func(unsigned long data)
786 */ 792 */
787static int atmel_startup(struct uart_port *port) 793static int atmel_startup(struct uart_port *port)
788{ 794{
789 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 795 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
790 int retval; 796 int retval;
791 797
792 /* 798 /*
@@ -896,7 +902,7 @@ static int atmel_startup(struct uart_port *port)
896 */ 902 */
897static void atmel_shutdown(struct uart_port *port) 903static void atmel_shutdown(struct uart_port *port)
898{ 904{
899 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 905 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
900 /* 906 /*
901 * Ensure everything is stopped. 907 * Ensure everything is stopped.
902 */ 908 */
@@ -953,7 +959,7 @@ static void atmel_shutdown(struct uart_port *port)
953static void atmel_serial_pm(struct uart_port *port, unsigned int state, 959static void atmel_serial_pm(struct uart_port *port, unsigned int state,
954 unsigned int oldstate) 960 unsigned int oldstate)
955{ 961{
956 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 962 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
957 963
958 switch (state) { 964 switch (state) {
959 case 0: 965 case 0:
@@ -1425,7 +1431,7 @@ static int atmel_serial_suspend(struct platform_device *pdev,
1425 pm_message_t state) 1431 pm_message_t state)
1426{ 1432{
1427 struct uart_port *port = platform_get_drvdata(pdev); 1433 struct uart_port *port = platform_get_drvdata(pdev);
1428 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 1434 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
1429 1435
1430 if (device_may_wakeup(&pdev->dev) 1436 if (device_may_wakeup(&pdev->dev)
1431 && !at91_suspend_entering_slow_clock()) 1437 && !at91_suspend_entering_slow_clock())
@@ -1441,7 +1447,7 @@ static int atmel_serial_suspend(struct platform_device *pdev,
1441static int atmel_serial_resume(struct platform_device *pdev) 1447static int atmel_serial_resume(struct platform_device *pdev)
1442{ 1448{
1443 struct uart_port *port = platform_get_drvdata(pdev); 1449 struct uart_port *port = platform_get_drvdata(pdev);
1444 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 1450 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
1445 1451
1446 if (atmel_port->suspended) { 1452 if (atmel_port->suspended) {
1447 uart_resume_port(&atmel_uart, port); 1453 uart_resume_port(&atmel_uart, port);
@@ -1501,7 +1507,7 @@ err_alloc_ring:
1501static int __devexit atmel_serial_remove(struct platform_device *pdev) 1507static int __devexit atmel_serial_remove(struct platform_device *pdev)
1502{ 1508{
1503 struct uart_port *port = platform_get_drvdata(pdev); 1509 struct uart_port *port = platform_get_drvdata(pdev);
1504 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *)port; 1510 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
1505 int ret = 0; 1511 int ret = 0;
1506 1512
1507 device_init_wakeup(&pdev->dev, 0); 1513 device_init_wakeup(&pdev->dev, 0);