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

watchdog: constify watchdog_ops structures

Check for watchdog_ops structures that are only stored in the ops field of
a watchdog_device structure. This field is declared const, so watchdog_ops
structures that have this property can be declared as const also.

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 watchdog_ops i@p = { ... };

@ok@
identifier r.i;
struct watchdog_device e;
position p;
@@
e.ops = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct watchdog_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct watchdog_ops i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Julia Lawall and committed by
Wim Van Sebroeck
85f15cfc 7123f253

+6 -6
+1 -1
drivers/watchdog/bcm7038_wdt.c
··· 107 107 WDIOF_MAGICCLOSE 108 108 }; 109 109 110 - static struct watchdog_ops bcm7038_wdt_ops = { 110 + static const struct watchdog_ops bcm7038_wdt_ops = { 111 111 .owner = THIS_MODULE, 112 112 .start = bcm7038_wdt_start, 113 113 .stop = bcm7038_wdt_stop,
+1 -1
drivers/watchdog/cadence_wdt.c
··· 269 269 }; 270 270 271 271 /* Watchdog Core Ops */ 272 - static struct watchdog_ops cdns_wdt_ops = { 272 + static const struct watchdog_ops cdns_wdt_ops = { 273 273 .owner = THIS_MODULE, 274 274 .start = cdns_wdt_start, 275 275 .stop = cdns_wdt_stop,
+1 -1
drivers/watchdog/kempld_wdt.c
··· 430 430 WDIOF_PRETIMEOUT 431 431 }; 432 432 433 - static struct watchdog_ops kempld_wdt_ops = { 433 + static const struct watchdog_ops kempld_wdt_ops = { 434 434 .owner = THIS_MODULE, 435 435 .start = kempld_wdt_start, 436 436 .stop = kempld_wdt_stop,
+1 -1
drivers/watchdog/rn5t618_wdt.c
··· 136 136 .identity = DRIVER_NAME, 137 137 }; 138 138 139 - static struct watchdog_ops rn5t618_wdt_ops = { 139 + static const struct watchdog_ops rn5t618_wdt_ops = { 140 140 .owner = THIS_MODULE, 141 141 .start = rn5t618_wdt_start, 142 142 .stop = rn5t618_wdt_stop,
+1 -1
drivers/watchdog/softdog.c
··· 92 92 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 93 93 }; 94 94 95 - static struct watchdog_ops softdog_ops = { 95 + static const struct watchdog_ops softdog_ops = { 96 96 .owner = THIS_MODULE, 97 97 .start = softdog_ping, 98 98 .stop = softdog_stop,
+1 -1
drivers/watchdog/w83627hf_wdt.c
··· 302 302 .identity = "W83627HF Watchdog", 303 303 }; 304 304 305 - static struct watchdog_ops wdt_ops = { 305 + static const struct watchdog_ops wdt_ops = { 306 306 .owner = THIS_MODULE, 307 307 .start = wdt_start, 308 308 .stop = wdt_stop,