summaryrefslogtreecommitdiff
path: root/ethtool.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2012-02-17 21:30:06 +0000
committerBen Hutchings <bhutchings@solarflare.com>2012-06-01 23:20:30 +0100
commit2038e9ecde330cb82eb368725034b21d30de91fc (patch)
tree53f4605a90e8a9da7219b34a73f54e50e4b23550 /ethtool.c
parentdfacc4a0fa3be71539be94da11f5cd3f47ffcbe5 (diff)
downloadethtool-2038e9ecde330cb82eb368725034b21d30de91fc.tar.gz
Add output file parameter to dump_hex() and make it extern
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'ethtool.c')
-rw-r--r--ethtool.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/ethtool.c b/ethtool.c
index 65bdd38..9d42ca8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -787,18 +787,18 @@ static const struct {
{ "st_gmac", st_gmac_dump_regs },
};
-static void dump_hex(__u8 *data, int len, int offset)
+void dump_hex(FILE *file, const u8 *data, int len, int offset)
{
int i;
- fprintf(stdout, "Offset\t\tValues\n");
- fprintf(stdout, "------\t\t------");
+ fprintf(file, "Offset\t\tValues\n");
+ fprintf(file, "------\t\t------");
for (i = 0; i < len; i++) {
if (i % 16 == 0)
- fprintf(stdout, "\n0x%04x:\t\t", i + offset);
- fprintf(stdout, "%02x ", data[i]);
+ fprintf(file, "\n0x%04x:\t\t", i + offset);
+ fprintf(file, "%02x ", data[i]);
}
- fprintf(stdout, "\n");
+ fprintf(file, "\n");
}
static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
@@ -834,7 +834,7 @@ static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
ETHTOOL_BUSINFO_LEN))
return driver_list[i].func(info, regs);
- dump_hex(regs->data, regs->len, 0);
+ dump_hex(stdout, regs->data, regs->len, 0);
return 0;
}
@@ -853,7 +853,7 @@ static int dump_eeprom(int geeprom_dump_raw, struct ethtool_drvinfo *info,
return tg3_dump_eeprom(info, ee);
}
- dump_hex(ee->data, ee->len, ee->offset);
+ dump_hex(stdout, ee->data, ee->len, ee->offset);
return 0;
}
@@ -3253,7 +3253,8 @@ static int do_getmodule(struct cmd_context *ctx)
}
}
if (geeprom_dump_hex)
- dump_hex(eeprom->data, eeprom->len, eeprom->offset);
+ dump_hex(stdout, eeprom->data,
+ eeprom->len, eeprom->offset);
}
free(eeprom);