summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/peripheral_charger.c6
-rw-r--r--include/peripheral_charger.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c
index c7371c5dc5..3c11c68be1 100644
--- a/common/peripheral_charger.c
+++ b/common/peripheral_charger.c
@@ -20,13 +20,11 @@
#define CPRINTS(fmt, args...) cprints(CC_PCHG, "PCHG: " fmt, ##args)
-static int dropped_event;
-
static void pchg_queue_event(struct pchg *ctx, enum pchg_event event)
{
mutex_lock(&ctx->mtx);
if (queue_add_unit(&ctx->events, &event) == 0) {
- dropped_event++;
+ ctx->dropped_event_count++;
CPRINTS("ERR: Queue is full");
}
mutex_unlock(&ctx->mtx);
@@ -487,6 +485,8 @@ static int cc_pchg(int argc, char **argv)
ccprintf("P%d STATE_%s EVENT_%s SOC=%d%%\n", port,
_text_state(ctx->state), _text_event(ctx->event),
ctx->battery_percent);
+ ccprintf("error=0x%x dropped=%u\n",
+ ctx->error, ctx->dropped_event_count);
return EC_SUCCESS;
}
diff --git a/include/peripheral_charger.h b/include/peripheral_charger.h
index b3d19edc52..a53fbb9104 100644
--- a/include/peripheral_charger.h
+++ b/include/peripheral_charger.h
@@ -138,6 +138,8 @@ struct pchg {
uint32_t error;
/* Battery percentage (0% ~ 100%) of the connected peripheral device */
uint8_t battery_percent;
+ /* Number of dropped events (due to queue overflow) */
+ uint32_t dropped_event_count;
};
/**