ectool: Allow usbpdpower command to take port #
Currently, usbpdpower command enumerates all USB-C ports found on the board. Since barrel jack adapters are not recognized as a USB-C port, they're not handled by the command. This patch allows the command to take a port number as a new parameter. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:841944 BRANCH=none TEST=Verify ectool usbpdpower 1 return 'Port 1: Disconnected' and 'Port 1: SNK (not charging)' without and with a BJ adapter connected respectively on Fizz. Change-Id: If3437c8f3f9952a4cc6004614ccff7bb6bbb4de5 Reviewed-on: https://chromium-review.googlesource.com/1217606 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1230993 Reviewed-by: Martin Roth <martinroth@chromium.org> Commit-Queue: Martin Roth <martinroth@chromium.org> Tested-by: Martin Roth <martinroth@chromium.org>
This commit is contained in:
parent
4b8c4db474
commit
6923c89ca9
|
@ -276,7 +276,7 @@ const char help_str[] =
|
|||
" Control USB PD/type-C\n"
|
||||
" usbpdmuxinfo\n"
|
||||
" Get USB-C SS mux info\n"
|
||||
" usbpdpower\n"
|
||||
" usbpdpower [port]\n"
|
||||
" Get USB PD power information\n"
|
||||
" version\n"
|
||||
" Prints EC version\n"
|
||||
|
@ -5119,6 +5119,7 @@ int cmd_usb_pd_power(int argc, char *argv[])
|
|||
struct ec_response_usb_pd_power_info *r =
|
||||
(struct ec_response_usb_pd_power_info *)ec_inbuf;
|
||||
int num_ports, i, rv;
|
||||
char *e;
|
||||
|
||||
rv = ec_command(EC_CMD_USB_PD_PORTS, 0, NULL, 0,
|
||||
ec_inbuf, ec_max_insize);
|
||||
|
@ -5126,15 +5127,31 @@ int cmd_usb_pd_power(int argc, char *argv[])
|
|||
return rv;
|
||||
num_ports = ((struct ec_response_usb_pd_ports *)r)->num_ports;
|
||||
|
||||
for (i = 0; i < num_ports; i++) {
|
||||
p.port = i;
|
||||
if (argc < 2) {
|
||||
for (i = 0; i < num_ports; i++) {
|
||||
p.port = i;
|
||||
rv = ec_command(EC_CMD_USB_PD_POWER_INFO, 0,
|
||||
&p, sizeof(p),
|
||||
ec_inbuf, ec_max_insize);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
printf("Port %d: ", i);
|
||||
print_pd_power_info(r);
|
||||
}
|
||||
} else {
|
||||
p.port = strtol(argv[1], &e, 0);
|
||||
if (e && *e) {
|
||||
fprintf(stderr, "Bad port.\n");
|
||||
return -1;
|
||||
}
|
||||
rv = ec_command(EC_CMD_USB_PD_POWER_INFO, 0,
|
||||
&p, sizeof(p),
|
||||
ec_inbuf, ec_max_insize);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
printf("Port %d: ", i);
|
||||
printf("Port %d: ", p.port);
|
||||
print_pd_power_info(r);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue