Commit fb7ba0c7 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/mgag200: Use managed device initialization

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200605135803.19811-15-tzimmermann@suse.de
parent 832eddf5
......@@ -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 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment