summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ast/ast_main.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2020-07-30 15:52:03 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2020-08-03 09:04:28 +0200
commite0f5a738cfe572bed3deb08fab0b5273b9535b74 (patch)
tree32dd34e08f829c4b08d4686b62f9925a6edc8765 /drivers/gpu/drm/ast/ast_main.c
parentdrm/ast: Don't use ast->dev if dev is available (diff)
downloadlinux-e0f5a738cfe572bed3deb08fab0b5273b9535b74.tar.xz
linux-e0f5a738cfe572bed3deb08fab0b5273b9535b74.zip
drm/ast: Embed struct drm_device in struct ast_private
Turns struct ast_private into a subclass of struct drm_device by embedding the latter. This allows for using DRM's managed device allocation. The use of struct drm_device.dev_private is deprecated. The patch converts the last remaining users to to_ast_private(). Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-7-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast/ast_main.c')
-rw-r--r--drivers/gpu/drm/ast/ast_main.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 8d46166f8462..792fb7f616ec 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -388,25 +388,17 @@ struct ast_private *ast_device_create(struct drm_driver *drv,
bool need_post;
int ret = 0;
- dev = drm_dev_alloc(drv, &pdev->dev);
- if (IS_ERR(dev))
- return ERR_CAST(dev);
+ ast = devm_drm_dev_alloc(&pdev->dev, drv, struct ast_private, base);
+ if (IS_ERR(ast))
+ return ast;
+ dev = &ast->base;
dev->pdev = pdev;
pci_set_drvdata(pdev, dev);
- ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL);
- if (!ast)
- return ERR_PTR(-ENOMEM);
-
- dev->dev_private = ast;
- ast->dev = dev;
-
ast->regs = pci_iomap(dev->pdev, 1, 0);
- if (!ast->regs) {
- ret = -EIO;
- goto out_free;
- }
+ if (!ast->regs)
+ return ERR_PTR(-EIO);
/*
* If we don't have IO space at all, use MMIO now and
@@ -421,17 +413,16 @@ struct ast_private *ast_device_create(struct drm_driver *drv,
/* "map" IO regs if the above hasn't done so already */
if (!ast->ioregs) {
ast->ioregs = pci_iomap(dev->pdev, 2, 0);
- if (!ast->ioregs) {
- ret = -EIO;
- goto out_free;
- }
+ if (!ast->ioregs)
+ return ERR_PTR(-EIO);
}
ast_detect_chip(dev, &need_post);
ret = ast_get_dram_info(dev);
if (ret)
- goto out_free;
+ return ERR_PTR(ret);
+
drm_info(dev, "dram MCLK=%u Mhz type=%d bus_width=%d\n",
ast->mclk, ast->dram_type, ast->dram_bus_width);
@@ -440,29 +431,22 @@ struct ast_private *ast_device_create(struct drm_driver *drv,
ret = ast_mm_init(ast);
if (ret)
- goto out_free;
+ return ERR_PTR(ret);
ret = ast_mode_config_init(ast);
if (ret)
- goto out_free;
+ return ERR_PTR(ret);
return ast;
-
-out_free:
- kfree(ast);
- dev->dev_private = NULL;
- return ERR_PTR(ret);
}
void ast_device_destroy(struct ast_private *ast)
{
- struct drm_device *dev = ast->dev;
+ struct drm_device *dev = &ast->base;
/* enable standard VGA decode */
ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
ast_release_firmware(dev);
kfree(ast->dp501_fw_addr);
-
- kfree(ast);
}