drivers: watchdog: constify watchdog_info structures
Subsystems (6)
PATCH 1/1 drivers: watchdog: constify watchdog_info structures
Declare watchdog_info structures as const as they are only stored in the info field of watchdog_device structures. This field is of type const struct watchdog_info *, so watchdog_info structures having this property can be declared const too.
Done using Coccinelle:
@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct watchdog_info i at p={...};
@ok@
identifier r1.i;
position p;
struct watchdog_device obj;
@@
obj.info=&i at p;
@bad@
position p!={r1.p,ok.p};
identifier r1.i;
@@
i at p
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct watchdog_info i;
Size details:
text data bss dec hex filename
1882 249 0 2131 853 drivers/watchdog/bcm7038_wdt.o 1938 193 0 2131 853 drivers/watchdog/bcm7038_wdt.o
1673 720 8 2401 961 drivers/watchdog/bcm_kona_wdt.o 1729 656 8 2393 959 drivers/watchdog/bcm_kona_wdt.o
2370 760 8 3138 c42 drivers/watchdog/cadence_wdt.o 2434 704 8 3146 c4a drivers/watchdog/cadence_wdt.o
1448 248 0 1696 6a0 drivers/watchdog/da9052_wdt.o 1512 192 0 1704 6a8 drivers/watchdog/da9052_wdt.o
1077 249 0 1326 52e drivers/watchdog/da9055_wdt.o 1141 193 0 1334 536 drivers/watchdog/da9055_wdt.o
1416 544 12 1972 7b4 drivers/watchdog/digicolor_wdt.o 1480 480 12 1972 7b4 drivers/watchdog/digicolor_wdt.o
2653 249 4 2906 b5a drivers/watchdog/imgpdc_wdt.o 2717 193 4 2914 b62 drivers/watchdog/imgpdc_wdt.o
2923 257 4 3184 c70 drivers/watchdog/kempld_wdt.o 2987 201 4 3192 c78 drivers/watchdog/kempld_wdt.o
2469 249 20 2738 ab2 drivers/watchdog/lpc18xx_wdt.o 2533 193 20 2746 aba drivers/watchdog/lpc18xx_wdt.o
1119 249 4 1372 55c drivers/watchdog/rn5t618_wdt.o 1183 193 4 1380 564 drivers/watchdog/rn5t618_wdt.o
1218 528 8 1754 6da drivers/watchdog/softdog.o 1282 464 8 1754 6da drivers/watchdog/softdog.o
2934 249 24 3207 c87 drivers/watchdog/w83627hf_wdt.o 2998 185 24 3207 c87 drivers/watchdog/w83627hf_wdt.o
--- drivers/watchdog/bcm7038_wdt.c | 2 +- drivers/watchdog/bcm_kona_wdt.c | 2 +- drivers/watchdog/cadence_wdt.c | 2 +- drivers/watchdog/da9052_wdt.c | 2 +- drivers/watchdog/da9055_wdt.c | 2 +- drivers/watchdog/digicolor_wdt.c | 2 +- drivers/watchdog/imgpdc_wdt.c | 2 +- drivers/watchdog/kempld_wdt.c | 2 +- drivers/watchdog/lpc18xx_wdt.c | 2 +- drivers/watchdog/rn5t618_wdt.c | 2 +- drivers/watchdog/sbsa_gwdt.c | 2 +- drivers/watchdog/w83627hf_wdt.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-)
drivers/watchdog/bcm7038_wdt.c +1 -1
@@ -101,7 +101,7 @@ static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog)return time_left / wdt->rate; } -static struct watchdog_info bcm7038_wdt_info = { +static const struct watchdog_info bcm7038_wdt_info = { .identity ="Broadcom BCM7038 Watchdog Timer" , .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE
drivers/watchdog/bcm_kona_wdt.c +1 -1
@@ -274,7 +274,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device *wdog) .get_timeleft = bcm_kona_wdt_get_timeleft, }; -static struct watchdog_info bcm_kona_wdt_info = { +static const struct watchdog_info bcm_kona_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_MAGICCLOSE |WDIOF_KEEPALIVEPING , .identity ="Broadcom Kona Watchdog Timer" ,
drivers/watchdog/cadence_wdt.c +1 -1
@@ -262,7 +262,7 @@ static irqreturn_t cdns_wdt_irq_handler(int irq, void *dev_id)* Info structure used to indicate the features supported by the device * to the upper layers. This is defined in watchdog.h header file. */ -static struct watchdog_info cdns_wdt_info = { +static const struct watchdog_info cdns_wdt_info = { .identity ="cdns_wdt watchdog" , .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE ,
drivers/watchdog/da9052_wdt.c +1 -1
@@ -140,7 +140,7 @@ static int da9052_wdt_ping(struct watchdog_device *wdt_dev)return ret; } -static struct watchdog_info da9052_wdt_info = { +static const struct watchdog_info da9052_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , .identity ="DA9052 Watchdog" , };
drivers/watchdog/da9055_wdt.c +1 -1
@@ -108,7 +108,7 @@ static int da9055_wdt_stop(struct watchdog_device *wdt_dev)return da9055_wdt_set_timeout (wdt_dev,0 ); } -static struct watchdog_info da9055_wdt_info = { +static const struct watchdog_info da9055_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , .identity ="DA9055 Watchdog" , };
drivers/watchdog/digicolor_wdt.c +1 -1
@@ -105,7 +105,7 @@ static unsigned int dc_wdt_get_timeleft(struct watchdog_device *wdog) .restart = dc_wdt_restart, }; -static struct watchdog_info dc_wdt_info = { +static const struct watchdog_info dc_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_MAGICCLOSE |WDIOF_KEEPALIVEPING , .identity ="Conexant Digicolor Watchdog" ,
drivers/watchdog/imgpdc_wdt.c +1 -1
@@ -161,7 +161,7 @@ static int pdc_wdt_restart(struct watchdog_device *wdt_dev,return 0 ; } -static struct watchdog_info pdc_wdt_info = { +static const struct watchdog_info pdc_wdt_info = { .identity ="IMG PDC Watchdog" , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
drivers/watchdog/kempld_wdt.c +1 -1
@@ -422,7 +422,7 @@ static int kempld_wdt_probe_stages(struct watchdog_device *wdd)return 0 ; } -static struct watchdog_info kempld_wdt_info = { +static const struct watchdog_info kempld_wdt_info = { .identity ="KEMPLD Watchdog" , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
drivers/watchdog/lpc18xx_wdt.c +1 -1
@@ -181,7 +181,7 @@ static int lpc18xx_wdt_restart(struct watchdog_device *wdt_dev,return 0 ; } -static struct watchdog_info lpc18xx_wdt_info = { +static const struct watchdog_info lpc18xx_wdt_info = { .identity ="NXP LPC18xx Watchdog" , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
drivers/watchdog/rn5t618_wdt.c +1 -1
@@ -130,7 +130,7 @@ static int rn5t618_wdt_ping(struct watchdog_device *wdt_dev) RN5T618_PWRIRQ_IR_WDOG, 0); } -static struct watchdog_info rn5t618_wdt_info = { +static const struct watchdog_info rn5t618_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_MAGICCLOSE |WDIOF_KEEPALIVEPING , .identity =DRIVER_NAME ,
drivers/watchdog/sbsa_gwdt.c +1 -1
@@ -207,7 +207,7 @@ static irqreturn_t sbsa_gwdt_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } -static struct watchdog_info sbsa_gwdt_info = { +static const struct watchdog_info sbsa_gwdt_info = { .identity =WATCHDOG_NAME , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
drivers/watchdog/w83627hf_wdt.c +1 -1
@@ -297,7 +297,7 @@ static unsigned int wdt_get_time(struct watchdog_device *wdog)* Kernel Interfaces */ -static struct watchdog_info wdt_info = { +static const struct watchdog_info wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE , .identity ="W83627HF Watchdog" , };
Signature · 1 line
1.9.1
Guenter Roeck
maintainerQuoted 62 lines · Bhumika Goyal
Declare
watchdog_infostructures as const as they are only stored in the info field ofwatchdog_devicestructures. This field is of type const structwatchdog_info*, sowatchdog_infostructures having this property can be declared const too.
Done using Coccinelle:@r1 disable optional_qualifier@
identifier i;
position p;
@@
static structwatchdog_infoi at p={...};@ok@
identifier r1.i;
position p;
structwatchdog_deviceobj;
@@
obj.info=&i at p;@bad@
position p!={r1.p,ok.p};
identifier r1.i;
@@
i at p@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
structwatchdog_infoi;Size details:
text data bss dec hex filename 1882 249 0 2131 853 drivers/watchdog/bcm7038_wdt.o 1938 193 0 2131 853 drivers/watchdog/bcm7038_wdt.o 1673 720 8 2401 961 drivers/watchdog/bcm_kona_wdt.o 1729 656 8 2393 959 drivers/watchdog/bcm_kona_wdt.o 2370 760 8 3138 c42 drivers/watchdog/cadence_wdt.o 2434 704 8 3146 c4a drivers/watchdog/cadence_wdt.o 1448 248 0 1696 6a0 drivers/watchdog/da9052_wdt.o 1512 192 0 1704 6a8 drivers/watchdog/da9052_wdt.o 1077 249 0 1326 52e drivers/watchdog/da9055_wdt.o 1141 193 0 1334 536 drivers/watchdog/da9055_wdt.o 1416 544 12 1972 7b4 drivers/watchdog/digicolor_wdt.o 1480 480 12 1972 7b4 drivers/watchdog/digicolor_wdt.o 2653 249 4 2906 b5a drivers/watchdog/imgpdc_wdt.o 2717 193 4 2914 b62 drivers/watchdog/imgpdc_wdt.o 2923 257 4 3184 c70 drivers/watchdog/kempld_wdt.o 2987 201 4 3192 c78 drivers/watchdog/kempld_wdt.o 2469 249 20 2738 ab2 drivers/watchdog/lpc18xx_wdt.o 2533 193 20 2746 aba drivers/watchdog/lpc18xx_wdt.o
Quoted 9 lines
1119 249 4 1372 55c drivers/watchdog/rn5t618_wdt.o 1183 193 4 1380 564 drivers/watchdog/rn5t618_wdt.o 1218 528 8 1754 6da drivers/watchdog/softdog.o 1282 464 8 1754 6da drivers/watchdog/softdog.o 2934 249 24 3207 c87 drivers/watchdog/w83627hf_wdt.o 2998 185 24 3207 c87 drivers/watchdog/w83627hf_wdt.o
The size details are quite irrelevant for the commit log. Also, please drop "drivers:" from the subject line.
Guenter
Quoted 173 lines
Signed-off-by Bhumika Goyal <[email protected]>--- drivers/watchdog/bcm7038_wdt.c | 2 +- drivers/watchdog/bcm_kona_wdt.c | 2 +- drivers/watchdog/cadence_wdt.c | 2 +- drivers/watchdog/da9052_wdt.c | 2 +- drivers/watchdog/da9055_wdt.c | 2 +- drivers/watchdog/digicolor_wdt.c | 2 +- drivers/watchdog/imgpdc_wdt.c | 2 +- drivers/watchdog/kempld_wdt.c | 2 +- drivers/watchdog/lpc18xx_wdt.c | 2 +- drivers/watchdog/rn5t618_wdt.c | 2 +- drivers/watchdog/sbsa_gwdt.c | 2 +- drivers/watchdog/w83627hf_wdt.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-)drivers/watchdog/bcm7038_wdt.c +1
-1@@ -101,7 +101,7 @@ static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog)return time_left / wdt->rate; } -static struct watchdog_info bcm7038_wdt_info = { +static const struct watchdog_info bcm7038_wdt_info = { .identity ="Broadcom BCM7038 Watchdog Timer" , .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE drivers/watchdog/bcm_kona_wdt.c +1
-1@@ -274,7 +274,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device *wdog) .get_timeleft = bcm_kona_wdt_get_timeleft, }; -static struct watchdog_info bcm_kona_wdt_info = { +static const struct watchdog_info bcm_kona_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_MAGICCLOSE |WDIOF_KEEPALIVEPING , .identity ="Broadcom Kona Watchdog Timer" ,drivers/watchdog/cadence_wdt.c +1
-1@@ -262,7 +262,7 @@ static irqreturn_t cdns_wdt_irq_handler(int irq, void *dev_id)* Info structure used to indicate the features supported by the device * to the upper layers. This is defined in watchdog.h header file. */ -static struct watchdog_info cdns_wdt_info = { +static const struct watchdog_info cdns_wdt_info = { .identity ="cdns_wdt watchdog" , .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE ,drivers/watchdog/da9052_wdt.c +1
-1@@ -140,7 +140,7 @@ static int da9052_wdt_ping(struct watchdog_device *wdt_dev)return ret; } -static struct watchdog_info da9052_wdt_info = { +static const struct watchdog_info da9052_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , .identity ="DA9052 Watchdog" , };drivers/watchdog/da9055_wdt.c +1
-1@@ -108,7 +108,7 @@ static int da9055_wdt_stop(struct watchdog_device *wdt_dev)return da9055_wdt_set_timeout (wdt_dev,0 ); } -static struct watchdog_info da9055_wdt_info = { +static const struct watchdog_info da9055_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , .identity ="DA9055 Watchdog" , };drivers/watchdog/digicolor_wdt.c +1
-1@@ -105,7 +105,7 @@ static unsigned int dc_wdt_get_timeleft(struct watchdog_device *wdog) .restart = dc_wdt_restart, }; -static struct watchdog_info dc_wdt_info = { +static const struct watchdog_info dc_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_MAGICCLOSE |WDIOF_KEEPALIVEPING , .identity ="Conexant Digicolor Watchdog" ,drivers/watchdog/imgpdc_wdt.c +1
-1@@ -161,7 +161,7 @@ static int pdc_wdt_restart(struct watchdog_device *wdt_dev,return 0 ; } -static struct watchdog_info pdc_wdt_info = { +static const struct watchdog_info pdc_wdt_info = { .identity ="IMG PDC Watchdog" , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |drivers/watchdog/kempld_wdt.c +1
-1@@ -422,7 +422,7 @@ static int kempld_wdt_probe_stages(struct watchdog_device *wdd)return 0 ; } -static struct watchdog_info kempld_wdt_info = { +static const struct watchdog_info kempld_wdt_info = { .identity ="KEMPLD Watchdog" , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |drivers/watchdog/lpc18xx_wdt.c +1
-1@@ -181,7 +181,7 @@ static int lpc18xx_wdt_restart(struct watchdog_device *wdt_dev,return 0 ; } -static struct watchdog_info lpc18xx_wdt_info = { +static const struct watchdog_info lpc18xx_wdt_info = { .identity ="NXP LPC18xx Watchdog" , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |drivers/watchdog/rn5t618_wdt.c +1
-1@@ -130,7 +130,7 @@ static int rn5t618_wdt_ping(struct watchdog_device *wdt_dev) RN5T618_PWRIRQ_IR_WDOG, 0); } -static struct watchdog_info rn5t618_wdt_info = { +static const struct watchdog_info rn5t618_wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_MAGICCLOSE |WDIOF_KEEPALIVEPING , .identity =DRIVER_NAME ,drivers/watchdog/sbsa_gwdt.c +1
-1@@ -207,7 +207,7 @@ static irqreturn_t sbsa_gwdt_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } -static struct watchdog_info sbsa_gwdt_info = { +static const struct watchdog_info sbsa_gwdt_info = { .identity =WATCHDOG_NAME , .options =WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |drivers/watchdog/w83627hf_wdt.c +1
-1@@ -297,7 +297,7 @@ static unsigned int wdt_get_time(struct watchdog_device *wdog)* Kernel Interfaces */ -static struct watchdog_info wdt_info = { +static const struct watchdog_info wdt_info = { .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE , .identity ="W83627HF Watchdog" , };