All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: platform: xilinx: xilinx-tpg: constify v4l2_subdev_* structures
@ 2016-12-11  9:52 ` Bhumika Goyal
  0 siblings, 0 replies; 4+ messages in thread
From: Bhumika Goyal @ 2016-12-11  9:52 UTC (permalink / raw)
  To: julia.lawall, laurent.pinchart, hyun.kwon, mchehab, michal.simek,
	soren.brinkmann, linux-media, linux-arm-kernel, linux-kernel
  Cc: 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=&i@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 size before:
   text	   data	    bss	    dec	    hex	filename
   6170	   2752	    144	   9066	   236a media/platform/xilinx/xilinx-tpg.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   6666	   2384	      8	   9058	   2362 media/platform/xilinx/xilinx-tpg.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/media/platform/xilinx/xilinx-tpg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c
index 2ec1f6c..9c49d1d 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -460,21 +460,21 @@ static int xtpg_s_ctrl(struct v4l2_ctrl *ctrl)
 	.s_ctrl	= xtpg_s_ctrl,
 };
 
-static struct v4l2_subdev_core_ops xtpg_core_ops = {
+static const struct v4l2_subdev_core_ops xtpg_core_ops = {
 };
 
-static struct v4l2_subdev_video_ops xtpg_video_ops = {
+static const struct v4l2_subdev_video_ops xtpg_video_ops = {
 	.s_stream = xtpg_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops xtpg_pad_ops = {
+static const struct v4l2_subdev_pad_ops xtpg_pad_ops = {
 	.enum_mbus_code		= xvip_enum_mbus_code,
 	.enum_frame_size	= xtpg_enum_frame_size,
 	.get_fmt		= xtpg_get_format,
 	.set_fmt		= xtpg_set_format,
 };
 
-static struct v4l2_subdev_ops xtpg_ops = {
+static const struct v4l2_subdev_ops xtpg_ops = {
 	.core   = &xtpg_core_ops,
 	.video  = &xtpg_video_ops,
 	.pad    = &xtpg_pad_ops,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] media: platform: xilinx: xilinx-tpg: constify v4l2_subdev_* structures
@ 2016-12-11  9:52 ` Bhumika Goyal
  0 siblings, 0 replies; 4+ messages in thread
From: Bhumika Goyal @ 2016-12-11  9:52 UTC (permalink / raw)
  To: linux-arm-kernel

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 at p = {...};

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

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

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

File size before:
   text	   data	    bss	    dec	    hex	filename
   6170	   2752	    144	   9066	   236a media/platform/xilinx/xilinx-tpg.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   6666	   2384	      8	   9058	   2362 media/platform/xilinx/xilinx-tpg.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/media/platform/xilinx/xilinx-tpg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c
index 2ec1f6c..9c49d1d 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -460,21 +460,21 @@ static int xtpg_s_ctrl(struct v4l2_ctrl *ctrl)
 	.s_ctrl	= xtpg_s_ctrl,
 };
 
-static struct v4l2_subdev_core_ops xtpg_core_ops = {
+static const struct v4l2_subdev_core_ops xtpg_core_ops = {
 };
 
-static struct v4l2_subdev_video_ops xtpg_video_ops = {
+static const struct v4l2_subdev_video_ops xtpg_video_ops = {
 	.s_stream = xtpg_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops xtpg_pad_ops = {
+static const struct v4l2_subdev_pad_ops xtpg_pad_ops = {
 	.enum_mbus_code		= xvip_enum_mbus_code,
 	.enum_frame_size	= xtpg_enum_frame_size,
 	.get_fmt		= xtpg_get_format,
 	.set_fmt		= xtpg_set_format,
 };
 
-static struct v4l2_subdev_ops xtpg_ops = {
+static const struct v4l2_subdev_ops xtpg_ops = {
 	.core   = &xtpg_core_ops,
 	.video  = &xtpg_video_ops,
 	.pad    = &xtpg_pad_ops,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: platform: xilinx: xilinx-tpg: constify v4l2_subdev_* structures
  2016-12-11  9:52 ` Bhumika Goyal
@ 2016-12-12  8:50   ` Laurent Pinchart
  -1 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2016-12-12  8:50 UTC (permalink / raw)
  To: Bhumika Goyal
  Cc: julia.lawall, hyun.kwon, mchehab, michal.simek, soren.brinkmann,
	linux-media, linux-arm-kernel, linux-kernel

Hi Bhumika,

Thank you for the patch.

On Sunday 11 Dec 2016 15:22: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=&i@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 size before:
>    text	   data	    bss	    dec	    hex	filename
>    6170	   2752	    144	   9066	   236a media/platform/xilinx/xilinx-
tpg.o
> 
> File size after:
>    text	   data	    bss	    dec	    hex	filename
>    6666	   2384	      8	   9058	   2362 media/platform/xilinx/xilinx-
tpg.o
> 
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/xilinx/xilinx-tpg.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c
> b/drivers/media/platform/xilinx/xilinx-tpg.c index 2ec1f6c..9c49d1d 100644
> --- a/drivers/media/platform/xilinx/xilinx-tpg.c
> +++ b/drivers/media/platform/xilinx/xilinx-tpg.c
> @@ -460,21 +460,21 @@ static int xtpg_s_ctrl(struct v4l2_ctrl *ctrl)
>  	.s_ctrl	= xtpg_s_ctrl,
>  };
> 
> -static struct v4l2_subdev_core_ops xtpg_core_ops = {
> +static const struct v4l2_subdev_core_ops xtpg_core_ops = {
>  };
> 
> -static struct v4l2_subdev_video_ops xtpg_video_ops = {
> +static const struct v4l2_subdev_video_ops xtpg_video_ops = {
>  	.s_stream = xtpg_s_stream,
>  };
> 
> -static struct v4l2_subdev_pad_ops xtpg_pad_ops = {
> +static const struct v4l2_subdev_pad_ops xtpg_pad_ops = {
>  	.enum_mbus_code		= xvip_enum_mbus_code,
>  	.enum_frame_size	= xtpg_enum_frame_size,
>  	.get_fmt		= xtpg_get_format,
>  	.set_fmt		= xtpg_set_format,
>  };
> 
> -static struct v4l2_subdev_ops xtpg_ops = {
> +static const struct v4l2_subdev_ops xtpg_ops = {
>  	.core   = &xtpg_core_ops,
>  	.video  = &xtpg_video_ops,
>  	.pad    = &xtpg_pad_ops,

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] media: platform: xilinx: xilinx-tpg: constify v4l2_subdev_* structures
@ 2016-12-12  8:50   ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2016-12-12  8:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Bhumika,

Thank you for the patch.

On Sunday 11 Dec 2016 15:22: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 at p = {...};
> 
> @ok1@
> identifier r1.i;
> position p;
> struct v4l2_subdev_ops obj;
> @@
> obj.video=&i at p;
> 
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i at p
> 
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct v4l2_subdev_video_ops i;
> 
> File size before:
>    text	   data	    bss	    dec	    hex	filename
>    6170	   2752	    144	   9066	   236a media/platform/xilinx/xilinx-
tpg.o
> 
> File size after:
>    text	   data	    bss	    dec	    hex	filename
>    6666	   2384	      8	   9058	   2362 media/platform/xilinx/xilinx-
tpg.o
> 
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/xilinx/xilinx-tpg.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c
> b/drivers/media/platform/xilinx/xilinx-tpg.c index 2ec1f6c..9c49d1d 100644
> --- a/drivers/media/platform/xilinx/xilinx-tpg.c
> +++ b/drivers/media/platform/xilinx/xilinx-tpg.c
> @@ -460,21 +460,21 @@ static int xtpg_s_ctrl(struct v4l2_ctrl *ctrl)
>  	.s_ctrl	= xtpg_s_ctrl,
>  };
> 
> -static struct v4l2_subdev_core_ops xtpg_core_ops = {
> +static const struct v4l2_subdev_core_ops xtpg_core_ops = {
>  };
> 
> -static struct v4l2_subdev_video_ops xtpg_video_ops = {
> +static const struct v4l2_subdev_video_ops xtpg_video_ops = {
>  	.s_stream = xtpg_s_stream,
>  };
> 
> -static struct v4l2_subdev_pad_ops xtpg_pad_ops = {
> +static const struct v4l2_subdev_pad_ops xtpg_pad_ops = {
>  	.enum_mbus_code		= xvip_enum_mbus_code,
>  	.enum_frame_size	= xtpg_enum_frame_size,
>  	.get_fmt		= xtpg_get_format,
>  	.set_fmt		= xtpg_set_format,
>  };
> 
> -static struct v4l2_subdev_ops xtpg_ops = {
> +static const struct v4l2_subdev_ops xtpg_ops = {
>  	.core   = &xtpg_core_ops,
>  	.video  = &xtpg_video_ops,
>  	.pad    = &xtpg_pad_ops,

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-12  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-11  9:52 [PATCH] media: platform: xilinx: xilinx-tpg: constify v4l2_subdev_* structures Bhumika Goyal
2016-12-11  9:52 ` Bhumika Goyal
2016-12-12  8:50 ` Laurent Pinchart
2016-12-12  8:50   ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.