diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2005-07-27 06:32:04 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-07-27 06:32:04 -0400 |
commit | 72ce9a83331afdd4df944f210a5210bf5acb7d6a (patch) | |
tree | 232cb0eefd8f62916e0a5732e876742517bfce25 /drivers/serial/8250_pci.c | |
parent | 1c7c1fe51629d82e1dff22b2c4d409b252fb2b05 (diff) |
[SERIAL] Factor out the common setup from the per-serial port loop.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/serial/8250_pci.c')
-rw-r--r-- | drivers/serial/8250_pci.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 84c8f8f592ca..8f2617206e8f 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -110,8 +110,9 @@ setup_port(struct pci_dev *dev, struct uart_port *port, | |||
110 | if (bar >= PCI_NUM_BAR_RESOURCES) | 110 | if (bar >= PCI_NUM_BAR_RESOURCES) |
111 | return -EINVAL; | 111 | return -EINVAL; |
112 | 112 | ||
113 | base = pci_resource_start(dev, bar); | ||
114 | |||
113 | if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { | 115 | if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { |
114 | base = pci_resource_start(dev, bar); | ||
115 | len = pci_resource_len(dev, bar); | 116 | len = pci_resource_len(dev, bar); |
116 | 117 | ||
117 | if (!priv->remapped_bar[bar]) | 118 | if (!priv->remapped_bar[bar]) |
@@ -120,13 +121,16 @@ setup_port(struct pci_dev *dev, struct uart_port *port, | |||
120 | return -ENOMEM; | 121 | return -ENOMEM; |
121 | 122 | ||
122 | port->iotype = UPIO_MEM; | 123 | port->iotype = UPIO_MEM; |
124 | port->iobase = 0; | ||
123 | port->mapbase = base + offset; | 125 | port->mapbase = base + offset; |
124 | port->membase = priv->remapped_bar[bar] + offset; | 126 | port->membase = priv->remapped_bar[bar] + offset; |
125 | port->regshift = regshift; | 127 | port->regshift = regshift; |
126 | } else { | 128 | } else { |
127 | base = pci_resource_start(dev, bar) + offset; | ||
128 | port->iotype = UPIO_PORT; | 129 | port->iotype = UPIO_PORT; |
129 | port->iobase = base; | 130 | port->iobase = base + offset; |
131 | port->mapbase = 0; | ||
132 | port->membase = NULL; | ||
133 | port->regshift = 0; | ||
130 | } | 134 | } |
131 | return 0; | 135 | return 0; |
132 | } | 136 | } |
@@ -991,7 +995,7 @@ static struct pci_serial_quirk *find_quirk(struct pci_dev *dev) | |||
991 | } | 995 | } |
992 | 996 | ||
993 | static _INLINE_ int | 997 | static _INLINE_ int |
994 | get_pci_irq(struct pci_dev *dev, struct pciserial_board *board, int idx) | 998 | get_pci_irq(struct pci_dev *dev, struct pciserial_board *board) |
995 | { | 999 | { |
996 | if (board->flags & FL_NOIRQ) | 1000 | if (board->flags & FL_NOIRQ) |
997 | return 0; | 1001 | return 0; |
@@ -1649,6 +1653,7 @@ serial_pci_matches(struct pciserial_board *board, | |||
1649 | static int __devinit | 1653 | static int __devinit |
1650 | pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) | 1654 | pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) |
1651 | { | 1655 | { |
1656 | struct uart_port serial_port; | ||
1652 | struct serial_private *priv; | 1657 | struct serial_private *priv; |
1653 | struct pciserial_board *board, tmp; | 1658 | struct pciserial_board *board, tmp; |
1654 | struct pci_serial_quirk *quirk; | 1659 | struct pci_serial_quirk *quirk; |
@@ -1731,17 +1736,16 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) | |||
1731 | priv->quirk = quirk; | 1736 | priv->quirk = quirk; |
1732 | pci_set_drvdata(dev, priv); | 1737 | pci_set_drvdata(dev, priv); |
1733 | 1738 | ||
1739 | memset(&serial_port, 0, sizeof(struct uart_port)); | ||
1740 | serial_port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ; | ||
1741 | serial_port.uartclk = board->base_baud * 16; | ||
1742 | serial_port.irq = get_pci_irq(dev, board); | ||
1743 | serial_port.dev = &dev->dev; | ||
1744 | |||
1734 | for (i = 0; i < nr_ports; i++) { | 1745 | for (i = 0; i < nr_ports; i++) { |
1735 | struct uart_port serial_port; | ||
1736 | memset(&serial_port, 0, sizeof(struct uart_port)); | ||
1737 | |||
1738 | serial_port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | | ||
1739 | UPF_SHARE_IRQ; | ||
1740 | serial_port.uartclk = board->base_baud * 16; | ||
1741 | serial_port.irq = get_pci_irq(dev, board, i); | ||
1742 | serial_port.dev = &dev->dev; | ||
1743 | if (quirk->setup(dev, board, &serial_port, i)) | 1746 | if (quirk->setup(dev, board, &serial_port, i)) |
1744 | break; | 1747 | break; |
1748 | |||
1745 | #ifdef SERIAL_DEBUG_PCI | 1749 | #ifdef SERIAL_DEBUG_PCI |
1746 | printk("Setup PCI port: port %x, irq %d, type %d\n", | 1750 | printk("Setup PCI port: port %x, irq %d, type %d\n", |
1747 | serial_port.iobase, serial_port.irq, serial_port.iotype); | 1751 | serial_port.iobase, serial_port.irq, serial_port.iotype); |