Commit 0c3fbaa8 authored by Ismael Fillonneau's avatar Ismael Fillonneau Committed by Ioannis Glaropoulos
Browse files

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: default avatarIsmael Fillonneau <ismael.fillonneau@stimio.fr>
parent d314253f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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.
		 */