diff options
Diffstat (limited to 'drivers/gpu/drm/vboxvideo/vbox_drv.c')
-rw-r--r-- | drivers/gpu/drm/vboxvideo/vbox_drv.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c index ac8f75db2ecd..cf2e3e6a2388 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c @@ -17,6 +17,7 @@ #include <drm/drm_fb_helper.h> #include <drm/drm_file.h> #include <drm/drm_ioctl.h> +#include <drm/drm_managed.h> #include "vbox_drv.h" @@ -45,28 +46,22 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) return ret; - vbox = kzalloc(sizeof(*vbox), GFP_KERNEL); - if (!vbox) - return -ENOMEM; - - ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev); - if (ret) { - kfree(vbox); - return ret; - } + vbox = devm_drm_dev_alloc(&pdev->dev, &driver, + struct vbox_private, ddev); + if (IS_ERR(vbox)) + return PTR_ERR(vbox); vbox->ddev.pdev = pdev; - vbox->ddev.dev_private = vbox; pci_set_drvdata(pdev, vbox); mutex_init(&vbox->hw_mutex); - ret = pci_enable_device(pdev); + ret = pcim_enable_device(pdev); if (ret) - goto err_dev_put; + return ret; ret = vbox_hw_init(vbox); if (ret) - goto err_pci_disable; + return ret; ret = vbox_mm_init(vbox); if (ret) @@ -80,14 +75,12 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto err_mode_fini; - ret = drm_fbdev_generic_setup(&vbox->ddev, 32); - if (ret) - goto err_irq_fini; - ret = drm_dev_register(&vbox->ddev, 0); if (ret) goto err_irq_fini; + drm_fbdev_generic_setup(&vbox->ddev, 32); + return 0; err_irq_fini: @@ -98,10 +91,6 @@ err_mm_fini: vbox_mm_fini(vbox); err_hw_fini: vbox_hw_fini(vbox); -err_pci_disable: - pci_disable_device(pdev); -err_dev_put: - drm_dev_put(&vbox->ddev); return ret; } @@ -114,7 +103,6 @@ static void vbox_pci_remove(struct pci_dev *pdev) vbox_mode_fini(vbox); vbox_mm_fini(vbox); vbox_hw_fini(vbox); - drm_dev_put(&vbox->ddev); } #ifdef CONFIG_PM_SLEEP |