/* Get endpoint from endpoint address. Also validates if the address is correct and endpoint is in correct state for receiving. If bounding callback was not called yet, then call it.  */
static struct ept_data* get_ept_and_rx_validate(struct backend_data *dev_data, uint8_t ept_addr)
/* Get endpoint from endpoint address. Also validates if the address is correct and endpoint is in correct state for receiving. If bounding callback was not called yet, then call it.  */
static struct ept_data* get_ept_and_rx_validate(struct backend_data *dev_data, uint8_t ept_addr)
{
	struct ept_data *ept;
	enum ept_bounding_state state;
	if (ept_addr >= NUM_EPT || dev_data->ept_map[ept_addr] >= NUM_EPT) {
		LOG_ERR("Received invalid endpoint addr %d", ept_addr);
		return NULL;
	}
	ept = &dev_data->ept[dev_data->ept_map[ept_addr]];
	state = atomic_get(&ept->state);
	if (state == EPT_READY) {
	} else if (state == EPT_BOUNDING) {
		atomic_set(&ept->state, EPT_READY);
		if (ept->cfg->cb.bound != NULL) {
			ept->cfg->cb.bound(ept->cfg->priv);
		}
	} else {
		LOG_ERR("Invalid state %d of receiving endpoint %d", state, ept->addr);
		return NULL;
	}
	return ept;
}