hdparm: shrink rodata by ~250 bytes

This commit is contained in:
Denis Vlasenko 2007-08-16 10:37:49 +00:00
parent 6a2f7f41cf
commit a0319ba936
3 changed files with 27 additions and 56 deletions

View File

@ -91,7 +91,7 @@ int dos2unix_main(int argc, char **argv)
} }
/* -u convert to unix, -d convert to dos */ /* -u convert to unix, -d convert to dos */
opt_complementary = "u--d:d--u"; /* mutally exclusive */ opt_complementary = "u--d:d--u"; /* mutually exclusive */
o = getopt32(argc, argv, "du"); o = getopt32(argc, argv, "du");
/* Do the conversion requested by an argument else do the default /* Do the conversion requested by an argument else do the default

View File

@ -211,7 +211,7 @@ Special characters:
For example: For example:
The cut applet must have only one type of list specified, so The cut applet must have only one type of list specified, so
-b, -c and -f are mutally exclusive and should raise an error -b, -c and -f are mutually exclusive and should raise an error
if specified together. In this case you must set if specified together. In this case you must set
opt_complementary = "b--cf:c--bf:f--bc". If two of the opt_complementary = "b--cf:c--bf:f--bc". If two of the
mutually exclusive options are found, getopt32 will call mutually exclusive options are found, getopt32 will call

View File

@ -1416,62 +1416,33 @@ static void interpret_standby(unsigned standby)
printf(")\n"); printf(")\n");
} }
struct xfermode_entry { static const uint8_t xfermode_val[] ALIGN1 = {
int val; 8, 9, 10, 11, 12, 13, 14, 15,
const char *name; 16, 17, 18, 19, 20, 21, 22, 23,
32, 33, 34, 35, 36, 37, 38, 39,
64, 65, 66, 67, 68, 69, 70, 71
};
/* NB: we save size by _not_ storing terninating NUL! */
static const char xfermode_name[][5] ALIGN1 = {
"pio0", "pio1", "pio2", "pio3", "pio4", "pio5", "pio6", "pio7",
"sdma0","sdma1","sdma2","sdma3","sdma4","sdma5","sdma6","sdma7",
"mdma0","mdma1","mdma2","mdma3","mdma4","mdma5","mdma6","mdma7",
"udma0","udma1","udma2","udma3","udma4","udma5","udma6","udma7"
}; };
static const struct xfermode_entry xfermode_table[] = { static int translate_xfermode(const char *name)
{ 8, "pio0" },
{ 9, "pio1" },
{ 10, "pio2" },
{ 11, "pio3" },
{ 12, "pio4" },
{ 13, "pio5" },
{ 14, "pio6" },
{ 15, "pio7" },
{ 16, "sdma0" },
{ 17, "sdma1" },
{ 18, "sdma2" },
{ 19, "sdma3" },
{ 20, "sdma4" },
{ 21, "sdma5" },
{ 22, "sdma6" },
{ 23, "sdma7" },
{ 32, "mdma0" },
{ 33, "mdma1" },
{ 34, "mdma2" },
{ 35, "mdma3" },
{ 36, "mdma4" },
{ 37, "mdma5" },
{ 38, "mdma6" },
{ 39, "mdma7" },
{ 64, "udma0" },
{ 65, "udma1" },
{ 66, "udma2" },
{ 67, "udma3" },
{ 68, "udma4" },
{ 69, "udma5" },
{ 70, "udma6" },
{ 71, "udma7" },
{ 0, NULL }
};
static int translate_xfermode(char * name)
{ {
const struct xfermode_entry *tmp; int val, i;
char *endptr;
int val = -1;
for (tmp = xfermode_table; tmp->name != NULL; ++tmp) { for (i = 0; i < ARRAY_SIZE(xfermode_val); i++) {
if (!strcmp(name, tmp->name)) if (!strncmp(name, xfermode_name[i], 5))
return tmp->val; if (strlen(name) <= 5)
return xfermode_val[i];
} }
/* Negative numbers are invalid and are caught later */
val = strtol(name, &endptr, 10); val = bb_strtoi(name, NULL, 10);
if (*endptr == '\0') if (!errno)
return val; return val;
return -1; return -1;
} }
@ -1483,13 +1454,13 @@ static void interpret_xfermode(unsigned xfermode)
else if (xfermode == 1) else if (xfermode == 1)
printf("default PIO mode, disable IORDY"); printf("default PIO mode, disable IORDY");
else if (xfermode >= 8 && xfermode <= 15) else if (xfermode >= 8 && xfermode <= 15)
printf("PIO flow control mode%u", xfermode-8); printf("PIO flow control mode%u", xfermode - 8);
else if (xfermode >= 16 && xfermode <= 23) else if (xfermode >= 16 && xfermode <= 23)
printf("singleword DMA mode%u", xfermode-16); printf("singleword DMA mode%u", xfermode - 16);
else if (xfermode >= 32 && xfermode <= 39) else if (xfermode >= 32 && xfermode <= 39)
printf("multiword DMA mode%u", xfermode-32); printf("multiword DMA mode%u", xfermode - 32);
else if (xfermode >= 64 && xfermode <= 71) else if (xfermode >= 64 && xfermode <= 71)
printf("UltraDMA mode%u", xfermode-64); printf("UltraDMA mode%u", xfermode - 64);
else else
printf("Unknown"); printf("Unknown");
printf(")\n"); printf(")\n");