fix semaphore initialisation in max17048 driver

Previously, we were using the semaphore before initialising it; this is now fixed.
This commit is contained in:
zhiayang 2023-05-16 21:11:01 +08:00 committed by zhiayang
parent 031db47519
commit 72e83db34a
No known key found for this signature in database
GPG key ID: 5E2F30AD6F08571F

View file

@ -186,13 +186,15 @@ static int max17048_init(const struct device *dev) {
return err; return err;
} }
// the functions below need the semaphore, so initialise it here
k_sem_init(&drv_data->lock, 1, 1);
// bring the device out of sleep // bring the device out of sleep
set_sleep_enabled(dev, false); set_sleep_enabled(dev, false);
// set the default rcomp value -- 0x97, as stated in the datasheet // set the default rcomp value -- 0x97, as stated in the datasheet
set_rcomp_value(dev, 0x97); set_rcomp_value(dev, 0x97);
k_sem_init(&drv_data->lock, 1, 1);
LOG_INF("device initialised at 0x%x (version %d)", config->i2c_bus.addr, ic_version); LOG_INF("device initialised at 0x%x (version %d)", config->i2c_bus.addr, ic_version);
return 0; return 0;