Skip to content

Commit

Permalink
sensor: bq274xx: use K_TIMEOUT_ABS_MS for the startup delay
Browse files Browse the repository at this point in the history
Use K_TIMEOUT_ABS_MS to control the startup delay. Same thing, more
compact.

Signed-off-by: Fabio Baltieri <[email protected]>
  • Loading branch information
fabiobaltieri authored and MaureenHelm committed Sep 11, 2023
1 parent 15c733a commit 5e63058
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions drivers/sensor/bq274xx/bq274xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ static int bq274xx_gauge_init(const struct device *dev)
struct bq274xx_data *data = dev->data;
int ret;
uint16_t id;
int32_t delay_remainder_ms;

if (!device_is_ready(config->i2c.bus)) {
LOG_ERR("I2C bus device not ready");
Expand All @@ -640,11 +639,7 @@ static int bq274xx_gauge_init(const struct device *dev)
}
#endif

delay_remainder_ms = POWER_UP_DELAY_MS - k_uptime_get_32();
if (delay_remainder_ms > 0) {
LOG_DBG("Power up delay remainder: %dms", delay_remainder_ms);
k_msleep(delay_remainder_ms);
}
k_sleep(K_TIMEOUT_ABS_MS(POWER_UP_DELAY_MS));

ret = bq274xx_get_device_type(dev, &id);
if (ret < 0) {
Expand Down

0 comments on commit 5e63058

Please sign in to comment.