/* Safely release the modem from any context. 
This function can be called from any context and guarantees that the release operations will only be run once. */
static bool modem_release(struct sx12xx_data *data)
/* Safely release the modem from any context. 
This function can be called from any context and guarantees that the release operations will only be run once. */
static bool modem_release(struct sx12xx_data *data)
{
	if (!atomic_cas(&data->modem_usage, STATE_BUSY, STATE_CLEANUP)) {
		return false;
	}
	Radio.Sleep();
	data->operation_done = NULL;
	atomic_clear(&data->modem_usage);
	return true;
}