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

watchdog: constify watchdog_ops structures

Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=&x@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

text data bss dec hex filename

1340 544 0 1884 75c drivers/watchdog/bcm_kona_wdt.o
1436 440 0 1876 754 drivers/watchdog/bcm_kona_wdt.o

1176 544 4 1724 6bc drivers/watchdog/digicolor_wdt.o
1272 440 4 1716 6b4 drivers/watchdog/digicolor_wdt.o

925 580 89 1594 63a drivers/watchdog/ep93xx_wdt.o
1021 476 89 1586 632 drivers/watchdog/ep93xx_wdt.o

4932 288 17 5237 1475 drivers/watchdog/s3c2410_wdt.o
5028 192 17 5237 1475 drivers/watchdog/s3c2410_wdt.o

1977 292 1 2270 8de drivers/watchdog/sama5d4_wdt.o
2073 196 1 2270 8de drivers/watchdog/sama5d4_wdt.o

1375 484 1 1860 744 drivers/watchdog/sirfsoc_wdt.o
1471 380 1 1852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Bhumika Goyal and committed by
Guenter Roeck
b893e344 bb292ac1

+14 -14
+1 -1
drivers/watchdog/asm9260_wdt.c
··· 186 186 .identity = "Alphascale asm9260 Watchdog", 187 187 }; 188 188 189 - static struct watchdog_ops asm9260_wdt_ops = { 189 + static const struct watchdog_ops asm9260_wdt_ops = { 190 190 .owner = THIS_MODULE, 191 191 .start = asm9260_wdt_enable, 192 192 .stop = asm9260_wdt_disable,
+1 -1
drivers/watchdog/atlas7_wdt.c
··· 105 105 .identity = "atlas7 Watchdog", 106 106 }; 107 107 108 - static struct watchdog_ops atlas7_wdt_ops = { 108 + static const struct watchdog_ops atlas7_wdt_ops = { 109 109 .owner = THIS_MODULE, 110 110 .start = atlas7_wdt_enable, 111 111 .stop = atlas7_wdt_disable,
+1 -1
drivers/watchdog/bcm_kona_wdt.c
··· 266 266 SECWDOG_SRSTEN_MASK, 0); 267 267 } 268 268 269 - static struct watchdog_ops bcm_kona_wdt_ops = { 269 + static const struct watchdog_ops bcm_kona_wdt_ops = { 270 270 .owner = THIS_MODULE, 271 271 .start = bcm_kona_wdt_start, 272 272 .stop = bcm_kona_wdt_stop,
+1 -1
drivers/watchdog/booke_wdt.c
··· 197 197 .identity = "PowerPC Book-E Watchdog", 198 198 }; 199 199 200 - static struct watchdog_ops booke_wdt_ops = { 200 + static const struct watchdog_ops booke_wdt_ops = { 201 201 .owner = THIS_MODULE, 202 202 .start = booke_wdt_start, 203 203 .stop = booke_wdt_stop,
+1 -1
drivers/watchdog/diag288_wdt.c
··· 205 205 return wdt_ping(dev); 206 206 } 207 207 208 - static struct watchdog_ops wdt_ops = { 208 + static const struct watchdog_ops wdt_ops = { 209 209 .owner = THIS_MODULE, 210 210 .start = wdt_start, 211 211 .stop = wdt_stop,
+1 -1
drivers/watchdog/digicolor_wdt.c
··· 96 96 return count / clk_get_rate(wdt->clk); 97 97 } 98 98 99 - static struct watchdog_ops dc_wdt_ops = { 99 + static const struct watchdog_ops dc_wdt_ops = { 100 100 .owner = THIS_MODULE, 101 101 .start = dc_wdt_start, 102 102 .stop = dc_wdt_stop,
+1 -1
drivers/watchdog/ep93xx_wdt.c
··· 99 99 .identity = "EP93xx Watchdog", 100 100 }; 101 101 102 - static struct watchdog_ops ep93xx_wdt_ops = { 102 + static const struct watchdog_ops ep93xx_wdt_ops = { 103 103 .owner = THIS_MODULE, 104 104 .start = ep93xx_wdt_start, 105 105 .stop = ep93xx_wdt_stop,
+1 -1
drivers/watchdog/mt7621_wdt.c
··· 110 110 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 111 111 }; 112 112 113 - static struct watchdog_ops mt7621_wdt_ops = { 113 + static const struct watchdog_ops mt7621_wdt_ops = { 114 114 .owner = THIS_MODULE, 115 115 .start = mt7621_wdt_start, 116 116 .stop = mt7621_wdt_stop,
+1 -1
drivers/watchdog/rt2880_wdt.c
··· 124 124 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 125 125 }; 126 126 127 - static struct watchdog_ops rt288x_wdt_ops = { 127 + static const struct watchdog_ops rt288x_wdt_ops = { 128 128 .owner = THIS_MODULE, 129 129 .start = rt288x_wdt_start, 130 130 .stop = rt288x_wdt_stop,
+1 -1
drivers/watchdog/s3c2410_wdt.c
··· 394 394 .identity = "S3C2410 Watchdog", 395 395 }; 396 396 397 - static struct watchdog_ops s3c2410wdt_ops = { 397 + static const struct watchdog_ops s3c2410wdt_ops = { 398 398 .owner = THIS_MODULE, 399 399 .start = s3c2410wdt_start, 400 400 .stop = s3c2410wdt_stop,
+1 -1
drivers/watchdog/sama5d4_wdt.c
··· 107 107 .identity = "Atmel SAMA5D4 Watchdog", 108 108 }; 109 109 110 - static struct watchdog_ops sama5d4_wdt_ops = { 110 + static const struct watchdog_ops sama5d4_wdt_ops = { 111 111 .owner = THIS_MODULE, 112 112 .start = sama5d4_wdt_start, 113 113 .stop = sama5d4_wdt_stop,
+1 -1
drivers/watchdog/sbsa_gwdt.c
··· 215 215 WDIOF_CARDRESET, 216 216 }; 217 217 218 - static struct watchdog_ops sbsa_gwdt_ops = { 218 + static const struct watchdog_ops sbsa_gwdt_ops = { 219 219 .owner = THIS_MODULE, 220 220 .start = sbsa_gwdt_start, 221 221 .stop = sbsa_gwdt_stop,
+1 -1
drivers/watchdog/sirfsoc_wdt.c
··· 127 127 .identity = "SiRFSOC Watchdog", 128 128 }; 129 129 130 - static struct watchdog_ops sirfsoc_wdt_ops = { 130 + static const struct watchdog_ops sirfsoc_wdt_ops = { 131 131 .owner = THIS_MODULE, 132 132 .start = sirfsoc_wdt_enable, 133 133 .stop = sirfsoc_wdt_disable,
+1 -1
drivers/watchdog/sun4v_wdt.c
··· 77 77 .firmware_version = 0, 78 78 }; 79 79 80 - static struct watchdog_ops sun4v_wdt_ops = { 80 + static const struct watchdog_ops sun4v_wdt_ops = { 81 81 .owner = THIS_MODULE, 82 82 .start = sun4v_wdt_ping, 83 83 .stop = sun4v_wdt_stop,