[PATCH 04/12] drm: provide a pci probe function for non modesetting devices
Sascha Hauer
s.hauer at pengutronix.de
Thu Feb 2 03:57:56 PST 2012
This way we do not need the legacy handcrafted probe mechanism
anymore and can remove it.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/gpu/drm/drm_pci.c | 41 +---------------------------------
drivers/gpu/drm/i810/i810_drv.c | 16 +++++++++++++
drivers/gpu/drm/mga/mga_drv.c | 16 +++++++++++++
drivers/gpu/drm/r128/r128_drv.c | 16 +++++++++++++
drivers/gpu/drm/savage/savage_drv.c | 16 +++++++++++++
drivers/gpu/drm/sis/sis_drv.c | 16 +++++++++++++
drivers/gpu/drm/tdfx/tdfx_drv.c | 16 +++++++++++++
7 files changed, 98 insertions(+), 39 deletions(-)
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index f2e8019..b53427e 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -363,8 +363,6 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
goto err_g4;
}
- list_add_tail(&dev->driver_item, &driver->device_list);
-
DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
driver->name, driver->major, driver->minor, driver->patchlevel,
driver->date, pci_name(pdev), dev->primary->index);
@@ -399,41 +397,12 @@ EXPORT_SYMBOL(drm_get_pci_dev);
*/
int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
{
- struct pci_dev *pdev = NULL;
- const struct pci_device_id *pid;
- int i;
-
DRM_DEBUG("\n");
INIT_LIST_HEAD(&driver->device_list);
driver->bus = &drm_pci_bus;
- if (driver->driver_features & DRIVER_MODESET)
- return pci_register_driver(pdriver);
-
- /* If not using KMS, fall back to stealth mode manual scanning. */
- for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
- pid = &pdriver->id_table[i];
-
- /* Loop around setting up a DRM device for each PCI device
- * matching our ID and device class. If we had the internal
- * function that pci_get_subsys and pci_get_class used, we'd
- * be able to just pass pid in instead of doing a two-stage
- * thing.
- */
- pdev = NULL;
- while ((pdev =
- pci_get_subsys(pid->vendor, pid->device, pid->subvendor,
- pid->subdevice, pdev)) != NULL) {
- if ((pdev->class & pid->class_mask) != pid->class)
- continue;
-
- /* stealth mode requires a manual probe */
- pci_dev_get(pdev);
- drm_get_pci_dev(pdev, pid, driver);
- }
- }
- return 0;
+ return pci_register_driver(pdriver);
}
#else
@@ -450,15 +419,9 @@ EXPORT_SYMBOL(drm_pci_init);
/*@}*/
void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
{
- struct drm_device *dev, *tmp;
DRM_DEBUG("\n");
- if (driver->driver_features & DRIVER_MODESET) {
- pci_unregister_driver(pdriver);
- } else {
- list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
- drm_put_dev(dev);
- }
+ pci_unregister_driver(pdriver);
DRM_INFO("Module unloaded\n");
}
EXPORT_SYMBOL(drm_pci_exit);
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index ec12f7d..94f0660 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -75,7 +75,23 @@ static struct drm_driver driver = {
.patchlevel = DRIVER_PATCHLEVEL,
};
+static int __devinit
+i810_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+static void
+i810_pci_remove(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+
+ drm_put_dev(dev);
+}
+
static struct pci_driver i810_pci_driver = {
+ .probe = i810_pci_probe,
+ .remove = i810_pci_remove,
.name = DRIVER_NAME,
.id_table = pciidlist,
};
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index f9a925d..45d848a 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -87,7 +87,23 @@ static struct drm_driver driver = {
.patchlevel = DRIVER_PATCHLEVEL,
};
+static int __devinit
+mga_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+static void
+mga_pci_remove(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+
+ drm_put_dev(dev);
+}
+
static struct pci_driver mga_pci_driver = {
+ .probe = mga_pci_probe,
+ .remove = mga_pci_remove,
.name = DRIVER_NAME,
.id_table = pciidlist,
};
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 6a5f439..257f8eb 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -88,7 +88,23 @@ int r128_driver_load(struct drm_device *dev, unsigned long flags)
return drm_vblank_init(dev, 1);
}
+static int __devinit
+r128_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+static void
+r128_pci_remove(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+
+ drm_put_dev(dev);
+}
+
static struct pci_driver r128_pci_driver = {
+ .probe = r128_pci_probe,
+ .remove = r128_pci_remove,
.name = DRIVER_NAME,
.id_table = pciidlist,
};
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 89afe0b..780270c 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -66,7 +66,23 @@ static struct drm_driver driver = {
.patchlevel = DRIVER_PATCHLEVEL,
};
+static int __devinit
+savage_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+static void
+savage_pci_remove(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+
+ drm_put_dev(dev);
+}
+
static struct pci_driver savage_pci_driver = {
+ .probe = savage_pci_probe,
+ .remove = savage_pci_remove,
.name = DRIVER_NAME,
.id_table = pciidlist,
};
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 573220c..8e3d39a 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -118,7 +118,23 @@ static struct drm_driver driver = {
.patchlevel = DRIVER_PATCHLEVEL,
};
+static int __devinit
+sis_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+static void
+sis_pci_remove(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+
+ drm_put_dev(dev);
+}
+
static struct pci_driver sis_pci_driver = {
+ .probe = sis_pci_probe,
+ .remove = sis_pci_remove,
.name = DRIVER_NAME,
.id_table = pciidlist,
};
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 1613c78..a863fdc 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -64,7 +64,23 @@ static struct drm_driver driver = {
.patchlevel = DRIVER_PATCHLEVEL,
};
+static int __devinit
+tdfx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ return drm_get_pci_dev(pdev, ent, &driver);
+}
+
+static void
+tdfx_pci_remove(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+
+ drm_put_dev(dev);
+}
+
static struct pci_driver tdfx_pci_driver = {
+ .probe = tdfx_pci_probe,
+ .remove = tdfx_pci_remove,
.name = DRIVER_NAME,
.id_table = pciidlist,
};
--
1.7.8.3
More information about the dri-devel
mailing list