[PATCH 9/9] miitool: Add option to scan mii buses

Sascha Hauer s.hauer at pengutronix.de
Wed Dec 11 06:41:17 EST 2013


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 at pengutronix.de>
---
 commands/miitool.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/commands/miitool.c b/commands/miitool.c
index 3a9ac45..a00514d 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];
 
-- 
1.8.5.1




More information about the barebox mailing list