summaryrefslogtreecommitdiff
path: root/common/usb_port_power_dumb.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/usb_port_power_dumb.c')
-rw-r--r--common/usb_port_power_dumb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/common/usb_port_power_dumb.c b/common/usb_port_power_dumb.c
index d298444fb7..ea2d4eb668 100644
--- a/common/usb_port_power_dumb.c
+++ b/common/usb_port_power_dumb.c
@@ -22,8 +22,13 @@ static uint8_t charge_mode[USB_PORT_COUNT];
static void usb_port_set_enabled(int port_id, int en)
{
- gpio_or_ioex_set_level(usb_port_enable[port_id], en);
- charge_mode[port_id] = en;
+ /*
+ * Only enable valid ports.
+ */
+ if (usb_port_enable[port_id] >= 0) {
+ gpio_or_ioex_set_level(usb_port_enable[port_id], en);
+ charge_mode[port_id] = en;
+ }
}
__maybe_unused static void usb_port_all_ports_on(void)