9
0
Fork 0

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>
This commit is contained in:
Sascha Hauer 2013-12-11 12:27:09 +01:00
parent 6cb2b2f29f
commit 8bc54c1721
1 changed files with 10 additions and 2 deletions

View File

@ -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];