ocpc: Do not report invalid charger if CHARGE_PORT_NONE
Do not report an invalid charger if there is no charger.
TEST=zmake configure -b nivviks; flash and run
BRANCH=none
@@ -515,7 +515,11 @@ enum ec_error_list charger_get_vbus_voltage(int port, int *voltage)
enum ec_error_list charger_set_input_current_limit(int chgnum,
int input_current)
{
- if ((chgnum < 0) || (chgnum >= board_get_charger_chip_count())) {
+ /* Note: may be called with CHARGE_PORT_NONE regularly */
+ if (chgnum < 0)
+ return EC_ERROR_INVAL;
+
+ if (chgnum >= board_get_charger_chip_count()) {
CPRINTS("%s(%d) Invalid charger!", __func__, chgnum);
return EC_ERROR_INVAL;
}
