Skip to contentSkip to conversation

drm/aspeed: gfc_crtc: Make structure aspeed_gfx_funcs constant

PATCH Applied Nishka Dasgupta 2 participants 2 messages Aug 13, 2019 – Aug 14, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/aspeed: gfc_crtc: Make structure aspeed_gfx_funcs constant

The static structure aspeed_gfx_funcs, of type drm_simple_display_pipe_funcs, is used only as an argument to drm_simple_display_pipe_init(), which does not modify it. Hence make it constant to protect it from unintended modification.
Issue found with Coccinelle.

---
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c +1 -1
index 15db9e426ec4..2184b8be6fd4 100644
@@ -215,7 +215,7 @@ static void aspeed_gfx_disable_vblank(struct drm_simple_display_pipe *pipe)
 	writel(reg | CRT_CTRL_VERTICAL_INTR_STS, priv->base + CRT_CTRL1);
 }
 
-static struct drm_simple_display_pipe_funcs aspeed_gfx_funcs = {
+static const struct drm_simple_display_pipe_funcs aspeed_gfx_funcs = {
 	.enable		= aspeed_gfx_pipe_enable,
 	.disable	= aspeed_gfx_pipe_disable,
 	.update		= aspeed_gfx_pipe_update,
Signature · 1 line
2.19.1
#1 lore raw
Quoted 7 lines · Nishka Dasgupta

The static structure aspeed_gfx_funcs, of type drm_simple_display_pipe_funcs, is used only as an argument to drm_simple_display_pipe_init(), which does not modify it. Hence make it constant to protect it from unintended modification.
Issue found with Coccinelle.

Applied, thanks for your patch.

Quoted 20 lines
---
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c +1 -1
index 15db9e426ec4..2184b8be6fd4 100644
@@ -215,7 +215,7 @@ static void aspeed_gfx_disable_vblank(struct drm_simple_display_pipe *pipe)
 	writel(reg | CRT_CTRL_VERTICAL_INTR_STS, priv->base + CRT_CTRL1);
 }
 
-static struct drm_simple_display_pipe_funcs aspeed_gfx_funcs = {
+static const struct drm_simple_display_pipe_funcs aspeed_gfx_funcs = {
 	.enable		= aspeed_gfx_pipe_enable,
 	.disable	= aspeed_gfx_pipe_disable,
 	.update		= aspeed_gfx_pipe_update,
Signature · 1 line
2.19.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch