diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-11 14:47:49 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-14 08:10:30 -0500 |
commit | 9a4253db0c4ea1b6b15aa289203bc0584298278e (patch) | |
tree | 2c3bc1790be312a8eb5747c71105e6b27c09b362 /drivers/virtio | |
parent | de2b48d581e522298eefa9c75abdcd87549a2465 (diff) |
virtio_pci: move probe to common file
It turns out this make everything easier.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_pci_common.c | 34 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_common.h | 6 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_legacy.c | 24 |
3 files changed, 38 insertions, 26 deletions
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 953057d84185..59d3685c31b4 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c | |||
@@ -458,7 +458,39 @@ static int virtio_pci_restore(struct device *dev) | |||
458 | return virtio_device_restore(&vp_dev->vdev); | 458 | return virtio_device_restore(&vp_dev->vdev); |
459 | } | 459 | } |
460 | 460 | ||
461 | const struct dev_pm_ops virtio_pci_pm_ops = { | 461 | static const struct dev_pm_ops virtio_pci_pm_ops = { |
462 | SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore) | 462 | SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore) |
463 | }; | 463 | }; |
464 | #endif | 464 | #endif |
465 | |||
466 | |||
467 | /* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ | ||
468 | static const struct pci_device_id virtio_pci_id_table[] = { | ||
469 | { PCI_DEVICE(0x1af4, PCI_ANY_ID) }, | ||
470 | { 0 } | ||
471 | }; | ||
472 | |||
473 | MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); | ||
474 | |||
475 | static int virtio_pci_probe(struct pci_dev *pci_dev, | ||
476 | const struct pci_device_id *id) | ||
477 | { | ||
478 | return virtio_pci_legacy_probe(pci_dev, id); | ||
479 | } | ||
480 | |||
481 | static void virtio_pci_remove(struct pci_dev *pci_dev) | ||
482 | { | ||
483 | virtio_pci_legacy_remove(pci_dev); | ||
484 | } | ||
485 | |||
486 | static struct pci_driver virtio_pci_driver = { | ||
487 | .name = "virtio-pci", | ||
488 | .id_table = virtio_pci_id_table, | ||
489 | .probe = virtio_pci_probe, | ||
490 | .remove = virtio_pci_remove, | ||
491 | #ifdef CONFIG_PM_SLEEP | ||
492 | .driver.pm = &virtio_pci_pm_ops, | ||
493 | #endif | ||
494 | }; | ||
495 | |||
496 | module_pci_driver(virtio_pci_driver); | ||
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h index 38d99adcc74a..adddb647b21d 100644 --- a/drivers/virtio/virtio_pci_common.h +++ b/drivers/virtio/virtio_pci_common.h | |||
@@ -128,8 +128,8 @@ const char *vp_bus_name(struct virtio_device *vdev); | |||
128 | int vp_set_vq_affinity(struct virtqueue *vq, int cpu); | 128 | int vp_set_vq_affinity(struct virtqueue *vq, int cpu); |
129 | void virtio_pci_release_dev(struct device *); | 129 | void virtio_pci_release_dev(struct device *); |
130 | 130 | ||
131 | #ifdef CONFIG_PM_SLEEP | 131 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, |
132 | extern const struct dev_pm_ops virtio_pci_pm_ops; | 132 | const struct pci_device_id *id); |
133 | #endif | 133 | void virtio_pci_legacy_remove(struct pci_dev *pci_dev); |
134 | 134 | ||
135 | #endif | 135 | #endif |
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index 2588252e5c1c..6c76f0f5658c 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c | |||
@@ -19,14 +19,6 @@ | |||
19 | 19 | ||
20 | #include "virtio_pci_common.h" | 20 | #include "virtio_pci_common.h" |
21 | 21 | ||
22 | /* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ | ||
23 | static const struct pci_device_id virtio_pci_id_table[] = { | ||
24 | { PCI_DEVICE(0x1af4, PCI_ANY_ID) }, | ||
25 | { 0 } | ||
26 | }; | ||
27 | |||
28 | MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); | ||
29 | |||
30 | /* virtio config->get_features() implementation */ | 22 | /* virtio config->get_features() implementation */ |
31 | static u64 vp_get_features(struct virtio_device *vdev) | 23 | static u64 vp_get_features(struct virtio_device *vdev) |
32 | { | 24 | { |
@@ -220,7 +212,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = { | |||
220 | }; | 212 | }; |
221 | 213 | ||
222 | /* the PCI probing function */ | 214 | /* the PCI probing function */ |
223 | static int virtio_pci_probe(struct pci_dev *pci_dev, | 215 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, |
224 | const struct pci_device_id *id) | 216 | const struct pci_device_id *id) |
225 | { | 217 | { |
226 | struct virtio_pci_device *vp_dev; | 218 | struct virtio_pci_device *vp_dev; |
@@ -300,7 +292,7 @@ out: | |||
300 | return err; | 292 | return err; |
301 | } | 293 | } |
302 | 294 | ||
303 | static void virtio_pci_remove(struct pci_dev *pci_dev) | 295 | void virtio_pci_legacy_remove(struct pci_dev *pci_dev) |
304 | { | 296 | { |
305 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); | 297 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); |
306 | 298 | ||
@@ -312,15 +304,3 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) | |||
312 | pci_disable_device(pci_dev); | 304 | pci_disable_device(pci_dev); |
313 | kfree(vp_dev); | 305 | kfree(vp_dev); |
314 | } | 306 | } |
315 | |||
316 | static struct pci_driver virtio_pci_driver = { | ||
317 | .name = "virtio-pci", | ||
318 | .id_table = virtio_pci_id_table, | ||
319 | .probe = virtio_pci_probe, | ||
320 | .remove = virtio_pci_remove, | ||
321 | #ifdef CONFIG_PM_SLEEP | ||
322 | .driver.pm = &virtio_pci_pm_ops, | ||
323 | #endif | ||
324 | }; | ||
325 | |||
326 | module_pci_driver(virtio_pci_driver); | ||