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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 30 +++++++--------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

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 = {
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux