2017-08-08 15:14:32

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH] drm/virtio: make drm_fb_helper_funcs const

Make these structures const as they are only passed to the function
drm_fb_helper_prepare and the corresponding argument is of type const.
Done using Coccinelle

@match disable optional_qualifier@
identifier s;
@@
static struct drm_fb_helper_funcs s = {...};

@ref@
position p;
identifier match.s;
@@
s@p

@good1@
identifier match.s;
expression e1,e2;
position ref.p;
@@
drm_fb_helper_prepare(e1,e2,&s@p,...)

@bad depends on !good1@
position ref.p;
identifier match.s;
@@
s@p

@depends on forall !bad disable optional_qualifier@
identifier match.s;
@@
static
+ const
struct drm_fb_helper_funcs s;

Signed-off-by: Bhumika Goyal <[email protected]>
---
drivers/gpu/drm/virtio/virtgpu_fb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
index 046e28b..15d18fd 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fb.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
@@ -308,7 +308,7 @@ static int virtio_gpu_fbdev_destroy(struct drm_device *dev,

return 0;
}
-static struct drm_fb_helper_funcs virtio_gpu_fb_helper_funcs = {
+static const struct drm_fb_helper_funcs virtio_gpu_fb_helper_funcs = {
.fb_probe = virtio_gpufb_create,
};

--
1.9.1


2017-08-09 16:40:17

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH] drm/virtio: make drm_fb_helper_funcs const

On Tue, Aug 08, 2017 at 08:44:05PM +0530, Bhumika Goyal wrote:
> Make these structures const as they are only passed to the function
> drm_fb_helper_prepare and the corresponding argument is of type const.
> Done using Coccinelle
>
> @match disable optional_qualifier@
> identifier s;
> @@
> static struct drm_fb_helper_funcs s = {...};
>
> @ref@
> position p;
> identifier match.s;
> @@
> s@p
>
> @good1@
> identifier match.s;
> expression e1,e2;
> position ref.p;
> @@
> drm_fb_helper_prepare(e1,e2,&s@p,...)
>
> @bad depends on !good1@
> position ref.p;
> identifier match.s;
> @@
> s@p
>
> @depends on forall !bad disable optional_qualifier@
> identifier match.s;
> @@
> static
> + const
> struct drm_fb_helper_funcs s;
>
> Signed-off-by: Bhumika Goyal <[email protected]>

This and the previous one merged too.
-Daniel

> ---
> drivers/gpu/drm/virtio/virtgpu_fb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c
> index 046e28b..15d18fd 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_fb.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_fb.c
> @@ -308,7 +308,7 @@ static int virtio_gpu_fbdev_destroy(struct drm_device *dev,
>
> return 0;
> }
> -static struct drm_fb_helper_funcs virtio_gpu_fb_helper_funcs = {
> +static const struct drm_fb_helper_funcs virtio_gpu_fb_helper_funcs = {
> .fb_probe = virtio_gpufb_create,
> };
>
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch