diff options
author | Denis Vlasenko | 2008-06-07 15:10:29 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-06-07 15:10:29 +0000 |
commit | 53354ac47df03bdccebad66bc22958fa2b4da520 (patch) | |
tree | b3d85b6cd19f81293848235560b24cbce86f77d7 /miscutils/hdparm.c | |
parent | f0d6c255860509b10148c70ef7cb518eb81bea6d (diff) | |
download | busybox-53354ac47df03bdccebad66bc22958fa2b4da520.zip busybox-53354ac47df03bdccebad66bc22958fa2b4da520.tar.gz |
libbb: introduce and use print_flags().
Mostly by Natanael Copa <natanael.copa AT gmail.com>
function old new delta
print_e2flags - 189 +189
print_flags_separated - 86 +86
static.flag_labels - 60 +60
static.dma_wmode_masks - 32 +32
static.flag_masks - 28 +28
static.arp_labels - 16 +16
static.arp_masks - 12 +12
ls_main 836 843 +7
...
popstring 140 134 -6
arp_show 740 708 -32
print_flags 189 25 -164
ipaddr_list_or_flush 2396 2170 -226
process_dev 5306 4706 -600
------------------------------------------------------------------------------
(add/remove: 10/0 grow/shrink: 5/10 up/down: 458/-1043) Total: -585 bytes
text data bss dec hex filename
810564 624 7060 818248 c7c48 busybox_old
810002 624 7060 817686 c7a16 busybox_unstripped
Diffstat (limited to 'miscutils/hdparm.c')
-rw-r--r-- | miscutils/hdparm.c | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index aa95b89..983de6d 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -1228,54 +1228,46 @@ static void dump_identity(const struct hd_driveid *id) if (id->tPIO >= 2) printf("pio2 "); } if (id->field_valid & 2) { - if (id->eide_pio_modes & 1) printf("pio3 "); - if (id->eide_pio_modes & 2) printf("pio4 "); - if (id->eide_pio_modes &~3) printf("pio? "); + static const masks_labels_t pio_modes = { + .masks = { 1, 2, ~3 }, + .labels = "pio3 \0""pio4 \0""pio? \0", + }; + print_flags(&pio_modes, id->eide_pio_modes); } if (id->capability & 1) { if (id->dma_1word | id->dma_mword) { + static const int dma_wmode_masks[] = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 }; printf("\n DMA modes: "); - if (id->dma_1word & 0x100) bb_putchar('*'); - if (id->dma_1word & 1) printf("sdma0 "); - if (id->dma_1word & 0x200) bb_putchar('*'); - if (id->dma_1word & 2) printf("sdma1 "); - if (id->dma_1word & 0x400) bb_putchar('*'); - if (id->dma_1word & 4) printf("sdma2 "); - if (id->dma_1word & 0xf800) bb_putchar('*'); - if (id->dma_1word & 0xf8) printf("sdma? "); - if (id->dma_mword & 0x100) bb_putchar('*'); - if (id->dma_mword & 1) printf("mdma0 "); - if (id->dma_mword & 0x200) bb_putchar('*'); - if (id->dma_mword & 2) printf("mdma1 "); - if (id->dma_mword & 0x400) bb_putchar('*'); - if (id->dma_mword & 4) printf("mdma2 "); - if (id->dma_mword & 0xf800) bb_putchar('*'); - if (id->dma_mword & 0xf8) printf("mdma? "); + print_flags_separated(dma_wmode_masks, + "*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0", + id->dma_1word, NULL); + print_flags_separated(dma_wmode_masks, + "*\0""mdma0\0""*\0""mdma1\0""*\0""mdma2\0""*\0""mdma?\0", + id->dma_mword, NULL); } } if (((id->capability & 8) || (id->field_valid & 2)) && id->field_valid & 4) { + static const masks_labels_t ultra_modes1 = { + .masks = { 0x100, 0x001, 0x200, 0x002, 0x400, 0x004 }, + .labels = "*\0""udma0 \0""*\0""udma1 \0""*\0""udma2 \0", + }; + printf("\n UDMA modes: "); - if (id->dma_ultra & 0x100) bb_putchar('*'); - if (id->dma_ultra & 0x001) printf("udma0 "); - if (id->dma_ultra & 0x200) bb_putchar('*'); - if (id->dma_ultra & 0x002) printf("udma1 "); - if (id->dma_ultra & 0x400) bb_putchar('*'); - if (id->dma_ultra & 0x004) printf("udma2 "); + print_flags(&ultra_modes1, id->dma_ultra); #ifdef __NEW_HD_DRIVE_ID if (id->hw_config & 0x2000) { #else /* !__NEW_HD_DRIVE_ID */ if (id->word93 & 0x2000) { #endif /* __NEW_HD_DRIVE_ID */ - if (id->dma_ultra & 0x0800) bb_putchar('*'); - if (id->dma_ultra & 0x0008) printf("udma3 "); - if (id->dma_ultra & 0x1000) bb_putchar('*'); - if (id->dma_ultra & 0x0010) printf("udma4 "); - if (id->dma_ultra & 0x2000) bb_putchar('*'); - if (id->dma_ultra & 0x0020) printf("udma5 "); - if (id->dma_ultra & 0x4000) bb_putchar('*'); - if (id->dma_ultra & 0x0040) printf("udma6 "); - if (id->dma_ultra & 0x8000) bb_putchar('*'); - if (id->dma_ultra & 0x0080) printf("udma7 "); + static const masks_labels_t ultra_modes2 = { + .masks = { 0x0800, 0x0008, 0x1000, 0x0010, + 0x2000, 0x0020, 0x4000, 0x0040, + 0x8000, 0x0080 }, + .labels = "*\0""udma3 \0""*\0""udma4 \0" + "*\0""udma5 \0""*\0""udma6 \0" + "*\0""udma7 \0" + }; + print_flags(&ultra_modes2, id->dma_ultra); } } printf("\n AdvancedPM=%s", (!(id_regs[83] & 8)) ? "no" : "yes"); |