Skip to contentSkip to conversation

drivers/watchdog: Constify static struct watchdog_ops

PATCH In review Rikard Falkeborn 2 participants 7 messages Jul 27, 2021 – Jul 28, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drivers/watchdog: Constify static struct watchdog_ops

Constify three instances of static struct watchdog_ops. These are only assigned to the ops field in the watchdog_device struct, which is a pointer to const struct watchdog_ops.

With these changes applied, all static watchdog_ops structs are const (checked for next-20210727), 119 instances).

Rikard Falkeborn (3):
watchdog: sl28cpld_wdt: Constify static struct watchdog_ops
watchdog: tqmx86: Constify static struct watchdog_ops
watchdog: mpc8xxx_wdt: Constify static struct watchdog_ops

 drivers/watchdog/mpc8xxx_wdt.c  | 2 +-
 drivers/watchdog/sl28cpld_wdt.c | 2 +-
 drivers/watchdog/tqmx86_wdt.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/3 watchdog: sl28cpld_wdt: Constify static struct watchdog_ops

The struct sl28cpld_wdt_ops is only assigned to the ops pointer in the watchdog_device struct, which is a pointer to const struct watchdog_ops. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/watchdog/sl28cpld_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/sl28cpld_wdt.c +1 -1
index 2de93298475f..9ce456f09f73 100644
@@ -108,7 +108,7 @@ static const struct watchdog_info sl28cpld_wdt_info = {
 	.identity = "sl28cpld watchdog",
 };
 
-static struct watchdog_ops sl28cpld_wdt_ops = {
+static const struct watchdog_ops sl28cpld_wdt_ops = {
 	.owner = THIS_MODULE,
 	.start = sl28cpld_wdt_start,
 	.stop = sl28cpld_wdt_stop,
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] watchdog: sl28cpld_wdt: Constify static struct watchdog_ops

Quoted 5 lines · Rikard Falkeborn

The struct sl28cpld_wdt_ops is only assigned to the ops pointer in the watchdog_device struct, which is a pointer to const struct watchdog_ops. Make it const to allow the compiler to put it in read-only memory.

Quoted 20 lines
---
 drivers/watchdog/sl28cpld_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/sl28cpld_wdt.c +1 -1
index 2de93298475f..9ce456f09f73 100644
@@ -108,7 +108,7 @@ static const struct watchdog_info sl28cpld_wdt_info = {
 	.identity = "sl28cpld watchdog",
 };
 
-static struct watchdog_ops sl28cpld_wdt_ops = {
+static const struct watchdog_ops sl28cpld_wdt_ops = {
 	.owner = THIS_MODULE,
 	.start = sl28cpld_wdt_start,
 	.stop = sl28cpld_wdt_stop,
Signature · 1 line
2.32.0
#3 lore raw

PATCH 2/3 watchdog: tqmx86: Constify static struct watchdog_ops

In reply to Rikard Falkeborn

The struct tqmx86_wdt_ops is only assigned to the ops pointer in the watchdog_device struct, which is a pointer to const struct watchdog_ops. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/watchdog/tqmx86_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/tqmx86_wdt.c +1 -1
index 72d0b0adde38..83860e94ce9d 100644
@@ -62,7 +62,7 @@ static const struct watchdog_info tqmx86_wdt_info = {
 	.identity	= "TQMx86 Watchdog",
 };
 
-static struct watchdog_ops tqmx86_wdt_ops = {
+static const struct watchdog_ops tqmx86_wdt_ops = {
 	.owner		= THIS_MODULE,
 	.start		= tqmx86_wdt_start,
 	.set_timeout	= tqmx86_wdt_set_timeout,
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] watchdog: tqmx86: Constify static struct watchdog_ops

Quoted 5 lines · Rikard Falkeborn

The struct tqmx86_wdt_ops is only assigned to the ops pointer in the watchdog_device struct, which is a pointer to const struct watchdog_ops. Make it const to allow the compiler to put it in read-only memory.

Quoted 20 lines
---
 drivers/watchdog/tqmx86_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/tqmx86_wdt.c +1 -1
index 72d0b0adde38..83860e94ce9d 100644
@@ -62,7 +62,7 @@ static const struct watchdog_info tqmx86_wdt_info = {
 	.identity	= "TQMx86 Watchdog",
 };
 
-static struct watchdog_ops tqmx86_wdt_ops = {
+static const struct watchdog_ops tqmx86_wdt_ops = {
 	.owner		= THIS_MODULE,
 	.start		= tqmx86_wdt_start,
 	.set_timeout	= tqmx86_wdt_set_timeout,
Signature · 1 line
2.32.0
#5 lore raw

PATCH 3/3 watchdog: mpc8xxx_wdt: Constify static struct watchdog_ops

In reply to Rikard Falkeborn

The struct mpc8xxx_wdt_ops is only assigned to the ops pointer in the watchdog_device struct, which is a pointer to const struct watchdog_ops. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/watchdog/mpc8xxx_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/mpc8xxx_wdt.c +1 -1
index 2f7ded32e878..1c569be72ea2 100644
@@ -118,7 +118,7 @@ static struct watchdog_info mpc8xxx_wdt_info = {
 	.identity = "MPC8xxx",
 };
 
-static struct watchdog_ops mpc8xxx_wdt_ops = {
+static const struct watchdog_ops mpc8xxx_wdt_ops = {
 	.owner = THIS_MODULE,
 	.start = mpc8xxx_wdt_start,
 	.ping = mpc8xxx_wdt_ping,
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] watchdog: mpc8xxx_wdt: Constify static struct watchdog_ops

Quoted 5 lines · Rikard Falkeborn

The struct mpc8xxx_wdt_ops is only assigned to the ops pointer in the watchdog_device struct, which is a pointer to const struct watchdog_ops. Make it const to allow the compiler to put it in read-only memory.

Quoted 20 lines
---
 drivers/watchdog/mpc8xxx_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/mpc8xxx_wdt.c +1 -1
index 2f7ded32e878..1c569be72ea2 100644
@@ -118,7 +118,7 @@ static struct watchdog_info mpc8xxx_wdt_info = {
 	.identity = "MPC8xxx",
 };
 
-static struct watchdog_ops mpc8xxx_wdt_ops = {
+static const struct watchdog_ops mpc8xxx_wdt_ops = {
 	.owner = THIS_MODULE,
 	.start = mpc8xxx_wdt_start,
 	.ping = mpc8xxx_wdt_ping,
Signature · 1 line
2.32.0