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

watchdog: constify watchdog_ops and watchdog_info structures

These watchdog_ops and watchdog_info structures are only stored
in the ops and info fields of a watchdog_device structure,
respectively, which are const. Thus make the watchdog_ops and
watchdog_info structures const as well.

Done with the help of Coccinelle. The rules for the watchdog_ops case are
as follows:

// <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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
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
323edb2e d94fa465

+3 -3
+1 -1
drivers/watchdog/diag288_wdt.c
··· 213 213 .set_timeout = wdt_set_timeout, 214 214 }; 215 215 216 - static struct watchdog_info wdt_info = { 216 + static const struct watchdog_info wdt_info = { 217 217 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 218 218 .firmware_version = 0, 219 219 .identity = "z Watchdog",
+1 -1
drivers/watchdog/mt7621_wdt.c
··· 105 105 return 0; 106 106 } 107 107 108 - static struct watchdog_info mt7621_wdt_info = { 108 + static const struct watchdog_info mt7621_wdt_info = { 109 109 .identity = "Mediatek Watchdog", 110 110 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 111 111 };
+1 -1
drivers/watchdog/rt2880_wdt.c
··· 119 119 return 0; 120 120 } 121 121 122 - static struct watchdog_info rt288x_wdt_info = { 122 + static const struct watchdog_info rt288x_wdt_info = { 123 123 .identity = "Ralink Watchdog", 124 124 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 125 125 };