diff mbox series

[3/9] media: hantro: Constify the control array

Message ID 20190619121540.29320-4-boris.brezillon@collabora.com (mailing list archive)
State New, archived
Headers show
Series media: hantro: Add support for H264 decoding | expand

Commit Message

Boris Brezillon June 19, 2019, 12:15 p.m. UTC
controls[] is not supposed to be modified at runtime, let's make it
explicit by adding a const specifier.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/staging/media/hantro/hantro_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ezequiel Garcia July 5, 2019, 4:05 p.m. UTC | #1
On Wed, 2019-06-19 at 14:15 +0200, Boris Brezillon wrote:
> controls[] is not supposed to be modified at runtime, let's make it
> explicit by adding a const specifier.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
>  drivers/staging/media/hantro/hantro_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> index 28b0fed89dcb..db49d643ddb7 100644
> --- a/drivers/staging/media/hantro/hantro_drv.c
> +++ b/drivers/staging/media/hantro/hantro_drv.c
> @@ -264,7 +264,7 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
>  	.s_ctrl = hantro_s_ctrl,
>  };
>  
> -static struct hantro_ctrl controls[] = {
> +static const struct hantro_ctrl controls[] = {
>  	{
>  		.id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
>  		.codec = HANTRO_JPEG_ENCODER,

This patch here breaks the build:

  CC [M]  drivers/staging/media/hantro/hantro_drv.o
/home/zeta/repos/linux/media_tree/drivers/staging/media/hantro/hantro_drv.c: In function ‘hantro_ctrls_setup’:
/home/zeta/repos/linux/media_tree/drivers/staging/media/hantro/hantro_drv.c:319:23: error: assignment of member ‘id’ in read-only object
    controls[i].cfg.id = controls[i].id;
                       ^
You can fix it by simply moving it after:

[PATCH 4/9] media: hantro: Simplify the controls creation logic

Regards,
Ezequiel
Boris Brezillon July 5, 2019, 5:17 p.m. UTC | #2
On Fri, 05 Jul 2019 13:05:10 -0300
Ezequiel Garcia <ezequiel@collabora.com> wrote:

> On Wed, 2019-06-19 at 14:15 +0200, Boris Brezillon wrote:
> > controls[] is not supposed to be modified at runtime, let's make it
> > explicit by adding a const specifier.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> >  drivers/staging/media/hantro/hantro_drv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> > index 28b0fed89dcb..db49d643ddb7 100644
> > --- a/drivers/staging/media/hantro/hantro_drv.c
> > +++ b/drivers/staging/media/hantro/hantro_drv.c
> > @@ -264,7 +264,7 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
> >  	.s_ctrl = hantro_s_ctrl,
> >  };
> >  
> > -static struct hantro_ctrl controls[] = {
> > +static const struct hantro_ctrl controls[] = {
> >  	{
> >  		.id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
> >  		.codec = HANTRO_JPEG_ENCODER,  
> 
> This patch here breaks the build:
> 
>   CC [M]  drivers/staging/media/hantro/hantro_drv.o
> /home/zeta/repos/linux/media_tree/drivers/staging/media/hantro/hantro_drv.c: In function ‘hantro_ctrls_setup’:
> /home/zeta/repos/linux/media_tree/drivers/staging/media/hantro/hantro_drv.c:319:23: error: assignment of member ‘id’ in read-only object
>     controls[i].cfg.id = controls[i].id;
>                        ^

Oops, didn't check bisectability.

> You can fix it by simply moving it after:
> 
> [PATCH 4/9] media: hantro: Simplify the controls creation logic

Yep, I'll do that.

Thanks,

Boris
diff mbox series

Patch

diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index 28b0fed89dcb..db49d643ddb7 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -264,7 +264,7 @@  static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
 	.s_ctrl = hantro_s_ctrl,
 };
 
-static struct hantro_ctrl controls[] = {
+static const struct hantro_ctrl controls[] = {
 	{
 		.id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
 		.codec = HANTRO_JPEG_ENCODER,