Skip to contentSkip to conversation

drm/gma500: Call psb_driver_{load, unload}() before registering device

PATCH In review Thomas Zimmermann 2 participants 2 messages Dec 4, 2019 – Dec 5, 2019

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH 1/1 drm/gma500: Call psb_driver_{load, unload}() before registering device

The load/unload callbacks in struct drm_driver are deprecated. Remove them and call functions explicitly.

---
 drivers/gpu/drm/gma500/psb_drv.c | 43 +++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/gpu/drm/gma500/psb_drv.c +37 -6
index 192a39e52617..52591416f8fe 100644
@@ -23,7 +23,6 @@
 #include <drm/drm_file.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_irq.h>
-#include <drm/drm_pci.h>
 #include <drm/drm_pciids.h>
 #include <drm/drm_vblank.h>
 
@@ -427,14 +426,48 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
 
 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	return drm_get_pci_dev(pdev, ent, &driver);
-}
+	struct drm_device *dev;
+	int ret;
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		return ret;
+
+	dev = drm_dev_alloc(&driver, &pdev->dev);
+	if (IS_ERR(dev)) {
+		ret = PTR_ERR(dev);
+		goto err_pci_disable_device;
+	}
+
+	dev->pdev = pdev;
+	pci_set_drvdata(pdev, dev);
+
+	ret = psb_driver_load(dev, ent->driver_data);
+	if (ret)
+		goto err_drm_dev_put;
 
+	ret = drm_dev_register(dev, ent->driver_data);
+	if (ret)
+		goto err_psb_driver_unload;
+
+	return 0;
+
+err_psb_driver_unload:
+	psb_driver_unload(dev);
+err_drm_dev_put:
+	drm_dev_put(dev);
+err_pci_disable_device:
+	pci_disable_device(pdev);
+	return ret;
+}
 
 static void psb_pci_remove(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
-	drm_put_dev(dev);
+
+	drm_dev_unregister(dev);
+	psb_driver_unload(dev);
+	drm_dev_put(dev);
 }
 
 static const struct dev_pm_ops psb_pm_ops = {
@@ -467,8 +500,6 @@ static const struct file_operations psb_gem_fops = {
 
 static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM,
-	.load = psb_driver_load,
-	.unload = psb_driver_unload,
 	.lastclose = drm_fb_helper_lastclose,
 
 	.num_ioctls = ARRAY_SIZE(psb_ioctls),

--
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Acked-by on v1 1/1
#1 lore raw

Re: [PATCH] drm/gma500: Call psb_driver_{load,unload}() before registering device

Quoted 5 lines · Thomas Zimmermann

The load/unload callbacks in struct drm_driver are deprecated. Remove them and call functions explicitly.

Thanks for the patch.

-Patrik

Quoted 78 lines
---
 drivers/gpu/drm/gma500/psb_drv.c | 43 +++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/gpu/drm/gma500/psb_drv.c +37 -7
index 192a39e52617..52591416f8fe 100644
@@ -23,7 +23,6 @@
 #include <drm/drm_file.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_irq.h>
-#include <drm/drm_pci.h>
 #include <drm/drm_pciids.h>
 #include <drm/drm_vblank.h>
 
@@ -427,14 +426,48 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
 
 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-       return drm_get_pci_dev(pdev, ent, &driver);
-}
+       struct drm_device *dev;
+       int ret;
+
+       ret = pci_enable_device(pdev);
+       if (ret)
+               return ret;
+
+       dev = drm_dev_alloc(&driver, &pdev->dev);
+       if (IS_ERR(dev)) {
+               ret = PTR_ERR(dev);
+               goto err_pci_disable_device;
+       }
+
+       dev->pdev = pdev;
+       pci_set_drvdata(pdev, dev);
+
+       ret = psb_driver_load(dev, ent->driver_data);
+       if (ret)
+               goto err_drm_dev_put;
 
+       ret = drm_dev_register(dev, ent->driver_data);
+       if (ret)
+               goto err_psb_driver_unload;
+
+       return 0;
+
+err_psb_driver_unload:
+       psb_driver_unload(dev);
+err_drm_dev_put:
+       drm_dev_put(dev);
+err_pci_disable_device:
+       pci_disable_device(pdev);
+       return ret;
+}
 
 static void psb_pci_remove(struct pci_dev *pdev)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
-       drm_put_dev(dev);
+
+       drm_dev_unregister(dev);
+       psb_driver_unload(dev);
+       drm_dev_put(dev);
 }
 
 static const struct dev_pm_ops psb_pm_ops = {
@@ -467,8 +500,6 @@ static const struct file_operations psb_gem_fops = {
 
 static struct drm_driver driver = {
        .driver_features = DRIVER_MODESET | DRIVER_GEM,
-       .load = psb_driver_load,
-       .unload = psb_driver_unload,
        .lastclose = drm_fb_helper_lastclose,
 
        .num_ioctls = ARRAY_SIZE(psb_ioctls),
--
Quoted 2 lines

2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel