]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/qxl: Use devm_drm_dev_alloc
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 15 Apr 2020 07:40:01 +0000 (09:40 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 28 Apr 2020 18:03:41 +0000 (20:03 +0200)
Also need to remove the drm_dev_put from the remove hook.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-27-daniel.vetter@ffwll.ch
drivers/gpu/drm/qxl/qxl_drv.c
drivers/gpu/drm/qxl/qxl_drv.h
drivers/gpu/drm/qxl/qxl_kms.c

index 09102e2efabc5e36d9d6eeff056bf92b06d07fd1..6b4ae4c5fb76abacefcf71e4f53cb72b32b5111e 100644 (file)
@@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                return -EINVAL; /* TODO: ENODEV ? */
        }
 
-       qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
-       if (!qdev)
+       qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
+                                 struct qxl_device, ddev);
+       if (IS_ERR(qdev)) {
+               pr_err("Unable to init drm dev");
                return -ENOMEM;
+       }
 
        ret = pci_enable_device(pdev);
        if (ret)
-               goto free_dev;
+               return ret;
 
        ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
        if (ret)
@@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                }
        }
 
-       ret = qxl_device_init(qdev, &qxl_driver, pdev);
+       ret = qxl_device_init(qdev, pdev);
        if (ret)
                goto put_vga;
 
@@ -128,8 +131,7 @@ put_vga:
                vga_put(pdev, VGA_RSRC_LEGACY_IO);
 disable_pci:
        pci_disable_device(pdev);
-free_dev:
-       kfree(qdev);
+
        return ret;
 }
 
@@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
        drm_atomic_helper_shutdown(dev);
        if (is_vga(pdev))
                vga_put(pdev, VGA_RSRC_LEGACY_IO);
-       drm_dev_put(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(qxl_fops);
index 435126facc9b01d9bf0af11f30e71cac4365c275..86ac191d92059970842595b38227c5463f120bc9 100644 (file)
@@ -276,8 +276,7 @@ struct qxl_device {
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
-int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
-                   struct pci_dev *pdev);
+int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
 void qxl_device_fini(struct qxl_device *qdev);
 
 int qxl_modeset_init(struct qxl_device *qdev);
index 9eed1a375f2409c6b4835f22d0256093cce2deff..91a34dd835d7b3d849e2aab0b1342817b4825602 100644 (file)
@@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
 }
 
 int qxl_device_init(struct qxl_device *qdev,
-                   struct drm_driver *drv,
                    struct pci_dev *pdev)
 {
        int r, sb;
 
-       r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
-       if (r) {
-               pr_err("Unable to init drm dev");
-               goto error;
-       }
-
        qdev->ddev.pdev = pdev;
        pci_set_drvdata(pdev, &qdev->ddev);
        qdev->ddev.dev_private = qdev;
-       drmm_add_final_kfree(&qdev->ddev, qdev);
 
        mutex_init(&qdev->gem.mutex);
        mutex_init(&qdev->update_area_mutex);
@@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
        qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
        if (!qdev->vram_mapping) {
                pr_err("Unable to create vram_mapping");
-               r = -ENOMEM;
-               goto error;
+               return -ENOMEM;
        }
 
        if (pci_resource_len(pdev, 4) > 0) {
@@ -293,7 +284,6 @@ surface_mapping_free:
        io_mapping_free(qdev->surface_mapping);
 vram_mapping_free:
        io_mapping_free(qdev->vram_mapping);
-error:
        return r;
 }