Commit c2ed8844 authored by Christopher Harvey's avatar Christopher Harvey Committed by Dave Airlie

drm/mgag200: Convert to managed device resources where possible

Signed-off-by: default avatarChristopher Harvey <charvey@matrox.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 715f59cc
......@@ -249,7 +249,7 @@ int mgag200_fbdev_init(struct mga_device *mdev)
struct mga_fbdev *mfbdev;
int ret;
mfbdev = kzalloc(sizeof(struct mga_fbdev), GFP_KERNEL);
mfbdev = devm_kzalloc(mdev->dev->dev, sizeof(struct mga_fbdev), GFP_KERNEL);
if (!mfbdev)
return -ENOMEM;
......@@ -258,10 +258,9 @@ int mgag200_fbdev_init(struct mga_device *mdev)
ret = drm_fb_helper_init(mdev->dev, &mfbdev->helper,
mdev->num_crtc, MGAG200FB_CONN_LIMIT);
if (ret) {
kfree(mfbdev);
if (ret)
return ret;
}
drm_fb_helper_single_add_all_connectors(&mfbdev->helper);
/* disable all the possible outputs/crtcs before entering KMS mode */
......@@ -278,6 +277,4 @@ void mgag200_fbdev_fini(struct mga_device *mdev)
return;
mga_fbdev_destroy(mdev->dev, mdev->mfbdev);
kfree(mdev->mfbdev);
mdev->mfbdev = NULL;
}
......@@ -76,15 +76,6 @@ static const struct drm_mode_config_funcs mga_mode_funcs = {
.fb_create = mgag200_user_framebuffer_create,
};
/* Unmap the framebuffer from the core and release the memory */
static void mga_vram_fini(struct mga_device *mdev)
{
pci_iounmap(mdev->dev->pdev, mdev->rmmio);
mdev->rmmio = NULL;
if (mdev->mc.vram_base)
release_mem_region(mdev->mc.vram_base, mdev->mc.vram_window);
}
static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem)
{
int offset;
......@@ -140,7 +131,7 @@ static int mga_vram_init(struct mga_device *mdev)
remove_conflicting_framebuffers(aper, "mgafb", true);
kfree(aper);
if (!request_mem_region(mdev->mc.vram_base, mdev->mc.vram_window,
if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window,
"mgadrmfb_vram")) {
DRM_ERROR("can't reserve VRAM\n");
return -ENXIO;
......@@ -173,13 +164,13 @@ static int mgag200_device_init(struct drm_device *dev,
mdev->rmmio_base = pci_resource_start(mdev->dev->pdev, 1);
mdev->rmmio_size = pci_resource_len(mdev->dev->pdev, 1);
if (!request_mem_region(mdev->rmmio_base, mdev->rmmio_size,
if (!devm_request_mem_region(mdev->dev->dev, mdev->rmmio_base, mdev->rmmio_size,
"mgadrmfb_mmio")) {
DRM_ERROR("can't reserve mmio registers\n");
return -ENOMEM;
}
mdev->rmmio = pci_iomap(dev->pdev, 1, 0);
mdev->rmmio = pcim_iomap(dev->pdev, 1, 0);
if (mdev->rmmio == NULL)
return -ENOMEM;
......@@ -188,10 +179,8 @@ static int mgag200_device_init(struct drm_device *dev,
mdev->reg_1e24 = RREG32(0x1e24);
ret = mga_vram_init(mdev);
if (ret) {
release_mem_region(mdev->rmmio_base, mdev->rmmio_size);
if (ret)
return ret;
}
mdev->bpp_shifts[0] = 0;
mdev->bpp_shifts[1] = 1;
......@@ -200,12 +189,6 @@ static int mgag200_device_init(struct drm_device *dev,
return 0;
}
void mgag200_device_fini(struct mga_device *mdev)
{
release_mem_region(mdev->rmmio_base, mdev->rmmio_size);
mga_vram_fini(mdev);
}
/*
* Functions here will be called by the core once it's bound the driver to
* a PCI device
......@@ -217,7 +200,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
struct mga_device *mdev;
int r;
mdev = kzalloc(sizeof(struct mga_device), GFP_KERNEL);
mdev = devm_kzalloc(dev->dev, sizeof(struct mga_device), GFP_KERNEL);
if (mdev == NULL)
return -ENOMEM;
dev->dev_private = (void *)mdev;
......@@ -258,8 +241,6 @@ int mgag200_driver_unload(struct drm_device *dev)
mgag200_fbdev_fini(mdev);
drm_mode_config_cleanup(dev);
mgag200_mm_fini(mdev);
mgag200_device_fini(mdev);
kfree(mdev);
dev->dev_private = NULL;
return 0;
}
......
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