drivers: i2c: nrfx: Fix power management assert
Calling device_set_power_state() with DEVICE_PM_SUSPEND_STATE then DEVICE_PM_OFF_STATE creates an assert in nrf driver Signed-off-by: Ismael Fillonneau <ismael.fillonneau@stimio.fr>
This commit is contained in:
parent
a401aefa0a
commit
6fd5dd894e
|
@ -193,11 +193,12 @@ static int twi_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
|||
void *context, device_pm_cb cb, void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
u32_t pm_current_state = get_dev_data(dev)->pm_state;
|
||||
|
||||
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
|
||||
u32_t new_state = *((const u32_t *)context);
|
||||
|
||||
if (new_state != get_dev_data(dev)->pm_state) {
|
||||
if (new_state != pm_current_state) {
|
||||
switch (new_state) {
|
||||
case DEVICE_PM_ACTIVE_STATE:
|
||||
init_twi(dev);
|
||||
|
@ -211,7 +212,9 @@ static int twi_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
|||
case DEVICE_PM_LOW_POWER_STATE:
|
||||
case DEVICE_PM_SUSPEND_STATE:
|
||||
case DEVICE_PM_OFF_STATE:
|
||||
nrfx_twi_uninit(&get_dev_config(dev)->twi);
|
||||
if (pm_current_state == DEVICE_PM_ACTIVE_STATE) {
|
||||
nrfx_twi_uninit(&get_dev_config(dev)->twi);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -167,11 +167,12 @@ static int twim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
|||
void *context, device_pm_cb cb, void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
u32_t pm_current_state = get_dev_data(dev)->pm_state;
|
||||
|
||||
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
|
||||
u32_t new_state = *((const u32_t *)context);
|
||||
|
||||
if (new_state != get_dev_data(dev)->pm_state) {
|
||||
if (new_state != pm_current_state) {
|
||||
switch (new_state) {
|
||||
case DEVICE_PM_ACTIVE_STATE:
|
||||
init_twim(dev);
|
||||
|
@ -185,6 +186,9 @@ static int twim_nrfx_pm_control(struct device *dev, u32_t ctrl_command,
|
|||
case DEVICE_PM_LOW_POWER_STATE:
|
||||
case DEVICE_PM_SUSPEND_STATE:
|
||||
case DEVICE_PM_OFF_STATE:
|
||||
if (pm_current_state != DEVICE_PM_ACTIVE_STATE) {
|
||||
break;
|
||||
}
|
||||
nrfx_twim_uninit(&get_dev_config(dev)->twim);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue