Re: [PATCH] media: platform: constify vb2_ops structures
Hi, Thanks for the patch. On Sat, Jan 21, 2017 at 9:29 AM, Bhumika Goyal wrote: > Declare vb2_ops structures as const as they are only stored in > the ops field of a vb2_queue structure. This field is of type > const, so vb2_ops structures having same properties can be made > const too. > Done using Coccinelle: > > @r1 disable optional_qualifier@ > identifier i; > position p; > @@ > static struct vb2_ops i@p={...}; > > @ok1@ > identifier r1.i; > position p; > struct sta2x11_vip vip; > struct vb2_queue q; > @@ > ( > vip.vb_vidq.ops=&i@p > | > q.ops=&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 vb2_ops i; > > Cross compiled the media/platform/blackfin/bfin_capture.o file for > blackfin architecture. > > File size before: > text data bss dec hex filename > 6776 176 069521b28 platform/blackfin/bfin_capture.o > The description doesnt match the changes. Can you please split the patches separately one for vpif_capture.c and vpif_display.c, one for mtk_mdp_m2m.c and lastly for pxa_camera.c . Cheers, --Prabhakar Lad
[PATCH] media: platform: constify vb2_ops structures
Declare vb2_ops structures as const as they are only stored in the ops field of a vb2_queue structure. This field is of type const, so vb2_ops structures having same properties can be made const too. Done using Coccinelle: @r1 disable optional_qualifier@ identifier i; position p; @@ static struct vb2_ops i@p={...}; @ok1@ identifier r1.i; position p; struct sta2x11_vip vip; struct vb2_queue q; @@ ( vip.vb_vidq.ops=&i@p | q.ops=&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 vb2_ops i; Cross compiled the media/platform/blackfin/bfin_capture.o file for blackfin architecture. File size before: text data bss dec hex filename 6776 176 069521b28 platform/blackfin/bfin_capture.o File size after: textdata bss dec hex filename 6816 136 069521b28 platform/blackfin/bfin_capture.o File size before: textdata bss dec hex filename 12852 456 272 13580350c platform/davinci/vpif_capture.o File size after: textdata bss dec hex filename 12932 360 272 1356434fc platform/davinci/vpif_capture.o File size before: textdata bss dec hex filename 12285 360 276 129213279 platform/davinci/vpif_display.o File size after: textdata bss dec hex filename 12365 296 276 129373289 platform/davinci/vpif_display.o File size details before and after applying the patch remains the same for drivers/media/platform/pxa_camera.o Signed-off-by: Bhumika Goyal --- drivers/media/platform/davinci/vpif_capture.c | 2 +- drivers/media/platform/davinci/vpif_display.c | 2 +- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 2 +- drivers/media/platform/pxa_camera.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index f791f5c..54c54d9 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -309,7 +309,7 @@ static void vpif_stop_streaming(struct vb2_queue *vq) spin_unlock_irqrestore(&common->irqlock, flags); } -static struct vb2_ops video_qops = { +static const struct vb2_ops video_qops = { .queue_setup= vpif_buffer_queue_setup, .buf_prepare= vpif_buffer_prepare, .start_streaming= vpif_start_streaming, diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index e5f1844..9604afd 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -289,7 +289,7 @@ static void vpif_stop_streaming(struct vb2_queue *vq) spin_unlock_irqrestore(&common->irqlock, flags); } -static struct vb2_ops video_qops = { +static const struct vb2_ops video_qops = { .queue_setup= vpif_buffer_queue_setup, .wait_prepare = vb2_ops_wait_prepare, .wait_finish= vb2_ops_wait_finish, diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c index 13afe48..3038d62 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c @@ -621,7 +621,7 @@ static void mtk_mdp_m2m_buf_queue(struct vb2_buffer *vb) v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb)); } -static struct vb2_ops mtk_mdp_m2m_qops = { +static const struct vb2_ops mtk_mdp_m2m_qops = { .queue_setup = mtk_mdp_m2m_queue_setup, .buf_prepare = mtk_mdp_m2m_buf_prepare, .buf_queue = mtk_mdp_m2m_buf_queue, diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c index 929006f..17167d1 100644 --- a/drivers/media/platform/pxa_camera.c +++ b/drivers/media/platform/pxa_camera.c @@ -1530,7 +1530,7 @@ static void pxac_vb2_stop_streaming(struct vb2_queue *vq) pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR); } -static struct vb2_ops pxac_vb2_ops = { +static const struct vb2_ops pxac_vb2_ops = { .queue_setup= pxac_vb2_queue_setup, .buf_init = pxac_vb2_init, .buf_prepare= pxac_vb2_prepare, -- 1.9.1
Re: [PATCH] [media] platform: constify vb2_ops structures
Hi, Thanks for the patch. Julia Lawall wrote on Fri [2016-Sep-09 01:59:10 +0200]: > Check for vb2_ops structures that are only stored in the ops field of a > vb2_queue structure. That field is declared const, so vb2_ops structures > that have this property can be declared as const also. > > The semantic patch that makes this change is as follows: > (http://coccinelle.lip6.fr/) > > // > @r disable optional_qualifier@ > identifier i; > position p; > @@ > static struct vb2_ops i@p = { ... }; > > @ok@ > identifier r.i; > struct vb2_queue e; > position p; > @@ > e.ops = &i@p; > > @bad@ > position p != {r.p,ok.p}; > identifier r.i; > struct vb2_ops e; > @@ > e@i@p > > @depends on !bad disable optional_qualifier@ > identifier r.i; > @@ > static > +const > struct vb2_ops i = { ... }; > // > > Signed-off-by: Julia Lawall > > --- > drivers/media/platform/exynos-gsc/gsc-m2m.c |2 +- > drivers/media/platform/exynos4-is/fimc-capture.c |2 +- > drivers/media/platform/exynos4-is/fimc-m2m.c |2 +- > drivers/media/platform/m2m-deinterlace.c |2 +- > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |2 +- > drivers/media/platform/mx2_emmaprp.c |2 +- > drivers/media/platform/rcar-vin/rcar-dma.c |2 +- > drivers/media/platform/rcar_jpu.c|2 +- > drivers/media/platform/s5p-g2d/g2d.c |2 +- > drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- > drivers/media/platform/sh_vou.c |2 +- > drivers/media/platform/soc_camera/atmel-isi.c|2 +- > drivers/media/platform/soc_camera/rcar_vin.c |2 +- > drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +- > drivers/media/platform/sti/bdisp/bdisp-v4l2.c|2 +- For the following 2 drivers, > drivers/media/platform/ti-vpe/cal.c |2 +- > drivers/media/platform/ti-vpe/vpe.c |2 +- Reviewed-by: Benoit Parrot > drivers/media/platform/vim2m.c |2 +- > drivers/media/platform/xilinx/xilinx-dma.c |2 +- > 19 files changed, 19 insertions(+), 19 deletions(-) Regards, Benoit Parrot
Re: [PATCH] [media] platform: constify vb2_ops structures
Hi Julia, On 09/09/2016 01:59 AM, Julia Lawall wrote: Check for vb2_ops structures that are only stored in the ops field of a vb2_queue structure. That field is declared const, so vb2_ops structures that have this property can be declared as const also. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) [...] diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 785e693..d9c07b8 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2538,7 +2538,7 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q) pm_runtime_put(ctx->jpeg->dev); } -static struct vb2_ops s5p_jpeg_qops = { +static const struct vb2_ops s5p_jpeg_qops = { .queue_setup= s5p_jpeg_queue_setup, .buf_prepare= s5p_jpeg_buf_prepare, .buf_queue = s5p_jpeg_buf_queue, diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index e967fcf..44323cb 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -1379,7 +1379,7 @@ static void cal_stop_streaming(struct vb2_queue *vq) cal_runtime_put(ctx->dev); } Thanks for the patch. For s5p-jpeg driver: Reviewed-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski
Re: [PATCH] [media] platform: constify vb2_ops structures
Hi On 09/09/2016 01:59 AM, Julia Lawall wrote: > Check for vb2_ops structures that are only stored in the ops field of a > vb2_queue structure. That field is declared const, so vb2_ops structures > that have this property can be declared as const also. > > The semantic patch that makes this change is as follows: > (http://coccinelle.lip6.fr/) > > // > @r disable optional_qualifier@ > identifier i; > position p; > @@ > static struct vb2_ops i@p = { ... }; > > @ok@ > identifier r.i; > struct vb2_queue e; > position p; > @@ > e.ops = &i@p; > > @bad@ > position p != {r.p,ok.p}; > identifier r.i; > struct vb2_ops e; > @@ > e@i@p > > @depends on !bad disable optional_qualifier@ > identifier r.i; > @@ > static > +const > struct vb2_ops i = { ... }; > // > > Signed-off-by: Julia Lawall > > --- > drivers/media/platform/exynos-gsc/gsc-m2m.c |2 +- > drivers/media/platform/exynos4-is/fimc-capture.c |2 +- > drivers/media/platform/exynos4-is/fimc-m2m.c |2 +- > drivers/media/platform/m2m-deinterlace.c |2 +- > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |2 +- > drivers/media/platform/mx2_emmaprp.c |2 +- > drivers/media/platform/rcar-vin/rcar-dma.c |2 +- > drivers/media/platform/rcar_jpu.c|2 +- > drivers/media/platform/s5p-g2d/g2d.c |2 +- > drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- > drivers/media/platform/sh_vou.c |2 +- > drivers/media/platform/soc_camera/atmel-isi.c|2 +- > drivers/media/platform/soc_camera/rcar_vin.c |2 +- > drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +- For this driver: > drivers/media/platform/sti/bdisp/bdisp-v4l2.c|2 +- Reviewed-by: Fabien Dessenne > drivers/media/platform/ti-vpe/cal.c |2 +- > drivers/media/platform/ti-vpe/vpe.c |2 +- > drivers/media/platform/vim2m.c |2 +- > drivers/media/platform/xilinx/xilinx-dma.c |2 +- > 19 files changed, 19 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/platform/xilinx/xilinx-dma.c > b/drivers/media/platform/xilinx/xilinx-dma.c > index 7ae1a13..1d5836c 100644 > --- a/drivers/media/platform/xilinx/xilinx-dma.c > +++ b/drivers/media/platform/xilinx/xilinx-dma.c > @@ -474,7 +474,7 @@ static void xvip_dma_stop_streaming(struct vb2_queue *vq) > spin_unlock_irq(&dma->queued_lock); > } > > -static struct vb2_ops xvip_dma_queue_qops = { > +static const struct vb2_ops xvip_dma_queue_qops = { > .queue_setup = xvip_dma_queue_setup, > .buf_prepare = xvip_dma_buffer_prepare, > .buf_queue = xvip_dma_buffer_queue, > diff --git a/drivers/media/platform/soc_camera/atmel-isi.c > b/drivers/media/platform/soc_camera/atmel-isi.c > index 30211f6..46de657 100644 > --- a/drivers/media/platform/soc_camera/atmel-isi.c > +++ b/drivers/media/platform/soc_camera/atmel-isi.c > @@ -536,7 +536,7 @@ static void stop_streaming(struct vb2_queue *vq) > pm_runtime_put(ici->v4l2_dev.dev); > } > > -static struct vb2_ops isi_video_qops = { > +static const struct vb2_ops isi_video_qops = { > .queue_setup= queue_setup, > .buf_init = buffer_init, > .buf_prepare= buffer_prepare, > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index 785e693..d9c07b8 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -2538,7 +2538,7 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q) > pm_runtime_put(ctx->jpeg->dev); > } > > -static struct vb2_ops s5p_jpeg_qops = { > +static const struct vb2_ops s5p_jpeg_qops = { > .queue_setup= s5p_jpeg_queue_setup, > .buf_prepare= s5p_jpeg_buf_prepare, > .buf_queue = s5p_jpeg_buf_queue, > diff --git a/drivers/media/platform/ti-vpe/cal.c > b/drivers/media/platform/ti-vpe/cal.c > index e967fcf..44323cb 100644 > --- a/drivers/media/platform/ti-vpe/cal.c > +++ b/drivers/media/platform/ti-vpe/cal.c > @@ -1379,7 +1379,7 @@ static void cal_stop_streaming(struct vb2_queue *vq) > cal_runtime_put(ctx->dev); > } > > -static struct vb2_ops cal_video_qops = { > +static const struct vb2_ops cal_video_qops = { > .queue_setup= cal_queue_setup, > .buf_prepare= cal_buffer_prepare, > .buf_queue = cal_buffer_queue, > diff --git a/drivers/media/platform/ti-vpe/vpe.c > b/drivers/media/platform/ti-vpe/vpe.c > index 55a1458..0189f7f 100644 > --- a/drivers/media/platform/ti-vpe/vpe.c > +++ b/drivers/media/platform/ti-vpe/vpe.c > @@ -1878,7 +1878,7 @@ static void vpe
Re: [PATCH] [media] platform: constify vb2_ops structures
Hi Julia, Thank you for the patch. On Friday 09 Sep 2016 01:59:10 Julia Lawall wrote: > Check for vb2_ops structures that are only stored in the ops field of a > vb2_queue structure. That field is declared const, so vb2_ops structures > that have this property can be declared as const also. > > The semantic patch that makes this change is as follows: > (http://coccinelle.lip6.fr/) > > // > @r disable optional_qualifier@ > identifier i; > position p; > @@ > static struct vb2_ops i@p = { ... }; > > @ok@ > identifier r.i; > struct vb2_queue e; > position p; > @@ > e.ops = &i@p; > > @bad@ > position p != {r.p,ok.p}; > identifier r.i; > struct vb2_ops e; > @@ > e@i@p > > @depends on !bad disable optional_qualifier@ > identifier r.i; > @@ > static > +const > struct vb2_ops i = { ... }; > // > > Signed-off-by: Julia Lawall For the drivers below, > drivers/media/platform/m2m-deinterlace.c |2 +- > drivers/media/platform/rcar-vin/rcar-dma.c |2 +- > drivers/media/platform/rcar_jpu.c|2 +- > drivers/media/platform/sh_vou.c |2 +- > drivers/media/platform/soc_camera/atmel-isi.c|2 +- > drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +- > drivers/media/platform/vim2m.c |2 +- > drivers/media/platform/xilinx/xilinx-dma.c |2 +- Reviewed-by: Laurent Pinchart For > drivers/media/platform/soc_camera/rcar_vin.c |2 +- you can also add my Reviewed-by: Laurent Pinchart tag, but the driver will be scheduled for removal very soon. -- Regards, Laurent Pinchart
[PATCH] [media] platform: constify vb2_ops structures
Check for vb2_ops structures that are only stored in the ops field of a vb2_queue structure. That field is declared const, so vb2_ops structures that have this property can be declared as const also. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r disable optional_qualifier@ identifier i; position p; @@ static struct vb2_ops i@p = { ... }; @ok@ identifier r.i; struct vb2_queue e; position p; @@ e.ops = &i@p; @bad@ position p != {r.p,ok.p}; identifier r.i; struct vb2_ops e; @@ e@i@p @depends on !bad disable optional_qualifier@ identifier r.i; @@ static +const struct vb2_ops i = { ... }; // Signed-off-by: Julia Lawall --- drivers/media/platform/exynos-gsc/gsc-m2m.c |2 +- drivers/media/platform/exynos4-is/fimc-capture.c |2 +- drivers/media/platform/exynos4-is/fimc-m2m.c |2 +- drivers/media/platform/m2m-deinterlace.c |2 +- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c |2 +- drivers/media/platform/mx2_emmaprp.c |2 +- drivers/media/platform/rcar-vin/rcar-dma.c |2 +- drivers/media/platform/rcar_jpu.c|2 +- drivers/media/platform/s5p-g2d/g2d.c |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- drivers/media/platform/sh_vou.c |2 +- drivers/media/platform/soc_camera/atmel-isi.c|2 +- drivers/media/platform/soc_camera/rcar_vin.c |2 +- drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c |2 +- drivers/media/platform/sti/bdisp/bdisp-v4l2.c|2 +- drivers/media/platform/ti-vpe/cal.c |2 +- drivers/media/platform/ti-vpe/vpe.c |2 +- drivers/media/platform/vim2m.c |2 +- drivers/media/platform/xilinx/xilinx-dma.c |2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 7ae1a13..1d5836c 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -474,7 +474,7 @@ static void xvip_dma_stop_streaming(struct vb2_queue *vq) spin_unlock_irq(&dma->queued_lock); } -static struct vb2_ops xvip_dma_queue_qops = { +static const struct vb2_ops xvip_dma_queue_qops = { .queue_setup = xvip_dma_queue_setup, .buf_prepare = xvip_dma_buffer_prepare, .buf_queue = xvip_dma_buffer_queue, diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index 30211f6..46de657 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c @@ -536,7 +536,7 @@ static void stop_streaming(struct vb2_queue *vq) pm_runtime_put(ici->v4l2_dev.dev); } -static struct vb2_ops isi_video_qops = { +static const struct vb2_ops isi_video_qops = { .queue_setup= queue_setup, .buf_init = buffer_init, .buf_prepare= buffer_prepare, diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 785e693..d9c07b8 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2538,7 +2538,7 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q) pm_runtime_put(ctx->jpeg->dev); } -static struct vb2_ops s5p_jpeg_qops = { +static const struct vb2_ops s5p_jpeg_qops = { .queue_setup= s5p_jpeg_queue_setup, .buf_prepare= s5p_jpeg_buf_prepare, .buf_queue = s5p_jpeg_buf_queue, diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index e967fcf..44323cb 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -1379,7 +1379,7 @@ static void cal_stop_streaming(struct vb2_queue *vq) cal_runtime_put(ctx->dev); } -static struct vb2_ops cal_video_qops = { +static const struct vb2_ops cal_video_qops = { .queue_setup= cal_queue_setup, .buf_prepare= cal_buffer_prepare, .buf_queue = cal_buffer_queue, diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index 55a1458..0189f7f 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c @@ -1878,7 +1878,7 @@ static void vpe_stop_streaming(struct vb2_queue *q) vpdma_dump_regs(ctx->dev->vpdma); } -static struct vb2_ops vpe_qops = { +static const struct vb2_ops vpe_qops = { .queue_setup = vpe_queue_setup, .buf_prepare = vpe_buf_prepare, .buf_queue = vpe_buf_queue, diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/