aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-11-05 08:28:06 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 18:18:05 -0500
commitb5849b1a82853171ce8a35220204f17ec282a9a8 (patch)
tree42276bb4b2c2fe5cf7ba241e9ed85acc5b4ea48e /drivers/mmc
parente707c35cbbe83a016cf0122a29e3a47b5a9e35c4 (diff)
sdio_uart: use tty_port
Add a tty_port object to the sdio uart. For the moment just begin using the tty field of the port, as this is the critical one to clean up. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/card/sdio_uart.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index b8e7c5ae981e..c2759dbfdfd2 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -73,6 +73,7 @@ struct uart_icount {
73}; 73};
74 74
75struct sdio_uart_port { 75struct sdio_uart_port {
76 struct tty_port port;
76 struct kref kref; 77 struct kref kref;
77 struct tty_struct *tty; 78 struct tty_struct *tty;
78 unsigned int index; 79 unsigned int index;
@@ -172,7 +173,7 @@ static void sdio_uart_port_remove(struct sdio_uart_port *port)
172 port->func = NULL; 173 port->func = NULL;
173 mutex_unlock(&port->func_lock); 174 mutex_unlock(&port->func_lock);
174 if (port->opened) 175 if (port->opened)
175 tty_hangup(port->tty); 176 tty_hangup(port->port.tty);
176 mutex_unlock(&port->open_lock); 177 mutex_unlock(&port->open_lock);
177 sdio_release_irq(func); 178 sdio_release_irq(func);
178 sdio_disable_func(func); 179 sdio_disable_func(func);
@@ -391,7 +392,7 @@ static void sdio_uart_stop_rx(struct sdio_uart_port *port)
391static void sdio_uart_receive_chars(struct sdio_uart_port *port, 392static void sdio_uart_receive_chars(struct sdio_uart_port *port,
392 unsigned int *status) 393 unsigned int *status)
393{ 394{
394 struct tty_struct *tty = port->tty; 395 struct tty_struct *tty = port->port.tty;
395 unsigned int ch, flag; 396 unsigned int ch, flag;
396 int max_count = 256; 397 int max_count = 256;
397 398
@@ -446,6 +447,7 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
446{ 447{
447 struct circ_buf *xmit = &port->xmit; 448 struct circ_buf *xmit = &port->xmit;
448 int count; 449 int count;
450 struct tty_struct *tty = port->port.tty;
449 451
450 if (port->x_char) { 452 if (port->x_char) {
451 sdio_out(port, UART_TX, port->x_char); 453 sdio_out(port, UART_TX, port->x_char);
@@ -453,7 +455,7 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
453 port->x_char = 0; 455 port->x_char = 0;
454 return; 456 return;
455 } 457 }
456 if (circ_empty(xmit) || port->tty->stopped || port->tty->hw_stopped) { 458 if (circ_empty(xmit) || tty->stopped || tty->hw_stopped) {
457 sdio_uart_stop_tx(port); 459 sdio_uart_stop_tx(port);
458 return; 460 return;
459 } 461 }
@@ -468,7 +470,7 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
468 } while (--count > 0); 470 } while (--count > 0);
469 471
470 if (circ_chars_pending(xmit) < WAKEUP_CHARS) 472 if (circ_chars_pending(xmit) < WAKEUP_CHARS)
471 tty_wakeup(port->tty); 473 tty_wakeup(tty);
472 474
473 if (circ_empty(xmit)) 475 if (circ_empty(xmit))
474 sdio_uart_stop_tx(port); 476 sdio_uart_stop_tx(port);
@@ -477,6 +479,7 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
477static void sdio_uart_check_modem_status(struct sdio_uart_port *port) 479static void sdio_uart_check_modem_status(struct sdio_uart_port *port)
478{ 480{
479 int status; 481 int status;
482 struct tty_struct *tty = port->port.tty;
480 483
481 status = sdio_in(port, UART_MSR); 484 status = sdio_in(port, UART_MSR);
482 485
@@ -491,17 +494,17 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port)
491 port->icount.dcd++; 494 port->icount.dcd++;
492 if (status & UART_MSR_DCTS) { 495 if (status & UART_MSR_DCTS) {
493 port->icount.cts++; 496 port->icount.cts++;
494 if (port->tty->termios->c_cflag & CRTSCTS) { 497 if (tty->termios->c_cflag & CRTSCTS) {
495 int cts = (status & UART_MSR_CTS); 498 int cts = (status & UART_MSR_CTS);
496 if (port->tty->hw_stopped) { 499 if (tty->hw_stopped) {
497 if (cts) { 500 if (cts) {
498 port->tty->hw_stopped = 0; 501 tty->hw_stopped = 0;
499 sdio_uart_start_tx(port); 502 sdio_uart_start_tx(port);
500 tty_wakeup(port->tty); 503 tty_wakeup(tty);
501 } 504 }
502 } else { 505 } else {
503 if (!cts) { 506 if (!cts) {
504 port->tty->hw_stopped = 1; 507 tty->hw_stopped = 1;
505 sdio_uart_stop_tx(port); 508 sdio_uart_stop_tx(port);
506 } 509 }
507 } 510 }
@@ -546,12 +549,13 @@ static int sdio_uart_startup(struct sdio_uart_port *port)
546{ 549{
547 unsigned long page; 550 unsigned long page;
548 int ret; 551 int ret;
552 struct tty_struct *tty = port->port.tty;
549 553
550 /* 554 /*
551 * Set the TTY IO error marker - we will only clear this 555 * Set the TTY IO error marker - we will only clear this
552 * once we have successfully opened the port. 556 * once we have successfully opened the port.
553 */ 557 */
554 set_bit(TTY_IO_ERROR, &port->tty->flags); 558 set_bit(TTY_IO_ERROR, &tty->flags);
555 559
556 /* Initialise and allocate the transmit buffer. */ 560 /* Initialise and allocate the transmit buffer. */
557 page = __get_free_page(GFP_KERNEL); 561 page = __get_free_page(GFP_KERNEL);
@@ -595,14 +599,14 @@ static int sdio_uart_startup(struct sdio_uart_port *port)
595 port->ier = UART_IER_RLSI | UART_IER_RDI | UART_IER_RTOIE | UART_IER_UUE; 599 port->ier = UART_IER_RLSI | UART_IER_RDI | UART_IER_RTOIE | UART_IER_UUE;
596 port->mctrl = TIOCM_OUT2; 600 port->mctrl = TIOCM_OUT2;
597 601
598 sdio_uart_change_speed(port, port->tty->termios, NULL); 602 sdio_uart_change_speed(port, tty->termios, NULL);
599 603
600 if (port->tty->termios->c_cflag & CBAUD) 604 if (tty->termios->c_cflag & CBAUD)
601 sdio_uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR); 605 sdio_uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
602 606
603 if (port->tty->termios->c_cflag & CRTSCTS) 607 if (tty->termios->c_cflag & CRTSCTS)
604 if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS)) 608 if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS))
605 port->tty->hw_stopped = 1; 609 tty->hw_stopped = 1;
606 610
607 clear_bit(TTY_IO_ERROR, &port->tty->flags); 611 clear_bit(TTY_IO_ERROR, &port->tty->flags);
608 612
@@ -634,7 +638,7 @@ static void sdio_uart_shutdown(struct sdio_uart_port *port)
634 /* TODO: wait here for TX FIFO to drain */ 638 /* TODO: wait here for TX FIFO to drain */
635 639
636 /* Turn off DTR and RTS early. */ 640 /* Turn off DTR and RTS early. */
637 if (port->tty->termios->c_cflag & HUPCL) 641 if (port->port.tty->termios->c_cflag & HUPCL)
638 sdio_uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 642 sdio_uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
639 643
640 /* Disable interrupts from this port */ 644 /* Disable interrupts from this port */
@@ -684,11 +688,11 @@ static int sdio_uart_open(struct tty_struct *tty, struct file *filp)
684 688
685 if (!port->opened) { 689 if (!port->opened) {
686 tty->driver_data = port; 690 tty->driver_data = port;
687 port->tty = tty; 691 port->port.tty = tty;
688 ret = sdio_uart_startup(port); 692 ret = sdio_uart_startup(port);
689 if (ret) { 693 if (ret) {
690 tty->driver_data = NULL; 694 tty->driver_data = NULL;
691 port->tty = NULL; 695 port->port.tty = NULL;
692 mutex_unlock(&port->open_lock); 696 mutex_unlock(&port->open_lock);
693 sdio_uart_port_put(port); 697 sdio_uart_port_put(port);
694 return ret; 698 return ret;
@@ -723,7 +727,7 @@ static void sdio_uart_close(struct tty_struct *tty, struct file * filp)
723 tty->closing = 1; 727 tty->closing = 1;
724 sdio_uart_shutdown(port); 728 sdio_uart_shutdown(port);
725 tty_ldisc_flush(tty); 729 tty_ldisc_flush(tty);
726 port->tty = NULL; 730 port->port.tty = NULL;
727 tty->driver_data = NULL; 731 tty->driver_data = NULL;
728 tty->closing = 0; 732 tty->closing = 0;
729 } 733 }
@@ -1068,6 +1072,7 @@ static int sdio_uart_probe(struct sdio_func *func,
1068 1072
1069 port->func = func; 1073 port->func = func;
1070 sdio_set_drvdata(func, port); 1074 sdio_set_drvdata(func, port);
1075 tty_port_init(&port->port);
1071 1076
1072 ret = sdio_uart_add_port(port); 1077 ret = sdio_uart_add_port(port);
1073 if (ret) { 1078 if (ret) {