Skip to contentSkip to conversation

video: xilinxfb: constify fb_fix_screeninfo and fb_var_screeninfo structures

PATCH In review Gustavo A. R. Silva 3 participants 4 messages Jul 8, 2017 – Aug 1, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: xilinxfb: constify fb_fix_screeninfo and fb_var_screeninfo structures

These structures are only used to copy into other structures, so declare them as const.

This issue was detected using Coccinelle and the following semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct fb_fix_screeninfo i at p = { ... };

@ok@
identifier r.i;
expression e;
position p;
@@
e = i at p

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct fb_fix_screeninfo e;
@@
e at i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct fb_fix_screeninfo i = { ... };

The semantic patch for fb_var_screeninfo is analogous.

---
 drivers/video/fbdev/xilinxfb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/xilinxfb.c +2 -2
index 17dc119..0bda18e 100644
@@ -110,14 +110,14 @@ static struct xilinxfb_platform_data xilinx_fb_default_pdata = {
 /*
  * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures
  */
-static struct fb_fix_screeninfo xilinx_fb_fix = {
+static const struct fb_fix_screeninfo xilinx_fb_fix = {
 	.id =		"Xilinx",
 	.type =		FB_TYPE_PACKED_PIXELS,
 	.visual =	FB_VISUAL_TRUECOLOR,
 	.accel =	FB_ACCEL_NONE
 };
 
-static struct fb_var_screeninfo xilinx_fb_var = {
+static const struct fb_var_screeninfo xilinx_fb_var = {
 	.bits_per_pixel =	BITS_PER_PIXEL,
 
 	.red =		{ RED_SHIFT, 8, 0 },
Signature · 1 line
2.5.0
Acked-by on v1 1/1
#1 lore raw
Quoted 51 lines · Gustavo A. R. Silva

These structures are only used to copy into other structures, so declare them as const.

This issue was detected using Coccinelle and the following semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct fb_fix_screeninfo i at p = { ... };

@ok@
identifier r.i;
expression e;
position p;
@@
e = i at p

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct fb_fix_screeninfo e;
@@
e at i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct fb_fix_screeninfo i = { ... };

The semantic patch for fb_var_screeninfo is analogous.

---
 drivers/video/fbdev/xilinxfb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/xilinxfb.c +1 -1
index 17dc119..0bda18e 100644
@@ -110,14 +110,14 @@ static struct xilinxfb_platform_data xilinx_fb_default_pdata = {
 /*
  * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures
  */
-static struct fb_fix_screeninfo xilinx_fb_fix = {
+static const struct fb_fix_screeninfo xilinx_fb_fix = {
 	.id =		"Xilinx",

drivers/video/fbdev/xilinxfb.c static struct xilinxfb_platform_data xilinx_fb_default_pdata = { · line 123

Quoted 10 lines
drivers/video/fbdev/xilinxfb.c +1 -1
 	.type =		FB_TYPE_PACKED_PIXELS,
 	.visual =	FB_VISUAL_TRUECOLOR,
 	.accel =	FB_ACCEL_NONE
 };
 
-static struct fb_var_screeninfo xilinx_fb_var = {
+static const struct fb_var_screeninfo xilinx_fb_var = {
 	.bits_per_pixel =	BITS_PER_PIXEL,
 
 	.red =		{ RED_SHIFT, 8, 0 },

Thanks,
Michal

#2 lore raw
Quoted 56 lines · Michal Simek
Quoted 55 lines · Gustavo A. R. Silva

These structures are only used to copy into other structures, so declare them as const.

This issue was detected using Coccinelle and the following semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct fb_fix_screeninfo i at p = { ... };

@ok@
identifier r.i;
expression e;
position p;
@@
e = i at p

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct fb_fix_screeninfo e;
@@
e at i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct fb_fix_screeninfo i = { ... };

The semantic patch for fb_var_screeninfo is analogous.

---
  drivers/video/fbdev/xilinxfb.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/xilinxfb.c +1 -1
index 17dc119..0bda18e 100644
@@ -110,14 +110,14 @@ static struct xilinxfb_platform_data xilinx_fb_default_pdata = {
  /*
   * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures
   */
-static struct fb_fix_screeninfo xilinx_fb_fix = {
+static const struct fb_fix_screeninfo xilinx_fb_fix = {
  	.id =		"Xilinx",
  	.type =		FB_TYPE_PACKED_PIXELS,
  	.visual =	FB_VISUAL_TRUECOLOR,
  	.accel =	FB_ACCEL_NONE
  };
 
Quoted 7 lines

drivers/video/fbdev/xilinxfb.c static struct xilinxfb_platform_data xilinx_fb_default_pdata = { · line 123

Quoted 6 lines
drivers/video/fbdev/xilinxfb.c +1 -1
-static struct fb_var_screeninfo xilinx_fb_var = {
+static const struct fb_var_screeninfo xilinx_fb_var = {
  	.bits_per_pixel =	BITS_PER_PIXEL,
 
  	.red =		{ RED_SHIFT, 8, 0 },

Thank you, Michal.

Signature · 1 line
Gustavo A. R. Silva
#3 lore raw
In reply to Gustavo A. R. Silva
Quoted 32 lines · Gustavo A. R. Silva

These structures are only used to copy into other structures, so declare them as const.

This issue was detected using Coccinelle and the following semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct fb_fix_screeninfo i at p = { ... };

@ok@
identifier r.i;
expression e;
position p;
@@
e = i at p

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct fb_fix_screeninfo e;
@@
e at i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct fb_fix_screeninfo i = { ... };

Quoted 3 lines

The semantic patch for fb_var_screeninfo is analogous.

Patch queued for 4.14, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics