From d93894b7d99b293dd858b472f74f1581a9a242fd Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 4 Aug 2024 15:41:57 +0100 Subject: [PATCH] remove highest voltage tracking --- drivers/tildagon_power/fusb302b/fusb302b_pd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/tildagon_power/fusb302b/fusb302b_pd.c b/drivers/tildagon_power/fusb302b/fusb302b_pd.c index a9c0b57..61a4d13 100644 --- a/drivers/tildagon_power/fusb302b/fusb302b_pd.c +++ b/drivers/tildagon_power/fusb302b/fusb302b_pd.c @@ -91,22 +91,19 @@ void fusbpd_decode( pd_state_t* state, fusb_state_t* fusb ) */ uint8_t fusbpd_select_pdo( pd_state_t* state ) { - uint16_t highest_voltage = 5000U; - uint8_t index = 0U; - for ( uint8_t i = 0U; i < state->last_rx_header.sop.number_objects; i++ ) + uint8_t i = 0U; + for ( i = 0U ; i < state->last_rx_header.sop.number_objects; i++ ) { const uint16_t voltage = state->pdos[i].fixed.voltage * 50; if ( ( state->pdos[i].fixed.pdo_type == PD_FIXED_SUPPLY ) - && ( voltage > highest_voltage ) - && ( voltage <= 5000U ) + && ( voltage == 5000U ) ) { - highest_voltage = voltage; - index = i; + break; } } - return index; + return i; } /**