Re: [PATCH] watchdog: constify watchdog_ops structures

2017-01-28 Thread Guenter Roeck

On 01/28/2017 07:30 AM, Bhumika Goyal wrote:

On Sat, Jan 28, 2017 at 8:57 PM, Guenter Roeck  wrote:

On 01/27/2017 11:41 PM, Bhumika Goyal wrote:


Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:



I have a very similar patch from you already in my queue, one that was acked
and
reviewed by several people. Is this one different or are you just resending
?



This is a different one. That patch was for watchdog_info structures
and this one is for watchdog_ops.



Ah, slight but significant difference. Thanks for the clarification.


Thanks,
Bhumika


Guenter



@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

   textdata bss dec hex filename

   1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
   1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o

   1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
   1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o

925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
   1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o

   4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
   5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o

   1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
   2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o

   1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
   1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o


This is a bit misleading. "were not compiled" would have been more appropriate.
Either case, they all build fine.

Reviewed-by: Guenter Roeck 



Signed-off-by: Bhumika Goyal 
---
 drivers/watchdog/asm9260_wdt.c   | 2 +-
 drivers/watchdog/atlas7_wdt.c| 2 +-
 drivers/watchdog/bcm_kona_wdt.c  | 2 +-
 drivers/watchdog/booke_wdt.c | 2 +-
 drivers/watchdog/diag288_wdt.c   | 2 +-
 drivers/watchdog/digicolor_wdt.c | 2 +-
 drivers/watchdog/ep93xx_wdt.c| 2 +-
 drivers/watchdog/mt7621_wdt.c| 2 +-
 drivers/watchdog/rt2880_wdt.c| 2 +-
 drivers/watchdog/s3c2410_wdt.c   | 2 +-
 drivers/watchdog/sama5d4_wdt.c   | 2 +-
 drivers/watchdog/sbsa_gwdt.c | 2 +-
 drivers/watchdog/sirfsoc_wdt.c   | 2 +-
 drivers/watchdog/sun4v_wdt.c | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c
b/drivers/watchdog/asm9260_wdt.c
index d0b59ba..233dfa9 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident =
{
.identity = "Alphascale asm9260 Watchdog",
 };

-static struct watchdog_ops asm9260_wdt_ops = {
+static const struct watchdog_ops asm9260_wdt_ops = {
.owner  = THIS_MODULE,
.start  = asm9260_wdt_enable,
.stop   = asm9260_wdt_disable,
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
index ed80734..4abdcab 100644
--- a/drivers/watchdog/atlas7_wdt.c
+++ b/drivers/watchdog/atlas7_wdt.c
@@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
.identity = "atlas7 Watchdog",
 };

-static struct watchdog_ops atlas7_wdt_ops = {
+static const struct watchdog_ops atlas7_wdt_ops = {
.owner = THIS_MODULE,
.start = atlas7_wdt_enable,
.stop = atlas7_wdt_disable,
diff --git a/drivers/watchdog/bcm_kona_wdt.c
b/drivers/watchdog/bcm_kona_wdt.c
index e0c9842..80cdd16 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device
*wdog)
SECWDOG_SRSTEN_MASK, 0);
 }

-static struct watchdog_ops bcm_kona_wdt_ops = {
+static const struct watchdog_ops bcm_kona_wdt_ops = {
.owner =THIS_MODULE,
.start =bcm_kona_wdt_start,
.stop = bcm_kona_wdt_stop,
diff --git 

Re: [PATCH] watchdog: constify watchdog_ops structures

2017-01-28 Thread Guenter Roeck

On 01/28/2017 07:30 AM, Bhumika Goyal wrote:

On Sat, Jan 28, 2017 at 8:57 PM, Guenter Roeck  wrote:

On 01/27/2017 11:41 PM, Bhumika Goyal wrote:


Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:



I have a very similar patch from you already in my queue, one that was acked
and
reviewed by several people. Is this one different or are you just resending
?



This is a different one. That patch was for watchdog_info structures
and this one is for watchdog_ops.



Ah, slight but significant difference. Thanks for the clarification.


Thanks,
Bhumika


Guenter



@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

   textdata bss dec hex filename

   1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
   1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o

   1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
   1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o

925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
   1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o

   4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
   5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o

   1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
   2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o

   1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
   1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o


This is a bit misleading. "were not compiled" would have been more appropriate.
Either case, they all build fine.

Reviewed-by: Guenter Roeck 



Signed-off-by: Bhumika Goyal 
---
 drivers/watchdog/asm9260_wdt.c   | 2 +-
 drivers/watchdog/atlas7_wdt.c| 2 +-
 drivers/watchdog/bcm_kona_wdt.c  | 2 +-
 drivers/watchdog/booke_wdt.c | 2 +-
 drivers/watchdog/diag288_wdt.c   | 2 +-
 drivers/watchdog/digicolor_wdt.c | 2 +-
 drivers/watchdog/ep93xx_wdt.c| 2 +-
 drivers/watchdog/mt7621_wdt.c| 2 +-
 drivers/watchdog/rt2880_wdt.c| 2 +-
 drivers/watchdog/s3c2410_wdt.c   | 2 +-
 drivers/watchdog/sama5d4_wdt.c   | 2 +-
 drivers/watchdog/sbsa_gwdt.c | 2 +-
 drivers/watchdog/sirfsoc_wdt.c   | 2 +-
 drivers/watchdog/sun4v_wdt.c | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c
b/drivers/watchdog/asm9260_wdt.c
index d0b59ba..233dfa9 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident =
{
.identity = "Alphascale asm9260 Watchdog",
 };

-static struct watchdog_ops asm9260_wdt_ops = {
+static const struct watchdog_ops asm9260_wdt_ops = {
.owner  = THIS_MODULE,
.start  = asm9260_wdt_enable,
.stop   = asm9260_wdt_disable,
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
index ed80734..4abdcab 100644
--- a/drivers/watchdog/atlas7_wdt.c
+++ b/drivers/watchdog/atlas7_wdt.c
@@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
.identity = "atlas7 Watchdog",
 };

-static struct watchdog_ops atlas7_wdt_ops = {
+static const struct watchdog_ops atlas7_wdt_ops = {
.owner = THIS_MODULE,
.start = atlas7_wdt_enable,
.stop = atlas7_wdt_disable,
diff --git a/drivers/watchdog/bcm_kona_wdt.c
b/drivers/watchdog/bcm_kona_wdt.c
index e0c9842..80cdd16 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device
*wdog)
SECWDOG_SRSTEN_MASK, 0);
 }

-static struct watchdog_ops bcm_kona_wdt_ops = {
+static const struct watchdog_ops bcm_kona_wdt_ops = {
.owner =THIS_MODULE,
.start =bcm_kona_wdt_start,
.stop = bcm_kona_wdt_stop,
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 

Re: [PATCH] watchdog: constify watchdog_ops structures

2017-01-28 Thread Guenter Roeck

On 01/27/2017 11:41 PM, Bhumika Goyal wrote:

Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:



I have a very similar patch from you already in my queue, one that was acked and
reviewed by several people. Is this one different or are you just resending ?

Guenter


@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

   textdata bss dec hex filename

   1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
   1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o

   1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
   1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o

925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
   1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o

   4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
   5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o

   1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
   2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o

   1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
   1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o

Signed-off-by: Bhumika Goyal 
---
 drivers/watchdog/asm9260_wdt.c   | 2 +-
 drivers/watchdog/atlas7_wdt.c| 2 +-
 drivers/watchdog/bcm_kona_wdt.c  | 2 +-
 drivers/watchdog/booke_wdt.c | 2 +-
 drivers/watchdog/diag288_wdt.c   | 2 +-
 drivers/watchdog/digicolor_wdt.c | 2 +-
 drivers/watchdog/ep93xx_wdt.c| 2 +-
 drivers/watchdog/mt7621_wdt.c| 2 +-
 drivers/watchdog/rt2880_wdt.c| 2 +-
 drivers/watchdog/s3c2410_wdt.c   | 2 +-
 drivers/watchdog/sama5d4_wdt.c   | 2 +-
 drivers/watchdog/sbsa_gwdt.c | 2 +-
 drivers/watchdog/sirfsoc_wdt.c   | 2 +-
 drivers/watchdog/sun4v_wdt.c | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index d0b59ba..233dfa9 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident = {
.identity = "Alphascale asm9260 Watchdog",
 };

-static struct watchdog_ops asm9260_wdt_ops = {
+static const struct watchdog_ops asm9260_wdt_ops = {
.owner  = THIS_MODULE,
.start  = asm9260_wdt_enable,
.stop   = asm9260_wdt_disable,
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
index ed80734..4abdcab 100644
--- a/drivers/watchdog/atlas7_wdt.c
+++ b/drivers/watchdog/atlas7_wdt.c
@@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
.identity = "atlas7 Watchdog",
 };

-static struct watchdog_ops atlas7_wdt_ops = {
+static const struct watchdog_ops atlas7_wdt_ops = {
.owner = THIS_MODULE,
.start = atlas7_wdt_enable,
.stop = atlas7_wdt_disable,
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c
index e0c9842..80cdd16 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device *wdog)
SECWDOG_SRSTEN_MASK, 0);
 }

-static struct watchdog_ops bcm_kona_wdt_ops = {
+static const struct watchdog_ops bcm_kona_wdt_ops = {
.owner =THIS_MODULE,
.start =bcm_kona_wdt_start,
.stop = bcm_kona_wdt_stop,
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 04da4b6..4925034 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -197,7 +197,7 @@ static struct watchdog_info booke_wdt_info = {
.identity = "PowerPC Book-E Watchdog",
 };

-static struct watchdog_ops booke_wdt_ops = {
+static const struct watchdog_ops booke_wdt_ops = {
.owner = THIS_MODULE,
.start = booke_wdt_start,
.stop = booke_wdt_stop,
diff --git 

Re: [PATCH] watchdog: constify watchdog_ops structures

2017-01-28 Thread Guenter Roeck

On 01/27/2017 11:41 PM, Bhumika Goyal wrote:

Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:



I have a very similar patch from you already in my queue, one that was acked and
reviewed by several people. Is this one different or are you just resending ?

Guenter


@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

   textdata bss dec hex filename

   1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
   1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o

   1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
   1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o

925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
   1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o

   4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
   5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o

   1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
   2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o

   1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
   1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o

Signed-off-by: Bhumika Goyal 
---
 drivers/watchdog/asm9260_wdt.c   | 2 +-
 drivers/watchdog/atlas7_wdt.c| 2 +-
 drivers/watchdog/bcm_kona_wdt.c  | 2 +-
 drivers/watchdog/booke_wdt.c | 2 +-
 drivers/watchdog/diag288_wdt.c   | 2 +-
 drivers/watchdog/digicolor_wdt.c | 2 +-
 drivers/watchdog/ep93xx_wdt.c| 2 +-
 drivers/watchdog/mt7621_wdt.c| 2 +-
 drivers/watchdog/rt2880_wdt.c| 2 +-
 drivers/watchdog/s3c2410_wdt.c   | 2 +-
 drivers/watchdog/sama5d4_wdt.c   | 2 +-
 drivers/watchdog/sbsa_gwdt.c | 2 +-
 drivers/watchdog/sirfsoc_wdt.c   | 2 +-
 drivers/watchdog/sun4v_wdt.c | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index d0b59ba..233dfa9 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident = {
.identity = "Alphascale asm9260 Watchdog",
 };

-static struct watchdog_ops asm9260_wdt_ops = {
+static const struct watchdog_ops asm9260_wdt_ops = {
.owner  = THIS_MODULE,
.start  = asm9260_wdt_enable,
.stop   = asm9260_wdt_disable,
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
index ed80734..4abdcab 100644
--- a/drivers/watchdog/atlas7_wdt.c
+++ b/drivers/watchdog/atlas7_wdt.c
@@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
.identity = "atlas7 Watchdog",
 };

-static struct watchdog_ops atlas7_wdt_ops = {
+static const struct watchdog_ops atlas7_wdt_ops = {
.owner = THIS_MODULE,
.start = atlas7_wdt_enable,
.stop = atlas7_wdt_disable,
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c
index e0c9842..80cdd16 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device *wdog)
SECWDOG_SRSTEN_MASK, 0);
 }

-static struct watchdog_ops bcm_kona_wdt_ops = {
+static const struct watchdog_ops bcm_kona_wdt_ops = {
.owner =THIS_MODULE,
.start =bcm_kona_wdt_start,
.stop = bcm_kona_wdt_stop,
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 04da4b6..4925034 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -197,7 +197,7 @@ static struct watchdog_info booke_wdt_info = {
.identity = "PowerPC Book-E Watchdog",
 };

-static struct watchdog_ops booke_wdt_ops = {
+static const struct watchdog_ops booke_wdt_ops = {
.owner = THIS_MODULE,
.start = booke_wdt_start,
.stop = booke_wdt_stop,
diff --git a/drivers/watchdog/diag288_wdt.c 

Re: [PATCH] watchdog: constify watchdog_ops structures

2017-01-28 Thread Bhumika Goyal
On Sat, Jan 28, 2017 at 8:57 PM, Guenter Roeck  wrote:
> On 01/27/2017 11:41 PM, Bhumika Goyal wrote:
>>
>> Declare watchdog_ops structures as const as they are only stored in the
>> ops field of a watchdog_device structure. This field is of type const, so
>> watchdog_ops structures having this property can be made const too.
>> Done using Coccinelle:
>>
>
> I have a very similar patch from you already in my queue, one that was acked
> and
> reviewed by several people. Is this one different or are you just resending
> ?
>

This is a different one. That patch was for watchdog_info structures
and this one is for watchdog_ops.

Thanks,
Bhumika

> Guenter
>
>
>> @r disable optional_qualifier@
>> identifier x;
>> position p;
>> @@
>> static struct watchdog_ops x@p={...};
>>
>> @ok@
>> struct watchdog_device w;
>> identifier r.x;
>> position p;
>> @@
>> w.ops=@p;
>>
>> @bad@
>> position p != {r.p,ok.p};
>> identifier r.x;
>> @@
>> x@p
>>
>> @depends on !bad disable optional_qualifier@
>> identifier r.x;
>> @@
>> +const
>> struct watchdog_ops x;
>>
>> File size details before and after patching.
>> First line of every .o file shows the file size before patching
>> and second line shows the size after patching.
>>
>>textdata bss dec hex filename
>>
>>1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
>>1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o
>>
>>1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
>>1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o
>>
>> 925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
>>1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o
>>
>>4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
>>5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o
>>
>>1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
>>2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o
>>
>>1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
>>1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o
>>
>> Size remains the same for the files drivers/watchdog/diag288_wdt.o
>> drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o
>>
>> The following .o files did not compile:
>> drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
>> drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
>> drivers/watchdog/mt7621_wdt.o
>>
>> Signed-off-by: Bhumika Goyal 
>> ---
>>  drivers/watchdog/asm9260_wdt.c   | 2 +-
>>  drivers/watchdog/atlas7_wdt.c| 2 +-
>>  drivers/watchdog/bcm_kona_wdt.c  | 2 +-
>>  drivers/watchdog/booke_wdt.c | 2 +-
>>  drivers/watchdog/diag288_wdt.c   | 2 +-
>>  drivers/watchdog/digicolor_wdt.c | 2 +-
>>  drivers/watchdog/ep93xx_wdt.c| 2 +-
>>  drivers/watchdog/mt7621_wdt.c| 2 +-
>>  drivers/watchdog/rt2880_wdt.c| 2 +-
>>  drivers/watchdog/s3c2410_wdt.c   | 2 +-
>>  drivers/watchdog/sama5d4_wdt.c   | 2 +-
>>  drivers/watchdog/sbsa_gwdt.c | 2 +-
>>  drivers/watchdog/sirfsoc_wdt.c   | 2 +-
>>  drivers/watchdog/sun4v_wdt.c | 2 +-
>>  14 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/watchdog/asm9260_wdt.c
>> b/drivers/watchdog/asm9260_wdt.c
>> index d0b59ba..233dfa9 100644
>> --- a/drivers/watchdog/asm9260_wdt.c
>> +++ b/drivers/watchdog/asm9260_wdt.c
>> @@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident =
>> {
>> .identity = "Alphascale asm9260 Watchdog",
>>  };
>>
>> -static struct watchdog_ops asm9260_wdt_ops = {
>> +static const struct watchdog_ops asm9260_wdt_ops = {
>> .owner  = THIS_MODULE,
>> .start  = asm9260_wdt_enable,
>> .stop   = asm9260_wdt_disable,
>> diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
>> index ed80734..4abdcab 100644
>> --- a/drivers/watchdog/atlas7_wdt.c
>> +++ b/drivers/watchdog/atlas7_wdt.c
>> @@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
>> .identity = "atlas7 Watchdog",
>>  };
>>
>> -static struct watchdog_ops atlas7_wdt_ops = {
>> +static const struct watchdog_ops atlas7_wdt_ops = {
>> .owner = THIS_MODULE,
>> .start = atlas7_wdt_enable,
>> .stop = atlas7_wdt_disable,
>> diff --git a/drivers/watchdog/bcm_kona_wdt.c
>> b/drivers/watchdog/bcm_kona_wdt.c
>> index e0c9842..80cdd16 100644
>> --- a/drivers/watchdog/bcm_kona_wdt.c
>> +++ b/drivers/watchdog/bcm_kona_wdt.c
>> @@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device
>> *wdog)
>> SECWDOG_SRSTEN_MASK, 0);
>>  }
>>
>> -static struct watchdog_ops bcm_kona_wdt_ops = {
>> +static const struct watchdog_ops bcm_kona_wdt_ops = {
>> .owner =THIS_MODULE,
>> .start =bcm_kona_wdt_start,
>>   

Re: [PATCH] watchdog: constify watchdog_ops structures

2017-01-28 Thread Bhumika Goyal
On Sat, Jan 28, 2017 at 8:57 PM, Guenter Roeck  wrote:
> On 01/27/2017 11:41 PM, Bhumika Goyal wrote:
>>
>> Declare watchdog_ops structures as const as they are only stored in the
>> ops field of a watchdog_device structure. This field is of type const, so
>> watchdog_ops structures having this property can be made const too.
>> Done using Coccinelle:
>>
>
> I have a very similar patch from you already in my queue, one that was acked
> and
> reviewed by several people. Is this one different or are you just resending
> ?
>

This is a different one. That patch was for watchdog_info structures
and this one is for watchdog_ops.

Thanks,
Bhumika

> Guenter
>
>
>> @r disable optional_qualifier@
>> identifier x;
>> position p;
>> @@
>> static struct watchdog_ops x@p={...};
>>
>> @ok@
>> struct watchdog_device w;
>> identifier r.x;
>> position p;
>> @@
>> w.ops=@p;
>>
>> @bad@
>> position p != {r.p,ok.p};
>> identifier r.x;
>> @@
>> x@p
>>
>> @depends on !bad disable optional_qualifier@
>> identifier r.x;
>> @@
>> +const
>> struct watchdog_ops x;
>>
>> File size details before and after patching.
>> First line of every .o file shows the file size before patching
>> and second line shows the size after patching.
>>
>>textdata bss dec hex filename
>>
>>1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
>>1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o
>>
>>1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
>>1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o
>>
>> 925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
>>1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o
>>
>>4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
>>5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o
>>
>>1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
>>2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o
>>
>>1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
>>1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o
>>
>> Size remains the same for the files drivers/watchdog/diag288_wdt.o
>> drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o
>>
>> The following .o files did not compile:
>> drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
>> drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
>> drivers/watchdog/mt7621_wdt.o
>>
>> Signed-off-by: Bhumika Goyal 
>> ---
>>  drivers/watchdog/asm9260_wdt.c   | 2 +-
>>  drivers/watchdog/atlas7_wdt.c| 2 +-
>>  drivers/watchdog/bcm_kona_wdt.c  | 2 +-
>>  drivers/watchdog/booke_wdt.c | 2 +-
>>  drivers/watchdog/diag288_wdt.c   | 2 +-
>>  drivers/watchdog/digicolor_wdt.c | 2 +-
>>  drivers/watchdog/ep93xx_wdt.c| 2 +-
>>  drivers/watchdog/mt7621_wdt.c| 2 +-
>>  drivers/watchdog/rt2880_wdt.c| 2 +-
>>  drivers/watchdog/s3c2410_wdt.c   | 2 +-
>>  drivers/watchdog/sama5d4_wdt.c   | 2 +-
>>  drivers/watchdog/sbsa_gwdt.c | 2 +-
>>  drivers/watchdog/sirfsoc_wdt.c   | 2 +-
>>  drivers/watchdog/sun4v_wdt.c | 2 +-
>>  14 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/watchdog/asm9260_wdt.c
>> b/drivers/watchdog/asm9260_wdt.c
>> index d0b59ba..233dfa9 100644
>> --- a/drivers/watchdog/asm9260_wdt.c
>> +++ b/drivers/watchdog/asm9260_wdt.c
>> @@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident =
>> {
>> .identity = "Alphascale asm9260 Watchdog",
>>  };
>>
>> -static struct watchdog_ops asm9260_wdt_ops = {
>> +static const struct watchdog_ops asm9260_wdt_ops = {
>> .owner  = THIS_MODULE,
>> .start  = asm9260_wdt_enable,
>> .stop   = asm9260_wdt_disable,
>> diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
>> index ed80734..4abdcab 100644
>> --- a/drivers/watchdog/atlas7_wdt.c
>> +++ b/drivers/watchdog/atlas7_wdt.c
>> @@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
>> .identity = "atlas7 Watchdog",
>>  };
>>
>> -static struct watchdog_ops atlas7_wdt_ops = {
>> +static const struct watchdog_ops atlas7_wdt_ops = {
>> .owner = THIS_MODULE,
>> .start = atlas7_wdt_enable,
>> .stop = atlas7_wdt_disable,
>> diff --git a/drivers/watchdog/bcm_kona_wdt.c
>> b/drivers/watchdog/bcm_kona_wdt.c
>> index e0c9842..80cdd16 100644
>> --- a/drivers/watchdog/bcm_kona_wdt.c
>> +++ b/drivers/watchdog/bcm_kona_wdt.c
>> @@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device
>> *wdog)
>> SECWDOG_SRSTEN_MASK, 0);
>>  }
>>
>> -static struct watchdog_ops bcm_kona_wdt_ops = {
>> +static const struct watchdog_ops bcm_kona_wdt_ops = {
>> .owner =THIS_MODULE,
>> .start =bcm_kona_wdt_start,
>> .stop = 

[PATCH] watchdog: constify watchdog_ops structures

2017-01-27 Thread Bhumika Goyal
Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

   textdata bss dec hex filename

   1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
   1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o

   1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
   1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o

925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
   1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o

   4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
   5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o

   1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
   2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o

   1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
   1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o

Signed-off-by: Bhumika Goyal 
---
 drivers/watchdog/asm9260_wdt.c   | 2 +-
 drivers/watchdog/atlas7_wdt.c| 2 +-
 drivers/watchdog/bcm_kona_wdt.c  | 2 +-
 drivers/watchdog/booke_wdt.c | 2 +-
 drivers/watchdog/diag288_wdt.c   | 2 +-
 drivers/watchdog/digicolor_wdt.c | 2 +-
 drivers/watchdog/ep93xx_wdt.c| 2 +-
 drivers/watchdog/mt7621_wdt.c| 2 +-
 drivers/watchdog/rt2880_wdt.c| 2 +-
 drivers/watchdog/s3c2410_wdt.c   | 2 +-
 drivers/watchdog/sama5d4_wdt.c   | 2 +-
 drivers/watchdog/sbsa_gwdt.c | 2 +-
 drivers/watchdog/sirfsoc_wdt.c   | 2 +-
 drivers/watchdog/sun4v_wdt.c | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index d0b59ba..233dfa9 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident = {
.identity = "Alphascale asm9260 Watchdog",
 };
 
-static struct watchdog_ops asm9260_wdt_ops = {
+static const struct watchdog_ops asm9260_wdt_ops = {
.owner  = THIS_MODULE,
.start  = asm9260_wdt_enable,
.stop   = asm9260_wdt_disable,
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
index ed80734..4abdcab 100644
--- a/drivers/watchdog/atlas7_wdt.c
+++ b/drivers/watchdog/atlas7_wdt.c
@@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
.identity = "atlas7 Watchdog",
 };
 
-static struct watchdog_ops atlas7_wdt_ops = {
+static const struct watchdog_ops atlas7_wdt_ops = {
.owner = THIS_MODULE,
.start = atlas7_wdt_enable,
.stop = atlas7_wdt_disable,
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c
index e0c9842..80cdd16 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device *wdog)
SECWDOG_SRSTEN_MASK, 0);
 }
 
-static struct watchdog_ops bcm_kona_wdt_ops = {
+static const struct watchdog_ops bcm_kona_wdt_ops = {
.owner =THIS_MODULE,
.start =bcm_kona_wdt_start,
.stop = bcm_kona_wdt_stop,
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 04da4b6..4925034 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -197,7 +197,7 @@ static struct watchdog_info booke_wdt_info = {
.identity = "PowerPC Book-E Watchdog",
 };
 
-static struct watchdog_ops booke_wdt_ops = {
+static const struct watchdog_ops booke_wdt_ops = {
.owner = THIS_MODULE,
.start = booke_wdt_start,
.stop = booke_wdt_stop,
diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
index 861d3d3..6f59108 100644
--- a/drivers/watchdog/diag288_wdt.c
+++ b/drivers/watchdog/diag288_wdt.c
@@ -205,7 +205,7 @@ static int wdt_set_timeout(struct watchdog_device 

[PATCH] watchdog: constify watchdog_ops structures

2017-01-27 Thread Bhumika Goyal
Declare watchdog_ops structures as const as they are only stored in the
ops field of a watchdog_device structure. This field is of type const, so
watchdog_ops structures having this property can be made const too.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct watchdog_ops x@p={...};

@ok@
struct watchdog_device w;
identifier r.x;
position p;
@@
w.ops=@p;

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct watchdog_ops x;

File size details before and after patching.
First line of every .o file shows the file size before patching
and second line shows the size after patching.

   textdata bss dec hex filename

   1340 544   01884 75c drivers/watchdog/bcm_kona_wdt.o
   1436 440   01876 754 drivers/watchdog/bcm_kona_wdt.o

   1176 544   41724 6bc drivers/watchdog/digicolor_wdt.o
   1272 440   41716 6b4 drivers/watchdog/digicolor_wdt.o

925 580  891594 63a drivers/watchdog/ep93xx_wdt.o
   1021 476  891586 632 drivers/watchdog/ep93xx_wdt.o

   4932 288  1752371475 drivers/watchdog/s3c2410_wdt.o
   5028 192  1752371475 drivers/watchdog/s3c2410_wdt.o

   1977 292   12270 8de drivers/watchdog/sama5d4_wdt.o
   2073 196   12270 8de drivers/watchdog/sama5d4_wdt.o

   1375 484   11860 744 drivers/watchdog/sirfsoc_wdt.o
   1471 380   11852 73c drivers/watchdog/sirfsoc_wdt.o

Size remains the same for the files drivers/watchdog/diag288_wdt.o
drivers/watchdog/asm9260_wdt.o and drivers/watchdog/atlas7_wdt.o

The following .o files did not compile:
drivers/watchdog/sun4v_wdt.o, drivers/watchdog/sbsa_gwdt.o,
drivers/watchdog/rt2880_wdt.o, drivers/watchdog/booke_wdt.o
drivers/watchdog/mt7621_wdt.o

Signed-off-by: Bhumika Goyal 
---
 drivers/watchdog/asm9260_wdt.c   | 2 +-
 drivers/watchdog/atlas7_wdt.c| 2 +-
 drivers/watchdog/bcm_kona_wdt.c  | 2 +-
 drivers/watchdog/booke_wdt.c | 2 +-
 drivers/watchdog/diag288_wdt.c   | 2 +-
 drivers/watchdog/digicolor_wdt.c | 2 +-
 drivers/watchdog/ep93xx_wdt.c| 2 +-
 drivers/watchdog/mt7621_wdt.c| 2 +-
 drivers/watchdog/rt2880_wdt.c| 2 +-
 drivers/watchdog/s3c2410_wdt.c   | 2 +-
 drivers/watchdog/sama5d4_wdt.c   | 2 +-
 drivers/watchdog/sbsa_gwdt.c | 2 +-
 drivers/watchdog/sirfsoc_wdt.c   | 2 +-
 drivers/watchdog/sun4v_wdt.c | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index d0b59ba..233dfa9 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -189,7 +189,7 @@ static const struct watchdog_info asm9260_wdt_ident = {
.identity = "Alphascale asm9260 Watchdog",
 };
 
-static struct watchdog_ops asm9260_wdt_ops = {
+static const struct watchdog_ops asm9260_wdt_ops = {
.owner  = THIS_MODULE,
.start  = asm9260_wdt_enable,
.stop   = asm9260_wdt_disable,
diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c
index ed80734..4abdcab 100644
--- a/drivers/watchdog/atlas7_wdt.c
+++ b/drivers/watchdog/atlas7_wdt.c
@@ -105,7 +105,7 @@ static const struct watchdog_info atlas7_wdt_ident = {
.identity = "atlas7 Watchdog",
 };
 
-static struct watchdog_ops atlas7_wdt_ops = {
+static const struct watchdog_ops atlas7_wdt_ops = {
.owner = THIS_MODULE,
.start = atlas7_wdt_enable,
.stop = atlas7_wdt_disable,
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c
index e0c9842..80cdd16 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -266,7 +266,7 @@ static int bcm_kona_wdt_stop(struct watchdog_device *wdog)
SECWDOG_SRSTEN_MASK, 0);
 }
 
-static struct watchdog_ops bcm_kona_wdt_ops = {
+static const struct watchdog_ops bcm_kona_wdt_ops = {
.owner =THIS_MODULE,
.start =bcm_kona_wdt_start,
.stop = bcm_kona_wdt_stop,
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 04da4b6..4925034 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -197,7 +197,7 @@ static struct watchdog_info booke_wdt_info = {
.identity = "PowerPC Book-E Watchdog",
 };
 
-static struct watchdog_ops booke_wdt_ops = {
+static const struct watchdog_ops booke_wdt_ops = {
.owner = THIS_MODULE,
.start = booke_wdt_start,
.stop = booke_wdt_stop,
diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
index 861d3d3..6f59108 100644
--- a/drivers/watchdog/diag288_wdt.c
+++ b/drivers/watchdog/diag288_wdt.c
@@ -205,7 +205,7 @@ static int wdt_set_timeout(struct watchdog_device * dev, 
unsigned