Skip to content

Commit

Permalink
virtio_pci: move probe to common file
Browse files Browse the repository at this point in the history
It turns out this make everything easier.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Michael S. Tsirkin committed Dec 14, 2014
1 parent de2b48d commit 9a4253d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
34 changes: 33 additions & 1 deletion drivers/virtio/virtio_pci_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,39 @@ static int virtio_pci_restore(struct device *dev)
return virtio_device_restore(&vp_dev->vdev);
}

const struct dev_pm_ops virtio_pci_pm_ops = {
static const struct dev_pm_ops virtio_pci_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore)
};
#endif


/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */
static const struct pci_device_id virtio_pci_id_table[] = {
{ PCI_DEVICE(0x1af4, PCI_ANY_ID) },
{ 0 }
};

MODULE_DEVICE_TABLE(pci, virtio_pci_id_table);

static int virtio_pci_probe(struct pci_dev *pci_dev,
const struct pci_device_id *id)
{
return virtio_pci_legacy_probe(pci_dev, id);
}

static void virtio_pci_remove(struct pci_dev *pci_dev)
{
virtio_pci_legacy_remove(pci_dev);
}

static struct pci_driver virtio_pci_driver = {
.name = "virtio-pci",
.id_table = virtio_pci_id_table,
.probe = virtio_pci_probe,
.remove = virtio_pci_remove,
#ifdef CONFIG_PM_SLEEP
.driver.pm = &virtio_pci_pm_ops,
#endif
};

module_pci_driver(virtio_pci_driver);
6 changes: 3 additions & 3 deletions drivers/virtio/virtio_pci_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ const char *vp_bus_name(struct virtio_device *vdev);
int vp_set_vq_affinity(struct virtqueue *vq, int cpu);
void virtio_pci_release_dev(struct device *);

#ifdef CONFIG_PM_SLEEP
extern const struct dev_pm_ops virtio_pci_pm_ops;
#endif
int virtio_pci_legacy_probe(struct pci_dev *pci_dev,
const struct pci_device_id *id);
void virtio_pci_legacy_remove(struct pci_dev *pci_dev);

#endif
24 changes: 2 additions & 22 deletions drivers/virtio/virtio_pci_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@

#include "virtio_pci_common.h"

/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */
static const struct pci_device_id virtio_pci_id_table[] = {
{ PCI_DEVICE(0x1af4, PCI_ANY_ID) },
{ 0 }
};

MODULE_DEVICE_TABLE(pci, virtio_pci_id_table);

/* virtio config->get_features() implementation */
static u64 vp_get_features(struct virtio_device *vdev)
{
Expand Down Expand Up @@ -220,7 +212,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
};

/* the PCI probing function */
static int virtio_pci_probe(struct pci_dev *pci_dev,
int virtio_pci_legacy_probe(struct pci_dev *pci_dev,
const struct pci_device_id *id)
{
struct virtio_pci_device *vp_dev;
Expand Down Expand Up @@ -300,7 +292,7 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
return err;
}

static void virtio_pci_remove(struct pci_dev *pci_dev)
void virtio_pci_legacy_remove(struct pci_dev *pci_dev)
{
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);

Expand All @@ -312,15 +304,3 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
pci_disable_device(pci_dev);
kfree(vp_dev);
}

static struct pci_driver virtio_pci_driver = {
.name = "virtio-pci",
.id_table = virtio_pci_id_table,
.probe = virtio_pci_probe,
.remove = virtio_pci_remove,
#ifdef CONFIG_PM_SLEEP
.driver.pm = &virtio_pci_pm_ops,
#endif
};

module_pci_driver(virtio_pci_driver);

0 comments on commit 9a4253d

Please sign in to comment.