* sisusb: Use static const, fix typo
@ 2014-02-22 2:00 Joe Perches
2014-02-24 10:26 ` David Laight
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-02-22 2:00 UTC (permalink / raw)
To: Thomas Winischhofer; +Cc: Greg Kroah-Hartman, linux-usb, LKML
Reduce text a bit by using static const.
Fix a symmetric typo and neaten a dev_info call
to 80 columns.
$ size drivers/usb/misc/sisusbvga/sisusb.o*
text data bss dec hex filename
30016 4841 9180 44037 ac05 drivers/usb/misc/sisusbvga/sisusb.o.new
30087 4841 9180 44108 ac4c drivers/usb/misc/sisusbvga/sisusb.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/usb/misc/sisusbvga/sisusb.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index de98906..1f89633 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2123,8 +2123,9 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
u8 tmp8, tmp82, ramtype;
int bw = 0;
char *ramtypetext1 = NULL;
- const char *ramtypetext2[] = { "SDR SDRAM", "SDR SGRAM",
- "DDR SDRAM", "DDR SGRAM" };
+ static const char *ramtypetext2[] = {
+ "SDR SDRAM", "SDR SGRAM", "DDR SDRAM", "DDR SGRAM"
+ };
static const int busSDR[4] = {64, 64, 128, 128};
static const int busDDR[4] = {32, 32, 64, 64};
static const int busDDRA[4] = {64+32, 64+32 , (64+32)*2, (64+32)*2};
@@ -2146,7 +2147,7 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
sisusb->vramsize <<= 1;
bw = busSDR[(tmp8 & 0x03)];
break;
- case 2: ramtypetext1 = "asymmeric";
+ case 2: ramtypetext1 = "asymmetric";
sisusb->vramsize += sisusb->vramsize/2;
bw = busDDRA[(tmp8 & 0x03)];
break;
@@ -2156,8 +2157,9 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
break;
}
- dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n", (sisusb->vramsize >> 20), ramtypetext1,
- ramtypetext2[ramtype], bw);
+ dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n",
+ sisusb->vramsize >> 20, ramtypetext1, ramtypetext2[ramtype],
+ bw);
}
static int
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: sisusb: Use static const, fix typo
2014-02-22 2:00 sisusb: Use static const, fix typo Joe Perches
@ 2014-02-24 10:26 ` David Laight
2014-02-24 18:01 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: David Laight @ 2014-02-24 10:26 UTC (permalink / raw)
To: 'Joe Perches', Thomas Winischhofer
Cc: Greg Kroah-Hartman, linux-usb, LKML
From: Joe Perches
> Reduce text a bit by using static const.
If you want to save a few bytes remove the pointers.
(and the fixed RAM text to get below 7 chars).
eg:
> - const char *ramtypetext2[] = { "SDR SDRAM", "SDR SGRAM",
> - "DDR SDRAM", "DDR SGRAM" };
static const char ramtypetext2[8][] = {
"SDR SD", "SDR SG", "DDR SD", "DDR SG"
...
> - dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n", (sisusb->vramsize >> 20),
> ramtypetext1,
> - ramtypetext2[ramtype], bw);
dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %sRAM, bus width %d\n",
sisusb->vramsize >> 20, ramtypetext1, ramtypetext2[ramtype],
bw);
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sisusb: Use static const, fix typo
2014-02-24 10:26 ` David Laight
@ 2014-02-24 18:01 ` Joe Perches
2014-02-25 9:09 ` David Laight
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-02-24 18:01 UTC (permalink / raw)
To: David Laight; +Cc: Thomas Winischhofer, Greg Kroah-Hartman, linux-usb, LKML
On Mon, 2014-02-24 at 10:26 +0000, David Laight wrote:
> From: Joe Perches
> > Reduce text a bit by using static const.
>
> If you want to save a few bytes remove the pointers.
> (and the fixed RAM text to get below 7 chars).
Hi David.
> eg:
>
> > - const char *ramtypetext2[] = { "SDR SDRAM", "SDR SGRAM",
> > - "DDR SDRAM", "DDR SGRAM" };
The idea was use static to avoid the array reload
on each function entry.
> static const char ramtypetext2[8][] = {
> "SDR SD", "SDR SG", "DDR SD", "DDR SG"
8 is an odd number here.
That could be done with char like:
static const char ram_datarate[4] = {'S', 'S', 'D', 'D'};
static const char ram_dynamictype[4] = {'D', 'G', 'D', 'G'};
> ...
> > - dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n", (sisusb->vramsize >> 20),
> > ramtypetext1,
> > - ramtypetext2[ramtype], bw);
>
> dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %sRAM, bus width %d\n",
> sisusb->vramsize >> 20, ramtypetext1, ramtypetext2[ramtype],
> bw);
dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %c%cRAM, bus width %d\n",
sisusb->vramsize >> 20, ramtypetext1,
ram_datarate[ramtype], ram_dynamictype[ramtype], bw);
So something like:
Convert 1 char * array to 2 char arrays to reduce size.
Use static const to avoid array reloads on function entry.
Fix asymmetric typo.
$ size drivers/usb/misc/sisusbvga/sisusb.o*
text data bss dec hex filename
29971 4841 9180 43992 abd8 drivers/usb/misc/sisusbvga/sisusb.o.new
30083 4841 9180 44104 ac48 drivers/usb/misc/sisusbvga/sisusb.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/usb/misc/sisusbvga/sisusb.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index de98906..06b5d77 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2123,8 +2123,8 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
u8 tmp8, tmp82, ramtype;
int bw = 0;
char *ramtypetext1 = NULL;
- const char *ramtypetext2[] = { "SDR SDRAM", "SDR SGRAM",
- "DDR SDRAM", "DDR SGRAM" };
+ static const char ram_datarate[4] = {'S', 'S', 'D', 'D'};
+ static const char ram_dynamictype[4] = {'D', 'G', 'D', 'G'};
static const int busSDR[4] = {64, 64, 128, 128};
static const int busDDR[4] = {32, 32, 64, 64};
static const int busDDRA[4] = {64+32, 64+32 , (64+32)*2, (64+32)*2};
@@ -2156,8 +2156,10 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
break;
}
- dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n", (sisusb->vramsize >> 20), ramtypetext1,
- ramtypetext2[ramtype], bw);
+
+ dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %cDR S%cRAM, bus width %d\n",
+ sisusb->vramsize >> 20, ramtypetext1,
+ ram_datarate[ramtype], ram_dynamictype[ramtype], bw);
}
static int
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: sisusb: Use static const, fix typo
2014-02-24 18:01 ` Joe Perches
@ 2014-02-25 9:09 ` David Laight
0 siblings, 0 replies; 4+ messages in thread
From: David Laight @ 2014-02-25 9:09 UTC (permalink / raw)
To: 'Joe Perches'
Cc: Thomas Winischhofer, Greg Kroah-Hartman, linux-usb, LKML
From: Joe Perches [
> On Mon, 2014-02-24 at 10:26 +0000, David Laight wrote:
> > From: Joe Perches
> > > Reduce text a bit by using static const.
> >
> > If you want to save a few bytes remove the pointers.
> > (and the fixed RAM text to get below 7 chars).
>
> Hi David.
>
> > eg:
> >
> > > - const char *ramtypetext2[] = { "SDR SDRAM", "SDR SGRAM",
> > > - "DDR SDRAM", "DDR SGRAM" };
>
> The idea was use static to avoid the array reload
> on each function entry.
>
> > static const char ramtypetext2[8][] = {
> > "SDR SD", "SDR SG", "DDR SD", "DDR SG"
>
> 8 is an odd number here.
Brain fade - not enough coffee.
I meant 'char ramtypetext2[][8]' so that you avoid the pointers as well.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-25 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-22 2:00 sisusb: Use static const, fix typo Joe Perches
2014-02-24 10:26 ` David Laight
2014-02-24 18:01 ` Joe Perches
2014-02-25 9:09 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®