diff mbox series

[14/14] drm/mgag200: Use managed device initialization

Message ID 20200605135803.19811-15-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/mgag200: Use managed interfaces for auto-cleanup | expand

Commit Message

Thomas Zimmermann June 5, 2020, 1:58 p.m. UTC
The mgag200 driver now uses managed functions for DRM devices. The
individual helpers for modesetting and memory managed are already
covered, so only device allocation and initialization is left for
conversion.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 30 +++++++--------------------
 1 file changed, 8 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 6dfb7c5f79e3c..e19660f4a6371 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -95,27 +95,20 @@  mgag200_device_create(struct pci_dev *pdev, unsigned long flags)
 	struct mga_device *mdev;
 	int ret;
 
-	mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL);
-	if (!mdev)
-		return ERR_PTR(-ENOMEM);
+	mdev = devm_drm_dev_alloc(&pdev->dev, &mgag200_driver,
+				  struct mga_device, base);
+	if (IS_ERR(mdev))
+		return mdev;
 	dev = &mdev->base;
 
-	ret = drm_dev_init(dev, &mgag200_driver, &pdev->dev);
-	if (ret)
-		return ERR_PTR(ret);
-
 	dev->pdev = pdev;
 	pci_set_drvdata(pdev, dev);
 
 	ret = mgag200_device_init(mdev, flags);
 	if (ret)
-		goto err_drm_dev_put;
+		return ERR_PTR(ret);
 
 	return mdev;
-
-err_drm_dev_put:
-	drm_dev_put(dev);
-	return ERR_PTR(ret);
 }
 
 /*
@@ -151,23 +144,17 @@  mgag200_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return ret;
 
 	mdev = mgag200_device_create(pdev, ent->driver_data);
-	if (IS_ERR(mdev)) {
-		ret = PTR_ERR(mdev);
-		goto err_drm_dev_put;
-	}
+	if (IS_ERR(mdev))
+		return PTR_ERR(mdev);
 	dev = &mdev->base;
 
 	ret = drm_dev_register(dev, ent->driver_data);
 	if (ret)
-		goto err_drm_dev_put;
+		return ret;
 
 	drm_fbdev_generic_setup(dev, 0);
 
 	return 0;
-
-err_drm_dev_put:
-	drm_dev_put(dev);
-	return ret;
 }
 
 static void mgag200_pci_remove(struct pci_dev *pdev)
@@ -175,7 +162,6 @@  static void mgag200_pci_remove(struct pci_dev *pdev)
 	struct drm_device *dev = pci_get_drvdata(pdev);
 
 	drm_dev_unregister(dev);
-	drm_dev_put(dev);
 }
 
 static struct pci_driver mgag200_pci_driver = {