Commit 9dc3a205 authored by Jiri Popelka's avatar Jiri Popelka

mii-tool: don't rely on eth0 being default network device name.

With this patch mii-tool requires interface name
to be specified as argument.
parent faf31f80
...@@ -16,7 +16,7 @@ mii\-tool \- view, manipulate media-independent interface status ...@@ -16,7 +16,7 @@ mii\-tool \- view, manipulate media-independent interface status
[\fB\-l\fR, \fB\-\-log\fR] [\fB\-l\fR, \fB\-\-log\fR]
[\fB\-A\fR, \fB\-\-advertise=\fImedia,...\fR] [\fB\-A\fR, \fB\-\-advertise=\fImedia,...\fR]
[\fB\-F\fR, \fB\-\-force=\fImedia\fR] [\fB\-F\fR, \fB\-\-force=\fImedia\fR]
.RI [ "interface\ ..." ] .RI "interface\ ..."
.SH DESCRIPTION .SH DESCRIPTION
This utility checks or sets the status of a network interface's Media This utility checks or sets the status of a network interface's Media
...@@ -36,9 +36,7 @@ one mode, instead of autonegotiating. The \fB\-A\fR and \fB\-F\fR ...@@ -36,9 +36,7 @@ one mode, instead of autonegotiating. The \fB\-A\fR and \fB\-F\fR
options are mutually exclusive. options are mutually exclusive.
.PP .PP
The default short output reports the negotiated link speed and link The default short output reports the negotiated link speed and link
status for each interface. If an interface or interfaces are not status for each interface.
specified on the command line, then \fBmii\-tool\fR will check any
available interfaces from \fBeth0\fR through \fBeth7\fR.
.SH OPTIONS .SH OPTIONS
.TP .TP
\fB\-v\fR, \fB\-\-verbose\fR \fB\-v\fR, \fB\-\-verbose\fR
......
...@@ -440,7 +440,7 @@ static void watch_one_xcvr(int skfd, char *ifname, int index) ...@@ -440,7 +440,7 @@ static void watch_one_xcvr(int skfd, char *ifname, int index)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
const char *usage = const char *usage =
"usage: %s [-VvRrwl] [-A media,... | -F media] [interface ...]\n" "usage: %s [-VvRrwl] [-A media,... | -F media] <interface ...>\n"
" -V, --version display version information\n" " -V, --version display version information\n"
" -v, --verbose more verbose output\n" " -v, --verbose more verbose output\n"
" -R, --reset reset MII to poweron state\n" " -R, --reset reset MII to poweron state\n"
...@@ -507,13 +507,10 @@ int main(int argc, char **argv) ...@@ -507,13 +507,10 @@ int main(int argc, char **argv)
/* No remaining args means show all interfaces. */ /* No remaining args means show all interfaces. */
if (optind == argc) { if (optind == argc) {
ret = 1; fprintf(stderr, "No interface specified\n");
for (i = 0; i < MAX_ETH; i++) { fprintf(stderr, usage, argv[0]);
sprintf(s, "eth%d", i); close(skfd);
ret &= do_one_xcvr(skfd, s, 1); return 2;
}
if (ret)
fprintf(stderr, "no MII interfaces found\n");
} else { } else {
ret = 0; ret = 0;
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
...@@ -524,15 +521,8 @@ int main(int argc, char **argv) ...@@ -524,15 +521,8 @@ int main(int argc, char **argv)
if (opt_watch && (ret == 0)) { if (opt_watch && (ret == 0)) {
while (1) { while (1) {
sleep(1); sleep(1);
if (optind == argc) { for (i = optind; i < argc; i++)
for (i = 0; i < MAX_ETH; i++) {
sprintf(s, "eth%d", i);
watch_one_xcvr(skfd, s, i);
}
} else {
for (i = optind; i < argc; i++)
watch_one_xcvr(skfd, argv[i], i-optind); watch_one_xcvr(skfd, argv[i], i-optind);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment