[PATCH] watchdog: apple: Constify some structures

Christophe JAILLET posted 1 patch 1 month, 2 weeks ago
drivers/watchdog/apple_wdt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] watchdog: apple: Constify some structures
Posted by Christophe JAILLET 1 month, 2 weeks ago
'struct watchdog_ops' and 'struct watchdog_info' are not modified in this
driver.

Constifying these structure moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   7319	   1768	      0	   9087	   237f	drivers/watchdog/apple_wdt.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   7543	   1544	      0	   9087	   237f	drivers/watchdog/apple_wdt.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 drivers/watchdog/apple_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/apple_wdt.c b/drivers/watchdog/apple_wdt.c
index 6b9b0f9b05ce..f533953294f6 100644
--- a/drivers/watchdog/apple_wdt.c
+++ b/drivers/watchdog/apple_wdt.c
@@ -139,7 +139,7 @@ static int apple_wdt_restart(struct watchdog_device *wdd, unsigned long mode,
 	return 0;
 }
 
-static struct watchdog_ops apple_wdt_ops = {
+static const struct watchdog_ops apple_wdt_ops = {
 	.owner = THIS_MODULE,
 	.start = apple_wdt_start,
 	.stop = apple_wdt_stop,
@@ -149,7 +149,7 @@ static struct watchdog_ops apple_wdt_ops = {
 	.restart = apple_wdt_restart,
 };
 
-static struct watchdog_info apple_wdt_info = {
+static const struct watchdog_info apple_wdt_info = {
 	.identity = "Apple SoC Watchdog",
 	.options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT,
 };
-- 
2.55.0
Re: [PATCH] watchdog: apple: Constify some structures
Posted by Guenter Roeck 1 month, 2 weeks ago
On Sun, Aug 09, 2026 at 03:49:10PM +0200, Christophe JAILLET wrote:
> 'struct watchdog_ops' and 'struct watchdog_info' are not modified in this
> driver.
> 
> Constifying these structure moves some data to a read-only section, so
> increases overall security, especially when the structure holds some
> function pointers.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>    7319	   1768	      0	   9087	   237f	drivers/watchdog/apple_wdt.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>    7543	   1544	      0	   9087	   237f	drivers/watchdog/apple_wdt.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied.

Thanks,
Guenter