]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Use devm_drm_dev_alloc
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 15 Apr 2020 07:40:13 +0000 (09:40 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 28 Apr 2020 18:51:33 +0000 (20:51 +0200)
Luckily we're already well set up in the main driver, with
drm_dev_put() being the last thing in both the unload error case and
the pci remove function.

Acked-by: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200415074034.175360-39-daniel.vetter@ffwll.ch
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_pci.c

index 2b5f13ca5ec428ff1e562753e89c12affccc45c7..43b4146c25f38da6b422a3f4e555abe783803d7b 100644 (file)
@@ -877,19 +877,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
                (struct intel_device_info *)ent->driver_data;
        struct intel_device_info *device_info;
        struct drm_i915_private *i915;
-       int err;
 
-       i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
-       if (!i915)
-               return ERR_PTR(-ENOMEM);
-
-       err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
-       if (err) {
-               kfree(i915);
-               return ERR_PTR(err);
-       }
-
-       drmm_add_final_kfree(&i915->drm, i915);
+       i915 = devm_drm_dev_alloc(&pdev->dev, &driver,
+                                 struct drm_i915_private, drm);
+       if (IS_ERR(i915))
+               return i915;
 
        i915->drm.pdev = pdev;
        pci_set_drvdata(pdev, i915);
@@ -1006,7 +998,6 @@ out_pci_disable:
        pci_disable_device(pdev);
 out_fini:
        i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
-       drm_dev_put(&i915->drm);
        return ret;
 }
 
index 2c80a0194c80dfcc4b655ebaf9890b9279222e70..0f8b439d6fd589f4178625df269c11c81e52ae0e 100644 (file)
@@ -920,8 +920,6 @@ static void i915_pci_remove(struct pci_dev *pdev)
 
        i915_driver_remove(i915);
        pci_set_drvdata(pdev, NULL);
-
-       drm_dev_put(&i915->drm);
 }
 
 /* is device_id present in comma separated list of ids */