Commit 4bc85b82 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Manage release of firmware backup memory

The ast driver keeps a backup copy of the DP501 encoder's firmware. This
patch adds managed release of the allocated memory.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-9-tzimmermann@suse.de
parent 2c0b6566
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <drm/drm_drv.h> #include <drm/drm_drv.h>
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
#include <drm/drm_gem_vram_helper.h> #include <drm/drm_gem_vram_helper.h>
#include <drm/drm_managed.h>
#include "ast_drv.h" #include "ast_drv.h"
...@@ -231,11 +232,11 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) ...@@ -231,11 +232,11 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
ast->tx_chip_type = AST_TX_SIL164; ast->tx_chip_type = AST_TX_SIL164;
break; break;
case 0x08: case 0x08:
ast->dp501_fw_addr = kzalloc(32*1024, GFP_KERNEL); ast->dp501_fw_addr = drmm_kzalloc(dev, 32*1024, GFP_KERNEL);
if (ast->dp501_fw_addr) { if (ast->dp501_fw_addr) {
/* backup firmware */ /* backup firmware */
if (ast_backup_fw(dev, ast->dp501_fw_addr, 32*1024)) { if (ast_backup_fw(dev, ast->dp501_fw_addr, 32*1024)) {
kfree(ast->dp501_fw_addr); drmm_kfree(dev, ast->dp501_fw_addr);
ast->dp501_fw_addr = NULL; ast->dp501_fw_addr = NULL;
} }
} }
...@@ -444,6 +445,4 @@ void ast_device_destroy(struct ast_private *ast) ...@@ -444,6 +445,4 @@ void ast_device_destroy(struct ast_private *ast)
{ {
/* enable standard VGA decode */ /* enable standard VGA decode */
ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04); ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
kfree(ast->dp501_fw_addr);
} }
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