Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux

Pull virtio updates from Rusty Russell:
"All trivial, thanks to the stuff which didn't quite make it time"

* tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
virtio_console: Initialize guest_connected=true for rproc_serial
virtio: use module_virtio_driver.
virtio: Add module driver macro for virtio drivers.
virtio_console: Use virtio device index to generate port name
virtio: make pci_device_id const
virtio: make config_ops const
virtio-mmio: fix wrong comment about register offset
virtio_console: Let unconnected rproc device receive data.

+26 -59
+1 -12
drivers/char/hw_random/virtio-rng.c
··· 154 154 #endif 155 155 }; 156 156 157 - static int __init init(void) 158 - { 159 - return register_virtio_driver(&virtio_rng_driver); 160 - } 161 - 162 - static void __exit fini(void) 163 - { 164 - unregister_virtio_driver(&virtio_rng_driver); 165 - } 166 - module_init(init); 167 - module_exit(fini); 168 - 157 + module_virtio_driver(virtio_rng_driver); 169 158 MODULE_DEVICE_TABLE(virtio, id_table); 170 159 MODULE_DESCRIPTION("Virtio random number driver"); 171 160 MODULE_LICENSE("GPL");
+4 -14
drivers/char/virtio_console.c
··· 61 61 /* List of all the devices we're handling */ 62 62 struct list_head portdevs; 63 63 64 - /* Number of devices this driver is handling */ 65 - unsigned int index; 66 - 67 64 /* 68 65 * This is used to keep track of the number of hvc consoles 69 66 * spawned by this driver. This number is given as the first ··· 165 168 166 169 /* Array of per-port IO virtqueues */ 167 170 struct virtqueue **in_vqs, **out_vqs; 168 - 169 - /* Used for numbering devices for sysfs and debugfs */ 170 - unsigned int drv_index; 171 171 172 172 /* Major number for this device. Ports will be created as minors. */ 173 173 int chr_major; ··· 1409 1415 } 1410 1416 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, 1411 1417 devt, port, "vport%up%u", 1412 - port->portdev->drv_index, id); 1418 + port->portdev->vdev->index, id); 1413 1419 if (IS_ERR(port->dev)) { 1414 1420 err = PTR_ERR(port->dev); 1415 1421 dev_err(&port->portdev->vdev->dev, ··· 1436 1442 * rproc_serial does not want the console port, only 1437 1443 * the generic port implementation. 1438 1444 */ 1439 - port->host_connected = true; 1445 + port->host_connected = port->guest_connected = true; 1440 1446 else if (!use_multiport(port->portdev)) { 1441 1447 /* 1442 1448 * If we're not using multiport support, ··· 1464 1470 * inspect a port's state at any time 1465 1471 */ 1466 1472 sprintf(debugfs_name, "vport%up%u", 1467 - port->portdev->drv_index, id); 1473 + port->portdev->vdev->index, id); 1468 1474 port->debugfs_file = debugfs_create_file(debugfs_name, 0444, 1469 1475 pdrvdata.debugfs_dir, 1470 1476 port, ··· 1952 1958 portdev->vdev = vdev; 1953 1959 vdev->priv = portdev; 1954 1960 1955 - spin_lock_irq(&pdrvdata_lock); 1956 - portdev->drv_index = pdrvdata.index++; 1957 - spin_unlock_irq(&pdrvdata_lock); 1958 - 1959 1961 portdev->chr_major = register_chrdev(0, "virtio-portsdev", 1960 1962 &portdev_fops); 1961 1963 if (portdev->chr_major < 0) { 1962 1964 dev_err(&vdev->dev, 1963 1965 "Error %d registering chrdev for device %u\n", 1964 - portdev->chr_major, portdev->drv_index); 1966 + portdev->chr_major, vdev->index); 1965 1967 err = portdev->chr_major; 1966 1968 goto free; 1967 1969 }
+1 -1
drivers/lguest/lguest_device.c
··· 396 396 } 397 397 398 398 /* The ops structure which hooks everything together. */ 399 - static struct virtio_config_ops lguest_config_ops = { 399 + static const struct virtio_config_ops lguest_config_ops = { 400 400 .get_features = lg_get_features, 401 401 .finalize_features = lg_finalize_features, 402 402 .get = lg_get,
+1 -11
drivers/net/virtio_net.c
··· 1736 1736 #endif 1737 1737 }; 1738 1738 1739 - static int __init init(void) 1740 - { 1741 - return register_virtio_driver(&virtio_net_driver); 1742 - } 1743 - 1744 - static void __exit fini(void) 1745 - { 1746 - unregister_virtio_driver(&virtio_net_driver); 1747 - } 1748 - module_init(init); 1749 - module_exit(fini); 1739 + module_virtio_driver(virtio_net_driver); 1750 1740 1751 1741 MODULE_DEVICE_TABLE(virtio, id_table); 1752 1742 MODULE_DESCRIPTION("Virtio network driver");
+1 -1
drivers/remoteproc/remoteproc_virtio.c
··· 222 222 rvdev->gfeatures = vdev->features[0]; 223 223 } 224 224 225 - static struct virtio_config_ops rproc_virtio_config_ops = { 225 + static const struct virtio_config_ops rproc_virtio_config_ops = { 226 226 .get_features = rproc_virtio_get_features, 227 227 .finalize_features = rproc_virtio_finalize_features, 228 228 .find_vqs = rproc_virtio_find_vqs,
+1 -1
drivers/s390/kvm/kvm_virtio.c
··· 275 275 /* 276 276 * The config ops structure as defined by virtio config 277 277 */ 278 - static struct virtio_config_ops kvm_vq_configspace_ops = { 278 + static const struct virtio_config_ops kvm_vq_configspace_ops = { 279 279 .get_features = kvm_get_features, 280 280 .finalize_features = kvm_finalize_features, 281 281 .get = kvm_get,
+1 -12
drivers/virtio/virtio_balloon.c
··· 560 560 #endif 561 561 }; 562 562 563 - static int __init init(void) 564 - { 565 - return register_virtio_driver(&virtio_balloon_driver); 566 - } 567 - 568 - static void __exit fini(void) 569 - { 570 - unregister_virtio_driver(&virtio_balloon_driver); 571 - } 572 - module_init(init); 573 - module_exit(fini); 574 - 563 + module_virtio_driver(virtio_balloon_driver); 575 564 MODULE_DEVICE_TABLE(virtio, id_table); 576 565 MODULE_DESCRIPTION("Virtio balloon driver"); 577 566 MODULE_LICENSE("GPL");
+2 -2
drivers/virtio/virtio_mmio.c
··· 75 75 * 76 76 * 0x050 W QueueNotify Queue notifier 77 77 * 0x060 R InterruptStatus Interrupt status register 78 - * 0x060 W InterruptACK Interrupt acknowledge register 78 + * 0x064 W InterruptACK Interrupt acknowledge register 79 79 * 0x070 RW Status Device status register 80 80 * 81 81 * 0x100+ RW Device-specific configuration space ··· 423 423 return vm_dev->pdev->name; 424 424 } 425 425 426 - static struct virtio_config_ops virtio_mmio_config_ops = { 426 + static const struct virtio_config_ops virtio_mmio_config_ops = { 427 427 .get = vm_get, 428 428 .set = vm_set, 429 429 .get_status = vm_get_status,
+4 -4
drivers/virtio/virtio_pci.c
··· 91 91 }; 92 92 93 93 /* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ 94 - static struct pci_device_id virtio_pci_id_table[] = { 95 - { 0x1af4, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 96 - { 0 }, 94 + static DEFINE_PCI_DEVICE_TABLE(virtio_pci_id_table) = { 95 + { PCI_DEVICE(0x1af4, PCI_ANY_ID) }, 96 + { 0 } 97 97 }; 98 98 99 99 MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); ··· 652 652 return 0; 653 653 } 654 654 655 - static struct virtio_config_ops virtio_pci_config_ops = { 655 + static const struct virtio_config_ops virtio_pci_config_ops = { 656 656 .get = vp_get, 657 657 .set = vp_set, 658 658 .get_status = vp_get_status,
+10 -1
include/linux/virtio.h
··· 78 78 int index; 79 79 struct device dev; 80 80 struct virtio_device_id id; 81 - struct virtio_config_ops *config; 81 + const struct virtio_config_ops *config; 82 82 struct list_head vqs; 83 83 /* Note that this is a Linux set_bit-style bitmap. */ 84 84 unsigned long features[1]; ··· 126 126 127 127 int register_virtio_driver(struct virtio_driver *drv); 128 128 void unregister_virtio_driver(struct virtio_driver *drv); 129 + 130 + /* module_virtio_driver() - Helper macro for drivers that don't do 131 + * anything special in module init/exit. This eliminates a lot of 132 + * boilerplate. Each module may only use this macro once, and 133 + * calling it replaces module_init() and module_exit() 134 + */ 135 + #define module_virtio_driver(__virtio_driver) \ 136 + module_driver(__virtio_driver, register_virtio_driver, \ 137 + unregister_virtio_driver) 129 138 #endif /* _LINUX_VIRTIO_H */