Skip to content

Commit c1779a2

Browse files
committed
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
1 parent 0994ea1 commit c1779a2

5 files changed

Lines changed: 21 additions & 27 deletions

File tree

drivers/gpu/drm/ast/ast_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int ast_drm_thaw(struct drm_device *dev)
396396
ast_enable_vga(ast->ioregs);
397397
ast_open_key(ast->ioregs);
398398
ast_enable_mmio(dev->dev, ast->ioregs);
399-
ast_post_gpu(dev);
399+
ast_post_gpu(ast);
400400

401401
return drm_mode_config_helper_resume(dev);
402402
}

drivers/gpu/drm/ast/ast_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ int ast_mode_config_init(struct ast_device *ast);
446446
int ast_mm_init(struct ast_device *ast);
447447

448448
/* ast post */
449-
void ast_post_gpu(struct drm_device *dev);
449+
void ast_post_gpu(struct ast_device *ast);
450450
u32 ast_mindwm(struct ast_device *ast, u32 r);
451451
void ast_moutdwm(struct ast_device *ast, u32 r, u32 v);
452452
void ast_patch_ahb_2500(void __iomem *regs);

drivers/gpu/drm/ast/ast_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ static void ast_detect_tx_chip(struct ast_device *ast, bool need_post)
132132
drm_info(dev, "Using %s\n", info_str[ast->tx_chip]);
133133
}
134134

135-
static int ast_get_dram_info(struct drm_device *dev)
135+
static int ast_get_dram_info(struct ast_device *ast)
136136
{
137+
struct drm_device *dev = &ast->base;
137138
struct device_node *np = dev->dev->of_node;
138-
struct ast_device *ast = to_ast_device(dev);
139139
uint32_t mcr_cfg, mcr_scu_mpll, mcr_scu_strap;
140140
uint32_t denum, num, div, ref_pll, dsel;
141141

@@ -277,15 +277,15 @@ struct drm_device *ast_device_create(struct pci_dev *pdev,
277277
ast_detect_widescreen(ast);
278278
ast_detect_tx_chip(ast, need_post);
279279

280-
ret = ast_get_dram_info(dev);
280+
ret = ast_get_dram_info(ast);
281281
if (ret)
282282
return ERR_PTR(ret);
283283

284284
drm_info(dev, "dram MCLK=%u Mhz type=%d bus_width=%d\n",
285285
ast->mclk, ast->dram_type, ast->dram_bus_width);
286286

287287
if (need_post)
288-
ast_post_gpu(dev);
288+
ast_post_gpu(ast);
289289

290290
ret = ast_mm_init(ast);
291291
if (ret)

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,9 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
12871287
.atomic_destroy_state = ast_crtc_atomic_destroy_state,
12881288
};
12891289

1290-
static int ast_crtc_init(struct drm_device *dev)
1290+
static int ast_crtc_init(struct ast_device *ast)
12911291
{
1292-
struct ast_device *ast = to_ast_device(dev);
1292+
struct drm_device *dev = &ast->base;
12931293
struct drm_crtc *crtc = &ast->crtc;
12941294
int ret;
12951295

@@ -1396,7 +1396,7 @@ int ast_mode_config_init(struct ast_device *ast)
13961396
if (ret)
13971397
return ret;
13981398

1399-
ret = ast_crtc_init(dev);
1399+
ret = ast_crtc_init(ast);
14001400
if (ret)
14011401
return ret;
14021402

drivers/gpu/drm/ast/ast_post.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@
3434
#include "ast_dram_tables.h"
3535
#include "ast_drv.h"
3636

37-
static void ast_post_chip_2300(struct drm_device *dev);
38-
static void ast_post_chip_2500(struct drm_device *dev);
37+
static void ast_post_chip_2300(struct ast_device *ast);
38+
static void ast_post_chip_2500(struct ast_device *ast);
3939

4040
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
4141
static const u8 extreginfo_ast2300[] = { 0x0f, 0x04, 0x1f, 0xff };
4242

43-
static void
44-
ast_set_def_ext_reg(struct drm_device *dev)
43+
static void ast_set_def_ext_reg(struct ast_device *ast)
4544
{
46-
struct ast_device *ast = to_ast_device(dev);
4745
u8 i, index, reg;
4846
const u8 *ext_reg_info;
4947

@@ -252,9 +250,8 @@ static void cbrdlli_ast2150(struct ast_device *ast, int busw)
252250

253251

254252

255-
static void ast_init_dram_reg(struct drm_device *dev)
253+
static void ast_init_dram_reg(struct ast_device *ast)
256254
{
257-
struct ast_device *ast = to_ast_device(dev);
258255
u8 j;
259256
u32 data, temp, i;
260257
const struct ast_dramstruct *dram_reg_info;
@@ -343,22 +340,20 @@ static void ast_init_dram_reg(struct drm_device *dev)
343340
} while ((j & 0x40) == 0);
344341
}
345342

346-
void ast_post_gpu(struct drm_device *dev)
343+
void ast_post_gpu(struct ast_device *ast)
347344
{
348-
struct ast_device *ast = to_ast_device(dev);
349-
350-
ast_set_def_ext_reg(dev);
345+
ast_set_def_ext_reg(ast);
351346

352347
if (IS_AST_GEN7(ast)) {
353348
if (ast->tx_chip == AST_TX_ASTDP)
354349
ast_dp_launch(ast);
355350
} else if (ast->config_mode == ast_use_p2a) {
356351
if (IS_AST_GEN6(ast))
357-
ast_post_chip_2500(dev);
352+
ast_post_chip_2500(ast);
358353
else if (IS_AST_GEN5(ast) || IS_AST_GEN4(ast))
359-
ast_post_chip_2300(dev);
354+
ast_post_chip_2300(ast);
360355
else
361-
ast_init_dram_reg(dev);
356+
ast_init_dram_reg(ast);
362357

363358
ast_init_3rdtx(ast);
364359
} else {
@@ -1569,9 +1564,8 @@ static void ddr2_init(struct ast_device *ast, struct ast2300_dram_param *param)
15691564

15701565
}
15711566

1572-
static void ast_post_chip_2300(struct drm_device *dev)
1567+
static void ast_post_chip_2300(struct ast_device *ast)
15731568
{
1574-
struct ast_device *ast = to_ast_device(dev);
15751569
struct ast2300_dram_param param;
15761570
u32 temp;
15771571
u8 reg;
@@ -2038,9 +2032,9 @@ void ast_patch_ahb_2500(void __iomem *regs)
20382032
__ast_moutdwm(regs, 0x1e6e207c, 0x08000000); /* clear fast reset */
20392033
}
20402034

2041-
void ast_post_chip_2500(struct drm_device *dev)
2035+
void ast_post_chip_2500(struct ast_device *ast)
20422036
{
2043-
struct ast_device *ast = to_ast_device(dev);
2037+
struct drm_device *dev = &ast->base;
20442038
u32 temp;
20452039
u8 reg;
20462040

0 commit comments

Comments
 (0)