Re: [PATCH] drivers: media: i2c: constify v4l2_subdev_* structures

2016-12-12 Thread Laurent Pinchart
Hi Bhumika,

Thank you for the patch.

On Monday 12 Dec 2016 13:15:32 Bhumika Goyal wrote:
> v4l2_subdev_{core/pad/video}_ops structures are stored in the
> fields of the v4l2_subdev_ops structure which are of type const.
> Also, v4l2_subdev_ops structure is passed to a function
> having its argument of type const. As these structures are never
> modified, so declare them as const.
> Done using Coccinelle: (One of the scripts used)
> 
> @r1 disable optional_qualifier @
> identifier i;
> position p;
> @@
> static struct v4l2_subdev_video_ops i@p = {...};
> 
> @ok1@
> identifier r1.i;
> position p;
> struct v4l2_subdev_ops obj;
> @@
> obj.video=@p;
> 
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct v4l2_subdev_video_ops i;
> 
> File sizes before:
>   text   data bss dec hex filename
>7810   736  1685622172 drivers/media/i2c/mt9p031.o
>9652   736  24   1041228ac drivers/media/i2c/mt9v032.o
>4613   552  2051851441 
drivers/media/i2c/noon010pc30.o
>2615   552   83175 c67 drivers/media/i2c/s5k6a3.o
> 
> File sizes after:
>   text   data bss dec hex filename
>8322   232  168570217a drivers/media/i2c/mt9p031.o
>   10164   232  24   1042028b4 drivers/media/i2c/mt9v032.o
>4933   232  2051851441 
drivers/media/i2c/noon010pc30.o
>2935   232   83175 c67 drivers/media/i2c/s5k6a3.o
> 
> Signed-off-by: Bhumika Goyal 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/media/i2c/mt9p031.c | 8 
>  drivers/media/i2c/mt9v032.c | 8 
>  drivers/media/i2c/noon010pc30.c | 4 ++--
>  drivers/media/i2c/s5k6a3.c  | 6 +++---
>  4 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
> index 237737f..91d822f 100644
> --- a/drivers/media/i2c/mt9p031.c
> +++ b/drivers/media/i2c/mt9p031.c
> @@ -972,15 +972,15 @@ static int mt9p031_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) return mt9p031_set_power(subdev, 0);
>  }
> 
> -static struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
> +static const struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
>   .s_power= mt9p031_set_power,
>  };
> 
> -static struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
> +static const struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
>   .s_stream   = mt9p031_s_stream,
>  };
> 
> -static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
> +static const struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
>   .enum_mbus_code = mt9p031_enum_mbus_code,
>   .enum_frame_size = mt9p031_enum_frame_size,
>   .get_fmt = mt9p031_get_format,
> @@ -989,7 +989,7 @@ static int mt9p031_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) .set_selection = mt9p031_set_selection,
>  };
> 
> -static struct v4l2_subdev_ops mt9p031_subdev_ops = {
> +static const struct v4l2_subdev_ops mt9p031_subdev_ops = {
>   .core   = _subdev_core_ops,
>   .video  = _subdev_video_ops,
>   .pad= _subdev_pad_ops,
> diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
> index 58eb62f..88b7890 100644
> --- a/drivers/media/i2c/mt9v032.c
> +++ b/drivers/media/i2c/mt9v032.c
> @@ -936,15 +936,15 @@ static int mt9v032_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) return mt9v032_set_power(subdev, 0);
>  }
> 
> -static struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
> +static const struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
>   .s_power= mt9v032_set_power,
>  };
> 
> -static struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
> +static const struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
>   .s_stream   = mt9v032_s_stream,
>  };
> 
> -static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
> +static const struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
>   .enum_mbus_code = mt9v032_enum_mbus_code,
>   .enum_frame_size = mt9v032_enum_frame_size,
>   .get_fmt = mt9v032_get_format,
> @@ -953,7 +953,7 @@ static int mt9v032_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) .set_selection = mt9v032_set_selection,
>  };
> 
> -static struct v4l2_subdev_ops mt9v032_subdev_ops = {
> +static const struct v4l2_subdev_ops mt9v032_subdev_ops = {
>   .core   = _subdev_core_ops,
>   .video  = _subdev_video_ops,
>   .pad= _subdev_pad_ops,
> diff --git a/drivers/media/i2c/noon010pc30.c
> b/drivers/media/i2c/noon010pc30.c index 30cb90b..88c498a 100644
> --- a/drivers/media/i2c/noon010pc30.c
> +++ b/drivers/media/i2c/noon010pc30.c
> @@ -664,13 +664,13 @@ static int noon010_open(struct v4l2_subdev *sd, 

Re: [PATCH] drivers: media: i2c: constify v4l2_subdev_* structures

2016-12-12 Thread Laurent Pinchart
Hi Bhumika,

Thank you for the patch.

On Monday 12 Dec 2016 13:15:32 Bhumika Goyal wrote:
> v4l2_subdev_{core/pad/video}_ops structures are stored in the
> fields of the v4l2_subdev_ops structure which are of type const.
> Also, v4l2_subdev_ops structure is passed to a function
> having its argument of type const. As these structures are never
> modified, so declare them as const.
> Done using Coccinelle: (One of the scripts used)
> 
> @r1 disable optional_qualifier @
> identifier i;
> position p;
> @@
> static struct v4l2_subdev_video_ops i@p = {...};
> 
> @ok1@
> identifier r1.i;
> position p;
> struct v4l2_subdev_ops obj;
> @@
> obj.video=@p;
> 
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct v4l2_subdev_video_ops i;
> 
> File sizes before:
>   text   data bss dec hex filename
>7810   736  1685622172 drivers/media/i2c/mt9p031.o
>9652   736  24   1041228ac drivers/media/i2c/mt9v032.o
>4613   552  2051851441 
drivers/media/i2c/noon010pc30.o
>2615   552   83175 c67 drivers/media/i2c/s5k6a3.o
> 
> File sizes after:
>   text   data bss dec hex filename
>8322   232  168570217a drivers/media/i2c/mt9p031.o
>   10164   232  24   1042028b4 drivers/media/i2c/mt9v032.o
>4933   232  2051851441 
drivers/media/i2c/noon010pc30.o
>2935   232   83175 c67 drivers/media/i2c/s5k6a3.o
> 
> Signed-off-by: Bhumika Goyal 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/media/i2c/mt9p031.c | 8 
>  drivers/media/i2c/mt9v032.c | 8 
>  drivers/media/i2c/noon010pc30.c | 4 ++--
>  drivers/media/i2c/s5k6a3.c  | 6 +++---
>  4 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
> index 237737f..91d822f 100644
> --- a/drivers/media/i2c/mt9p031.c
> +++ b/drivers/media/i2c/mt9p031.c
> @@ -972,15 +972,15 @@ static int mt9p031_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) return mt9p031_set_power(subdev, 0);
>  }
> 
> -static struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
> +static const struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
>   .s_power= mt9p031_set_power,
>  };
> 
> -static struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
> +static const struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
>   .s_stream   = mt9p031_s_stream,
>  };
> 
> -static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
> +static const struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
>   .enum_mbus_code = mt9p031_enum_mbus_code,
>   .enum_frame_size = mt9p031_enum_frame_size,
>   .get_fmt = mt9p031_get_format,
> @@ -989,7 +989,7 @@ static int mt9p031_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) .set_selection = mt9p031_set_selection,
>  };
> 
> -static struct v4l2_subdev_ops mt9p031_subdev_ops = {
> +static const struct v4l2_subdev_ops mt9p031_subdev_ops = {
>   .core   = _subdev_core_ops,
>   .video  = _subdev_video_ops,
>   .pad= _subdev_pad_ops,
> diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
> index 58eb62f..88b7890 100644
> --- a/drivers/media/i2c/mt9v032.c
> +++ b/drivers/media/i2c/mt9v032.c
> @@ -936,15 +936,15 @@ static int mt9v032_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) return mt9v032_set_power(subdev, 0);
>  }
> 
> -static struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
> +static const struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
>   .s_power= mt9v032_set_power,
>  };
> 
> -static struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
> +static const struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
>   .s_stream   = mt9v032_s_stream,
>  };
> 
> -static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
> +static const struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
>   .enum_mbus_code = mt9v032_enum_mbus_code,
>   .enum_frame_size = mt9v032_enum_frame_size,
>   .get_fmt = mt9v032_get_format,
> @@ -953,7 +953,7 @@ static int mt9v032_close(struct v4l2_subdev *subdev,
> struct v4l2_subdev_fh *fh) .set_selection = mt9v032_set_selection,
>  };
> 
> -static struct v4l2_subdev_ops mt9v032_subdev_ops = {
> +static const struct v4l2_subdev_ops mt9v032_subdev_ops = {
>   .core   = _subdev_core_ops,
>   .video  = _subdev_video_ops,
>   .pad= _subdev_pad_ops,
> diff --git a/drivers/media/i2c/noon010pc30.c
> b/drivers/media/i2c/noon010pc30.c index 30cb90b..88c498a 100644
> --- a/drivers/media/i2c/noon010pc30.c
> +++ b/drivers/media/i2c/noon010pc30.c
> @@ -664,13 +664,13 @@ static int noon010_open(struct v4l2_subdev *sd, struct
> v4l2_subdev_fh *fh) .log_status   = 

[PATCH] drivers: media: i2c: constify v4l2_subdev_* structures

2016-12-11 Thread Bhumika Goyal
v4l2_subdev_{core/pad/video}_ops structures are stored in the
fields of the v4l2_subdev_ops structure which are of type const.
Also, v4l2_subdev_ops structure is passed to a function
having its argument of type const. As these structures are never
modified, so declare them as const.
Done using Coccinelle: (One of the scripts used)

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct v4l2_subdev_video_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct v4l2_subdev_ops obj;
@@
obj.video=@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct v4l2_subdev_video_ops i;

File sizes before:
  text data bss dec hex filename
   7810 736  1685622172 drivers/media/i2c/mt9p031.o
   9652 736  24   1041228ac drivers/media/i2c/mt9v032.o
   4613 552  2051851441 drivers/media/i2c/noon010pc30.o
   2615 552   83175 c67 drivers/media/i2c/s5k6a3.o

File sizes after:
  text data bss dec hex filename
   8322 232  168570217a drivers/media/i2c/mt9p031.o
  10164 232  24   1042028b4 drivers/media/i2c/mt9v032.o
   4933 232  2051851441 drivers/media/i2c/noon010pc30.o
   2935 232   83175 c67 drivers/media/i2c/s5k6a3.o

Signed-off-by: Bhumika Goyal 
---
 drivers/media/i2c/mt9p031.c | 8 
 drivers/media/i2c/mt9v032.c | 8 
 drivers/media/i2c/noon010pc30.c | 4 ++--
 drivers/media/i2c/s5k6a3.c  | 6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 237737f..91d822f 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -972,15 +972,15 @@ static int mt9p031_close(struct v4l2_subdev *subdev, 
struct v4l2_subdev_fh *fh)
return mt9p031_set_power(subdev, 0);
 }
 
-static struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
.s_power= mt9p031_set_power,
 };
 
-static struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
.s_stream   = mt9p031_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
.enum_mbus_code = mt9p031_enum_mbus_code,
.enum_frame_size = mt9p031_enum_frame_size,
.get_fmt = mt9p031_get_format,
@@ -989,7 +989,7 @@ static int mt9p031_close(struct v4l2_subdev *subdev, struct 
v4l2_subdev_fh *fh)
.set_selection = mt9p031_set_selection,
 };
 
-static struct v4l2_subdev_ops mt9p031_subdev_ops = {
+static const struct v4l2_subdev_ops mt9p031_subdev_ops = {
.core   = _subdev_core_ops,
.video  = _subdev_video_ops,
.pad= _subdev_pad_ops,
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 58eb62f..88b7890 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -936,15 +936,15 @@ static int mt9v032_close(struct v4l2_subdev *subdev, 
struct v4l2_subdev_fh *fh)
return mt9v032_set_power(subdev, 0);
 }
 
-static struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
.s_power= mt9v032_set_power,
 };
 
-static struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
.s_stream   = mt9v032_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
.enum_mbus_code = mt9v032_enum_mbus_code,
.enum_frame_size = mt9v032_enum_frame_size,
.get_fmt = mt9v032_get_format,
@@ -953,7 +953,7 @@ static int mt9v032_close(struct v4l2_subdev *subdev, struct 
v4l2_subdev_fh *fh)
.set_selection = mt9v032_set_selection,
 };
 
-static struct v4l2_subdev_ops mt9v032_subdev_ops = {
+static const struct v4l2_subdev_ops mt9v032_subdev_ops = {
.core   = _subdev_core_ops,
.video  = _subdev_video_ops,
.pad= _subdev_pad_ops,
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 30cb90b..88c498a 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -664,13 +664,13 @@ static int noon010_open(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
.log_status = noon010_log_status,
 };
 
-static struct v4l2_subdev_pad_ops noon010_pad_ops = {
+static const struct v4l2_subdev_pad_ops noon010_pad_ops = {
.enum_mbus_code = noon010_enum_mbus_code,
.get_fmt= noon010_get_fmt,
.set_fmt= noon010_set_fmt,
 };
 
-static struct v4l2_subdev_video_ops noon010_video_ops = {

[PATCH] drivers: media: i2c: constify v4l2_subdev_* structures

2016-12-11 Thread Bhumika Goyal
v4l2_subdev_{core/pad/video}_ops structures are stored in the
fields of the v4l2_subdev_ops structure which are of type const.
Also, v4l2_subdev_ops structure is passed to a function
having its argument of type const. As these structures are never
modified, so declare them as const.
Done using Coccinelle: (One of the scripts used)

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct v4l2_subdev_video_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct v4l2_subdev_ops obj;
@@
obj.video=@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct v4l2_subdev_video_ops i;

File sizes before:
  text data bss dec hex filename
   7810 736  1685622172 drivers/media/i2c/mt9p031.o
   9652 736  24   1041228ac drivers/media/i2c/mt9v032.o
   4613 552  2051851441 drivers/media/i2c/noon010pc30.o
   2615 552   83175 c67 drivers/media/i2c/s5k6a3.o

File sizes after:
  text data bss dec hex filename
   8322 232  168570217a drivers/media/i2c/mt9p031.o
  10164 232  24   1042028b4 drivers/media/i2c/mt9v032.o
   4933 232  2051851441 drivers/media/i2c/noon010pc30.o
   2935 232   83175 c67 drivers/media/i2c/s5k6a3.o

Signed-off-by: Bhumika Goyal 
---
 drivers/media/i2c/mt9p031.c | 8 
 drivers/media/i2c/mt9v032.c | 8 
 drivers/media/i2c/noon010pc30.c | 4 ++--
 drivers/media/i2c/s5k6a3.c  | 6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 237737f..91d822f 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -972,15 +972,15 @@ static int mt9p031_close(struct v4l2_subdev *subdev, 
struct v4l2_subdev_fh *fh)
return mt9p031_set_power(subdev, 0);
 }
 
-static struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
.s_power= mt9p031_set_power,
 };
 
-static struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
.s_stream   = mt9p031_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
.enum_mbus_code = mt9p031_enum_mbus_code,
.enum_frame_size = mt9p031_enum_frame_size,
.get_fmt = mt9p031_get_format,
@@ -989,7 +989,7 @@ static int mt9p031_close(struct v4l2_subdev *subdev, struct 
v4l2_subdev_fh *fh)
.set_selection = mt9p031_set_selection,
 };
 
-static struct v4l2_subdev_ops mt9p031_subdev_ops = {
+static const struct v4l2_subdev_ops mt9p031_subdev_ops = {
.core   = _subdev_core_ops,
.video  = _subdev_video_ops,
.pad= _subdev_pad_ops,
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 58eb62f..88b7890 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -936,15 +936,15 @@ static int mt9v032_close(struct v4l2_subdev *subdev, 
struct v4l2_subdev_fh *fh)
return mt9v032_set_power(subdev, 0);
 }
 
-static struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
.s_power= mt9v032_set_power,
 };
 
-static struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
.s_stream   = mt9v032_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
.enum_mbus_code = mt9v032_enum_mbus_code,
.enum_frame_size = mt9v032_enum_frame_size,
.get_fmt = mt9v032_get_format,
@@ -953,7 +953,7 @@ static int mt9v032_close(struct v4l2_subdev *subdev, struct 
v4l2_subdev_fh *fh)
.set_selection = mt9v032_set_selection,
 };
 
-static struct v4l2_subdev_ops mt9v032_subdev_ops = {
+static const struct v4l2_subdev_ops mt9v032_subdev_ops = {
.core   = _subdev_core_ops,
.video  = _subdev_video_ops,
.pad= _subdev_pad_ops,
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 30cb90b..88c498a 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -664,13 +664,13 @@ static int noon010_open(struct v4l2_subdev *sd, struct 
v4l2_subdev_fh *fh)
.log_status = noon010_log_status,
 };
 
-static struct v4l2_subdev_pad_ops noon010_pad_ops = {
+static const struct v4l2_subdev_pad_ops noon010_pad_ops = {
.enum_mbus_code = noon010_enum_mbus_code,
.get_fmt= noon010_get_fmt,
.set_fmt= noon010_set_fmt,
 };
 
-static struct v4l2_subdev_video_ops noon010_video_ops = {
+static const