drm/ast: Avoid upcasting to struct ast_device
Several functions receive an instance of struct drm_device only to upcast it to struct ast_device. Improve type safety by passing the AST device directly. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240911115347.899148-11-tzimmermann@suse.de
This commit is contained in:
@@ -396,7 +396,7 @@ static int ast_drm_thaw(struct drm_device *dev)
|
|||||||
ast_enable_vga(ast->ioregs);
|
ast_enable_vga(ast->ioregs);
|
||||||
ast_open_key(ast->ioregs);
|
ast_open_key(ast->ioregs);
|
||||||
ast_enable_mmio(dev->dev, ast->ioregs);
|
ast_enable_mmio(dev->dev, ast->ioregs);
|
||||||
ast_post_gpu(dev);
|
ast_post_gpu(ast);
|
||||||
|
|
||||||
return drm_mode_config_helper_resume(dev);
|
return drm_mode_config_helper_resume(dev);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ int ast_mode_config_init(struct ast_device *ast);
|
|||||||
int ast_mm_init(struct ast_device *ast);
|
int ast_mm_init(struct ast_device *ast);
|
||||||
|
|
||||||
/* ast post */
|
/* ast post */
|
||||||
void ast_post_gpu(struct drm_device *dev);
|
void ast_post_gpu(struct ast_device *ast);
|
||||||
u32 ast_mindwm(struct ast_device *ast, u32 r);
|
u32 ast_mindwm(struct ast_device *ast, u32 r);
|
||||||
void ast_moutdwm(struct ast_device *ast, u32 r, u32 v);
|
void ast_moutdwm(struct ast_device *ast, u32 r, u32 v);
|
||||||
void ast_patch_ahb_2500(void __iomem *regs);
|
void ast_patch_ahb_2500(void __iomem *regs);
|
||||||
|
|||||||
@@ -132,10 +132,10 @@ static void ast_detect_tx_chip(struct ast_device *ast, bool need_post)
|
|||||||
drm_info(dev, "Using %s\n", info_str[ast->tx_chip]);
|
drm_info(dev, "Using %s\n", info_str[ast->tx_chip]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ast_get_dram_info(struct drm_device *dev)
|
static int ast_get_dram_info(struct ast_device *ast)
|
||||||
{
|
{
|
||||||
|
struct drm_device *dev = &ast->base;
|
||||||
struct device_node *np = dev->dev->of_node;
|
struct device_node *np = dev->dev->of_node;
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
|
||||||
uint32_t mcr_cfg, mcr_scu_mpll, mcr_scu_strap;
|
uint32_t mcr_cfg, mcr_scu_mpll, mcr_scu_strap;
|
||||||
uint32_t denum, num, div, ref_pll, dsel;
|
uint32_t denum, num, div, ref_pll, dsel;
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ struct drm_device *ast_device_create(struct pci_dev *pdev,
|
|||||||
ast_detect_widescreen(ast);
|
ast_detect_widescreen(ast);
|
||||||
ast_detect_tx_chip(ast, need_post);
|
ast_detect_tx_chip(ast, need_post);
|
||||||
|
|
||||||
ret = ast_get_dram_info(dev);
|
ret = ast_get_dram_info(ast);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ struct drm_device *ast_device_create(struct pci_dev *pdev,
|
|||||||
ast->mclk, ast->dram_type, ast->dram_bus_width);
|
ast->mclk, ast->dram_type, ast->dram_bus_width);
|
||||||
|
|
||||||
if (need_post)
|
if (need_post)
|
||||||
ast_post_gpu(dev);
|
ast_post_gpu(ast);
|
||||||
|
|
||||||
ret = ast_mm_init(ast);
|
ret = ast_mm_init(ast);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|||||||
@@ -1287,9 +1287,9 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
|
|||||||
.atomic_destroy_state = ast_crtc_atomic_destroy_state,
|
.atomic_destroy_state = ast_crtc_atomic_destroy_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ast_crtc_init(struct drm_device *dev)
|
static int ast_crtc_init(struct ast_device *ast)
|
||||||
{
|
{
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
struct drm_device *dev = &ast->base;
|
||||||
struct drm_crtc *crtc = &ast->crtc;
|
struct drm_crtc *crtc = &ast->crtc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -1396,7 +1396,7 @@ int ast_mode_config_init(struct ast_device *ast)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = ast_crtc_init(dev);
|
ret = ast_crtc_init(ast);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
@@ -34,16 +34,14 @@
|
|||||||
#include "ast_dram_tables.h"
|
#include "ast_dram_tables.h"
|
||||||
#include "ast_drv.h"
|
#include "ast_drv.h"
|
||||||
|
|
||||||
static void ast_post_chip_2300(struct drm_device *dev);
|
static void ast_post_chip_2300(struct ast_device *ast);
|
||||||
static void ast_post_chip_2500(struct drm_device *dev);
|
static void ast_post_chip_2500(struct ast_device *ast);
|
||||||
|
|
||||||
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
|
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
|
||||||
static const u8 extreginfo_ast2300[] = { 0x0f, 0x04, 0x1f, 0xff };
|
static const u8 extreginfo_ast2300[] = { 0x0f, 0x04, 0x1f, 0xff };
|
||||||
|
|
||||||
static void
|
static void ast_set_def_ext_reg(struct ast_device *ast)
|
||||||
ast_set_def_ext_reg(struct drm_device *dev)
|
|
||||||
{
|
{
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
|
||||||
u8 i, index, reg;
|
u8 i, index, reg;
|
||||||
const u8 *ext_reg_info;
|
const u8 *ext_reg_info;
|
||||||
|
|
||||||
@@ -252,9 +250,8 @@ cbr_start:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ast_init_dram_reg(struct drm_device *dev)
|
static void ast_init_dram_reg(struct ast_device *ast)
|
||||||
{
|
{
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
|
||||||
u8 j;
|
u8 j;
|
||||||
u32 data, temp, i;
|
u32 data, temp, i;
|
||||||
const struct ast_dramstruct *dram_reg_info;
|
const struct ast_dramstruct *dram_reg_info;
|
||||||
@@ -343,22 +340,20 @@ static void ast_init_dram_reg(struct drm_device *dev)
|
|||||||
} while ((j & 0x40) == 0);
|
} while ((j & 0x40) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_post_gpu(struct drm_device *dev)
|
void ast_post_gpu(struct ast_device *ast)
|
||||||
{
|
{
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
ast_set_def_ext_reg(ast);
|
||||||
|
|
||||||
ast_set_def_ext_reg(dev);
|
|
||||||
|
|
||||||
if (IS_AST_GEN7(ast)) {
|
if (IS_AST_GEN7(ast)) {
|
||||||
if (ast->tx_chip == AST_TX_ASTDP)
|
if (ast->tx_chip == AST_TX_ASTDP)
|
||||||
ast_dp_launch(ast);
|
ast_dp_launch(ast);
|
||||||
} else if (ast->config_mode == ast_use_p2a) {
|
} else if (ast->config_mode == ast_use_p2a) {
|
||||||
if (IS_AST_GEN6(ast))
|
if (IS_AST_GEN6(ast))
|
||||||
ast_post_chip_2500(dev);
|
ast_post_chip_2500(ast);
|
||||||
else if (IS_AST_GEN5(ast) || IS_AST_GEN4(ast))
|
else if (IS_AST_GEN5(ast) || IS_AST_GEN4(ast))
|
||||||
ast_post_chip_2300(dev);
|
ast_post_chip_2300(ast);
|
||||||
else
|
else
|
||||||
ast_init_dram_reg(dev);
|
ast_init_dram_reg(ast);
|
||||||
|
|
||||||
ast_init_3rdtx(ast);
|
ast_init_3rdtx(ast);
|
||||||
} else {
|
} else {
|
||||||
@@ -1569,9 +1564,8 @@ ddr2_init_start:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ast_post_chip_2300(struct drm_device *dev)
|
static void ast_post_chip_2300(struct ast_device *ast)
|
||||||
{
|
{
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
|
||||||
struct ast2300_dram_param param;
|
struct ast2300_dram_param param;
|
||||||
u32 temp;
|
u32 temp;
|
||||||
u8 reg;
|
u8 reg;
|
||||||
@@ -2038,9 +2032,9 @@ void ast_patch_ahb_2500(void __iomem *regs)
|
|||||||
__ast_moutdwm(regs, 0x1e6e207c, 0x08000000); /* clear fast reset */
|
__ast_moutdwm(regs, 0x1e6e207c, 0x08000000); /* clear fast reset */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_post_chip_2500(struct drm_device *dev)
|
void ast_post_chip_2500(struct ast_device *ast)
|
||||||
{
|
{
|
||||||
struct ast_device *ast = to_ast_device(dev);
|
struct drm_device *dev = &ast->base;
|
||||||
u32 temp;
|
u32 temp;
|
||||||
u8 reg;
|
u8 reg;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user