aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ast/ast_main.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2020-07-30 15:52:06 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2020-08-03 09:05:00 +0200
commitcff0adca1edd6eb2bc6116e4d83e442f372cca64 (patch)
tree315ee5445a9b730048c97846ee01bb005e8a4903 /drivers/gpu/drm/ast/ast_main.c
parent4bc85b82c8ba5cfad6d750748d36e2b852fad80d (diff)
downloadlinux-cff0adca1edd6eb2bc6116e4d83e442f372cca64.tar.gz
drm/ast: Managed device release
This turns the ast's device cleanup code into a managed release helper function. Note that the code uses devres helpers. The release function switches the device back to VGA mode and therefore runs during HW device cleanup; not at DRM device cleanup. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-10-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast/ast_main.c')
-rw-r--r--drivers/gpu/drm/ast/ast_main.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 67e20727d82d..d62749a10cdd 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -380,6 +380,18 @@ static int ast_get_dram_info(struct drm_device *dev)
return 0;
}
+/*
+ * Run this function as part of the HW device cleanup; not
+ * when the DRM device gets released.
+ */
+static void ast_device_release(void *data)
+{
+ struct ast_private *ast = data;
+
+ /* enable standard VGA decode */
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
+}
+
struct ast_private *ast_device_create(struct drm_driver *drv,
struct pci_dev *pdev,
unsigned long flags)
@@ -438,11 +450,9 @@ struct ast_private *ast_device_create(struct drm_driver *drv,
if (ret)
return ERR_PTR(ret);
- return ast;
-}
+ ret = devm_add_action_or_reset(dev->dev, ast_device_release, ast);
+ if (ret)
+ return ERR_PTR(ret);
-void ast_device_destroy(struct ast_private *ast)
-{
- /* enable standard VGA decode */
- ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
+ return ast;
}