RE: sisusb: Use static const, fix typo

2014-02-25 Thread David Laight
From: Joe Perches [ 
> On Mon, 2014-02-24 at 10:26 +, 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



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: sisusb: Use static const, fix typo

2014-02-25 Thread David Laight
From: Joe Perches [ 
 On Mon, 2014-02-24 at 10:26 +, 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



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: sisusb: Use static const, fix typo

2014-02-24 Thread Joe Perches
On Mon, 2014-02-24 at 10:26 +, 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_dev->dev, "%dMB %s %s, bus width %d\n", 
> > (sisusb->vramsize >> 20),
> > ramtypetext1,
> > -   ramtypetext2[ramtype], bw);
> 
>   dev_info(>sisusb_dev->dev, "%dMB %s %sRAM, bus width %d\n",
>sisusb->vramsize >> 20, ramtypetext1, ramtypetext2[ramtype],
>bw);

dev_info(>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*
   textdata bss dec hex filename
  2997148419180   43992abd8 drivers/usb/misc/sisusbvga/sisusb.o.new
  3008348419180   44104ac48 drivers/usb/misc/sisusbvga/sisusb.o.old

Signed-off-by: Joe Perches 
---
 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_dev->dev, "%dMB %s %s, bus width %d\n", 
(sisusb->vramsize >> 20), ramtypetext1,
-   ramtypetext2[ramtype], bw);
+
+   dev_info(>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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: sisusb: Use static const, fix typo

2014-02-24 Thread David Laight
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_dev->dev, "%dMB %s %s, bus width %d\n", 
> (sisusb->vramsize >> 20),
> ramtypetext1,
> - ramtypetext2[ramtype], bw);

dev_info(>sisusb_dev->dev, "%dMB %s %sRAM, bus width %d\n",
 sisusb->vramsize >> 20, ramtypetext1, ramtypetext2[ramtype],
 bw);

David



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: sisusb: Use static const, fix typo

2014-02-24 Thread David Laight
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



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: sisusb: Use static const, fix typo

2014-02-24 Thread Joe Perches
On Mon, 2014-02-24 at 10:26 +, 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*
   textdata bss dec hex filename
  2997148419180   43992abd8 drivers/usb/misc/sisusbvga/sisusb.o.new
  3008348419180   44104ac48 drivers/usb/misc/sisusbvga/sisusb.o.old

Signed-off-by: Joe Perches j...@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


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/