aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 17:49:12 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 17:49:12 -0500
commit3c834b6f41fa21a48389b13c3bf63aa8df1d7080 (patch)
tree126447276497510f44277e8442715e103e2cb85a
parent515d01f7726b9ba4838787d247115e1b259e1cc7 (diff)
parent8078db789a92b10ff6e2d713231b5367e014c53b (diff)
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.
-rw-r--r--drivers/char/hw_random/virtio-rng.c13
-rw-r--r--drivers/char/virtio_console.c18
-rw-r--r--drivers/lguest/lguest_device.c2
-rw-r--r--drivers/net/virtio_net.c12
-rw-r--r--drivers/remoteproc/remoteproc_virtio.c2
-rw-r--r--drivers/s390/kvm/kvm_virtio.c2
-rw-r--r--drivers/virtio/virtio_balloon.c13
-rw-r--r--drivers/virtio/virtio_mmio.c4
-rw-r--r--drivers/virtio/virtio_pci.c8
-rw-r--r--include/linux/virtio.h11
10 files changed, 26 insertions, 59 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index b65c10395959..10fd71ccf587 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -154,18 +154,7 @@ static struct virtio_driver virtio_rng_driver = {
154#endif 154#endif
155}; 155};
156 156
157static int __init init(void) 157module_virtio_driver(virtio_rng_driver);
158{
159 return register_virtio_driver(&virtio_rng_driver);
160}
161
162static void __exit fini(void)
163{
164 unregister_virtio_driver(&virtio_rng_driver);
165}
166module_init(init);
167module_exit(fini);
168
169MODULE_DEVICE_TABLE(virtio, id_table); 158MODULE_DEVICE_TABLE(virtio, id_table);
170MODULE_DESCRIPTION("Virtio random number driver"); 159MODULE_DESCRIPTION("Virtio random number driver");
171MODULE_LICENSE("GPL"); 160MODULE_LICENSE("GPL");
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index ee4dbeafb377..e905d5f53051 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -61,9 +61,6 @@ struct ports_driver_data {
61 /* List of all the devices we're handling */ 61 /* List of all the devices we're handling */
62 struct list_head portdevs; 62 struct list_head portdevs;
63 63
64 /* Number of devices this driver is handling */
65 unsigned int index;
66
67 /* 64 /*
68 * This is used to keep track of the number of hvc consoles 65 * This is used to keep track of the number of hvc consoles
69 * spawned by this driver. This number is given as the first 66 * spawned by this driver. This number is given as the first
@@ -169,9 +166,6 @@ struct ports_device {
169 /* Array of per-port IO virtqueues */ 166 /* Array of per-port IO virtqueues */
170 struct virtqueue **in_vqs, **out_vqs; 167 struct virtqueue **in_vqs, **out_vqs;
171 168
172 /* Used for numbering devices for sysfs and debugfs */
173 unsigned int drv_index;
174
175 /* Major number for this device. Ports will be created as minors. */ 169 /* Major number for this device. Ports will be created as minors. */
176 int chr_major; 170 int chr_major;
177}; 171};
@@ -1415,7 +1409,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1415 } 1409 }
1416 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, 1410 port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,
1417 devt, port, "vport%up%u", 1411 devt, port, "vport%up%u",
1418 port->portdev->drv_index, id); 1412 port->portdev->vdev->index, id);
1419 if (IS_ERR(port->dev)) { 1413 if (IS_ERR(port->dev)) {
1420 err = PTR_ERR(port->dev); 1414 err = PTR_ERR(port->dev);
1421 dev_err(&port->portdev->vdev->dev, 1415 dev_err(&port->portdev->vdev->dev,
@@ -1442,7 +1436,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1442 * rproc_serial does not want the console port, only 1436 * rproc_serial does not want the console port, only
1443 * the generic port implementation. 1437 * the generic port implementation.
1444 */ 1438 */
1445 port->host_connected = true; 1439 port->host_connected = port->guest_connected = true;
1446 else if (!use_multiport(port->portdev)) { 1440 else if (!use_multiport(port->portdev)) {
1447 /* 1441 /*
1448 * If we're not using multiport support, 1442 * If we're not using multiport support,
@@ -1470,7 +1464,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1470 * inspect a port's state at any time 1464 * inspect a port's state at any time
1471 */ 1465 */
1472 sprintf(debugfs_name, "vport%up%u", 1466 sprintf(debugfs_name, "vport%up%u",
1473 port->portdev->drv_index, id); 1467 port->portdev->vdev->index, id);
1474 port->debugfs_file = debugfs_create_file(debugfs_name, 0444, 1468 port->debugfs_file = debugfs_create_file(debugfs_name, 0444,
1475 pdrvdata.debugfs_dir, 1469 pdrvdata.debugfs_dir,
1476 port, 1470 port,
@@ -1958,16 +1952,12 @@ static int virtcons_probe(struct virtio_device *vdev)
1958 portdev->vdev = vdev; 1952 portdev->vdev = vdev;
1959 vdev->priv = portdev; 1953 vdev->priv = portdev;
1960 1954
1961 spin_lock_irq(&pdrvdata_lock);
1962 portdev->drv_index = pdrvdata.index++;
1963 spin_unlock_irq(&pdrvdata_lock);
1964
1965 portdev->chr_major = register_chrdev(0, "virtio-portsdev", 1955 portdev->chr_major = register_chrdev(0, "virtio-portsdev",
1966 &portdev_fops); 1956 &portdev_fops);
1967 if (portdev->chr_major < 0) { 1957 if (portdev->chr_major < 0) {
1968 dev_err(&vdev->dev, 1958 dev_err(&vdev->dev,
1969 "Error %d registering chrdev for device %u\n", 1959 "Error %d registering chrdev for device %u\n",
1970 portdev->chr_major, portdev->drv_index); 1960 portdev->chr_major, vdev->index);
1971 err = portdev->chr_major; 1961 err = portdev->chr_major;
1972 goto free; 1962 goto free;
1973 } 1963 }
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index fc92ccbd71dc..b3256ff0d426 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -396,7 +396,7 @@ static const char *lg_bus_name(struct virtio_device *vdev)
396} 396}
397 397
398/* The ops structure which hooks everything together. */ 398/* The ops structure which hooks everything together. */
399static struct virtio_config_ops lguest_config_ops = { 399static const struct virtio_config_ops lguest_config_ops = {
400 .get_features = lg_get_features, 400 .get_features = lg_get_features,
401 .finalize_features = lg_finalize_features, 401 .finalize_features = lg_finalize_features,
402 .get = lg_get, 402 .get = lg_get,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 192c91c8e799..57ac4b0294bc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1736,17 +1736,7 @@ static struct virtio_driver virtio_net_driver = {
1736#endif 1736#endif
1737}; 1737};
1738 1738
1739static int __init init(void) 1739module_virtio_driver(virtio_net_driver);
1740{
1741 return register_virtio_driver(&virtio_net_driver);
1742}
1743
1744static void __exit fini(void)
1745{
1746 unregister_virtio_driver(&virtio_net_driver);
1747}
1748module_init(init);
1749module_exit(fini);
1750 1740
1751MODULE_DEVICE_TABLE(virtio, id_table); 1741MODULE_DEVICE_TABLE(virtio, id_table);
1752MODULE_DESCRIPTION("Virtio network driver"); 1742MODULE_DESCRIPTION("Virtio network driver");
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 9e198e590675..afed9b7731c4 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -222,7 +222,7 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev)
222 rvdev->gfeatures = vdev->features[0]; 222 rvdev->gfeatures = vdev->features[0];
223} 223}
224 224
225static struct virtio_config_ops rproc_virtio_config_ops = { 225static const struct virtio_config_ops rproc_virtio_config_ops = {
226 .get_features = rproc_virtio_get_features, 226 .get_features = rproc_virtio_get_features,
227 .finalize_features = rproc_virtio_finalize_features, 227 .finalize_features = rproc_virtio_finalize_features,
228 .find_vqs = rproc_virtio_find_vqs, 228 .find_vqs = rproc_virtio_find_vqs,
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 03a15e016778..6711e65764b5 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -275,7 +275,7 @@ static const char *kvm_bus_name(struct virtio_device *vdev)
275/* 275/*
276 * The config ops structure as defined by virtio config 276 * The config ops structure as defined by virtio config
277 */ 277 */
278static struct virtio_config_ops kvm_vq_configspace_ops = { 278static const struct virtio_config_ops kvm_vq_configspace_ops = {
279 .get_features = kvm_get_features, 279 .get_features = kvm_get_features,
280 .finalize_features = kvm_finalize_features, 280 .finalize_features = kvm_finalize_features,
281 .get = kvm_get, 281 .get = kvm_get,
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 797e1c79a104..8dab163c5ef0 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -560,18 +560,7 @@ static struct virtio_driver virtio_balloon_driver = {
560#endif 560#endif
561}; 561};
562 562
563static int __init init(void) 563module_virtio_driver(virtio_balloon_driver);
564{
565 return register_virtio_driver(&virtio_balloon_driver);
566}
567
568static void __exit fini(void)
569{
570 unregister_virtio_driver(&virtio_balloon_driver);
571}
572module_init(init);
573module_exit(fini);
574
575MODULE_DEVICE_TABLE(virtio, id_table); 564MODULE_DEVICE_TABLE(virtio, id_table);
576MODULE_DESCRIPTION("Virtio balloon driver"); 565MODULE_DESCRIPTION("Virtio balloon driver");
577MODULE_LICENSE("GPL"); 566MODULE_LICENSE("GPL");
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 31f966f4d27f..1ba0d6831015 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -75,7 +75,7 @@
75 * 75 *
76 * 0x050 W QueueNotify Queue notifier 76 * 0x050 W QueueNotify Queue notifier
77 * 0x060 R InterruptStatus Interrupt status register 77 * 0x060 R InterruptStatus Interrupt status register
78 * 0x060 W InterruptACK Interrupt acknowledge register 78 * 0x064 W InterruptACK Interrupt acknowledge register
79 * 0x070 RW Status Device status register 79 * 0x070 RW Status Device status register
80 * 80 *
81 * 0x100+ RW Device-specific configuration space 81 * 0x100+ RW Device-specific configuration space
@@ -423,7 +423,7 @@ static const char *vm_bus_name(struct virtio_device *vdev)
423 return vm_dev->pdev->name; 423 return vm_dev->pdev->name;
424} 424}
425 425
426static struct virtio_config_ops virtio_mmio_config_ops = { 426static const struct virtio_config_ops virtio_mmio_config_ops = {
427 .get = vm_get, 427 .get = vm_get,
428 .set = vm_set, 428 .set = vm_set,
429 .get_status = vm_get_status, 429 .get_status = vm_get_status,
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 0c142892c105..a7ce73029f59 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -91,9 +91,9 @@ struct virtio_pci_vq_info
91}; 91};
92 92
93/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ 93/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */
94static struct pci_device_id virtio_pci_id_table[] = { 94static DEFINE_PCI_DEVICE_TABLE(virtio_pci_id_table) = {
95 { 0x1af4, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 95 { PCI_DEVICE(0x1af4, PCI_ANY_ID) },
96 { 0 }, 96 { 0 }
97}; 97};
98 98
99MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); 99MODULE_DEVICE_TABLE(pci, virtio_pci_id_table);
@@ -652,7 +652,7 @@ static int vp_set_vq_affinity(struct virtqueue *vq, int cpu)
652 return 0; 652 return 0;
653} 653}
654 654
655static struct virtio_config_ops virtio_pci_config_ops = { 655static const struct virtio_config_ops virtio_pci_config_ops = {
656 .get = vp_get, 656 .get = vp_get,
657 .set = vp_set, 657 .set = vp_set,
658 .get_status = vp_get_status, 658 .get_status = vp_get_status,
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index cf8adb1f5b2c..ff6714e6d0f5 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -78,7 +78,7 @@ struct virtio_device {
78 int index; 78 int index;
79 struct device dev; 79 struct device dev;
80 struct virtio_device_id id; 80 struct virtio_device_id id;
81 struct virtio_config_ops *config; 81 const struct virtio_config_ops *config;
82 struct list_head vqs; 82 struct list_head vqs;
83 /* Note that this is a Linux set_bit-style bitmap. */ 83 /* Note that this is a Linux set_bit-style bitmap. */
84 unsigned long features[1]; 84 unsigned long features[1];
@@ -126,4 +126,13 @@ static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv)
126 126
127int register_virtio_driver(struct virtio_driver *drv); 127int register_virtio_driver(struct virtio_driver *drv);
128void unregister_virtio_driver(struct virtio_driver *drv); 128void 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#endif /* _LINUX_VIRTIO_H */ 138#endif /* _LINUX_VIRTIO_H */