staging: vboxvideo: Update driver to use drm_dev_register.
authorFabio Rafael da Rosa <fdr@pid42.net>
Mon, 4 Jun 2018 02:24:45 +0000 (23:24 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Jun 2018 07:05:13 +0000 (09:05 +0200)
The use of load and unload hooks is deprecated. DRM drivers should
use drm_dev_alloc|drm_dev_init and drm_dev_register for initialization
and publishing.

Signed-off-by: Fabio Rafael da Rosa <fdr@pid42.net>
Reviewed-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vboxvideo/TODO
drivers/staging/vboxvideo/vbox_drv.c
drivers/staging/vboxvideo/vbox_drv.h
drivers/staging/vboxvideo/vbox_main.c

index bd381d861ab3902975c24a30b1b48cee4caef71f..468eea856ca6491f323533514f8e96ffb46b7701 100644 (file)
@@ -1,6 +1,5 @@
 TODO:
 -Move the driver over to the atomic API
--Stop using old load / unload drm_driver hooks
 -Get a full review from the drm-maintainers on dri-devel done on this driver
 -Extend this TODO with the results of that review
 
index f6d26beffa543ea6a8164d8d8e0516593cce7ab3..da92c493f1577ab7d35da20c73dd70f052fffc77 100644 (file)
@@ -51,14 +51,42 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
 
 static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-       return drm_get_pci_dev(pdev, ent, &driver);
+       struct drm_device *dev = NULL;
+       int ret = 0;
+
+       dev = drm_dev_alloc(&driver, &pdev->dev);
+       if (IS_ERR(dev)) {
+               ret = PTR_ERR(dev);
+               goto err_drv_alloc;
+       }
+       dev->pdev = pdev;
+       pci_set_drvdata(pdev, dev);
+
+       ret = vbox_driver_load(dev);
+       if (ret)
+               goto err_vbox_driver_load;
+
+       ret = drm_dev_register(dev, 0);
+       if (ret)
+               goto err_drv_dev_register;
+
+       return ret;
+
+ err_drv_dev_register:
+       vbox_driver_unload(dev);
+ err_vbox_driver_load:
+       drm_dev_put(dev);
+ err_drv_alloc:
+       return ret;
 }
 
 static void vbox_pci_remove(struct pci_dev *pdev)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
 
-       drm_put_dev(dev);
+       drm_dev_unregister(dev);
+       vbox_driver_unload(dev);
+       drm_dev_put(dev);
 }
 
 static int vbox_drm_freeze(struct drm_device *dev)
@@ -227,8 +255,6 @@ static struct drm_driver driver = {
            DRIVER_PRIME,
        .dev_priv_size = 0,
 
-       .load = vbox_driver_load,
-       .unload = vbox_driver_unload,
        .lastclose = vbox_driver_lastclose,
        .master_set = vbox_master_set,
        .master_drop = vbox_master_drop,
index eeac4f0cb2c65027fd8de8ec76dfd12b5cbeee74..594f84272957ac9a657315fbbe5b1a87a2d36e48 100644 (file)
@@ -126,7 +126,7 @@ struct vbox_private {
 #undef CURSOR_PIXEL_COUNT
 #undef CURSOR_DATA_SIZE
 
-int vbox_driver_load(struct drm_device *dev, unsigned long flags);
+int vbox_driver_load(struct drm_device *dev);
 void vbox_driver_unload(struct drm_device *dev);
 void vbox_driver_lastclose(struct drm_device *dev);
 
index 9d2018cd544ecdc4e39c25067a54f644e6f5f86e..429f6a453619e32afa41e19dc9c235f704f0944d 100644 (file)
@@ -350,7 +350,7 @@ static void vbox_hw_fini(struct vbox_private *vbox)
        pci_iounmap(vbox->dev->pdev, vbox->guest_heap);
 }
 
-int vbox_driver_load(struct drm_device *dev, unsigned long flags)
+int vbox_driver_load(struct drm_device *dev)
 {
        struct vbox_private *vbox;
        int ret = 0;