]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/gma500: Managed device release
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 20 Sep 2021 14:10:51 +0000 (16:10 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Thu, 23 Sep 2021 07:40:47 +0000 (09:40 +0200)
Set up a clean-up action to automatically release device resources
during driver shutdown. Remove manual release code.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210920141051.30988-6-tzimmermann@suse.de
drivers/gpu/drm/gma500/psb_drv.c

index cef9fb6a06d23d17375f573f3a88f5a026245140..3d036d2a3b299ef0381c2aa318655d9efdcdf6d1 100644 (file)
@@ -220,6 +220,13 @@ static void psb_driver_unload(struct drm_device *dev)
        gma_power_uninit(dev);
 }
 
+static void psb_device_release(void *data)
+{
+       struct drm_device *dev = data;
+
+       psb_driver_unload(dev);
+}
+
 static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 {
        struct pci_dev *pdev = to_pci_dev(dev->dev);
@@ -400,8 +407,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
        pm_runtime_enable(dev->dev);
        pm_runtime_set_active(dev->dev);
 #endif
-       /* Intel drm driver load is done, continue doing pvr load */
-       return 0;
+
+       return devm_add_action_or_reset(dev->dev, psb_device_release, dev);
+
 out_err:
        psb_driver_unload(dev);
        return ret;
@@ -457,13 +465,9 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        ret = drm_dev_register(dev, ent->driver_data);
        if (ret)
-               goto err_psb_driver_unload;
+               return ret;
 
        return 0;
-
-err_psb_driver_unload:
-       psb_driver_unload(dev);
-       return ret;
 }
 
 static void psb_pci_remove(struct pci_dev *pdev)
@@ -471,7 +475,6 @@ static void psb_pci_remove(struct pci_dev *pdev)
        struct drm_device *dev = pci_get_drvdata(pdev);
 
        drm_dev_unregister(dev);
-       psb_driver_unload(dev);
 }
 
 static const struct dev_pm_ops psb_pm_ops = {