diff options
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/altera_uart.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c index 6d5b036ac783..50bc5a5ac653 100644 --- a/drivers/tty/serial/altera_uart.c +++ b/drivers/tty/serial/altera_uart.c | |||
@@ -540,11 +540,14 @@ static int __devinit altera_uart_probe(struct platform_device *pdev) | |||
540 | int i = pdev->id; | 540 | int i = pdev->id; |
541 | int ret; | 541 | int ret; |
542 | 542 | ||
543 | /* -1 emphasizes that the platform must have one port, no .N suffix */ | 543 | /* if id is -1 scan for a free id and use that one */ |
544 | if (i == -1) | 544 | if (i == -1) { |
545 | i = 0; | 545 | for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS; i++) |
546 | if (altera_uart_ports[i].port.mapbase == 0) | ||
547 | break; | ||
548 | } | ||
546 | 549 | ||
547 | if (i >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS) | 550 | if (i < 0 || i >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS) |
548 | return -EINVAL; | 551 | return -EINVAL; |
549 | 552 | ||
550 | port = &altera_uart_ports[i].port; | 553 | port = &altera_uart_ports[i].port; |
@@ -587,6 +590,8 @@ static int __devinit altera_uart_probe(struct platform_device *pdev) | |||
587 | port->ops = &altera_uart_ops; | 590 | port->ops = &altera_uart_ops; |
588 | port->flags = UPF_BOOT_AUTOCONF; | 591 | port->flags = UPF_BOOT_AUTOCONF; |
589 | 592 | ||
593 | dev_set_drvdata(&pdev->dev, port); | ||
594 | |||
590 | uart_add_one_port(&altera_uart_driver, port); | 595 | uart_add_one_port(&altera_uart_driver, port); |
591 | 596 | ||
592 | return 0; | 597 | return 0; |
@@ -594,14 +599,13 @@ static int __devinit altera_uart_probe(struct platform_device *pdev) | |||
594 | 599 | ||
595 | static int __devexit altera_uart_remove(struct platform_device *pdev) | 600 | static int __devexit altera_uart_remove(struct platform_device *pdev) |
596 | { | 601 | { |
597 | struct uart_port *port; | 602 | struct uart_port *port = dev_get_drvdata(&pdev->dev); |
598 | int i = pdev->id; | ||
599 | 603 | ||
600 | if (i == -1) | 604 | if (port) { |
601 | i = 0; | 605 | uart_remove_one_port(&altera_uart_driver, port); |
602 | 606 | dev_set_drvdata(&pdev->dev, NULL); | |
603 | port = &altera_uart_ports[i].port; | 607 | port->mapbase = 0; |
604 | uart_remove_one_port(&altera_uart_driver, port); | 608 | } |
605 | 609 | ||
606 | return 0; | 610 | return 0; |
607 | } | 611 | } |