drivers: nrf: avoid UARTE pm infinite loop
calling UARTE power management with DEVICE_PM_SUSPEND_STATE then DEVICE_PM_OFF_STATE causes a deadlock in while loop. It waits for an event witch never comes Signed-off-by: Ismael Fillonneau <ismael.fillonneau@stimio.fr>
This commit is contained in:
parent
d314253fbb
commit
0c3fbaa882
1 changed files with 8 additions and 0 deletions
|
@ -1260,6 +1260,7 @@ static void uarte_nrfx_pins_enable(struct device *dev, bool enable)
|
|||
static void uarte_nrfx_set_power_state(struct device *dev, u32_t new_state)
|
||||
{
|
||||
NRF_UARTE_Type *uarte = get_uarte_instance(dev);
|
||||
struct uarte_nrfx_data *data = get_dev_data(dev);
|
||||
|
||||
if (new_state == DEVICE_PM_ACTIVE_STATE) {
|
||||
uarte_nrfx_pins_enable(dev, true);
|
||||
|
@ -1275,6 +1276,13 @@ static void uarte_nrfx_set_power_state(struct device *dev, u32_t new_state)
|
|||
new_state == DEVICE_PM_SUSPEND_STATE ||
|
||||
new_state == DEVICE_PM_OFF_STATE);
|
||||
|
||||
/* if pm is already not active, driver will stay indefinitely
|
||||
* in while loop waiting for event NRF_UARTE_EVENT_RXTO
|
||||
*/
|
||||
if (data->pm_state != DEVICE_PM_ACTIVE_STATE) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disabling UART requires stopping RX, but stop RX event is
|
||||
* only sent after each RX if async UART API is used.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue