Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/sun4i: constify component_ops structures

These component_ops structures are only used as the second argument to
component_add and component_del, which are declared as const, so the
structures can be declared as const as well.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@

static struct component_ops i@p = { ... };

@ok1@
identifier r.i;
expression e1;
position p;
@@

component_add(e1,&i@p)

@ok2@
identifier r.i;
expression e1;
position p;
@@

component_del(e1, &i@p)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct component_ops e;
@@

e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@

static
+const
struct component_ops i = { ... };
// </smpl>

The result of the size command before the change is (arm):

text data bss dec hex filename
5266 236 8 5510 1586 sun4i_backend.o
6393 236 8 6637 19ed sun4i_tcon.o
3700 368 8 4076 fec sun4i_tv.o
1668 108 0 1776 6f0 sun6i_drc.o

and after the change:

text data bss dec hex filename
5274 228 8 5510 1586 sun4i_backend.o
6401 228 8 6637 19ed sun4i_tcon.o
3708 360 8 4076 fec sun4i_tv.o
1676 100 0 1776 6f0 sun6i_drc.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1478971198-3659-1-git-send-email-Julia.Lawall@lip6.fr

authored by

Julia Lawall and committed by
Daniel Vetter
dfeb693d b3c11ac2

+4 -4
+1 -1
drivers/gpu/drm/sun4i/sun4i_backend.c
··· 389 389 reset_control_assert(backend->reset); 390 390 } 391 391 392 - static struct component_ops sun4i_backend_ops = { 392 + static const struct component_ops sun4i_backend_ops = { 393 393 .bind = sun4i_backend_bind, 394 394 .unbind = sun4i_backend_unbind, 395 395 };
+1 -1
drivers/gpu/drm/sun4i/sun4i_tcon.c
··· 551 551 sun4i_tcon_free_clocks(tcon); 552 552 } 553 553 554 - static struct component_ops sun4i_tcon_ops = { 554 + static const struct component_ops sun4i_tcon_ops = { 555 555 .bind = sun4i_tcon_bind, 556 556 .unbind = sun4i_tcon_unbind, 557 557 };
+1 -1
drivers/gpu/drm/sun4i/sun4i_tv.c
··· 667 667 clk_disable_unprepare(tv->clk); 668 668 } 669 669 670 - static struct component_ops sun4i_tv_ops = { 670 + static const struct component_ops sun4i_tv_ops = { 671 671 .bind = sun4i_tv_bind, 672 672 .unbind = sun4i_tv_unbind, 673 673 };
+1 -1
drivers/gpu/drm/sun4i/sun6i_drc.c
··· 80 80 reset_control_assert(drc->reset); 81 81 } 82 82 83 - static struct component_ops sun6i_drc_ops = { 83 + static const struct component_ops sun6i_drc_ops = { 84 84 .bind = sun6i_drc_bind, 85 85 .unbind = sun6i_drc_unbind, 86 86 };