* Sasha Levin <[email protected]> wrote:
> void virtio_console__init(struct kvm *kvm)
> {
> u8 dev, line, pin;
> + u16 console_base_addr;
>
> if (irq__register_device(VIRTIO_ID_CONSOLE, &dev, &pin, &line) < 0)
> return;
>
> virtio_console_pci_device.irq_pin = pin;
> virtio_console_pci_device.irq_line = line;
> + console_base_addr = ioport__find_free_range();
> + virtio_console_pci_device.bar[0] = console_base_addr |
> PCI_BASE_ADDRESS_SPACE_IO;
> + cdev.base_addr = console_base_addr;
> pci__register(&virtio_console_pci_device, dev);
> - ioport__register(IOPORT_VIRTIO_CONSOLE, &virtio_console_io_ops,
> IOPORT_VIRTIO_CONSOLE_SIZE);
> + ioport__register(console_base_addr, &virtio_console_io_ops,
> IOPORT_SIZE);
Why is the ioport registration done in two steps?
Wouldnt a better sequence be something like:
> + console_base_addr =
> ioport__register(&virtio_console_io_ops, IOPORT_SIZE);
>
> + virtio_console_pci_device.bar[0] = console_base_addr |
> PCI_BASE_ADDRESS_SPACE_IO;
> + cdev.base_addr = console_base_addr;
> pci__register(&virtio_console_pci_device, dev);
I.e. first register the ioport range - this would also get a free
range for you, and then register the PCI driver?
Or something even more compact could be done i suspect - all of the
drivers seem to be using the same registration sequence.
Thanks,
Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html