diff options
-rw-r--r-- | drivers/serial/sh-sci.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 44d5bd10702b..cf2c78079c0d 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -1595,27 +1595,43 @@ static const char *sci_type(struct uart_port *port) | |||
1595 | return NULL; | 1595 | return NULL; |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | static void sci_release_port(struct uart_port *port) | 1598 | static inline unsigned long sci_port_size(struct uart_port *port) |
1599 | { | 1599 | { |
1600 | /* Nothing here yet .. */ | 1600 | /* |
1601 | * Pick an arbitrary size that encapsulates all of the base | ||
1602 | * registers by default. This can be optimized later, or derived | ||
1603 | * from platform resource data at such a time that ports begin to | ||
1604 | * behave more erratically. | ||
1605 | */ | ||
1606 | return 64; | ||
1601 | } | 1607 | } |
1602 | 1608 | ||
1603 | static int sci_request_port(struct uart_port *port) | 1609 | static void sci_release_port(struct uart_port *port) |
1604 | { | 1610 | { |
1605 | /* Nothing here yet .. */ | 1611 | if (port->flags & UPF_IOREMAP) { |
1606 | return 0; | 1612 | iounmap(port->membase); |
1613 | port->membase = NULL; | ||
1614 | } | ||
1615 | |||
1616 | release_mem_region(port->mapbase, sci_port_size(port)); | ||
1607 | } | 1617 | } |
1608 | 1618 | ||
1609 | static void sci_config_port(struct uart_port *port, int flags) | 1619 | static int sci_request_port(struct uart_port *port) |
1610 | { | 1620 | { |
1611 | struct sci_port *s = to_sci_port(port); | 1621 | unsigned long size = sci_port_size(port); |
1622 | struct resource *res; | ||
1612 | 1623 | ||
1613 | port->type = s->cfg->type; | 1624 | res = request_mem_region(port->mapbase, size, sci_type(port)); |
1625 | if (unlikely(res == NULL)) | ||
1626 | return -EBUSY; | ||
1614 | 1627 | ||
1615 | if (port->flags & UPF_IOREMAP) { | 1628 | if (port->flags & UPF_IOREMAP) { |
1616 | port->membase = ioremap_nocache(port->mapbase, 0x40); | 1629 | port->membase = ioremap_nocache(port->mapbase, size); |
1617 | if (unlikely(!port->membase)) | 1630 | if (unlikely(!port->membase)) { |
1618 | dev_err(port->dev, "can't remap port#%d\n", port->line); | 1631 | dev_err(port->dev, "can't remap port#%d\n", port->line); |
1632 | release_resource(res); | ||
1633 | return -ENXIO; | ||
1634 | } | ||
1619 | } else { | 1635 | } else { |
1620 | /* | 1636 | /* |
1621 | * For the simple (and majority of) cases where we don't | 1637 | * For the simple (and majority of) cases where we don't |
@@ -1624,6 +1640,18 @@ static void sci_config_port(struct uart_port *port, int flags) | |||
1624 | */ | 1640 | */ |
1625 | port->membase = (void __iomem *)port->mapbase; | 1641 | port->membase = (void __iomem *)port->mapbase; |
1626 | } | 1642 | } |
1643 | |||
1644 | return 0; | ||
1645 | } | ||
1646 | |||
1647 | static void sci_config_port(struct uart_port *port, int flags) | ||
1648 | { | ||
1649 | if (flags & UART_CONFIG_TYPE) { | ||
1650 | struct sci_port *sport = to_sci_port(port); | ||
1651 | |||
1652 | port->type = sport->cfg->type; | ||
1653 | sci_request_port(port); | ||
1654 | } | ||
1627 | } | 1655 | } |
1628 | 1656 | ||
1629 | static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) | 1657 | static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) |