summaryrefslogtreecommitdiffstats
path: root/commands/miitool.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-12-11 12:27:09 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-12-11 12:33:05 +0100
commit8bc54c172131244abbc5adabfd7fee07d8400d8a (patch)
tree831db2dfca5b6bb09a46ca273c62324a8b8ab7b0 /commands/miitool.c
parent6cb2b2f29f362c7021a05b6f68a6e8d7a79f2972 (diff)
downloadbarebox-8bc54c172131244abbc5adabfd7fee07d8400d8a.tar.gz
barebox-8bc54c172131244abbc5adabfd7fee07d8400d8a.tar.xz
miitool: Add option to scan mii buses
With the -s option all mii buses can be scanned for devices so that they are available without doing network operations. Also, now *all* phy devices on a mii bus can be examined, not only the one attached to an ethernet device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/miitool.c')
-rw-r--r--commands/miitool.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/commands/miitool.c b/commands/miitool.c
index 3a9ac45605..a00514d3cc 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -37,6 +37,7 @@
#include <linux/stat.h>
#include <xfuncs.h>
#include <linux/mii.h>
+#include <linux/phy.h>
static u16 mdio_read(int fd, int offset)
{
@@ -218,13 +219,17 @@ static int do_miitool(int argc, char *argv[])
int argc_min;
int fd;
int verbose;
+ int scan = 0;
verbose = 0;
- while ((opt = getopt(argc, argv, "v")) > 0) {
+ while ((opt = getopt(argc, argv, "vs")) > 0) {
switch (opt) {
case 'v':
verbose++;
break;
+ case 's':
+ scan = 1;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -232,8 +237,11 @@ static int do_miitool(int argc, char *argv[])
argc_min = optind + 1;
+ if (scan)
+ mdiobus_detect_all();
+
if (argc < argc_min)
- return COMMAND_ERROR_USAGE;
+ return scan ? 0 : COMMAND_ERROR_USAGE;
filename = argv[optind];