summaryrefslogtreecommitdiff
path: root/common/i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/i2c.c')
-rw-r--r--common/i2c.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/common/i2c.c b/common/i2c.c
index 2540a325c7..bd2e780466 100644
--- a/common/i2c.c
+++ b/common/i2c.c
@@ -755,14 +755,25 @@ static void scan_bus(int port, const char *desc)
static int command_scan(int argc, char **argv)
{
- int i;
+ int port;
+ char *e;
+
+ if (argc == 1) {
+ for (port = 0; port < i2c_ports_used; port++)
+ scan_bus(i2c_ports[port].port, i2c_ports[port].name);
+ return EC_SUCCESS;
+ }
+
+
+ port = strtoi(argv[1], &e, 0);
+ if ((*e) || (port >= i2c_ports_used))
+ return EC_ERROR_PARAM2;
- for (i = 0; i < i2c_ports_used; i++)
- scan_bus(i2c_ports[i].port, i2c_ports[i].name);
+ scan_bus(i2c_ports[port].port, i2c_ports[port].name);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(i2cscan, command_scan,
- NULL,
+ "i2cscan [port]",
"Scan I2C ports for devices",
NULL);
#endif