From: Joe Perches <joe@perches.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Thomas Winischhofer <thomas@winischhofer.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb <linux-usb@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: sisusb: Use static const, fix typo
Date: Mon, 24 Feb 2014 10:01:16 -0800 [thread overview]
Message-ID: <1393264876.11020.38.camel@joe-AO722> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D0F6C9771@AcuExch.aculab.com>
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
next prev parent reply other threads:[~2014-02-24 18:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-22 2:00 Joe Perches
2014-02-24 10:26 ` David Laight
2014-02-24 18:01 ` Joe Perches [this message]
2014-02-25 9:09 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393264876.11020.38.camel@joe-AO722 \
--to=joe@perches.com \
--cc=David.Laight@ACULAB.COM \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=thomas@winischhofer.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®