diff mbox

[8/9] video: fbdev: aty: use c99 initializers in structures

Message ID 1408792831-25615-9-git-send-email-Julia.Lawall@lip6.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Julia Lawall Aug. 23, 2014, 11:20 a.m. UTC
From: Julia Lawall <Julia.Lawall@lip6.fr>

Use c99 initializers for structures.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@decl@
identifier i1,fld;
type T;
field list[n] fs;
@@

struct i1 {
 fs
 T fld;
 ...};

@bad@
identifier decl.i1,i2;
expression e;
initializer list[decl.n] is;
@@

struct i1 i2 = { is,
+ .fld = e
- e
 ,...};
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
The patches in this series do not depend on each other.

 drivers/video/fbdev/aty/aty128fb.c |   59 +++++++++++++++++++++++++++++++------
 1 file changed, 51 insertions(+), 8 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Josh Triplett Aug. 23, 2014, 3:20 p.m. UTC | #1
On Sat, Aug 23, 2014 at 01:20:30PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Use c99 initializers for structures.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @decl@
> identifier i1,fld;
> type T;
> field list[n] fs;
> @@
> 
> struct i1 {
>  fs
>  T fld;
>  ...};
> 
> @bad@
> identifier decl.i1,i2;
> expression e;
> initializer list[decl.n] is;
> @@
> 
> struct i1 i2 = { is,
> + .fld = e
> - e
>  ,...};
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

One comment below about formatting.  With that addressed:
Reviewed-by: Josh Triplett <josh@joshtriplett.org>

> --- a/drivers/video/fbdev/aty/aty128fb.c
> +++ b/drivers/video/fbdev/aty/aty128fb.c
> @@ -324,14 +324,57 @@ struct aty128_meminfo {
>  };
>  
>  /* various memory configurations */
> -static const struct aty128_meminfo sdr_128   =
> -	{ 4, 4, 3, 3, 1, 3, 1, 16, 30, 16, "128-bit SDR SGRAM (1:1)" };
> -static const struct aty128_meminfo sdr_64    =
> -	{ 4, 8, 3, 3, 1, 3, 1, 17, 46, 17, "64-bit SDR SGRAM (1:1)" };
> -static const struct aty128_meminfo sdr_sgram =
> -	{ 4, 4, 1, 2, 1, 2, 1, 16, 24, 16, "64-bit SDR SGRAM (2:1)" };
> -static const struct aty128_meminfo ddr_sgram =
> -	{ 4, 4, 3, 3, 2, 3, 1, 16, 31, 16, "64-bit DDR SGRAM" };
> +static const struct aty128_meminfo sdr_128 = {
> +	.ML = 4,
> +	.MB = 4,
> +	.Trcd = 3,
> +	.Trp = 3,
> +	.Twr = 1,
> +	.CL = 3,
> +	.Tr2w = 1,
> +	.LoopLatency = 16,
> +	.DspOn = 30,
> +	.Rloop = 16,
> +	.name = "128-bit SDR SGRAM (1:1)" };

The closing brace should be in column 0 of the next line.  Also, the
final field initializer should have a comma after it. (Likewise for the
remaining changes in this file.)

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julia Lawall Aug. 23, 2014, 3:32 p.m. UTC | #2
On Sat, 23 Aug 2014, Josh Triplett wrote:

> On Sat, Aug 23, 2014 at 01:20:30PM +0200, Julia Lawall wrote:
> > From: Julia Lawall <Julia.Lawall@lip6.fr>
> > 
> > Use c99 initializers for structures.
> > 
> > A simplified version of the semantic match that finds this problem is as
> > follows: (http://coccinelle.lip6.fr/)
> > 
> > // <smpl>
> > @decl@
> > identifier i1,fld;
> > type T;
> > field list[n] fs;
> > @@
> > 
> > struct i1 {
> >  fs
> >  T fld;
> >  ...};
> > 
> > @bad@
> > identifier decl.i1,i2;
> > expression e;
> > initializer list[decl.n] is;
> > @@
> > 
> > struct i1 i2 = { is,
> > + .fld = e
> > - e
> >  ,...};
> > // </smpl>
> > 
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> One comment below about formatting.  With that addressed:
> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
> 
> > --- a/drivers/video/fbdev/aty/aty128fb.c
> > +++ b/drivers/video/fbdev/aty/aty128fb.c
> > @@ -324,14 +324,57 @@ struct aty128_meminfo {
> >  };
> >  
> >  /* various memory configurations */
> > -static const struct aty128_meminfo sdr_128   =
> > -	{ 4, 4, 3, 3, 1, 3, 1, 16, 30, 16, "128-bit SDR SGRAM (1:1)" };
> > -static const struct aty128_meminfo sdr_64    =
> > -	{ 4, 8, 3, 3, 1, 3, 1, 17, 46, 17, "64-bit SDR SGRAM (1:1)" };
> > -static const struct aty128_meminfo sdr_sgram =
> > -	{ 4, 4, 1, 2, 1, 2, 1, 16, 24, 16, "64-bit SDR SGRAM (2:1)" };
> > -static const struct aty128_meminfo ddr_sgram =
> > -	{ 4, 4, 3, 3, 2, 3, 1, 16, 31, 16, "64-bit DDR SGRAM" };
> > +static const struct aty128_meminfo sdr_128 = {
> > +	.ML = 4,
> > +	.MB = 4,
> > +	.Trcd = 3,
> > +	.Trp = 3,
> > +	.Twr = 1,
> > +	.CL = 3,
> > +	.Tr2w = 1,
> > +	.LoopLatency = 16,
> > +	.DspOn = 30,
> > +	.Rloop = 16,
> > +	.name = "128-bit SDR SGRAM (1:1)" };
> 
> The closing brace should be in column 0 of the next line.  Also, the
> final field initializer should have a comma after it. (Likewise for the
> remaining changes in this file.)

In general, I haven't changed the presence or absence of trailing commas.  
Should I add them everywhere?

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Josh Triplett Aug. 23, 2014, 4:03 p.m. UTC | #3
On Sat, Aug 23, 2014 at 05:32:37PM +0200, Julia Lawall wrote:
> On Sat, 23 Aug 2014, Josh Triplett wrote:
> > On Sat, Aug 23, 2014 at 01:20:30PM +0200, Julia Lawall wrote:
> > > From: Julia Lawall <Julia.Lawall@lip6.fr>
> > > 
> > > Use c99 initializers for structures.
> > > 
> > > A simplified version of the semantic match that finds this problem is as
> > > follows: (http://coccinelle.lip6.fr/)
> > > 
> > > // <smpl>
> > > @decl@
> > > identifier i1,fld;
> > > type T;
> > > field list[n] fs;
> > > @@
> > > 
> > > struct i1 {
> > >  fs
> > >  T fld;
> > >  ...};
> > > 
> > > @bad@
> > > identifier decl.i1,i2;
> > > expression e;
> > > initializer list[decl.n] is;
> > > @@
> > > 
> > > struct i1 i2 = { is,
> > > + .fld = e
> > > - e
> > >  ,...};
> > > // </smpl>
> > > 
> > > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> > 
> > One comment below about formatting.  With that addressed:
> > Reviewed-by: Josh Triplett <josh@joshtriplett.org>
> > 
> > > --- a/drivers/video/fbdev/aty/aty128fb.c
> > > +++ b/drivers/video/fbdev/aty/aty128fb.c
> > > @@ -324,14 +324,57 @@ struct aty128_meminfo {
> > >  };
> > >  
> > >  /* various memory configurations */
> > > -static const struct aty128_meminfo sdr_128   =
> > > -	{ 4, 4, 3, 3, 1, 3, 1, 16, 30, 16, "128-bit SDR SGRAM (1:1)" };
> > > -static const struct aty128_meminfo sdr_64    =
> > > -	{ 4, 8, 3, 3, 1, 3, 1, 17, 46, 17, "64-bit SDR SGRAM (1:1)" };
> > > -static const struct aty128_meminfo sdr_sgram =
> > > -	{ 4, 4, 1, 2, 1, 2, 1, 16, 24, 16, "64-bit SDR SGRAM (2:1)" };
> > > -static const struct aty128_meminfo ddr_sgram =
> > > -	{ 4, 4, 3, 3, 2, 3, 1, 16, 31, 16, "64-bit DDR SGRAM" };
> > > +static const struct aty128_meminfo sdr_128 = {
> > > +	.ML = 4,
> > > +	.MB = 4,
> > > +	.Trcd = 3,
> > > +	.Trp = 3,
> > > +	.Twr = 1,
> > > +	.CL = 3,
> > > +	.Tr2w = 1,
> > > +	.LoopLatency = 16,
> > > +	.DspOn = 30,
> > > +	.Rloop = 16,
> > > +	.name = "128-bit SDR SGRAM (1:1)" };
> > 
> > The closing brace should be in column 0 of the next line.  Also, the
> > final field initializer should have a comma after it. (Likewise for the
> > remaining changes in this file.)
> 
> In general, I haven't changed the presence or absence of trailing commas.  
> Should I add them everywhere?

In general, I'd suggest using trailing commas; they make the initializer
order no longer matter, and avoid the need to patch the last line if
adding another initializer.  However, I wouldn't suggest going out of
your way to change existing initializers, just adding them as part of
initializers you're changing already.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter Aug. 25, 2014, 10:16 a.m. UTC | #4
On Sat, Aug 23, 2014 at 05:32:37PM +0200, Julia Lawall wrote:
> > 
> > The closing brace should be in column 0 of the next line.  Also, the
> > final field initializer should have a comma after it. (Likewise for the
> > remaining changes in this file.)
> 
> In general, I haven't changed the presence or absence of trailing commas.
> Should I add them everywhere?

Probably, yeah.  Trailing commas are better.

It's not worth resending, but the script should add them I think.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
index ff60701..5a72fbd 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -324,14 +324,57 @@  struct aty128_meminfo {
 };
 
 /* various memory configurations */
-static const struct aty128_meminfo sdr_128   =
-	{ 4, 4, 3, 3, 1, 3, 1, 16, 30, 16, "128-bit SDR SGRAM (1:1)" };
-static const struct aty128_meminfo sdr_64    =
-	{ 4, 8, 3, 3, 1, 3, 1, 17, 46, 17, "64-bit SDR SGRAM (1:1)" };
-static const struct aty128_meminfo sdr_sgram =
-	{ 4, 4, 1, 2, 1, 2, 1, 16, 24, 16, "64-bit SDR SGRAM (2:1)" };
-static const struct aty128_meminfo ddr_sgram =
-	{ 4, 4, 3, 3, 2, 3, 1, 16, 31, 16, "64-bit DDR SGRAM" };
+static const struct aty128_meminfo sdr_128 = {
+	.ML = 4,
+	.MB = 4,
+	.Trcd = 3,
+	.Trp = 3,
+	.Twr = 1,
+	.CL = 3,
+	.Tr2w = 1,
+	.LoopLatency = 16,
+	.DspOn = 30,
+	.Rloop = 16,
+	.name = "128-bit SDR SGRAM (1:1)" };
+
+static const struct aty128_meminfo sdr_64 = {
+	.ML = 4,
+	.MB = 8,
+	.Trcd = 3,
+	.Trp = 3,
+	.Twr = 1,
+	.CL = 3,
+	.Tr2w = 1,
+	.LoopLatency = 17,
+	.DspOn = 46,
+	.Rloop = 17,
+	.name = "64-bit SDR SGRAM (1:1)" };
+
+static const struct aty128_meminfo sdr_sgram = {
+	.ML = 4,
+	.MB = 4,
+	.Trcd = 1,
+	.Trp = 2,
+	.Twr = 1,
+	.CL = 2,
+	.Tr2w = 1,
+	.LoopLatency = 16,
+	.DspOn = 24,
+	.Rloop = 16,
+	.name = "64-bit SDR SGRAM (2:1)" };
+
+static const struct aty128_meminfo ddr_sgram = {
+	.ML = 4,
+	.MB = 4,
+	.Trcd = 3,
+	.Trp = 3,
+	.Twr = 2,
+	.CL = 3,
+	.Tr2w = 1,
+	.LoopLatency = 16,
+	.DspOn = 31,
+	.Rloop = 16,
+	.name = "64-bit DDR SGRAM" };
 
 static struct fb_fix_screeninfo aty128fb_fix = {
 	.id		= "ATY Rage128",