* [PATCH] watchdog: constify watchdog_ops and watchdog_info structures
@ 2017-08-03 21:21 Julia Lawall
2017-08-07 12:56 ` Linus Walleij
2017-08-14 14:44 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2017-08-03 21:21 UTC (permalink / raw)
To: linux-arm-kernel
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 at p = { ... };
@ok@
identifier r.i;
struct watchdog_device e;
position p;
@@
e.ops = &i at p;
@bad@
position p != {r.p,ok.p};
identifier r.i;
struct watchdog_ops e;
@@
e at 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>
---
drivers/watchdog/coh901327_wdt.c | 2 +-
drivers/watchdog/diag288_wdt.c | 2 +-
drivers/watchdog/it87_wdt.c | 2 +-
drivers/watchdog/mt7621_wdt.c | 2 +-
drivers/watchdog/rt2880_wdt.c | 2 +-
drivers/watchdog/stm32_iwdg.c | 2 +-
drivers/watchdog/ts72xx_wdt.c | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
index 6f59108..806a04a 100644
--- a/drivers/watchdog/diag288_wdt.c
+++ b/drivers/watchdog/diag288_wdt.c
@@ -213,7 +213,7 @@ static int wdt_set_timeout(struct watchdog_device * dev, unsigned int new_to)
.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",
diff --git a/drivers/watchdog/it87_wdt.c b/drivers/watchdog/it87_wdt.c
index dd1e7ea..e96faea 100644
--- a/drivers/watchdog/it87_wdt.c
+++ b/drivers/watchdog/it87_wdt.c
@@ -253,7 +253,7 @@ static int wdt_set_timeout(struct watchdog_device *wdd, unsigned int t)
.identity = WATCHDOG_NAME,
};
-static struct watchdog_ops wdt_ops = {
+static const struct watchdog_ops wdt_ops = {
.owner = THIS_MODULE,
.start = wdt_start,
.stop = wdt_stop,
diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c
index 48a0606..878835c 100644
--- a/drivers/watchdog/mt7621_wdt.c
+++ b/drivers/watchdog/mt7621_wdt.c
@@ -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,
};
diff --git a/drivers/watchdog/rt2880_wdt.c b/drivers/watchdog/rt2880_wdt.c
index 05524ba..1727aa3 100644
--- a/drivers/watchdog/rt2880_wdt.c
+++ b/drivers/watchdog/rt2880_wdt.c
@@ -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,
};
diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c
index 17c25da..811e43c 100644
--- a/drivers/watchdog/ts72xx_wdt.c
+++ b/drivers/watchdog/ts72xx_wdt.c
@@ -112,7 +112,7 @@ static int ts72xx_wdt_settimeout(struct watchdog_device *wdd, unsigned int to)
.identity = "TS-72XX WDT",
};
-static struct watchdog_ops ts72xx_wdt_ops = {
+static const struct watchdog_ops ts72xx_wdt_ops = {
.owner = THIS_MODULE,
.start = ts72xx_wdt_start,
.stop = ts72xx_wdt_stop,
diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
index 6c501b7..be64a86 100644
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -140,7 +140,7 @@ static int stm32_iwdg_set_timeout(struct watchdog_device *wdd,
.identity = "STM32 Independent Watchdog",
};
-static struct watchdog_ops stm32_iwdg_ops = {
+static const struct watchdog_ops stm32_iwdg_ops = {
.owner = THIS_MODULE,
.start = stm32_iwdg_start,
.ping = stm32_iwdg_ping,
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index 38dd60f0..4410337 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -218,7 +218,7 @@ static irqreturn_t coh901327_interrupt(int irq, void *data)
.identity = DRV_NAME,
};
-static struct watchdog_ops coh901327_ops = {
+static const struct watchdog_ops coh901327_ops = {
.owner = THIS_MODULE,
.start = coh901327_start,
.stop = coh901327_stop,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] watchdog: constify watchdog_ops and watchdog_info structures
2017-08-03 21:21 [PATCH] watchdog: constify watchdog_ops and watchdog_info structures Julia Lawall
@ 2017-08-07 12:56 ` Linus Walleij
2017-08-14 14:44 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-08-07 12:56 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Aug 3, 2017 at 11:21 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> 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 at p = { ... };
>
> @ok@
> identifier r.i;
> struct watchdog_device e;
> position p;
> @@
> e.ops = &i at p;
>
> @bad@
> position p != {r.p,ok.p};
> identifier r.i;
> struct watchdog_ops e;
> @@
> e at 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>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] watchdog: constify watchdog_ops and watchdog_info structures
2017-08-03 21:21 [PATCH] watchdog: constify watchdog_ops and watchdog_info structures Julia Lawall
2017-08-07 12:56 ` Linus Walleij
@ 2017-08-14 14:44 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2017-08-14 14:44 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Aug 03, 2017 at 11:21:31PM +0200, Julia Lawall wrote:
> 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 at p = { ... };
>
> @ok@
> identifier r.i;
> struct watchdog_device e;
> position p;
> @@
> e.ops = &i at p;
>
> @bad@
> position p != {r.p,ok.p};
> identifier r.i;
> struct watchdog_ops e;
> @@
> e at 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>
>
> ---
> drivers/watchdog/coh901327_wdt.c | 2 +-
> drivers/watchdog/diag288_wdt.c | 2 +-
> drivers/watchdog/it87_wdt.c | 2 +-
> drivers/watchdog/mt7621_wdt.c | 2 +-
> drivers/watchdog/rt2880_wdt.c | 2 +-
> drivers/watchdog/stm32_iwdg.c | 2 +-
> drivers/watchdog/ts72xx_wdt.c | 2 +-
> 7 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
> index 6f59108..806a04a 100644
> --- a/drivers/watchdog/diag288_wdt.c
> +++ b/drivers/watchdog/diag288_wdt.c
> @@ -213,7 +213,7 @@ static int wdt_set_timeout(struct watchdog_device * dev, unsigned int new_to)
> .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",
> diff --git a/drivers/watchdog/it87_wdt.c b/drivers/watchdog/it87_wdt.c
> index dd1e7ea..e96faea 100644
> --- a/drivers/watchdog/it87_wdt.c
> +++ b/drivers/watchdog/it87_wdt.c
> @@ -253,7 +253,7 @@ static int wdt_set_timeout(struct watchdog_device *wdd, unsigned int t)
> .identity = WATCHDOG_NAME,
> };
>
> -static struct watchdog_ops wdt_ops = {
> +static const struct watchdog_ops wdt_ops = {
> .owner = THIS_MODULE,
> .start = wdt_start,
> .stop = wdt_stop,
> diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c
> index 48a0606..878835c 100644
> --- a/drivers/watchdog/mt7621_wdt.c
> +++ b/drivers/watchdog/mt7621_wdt.c
> @@ -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,
> };
> diff --git a/drivers/watchdog/rt2880_wdt.c b/drivers/watchdog/rt2880_wdt.c
> index 05524ba..1727aa3 100644
> --- a/drivers/watchdog/rt2880_wdt.c
> +++ b/drivers/watchdog/rt2880_wdt.c
> @@ -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,
> };
> diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c
> index 17c25da..811e43c 100644
> --- a/drivers/watchdog/ts72xx_wdt.c
> +++ b/drivers/watchdog/ts72xx_wdt.c
> @@ -112,7 +112,7 @@ static int ts72xx_wdt_settimeout(struct watchdog_device *wdd, unsigned int to)
> .identity = "TS-72XX WDT",
> };
>
> -static struct watchdog_ops ts72xx_wdt_ops = {
> +static const struct watchdog_ops ts72xx_wdt_ops = {
> .owner = THIS_MODULE,
> .start = ts72xx_wdt_start,
> .stop = ts72xx_wdt_stop,
> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index 6c501b7..be64a86 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
> @@ -140,7 +140,7 @@ static int stm32_iwdg_set_timeout(struct watchdog_device *wdd,
> .identity = "STM32 Independent Watchdog",
> };
>
> -static struct watchdog_ops stm32_iwdg_ops = {
> +static const struct watchdog_ops stm32_iwdg_ops = {
> .owner = THIS_MODULE,
> .start = stm32_iwdg_start,
> .ping = stm32_iwdg_ping,
> diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
> index 38dd60f0..4410337 100644
> --- a/drivers/watchdog/coh901327_wdt.c
> +++ b/drivers/watchdog/coh901327_wdt.c
> @@ -218,7 +218,7 @@ static irqreturn_t coh901327_interrupt(int irq, void *data)
> .identity = DRV_NAME,
> };
>
> -static struct watchdog_ops coh901327_ops = {
> +static const struct watchdog_ops coh901327_ops = {
> .owner = THIS_MODULE,
> .start = coh901327_start,
> .stop = coh901327_stop,
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-14 14:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03 21:21 [PATCH] watchdog: constify watchdog_ops and watchdog_info structures Julia Lawall
2017-08-07 12:56 ` Linus Walleij
2017-08-14 14:44 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).