serial: fix multi-pci card error cleanup.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJVWxTBAAoJEEy22O7T6HE48boP/0e+WavR48nhASyYNLTW5SR7
 NmOPqN964HN0dDP3S5jItD1GP2DtPb/9kQga0l8b/t5X89oW23ZjB6EHlVDLboNS
 b0zc6ahcvNpvNRm/DYEv8zZCXU9e6qwCUKfo/TZ7L74bP0/2ol49Ry3fvKZrs/JK
 M8emDFh3CoVvvQoLO1eUpoj9ATi20I28silVFgaHeU7kB/qGXoQCPiO8Wu5GBGgS
 HvtfB2VA0tn4D/NeWO5ll78GhO+TtB0SXsFfW9ln7wlYAgTv0/7mPaS4ELTTeSye
 ThBR/CN7ArKINPIEEDIJUT2y8Hv4XeKgFTH1WjAce3LMjx1kGeA6mfOsXm63YCgj
 JqMJhnxSkNY4GqHLxzb6+KYgqOq7KVPsjbUyHR52M2thl0PEEbP9Ft/XXZT6WAkB
 8ISjk+vmfojAEVYXjk/ZZvDTkws+53r/aWO5FakObAj/l2Sk8FtrBMJyqdo/+2QO
 6GCJUVnmPVhGpaT94ysCwihIJl6CPpARAFWwKKleCZx2AENL7amk8HxilaDcJE5S
 /is3c7YIc6vL5PENUuyoAIsnvWhnocSvwGvsMtWkLtrnGbCYaEGyLpk1ty12PSQM
 e2kWd/qxIerKECyJ1+BPZb8zewR0o9wxHX/qZtrfOo9zsSwc8JOZFw8s1HWxDMj8
 XbqDYzHlmBUvMg8kQY02
 =4NPQ
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/pull-serial-20150519-1' into staging

serial: fix multi-pci card error cleanup.

# gpg: Signature made Tue May 19 11:47:29 2015 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-serial-20150519-1:
  serial: fix multi-pci card error cleanup.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-05-19 14:10:33 +01:00
commit eba05e922e

View File

@ -48,6 +48,8 @@ typedef struct PCIMultiSerialState {
uint8_t prog_if;
} PCIMultiSerialState;
static void multi_serial_pci_exit(PCIDevice *dev);
static void serial_pci_realize(PCIDevice *dev, Error **errp)
{
PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev);
@ -89,32 +91,33 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev);
SerialState *s;
Error *err = NULL;
int i;
int i, nr_ports = 0;
switch (pc->device_id) {
case 0x0003:
pci->ports = 2;
nr_ports = 2;
break;
case 0x0004:
pci->ports = 4;
nr_ports = 4;
break;
}
assert(pci->ports > 0);
assert(pci->ports <= PCI_SERIAL_MAX_PORTS);
assert(nr_ports > 0);
assert(nr_ports <= PCI_SERIAL_MAX_PORTS);
pci->dev.config[PCI_CLASS_PROG] = pci->prog_if;
pci->dev.config[PCI_INTERRUPT_PIN] = 0x01;
memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports);
memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * nr_ports);
pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar);
pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci,
pci->ports);
nr_ports);
for (i = 0; i < pci->ports; i++) {
for (i = 0; i < nr_ports; i++) {
s = pci->state + i;
s->baudbase = 115200;
serial_realize_core(s, &err);
if (err != NULL) {
error_propagate(errp, err);
multi_serial_pci_exit(dev);
return;
}
s->irq = pci->irqs[i];
@ -122,6 +125,7 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s,
pci->name[i], 8);
memory_region_add_subregion(&pci->iobar, 8 * i, &s->io);
pci->ports++;
}
}