summaryrefslogtreecommitdiff
path: root/common/dps.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2022-06-27 14:35:21 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-30 21:01:04 +0000
commit008aabb956faa178acd0d75a465979c990d65e58 (patch)
tree70d707162d17cd4dc751ed3478a1a9e2982e3204 /common/dps.c
parenta200ef3f964cc31fc44a9361c5b4c527b7021174 (diff)
downloadchrome-ec-008aabb956faa178acd0d75a465979c990d65e58.tar.gz
common/dps.c: Format with clang-format
BUG=b:236386294 BRANCH=none TEST=none Change-Id: Iebab9e7635dd66ad3af68be2dce5fd69fec6b7dd Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729604 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'common/dps.c')
-rw-r--r--common/dps.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/common/dps.c b/common/dps.c
index 3af25e6280..22934b56f8 100644
--- a/common/dps.c
+++ b/common/dps.c
@@ -25,7 +25,6 @@
#include "util.h"
#include "usb_pe_sm.h"
-
#define K_MORE_PWR 96
#define K_LESS_PWR 93
#define K_SAMPLE 1
@@ -33,17 +32,16 @@
#define T_REQUEST_STABLE_TIME (10 * SECOND)
#define T_NEXT_CHECK_TIME (5 * SECOND)
-#define DPS_FLAG_DISABLED BIT(0)
-#define DPS_FLAG_NO_SRCCAP BIT(1)
-#define DPS_FLAG_WAITING BIT(2)
-#define DPS_FLAG_SAMPLED BIT(3)
-#define DPS_FLAG_NEED_MORE_PWR BIT(4)
+#define DPS_FLAG_DISABLED BIT(0)
+#define DPS_FLAG_NO_SRCCAP BIT(1)
+#define DPS_FLAG_WAITING BIT(2)
+#define DPS_FLAG_SAMPLED BIT(3)
+#define DPS_FLAG_NEED_MORE_PWR BIT(4)
-#define DPS_FLAG_STOP_EVENTS (DPS_FLAG_DISABLED | \
- DPS_FLAG_NO_SRCCAP)
-#define DPS_FLAG_ALL GENMASK(31, 0)
+#define DPS_FLAG_STOP_EVENTS (DPS_FLAG_DISABLED | DPS_FLAG_NO_SRCCAP)
+#define DPS_FLAG_ALL GENMASK(31, 0)
-#define MAX_MOVING_AVG_WINDOW 5
+#define MAX_MOVING_AVG_WINDOW 5
BUILD_ASSERT(K_MORE_PWR > K_LESS_PWR && 100 >= K_MORE_PWR && 100 >= K_LESS_PWR);
@@ -135,8 +133,7 @@ static void dps_init(void)
CPRINTS("ERR:WIN");
}
- if (dps_config.k_less_pwr > 100 ||
- dps_config.k_more_pwr > 100 ||
+ if (dps_config.k_less_pwr > 100 || dps_config.k_more_pwr > 100 ||
dps_config.k_more_pwr <= dps_config.k_less_pwr) {
dps_config.k_less_pwr = K_LESS_PWR;
dps_config.k_more_pwr = K_MORE_PWR;
@@ -258,16 +255,16 @@ struct pdo_candidate {
};
#define UPDATE_CANDIDATE(new_port, new_mv, new_mw) \
- do { \
- cand->port = new_port; \
- cand->mv = new_mv; \
- cand->mw = new_mw; \
+ do { \
+ cand->port = new_port; \
+ cand->mv = new_mv; \
+ cand->mw = new_mw; \
} while (0)
-#define CLEAR_AND_RETURN() \
- do { \
+#define CLEAR_AND_RETURN() \
+ do { \
moving_avg_count = 0; \
- return false; \
+ return false; \
} while (0)
/*
@@ -360,7 +357,7 @@ static bool has_new_power_request(struct pdo_candidate *cand)
input_curr, input_pwr_avg, input_curr_avg);
for (int i = 0; i < board_get_usb_pd_port_count(); ++i) {
- const uint32_t * const src_caps = pd_get_src_caps(i);
+ const uint32_t *const src_caps = pd_get_src_caps(i);
/* If the port is not SNK, skip evaluating this port. */
if (pd_get_power_role(i) != PD_ROLE_SINK)
@@ -419,7 +416,6 @@ static bool has_new_power_request(struct pdo_candidate *cand)
}
}
-
/*
* if the candidate is the same as the current one, pick
* the one at active charge port.
@@ -454,14 +450,14 @@ void dps_update_stabilized_time(int port)
void dps_task(void *u)
{
- struct pdo_candidate last_cand = {CHARGE_PORT_NONE, 0, 0};
+ struct pdo_candidate last_cand = { CHARGE_PORT_NONE, 0, 0 };
int sample_count = 0;
dps_init();
update_timeout(dps_config.t_check);
while (1) {
- struct pdo_candidate curr_cand = {CHARGE_PORT_NONE, 0, 0};
+ struct pdo_candidate curr_cand = { CHARGE_PORT_NONE, 0, 0 };
timestamp_t now;
now = get_time();
@@ -505,8 +501,7 @@ void dps_task(void *u)
if (sample_count == dps_config.k_sample) {
dynamic_mv = curr_cand.mv;
dps_port = curr_cand.port;
- pd_dpm_request(dps_port,
- DPM_REQUEST_NEW_POWER_LEVEL);
+ pd_dpm_request(dps_port, DPM_REQUEST_NEW_POWER_LEVEL);
sample_count = 0;
flag &= ~(DPS_FLAG_SAMPLED | DPS_FLAG_NEED_MORE_PWR);
}
@@ -557,10 +552,8 @@ static int command_dps(int argc, char **argv)
"Efficient: %dmV\n"
"Batt: %dmv\n"
"PDMaxMV: %dmV\n",
- port, last_mv, last_ma,
- vbus, input_curr, input_pwr,
- get_efficient_voltage(),
- batt_mv,
+ port, last_mv, last_ma, vbus, input_curr, input_pwr,
+ get_efficient_voltage(), batt_mv,
pd_get_max_voltage());
return EC_SUCCESS;
}
@@ -657,6 +650,5 @@ static enum ec_status hc_usb_pd_dps_control(struct host_cmd_handler_args *args)
dps_enable(p->enable);
return EC_RES_SUCCESS;
}
-DECLARE_HOST_COMMAND(EC_CMD_USB_PD_DPS_CONTROL,
- hc_usb_pd_dps_control,
+DECLARE_HOST_COMMAND(EC_CMD_USB_PD_DPS_CONTROL, hc_usb_pd_dps_control,
EC_VER_MASK(0));