diff options
-rw-r--r-- | drivers/tty/serial/altera_jtaguart.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c index 94ccf4741f0e..aa2a4caaa1c3 100644 --- a/drivers/tty/serial/altera_jtaguart.c +++ b/drivers/tty/serial/altera_jtaguart.c | |||
@@ -409,22 +409,45 @@ static int __devinit altera_jtaguart_probe(struct platform_device *pdev) | |||
409 | { | 409 | { |
410 | struct altera_jtaguart_platform_uart *platp = pdev->dev.platform_data; | 410 | struct altera_jtaguart_platform_uart *platp = pdev->dev.platform_data; |
411 | struct uart_port *port; | 411 | struct uart_port *port; |
412 | int i; | 412 | struct resource *res_irq, *res_mem; |
413 | int i = pdev->id; | ||
413 | 414 | ||
414 | for (i = 0; i < ALTERA_JTAGUART_MAXPORTS && platp[i].mapbase; i++) { | 415 | /* -1 emphasizes that the platform must have one port, no .N suffix */ |
415 | port = &altera_jtaguart_ports[i].port; | 416 | if (i == -1) |
417 | i = 0; | ||
416 | 418 | ||
417 | port->line = i; | 419 | if (i >= ALTERA_JTAGUART_MAXPORTS) |
418 | port->type = PORT_ALTERA_JTAGUART; | 420 | return -EINVAL; |
419 | port->mapbase = platp[i].mapbase; | ||
420 | port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE); | ||
421 | port->iotype = SERIAL_IO_MEM; | ||
422 | port->irq = platp[i].irq; | ||
423 | port->ops = &altera_jtaguart_ops; | ||
424 | port->flags = ASYNC_BOOT_AUTOCONF; | ||
425 | 421 | ||
426 | uart_add_one_port(&altera_jtaguart_driver, port); | 422 | port = &altera_jtaguart_ports[i].port; |
427 | } | 423 | |
424 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
425 | if (res_mem) | ||
426 | port->mapbase = res_mem->start; | ||
427 | else if (platp) | ||
428 | port->mapbase = platp->mapbase; | ||
429 | else | ||
430 | return -ENODEV; | ||
431 | |||
432 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
433 | if (res_irq) | ||
434 | port->irq = res_irq->start; | ||
435 | else if (platp) | ||
436 | port->irq = platp->irq; | ||
437 | else | ||
438 | return -ENODEV; | ||
439 | |||
440 | port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE); | ||
441 | if (!port->membase) | ||
442 | return -ENOMEM; | ||
443 | |||
444 | port->line = i; | ||
445 | port->type = PORT_ALTERA_JTAGUART; | ||
446 | port->iotype = SERIAL_IO_MEM; | ||
447 | port->ops = &altera_jtaguart_ops; | ||
448 | port->flags = ASYNC_BOOT_AUTOCONF; | ||
449 | |||
450 | uart_add_one_port(&altera_jtaguart_driver, port); | ||
428 | 451 | ||
429 | return 0; | 452 | return 0; |
430 | } | 453 | } |
@@ -432,13 +455,13 @@ static int __devinit altera_jtaguart_probe(struct platform_device *pdev) | |||
432 | static int __devexit altera_jtaguart_remove(struct platform_device *pdev) | 455 | static int __devexit altera_jtaguart_remove(struct platform_device *pdev) |
433 | { | 456 | { |
434 | struct uart_port *port; | 457 | struct uart_port *port; |
435 | int i; | 458 | int i = pdev->id; |
436 | 459 | ||
437 | for (i = 0; i < ALTERA_JTAGUART_MAXPORTS; i++) { | 460 | if (i == -1) |
438 | port = &altera_jtaguart_ports[i].port; | 461 | i = 0; |
439 | if (port) | 462 | |
440 | uart_remove_one_port(&altera_jtaguart_driver, port); | 463 | port = &altera_jtaguart_ports[i].port; |
441 | } | 464 | uart_remove_one_port(&altera_jtaguart_driver, port); |
442 | 465 | ||
443 | return 0; | 466 | return 0; |
444 | } | 467 | } |