watchdog: constify watchdog_ops and watchdog_info structures
authorJulia Lawall <Julia.Lawall@lip6.fr>
Thu, 3 Aug 2017 21:21:31 +0000 (23:21 +0200)
committerWim Van Sebroeck <wim@iguana.be>
Sat, 9 Sep 2017 18:29:53 +0000 (20:29 +0200)
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>
drivers/watchdog/diag288_wdt.c
drivers/watchdog/mt7621_wdt.c
drivers/watchdog/rt2880_wdt.c

index 6f591084bb7af2fb64510171a8ba872c919f53b1..806a04a676b7ee6c369da99d6d09f0ecd50d1fd1 100644 (file)
@@ -213,7 +213,7 @@ static const struct watchdog_ops wdt_ops = {
        .set_timeout = wdt_set_timeout,
 };
 
-static struct watchdog_info wdt_info = {
+static const struct watchdog_info wdt_info = {
        .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
        .firmware_version = 0,
        .identity = "z Watchdog",
index f6f4c1bf24c95481917f1d4d1fb017684734c18b..db38f801721871566251a1f34374236444a65d69 100644 (file)
@@ -105,7 +105,7 @@ static int mt7621_wdt_bootcause(void)
        return 0;
 }
 
-static struct watchdog_info mt7621_wdt_info = {
+static const struct watchdog_info mt7621_wdt_info = {
        .identity = "Mediatek Watchdog",
        .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
 };
index 0d481a63cab147cefa2baf3285fac37322c52aca..98967f0a7d10e239e51080e5489b656bbdff084b 100644 (file)
@@ -119,7 +119,7 @@ static int rt288x_wdt_bootcause(void)
        return 0;
 }
 
-static struct watchdog_info rt288x_wdt_info = {
+static const struct watchdog_info rt288x_wdt_info = {
        .identity = "Ralink Watchdog",
        .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
 };