Skip to contentSkip to conversation

ARM: prima2: constify reset_control_ops structures

PATCH New Bhumika Goyal 1 participant 1 message Jan 9, 2017

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

PATCH 1/1 ARM: prima2: constify reset_control_ops structures

Declare reset_control_ops structures as const as they are only stored in the ops field of a reset_controller_dev structure. This field is of type const struct reset_control_ops *, so reset_control_ops structures having this property can be declared as const.
Done using Coccinelle:

@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct reset_control_ops i at p={...};

@ok1@
identifier r1.i;
position p;
struct reset_controller_dev x;
@@
x.ops=&i at p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i at p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct reset_control_ops i;

File size before: arch/arm/mach-prima2/rstc.o
text data bss dec hex filename

    992	    236	      4	   1232	    4d0	arch/arm/mach-prima2/rstc.o

File size after: arch/arm/mach-prima2/rstc.o
text data bss dec hex filename
1008 220 4 1232 4d0 arch/arm/mach-prima2/rstc.o

---
 arch/arm/mach-prima2/rstc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-prima2/rstc.c +1 -1
index 7c251eb..1cdb616 100644
@@ -54,7 +54,7 @@ static int sirfsoc_reset_module(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
-static struct reset_control_ops sirfsoc_rstc_ops = {
+static const struct reset_control_ops sirfsoc_rstc_ops = {
 	.reset = sirfsoc_reset_module,
 };
 
Signature · 1 line
1.9.1