2018-10-30 16:10:34

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/2] constify vb2_ops structures

The vb2_ops structures can be const as they are only stored in the ops
field of a vb2_queue structure and this field is const.

Done with the help of Coccinelle.

---

drivers/media/i2c/video-i2c.c | 2 +-
drivers/usb/gadget/function/uvc_queue.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)


2018-10-30 16:08:02

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/2] media: video-i2c: hwmon: constify vb2_ops structure

The vb2_ops structure can be const as it is only stored in the ops
field of a vb2_queue structure and this field is const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/media/i2c/video-i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
index 4d49af86c15e..cb89cda6553d 100644
--- a/drivers/media/i2c/video-i2c.c
+++ b/drivers/media/i2c/video-i2c.c
@@ -336,7 +336,7 @@ static void stop_streaming(struct vb2_queue *vq)
video_i2c_del_list(vq, VB2_BUF_STATE_ERROR);
}

-static struct vb2_ops video_i2c_video_qops = {
+static const struct vb2_ops video_i2c_video_qops = {
.queue_setup = queue_setup,
.buf_prepare = buffer_prepare,
.buf_queue = buffer_queue,


2018-10-30 16:11:09

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/2] usb: gadget: uvc: constify vb2_ops structure

The vb2_ops structure can be const as it is only stored in the ops
field of a vb2_queue structure and this field is const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/usb/gadget/function/uvc_queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
index 9e33d5206d54..526a10a33094 100644
--- a/drivers/usb/gadget/function/uvc_queue.c
+++ b/drivers/usb/gadget/function/uvc_queue.c
@@ -102,7 +102,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(&queue->irqlock, flags);
}

-static struct vb2_ops uvc_queue_qops = {
+static const struct vb2_ops uvc_queue_qops = {
.queue_setup = uvc_queue_setup,
.buf_prepare = uvc_buffer_prepare,
.buf_queue = uvc_buffer_queue,


2018-10-30 16:44:39

by Matt Ranostay

[permalink] [raw]
Subject: Re: [PATCH 2/2] media: video-i2c: hwmon: constify vb2_ops structure

On Tue, Oct 30, 2018 at 9:06 AM Julia Lawall <[email protected]> wrote:
>
> The vb2_ops structure can be const as it is only stored in the ops
> field of a vb2_queue structure and this field is const.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Acked-by: Matt Ranostay <[email protected]>

>
> ---
> drivers/media/i2c/video-i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
> index 4d49af86c15e..cb89cda6553d 100644
> --- a/drivers/media/i2c/video-i2c.c
> +++ b/drivers/media/i2c/video-i2c.c
> @@ -336,7 +336,7 @@ static void stop_streaming(struct vb2_queue *vq)
> video_i2c_del_list(vq, VB2_BUF_STATE_ERROR);
> }
>
> -static struct vb2_ops video_i2c_video_qops = {
> +static const struct vb2_ops video_i2c_video_qops = {
> .queue_setup = queue_setup,
> .buf_prepare = buffer_prepare,
> .buf_queue = buffer_queue,
>

2018-10-30 19:46:44

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 1/2] usb: gadget: uvc: constify vb2_ops structure

Hello Julia,

Thank you for the patch.

On Tuesday, 30 October 2018 17:31:21 EET Julia Lawall wrote:
> The vb2_ops structure can be const as it is only stored in the ops
> field of a vb2_queue structure and this field is const.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

and applied to my tree.

> ---
> drivers/usb/gadget/function/uvc_queue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/uvc_queue.c
> b/drivers/usb/gadget/function/uvc_queue.c index 9e33d5206d54..526a10a33094
> 100644
> --- a/drivers/usb/gadget/function/uvc_queue.c
> +++ b/drivers/usb/gadget/function/uvc_queue.c
> @@ -102,7 +102,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
> spin_unlock_irqrestore(&queue->irqlock, flags);
> }
>
> -static struct vb2_ops uvc_queue_qops = {
> +static const struct vb2_ops uvc_queue_qops = {
> .queue_setup = uvc_queue_setup,
> .buf_prepare = uvc_buffer_prepare,
> .buf_queue = uvc_buffer_queue,

--
Regards,

Laurent Pinchart