[PATCH 6/6] [media] media: imx: capture: constify vb2_ops structures

Steve Longerbeam slongerbeam at gmail.com
Mon Aug 14 23:14:49 UTC 2017


Thanks,

Reviewed-by: Steve Longerbeam <steve_longerbeam at mentor.com>

Steve

On 08/05/2017 03:47 AM, Julia Lawall wrote:
> These vb2_ops structures are only stored in the ops field of a
> vb2_queue structure, which is declared as const.  Thus the vb2_ops
> structures themselves can be const.
>
> Done with the help of Coccinelle.
>
> // <smpl>
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct vb2_ops i at p = { ... };
>
> @ok@
> identifier r.i;
> struct vb2_queue e;
> position p;
> @@
> e.ops = &i at p;
>
> @bad@
> position p != {r.p,ok.p};
> identifier r.i;
> struct vb2_ops e;
> @@
> e at i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> static
> +const
>   struct vb2_ops i = { ... };
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall at lip6.fr>
>
> ---
>   drivers/staging/media/imx/imx-media-capture.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
> index ddab4c2..ea145ba 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
> @@ -62,7 +62,7 @@ struct capture_priv {
>   /* In bytes, per queue */
>   #define VID_MEM_LIMIT	SZ_64M
>   
> -static struct vb2_ops capture_qops;
> +static const struct vb2_ops capture_qops;
>   
>   /*
>    * Video ioctls follow
> @@ -503,7 +503,7 @@ static void capture_stop_streaming(struct vb2_queue *vq)
>   	spin_unlock_irqrestore(&priv->q_lock, flags);
>   }
>   
> -static struct vb2_ops capture_qops = {
> +static const struct vb2_ops capture_qops = {
>   	.queue_setup	 = capture_queue_setup,
>   	.buf_init        = capture_buf_init,
>   	.buf_prepare	 = capture_buf_prepare,
>



More information about the devel mailing list