/* Try to locate a physical channel to be used for this transfer. If all are taken return NULL and the requester will have to cope by using some fallback PIO mode or retrying later.  */
static struct pl08x_phy_chan* pl08x_get_phy_channel(struct pl08x_driver_data *pl08x, struct pl08x_dma_chan *virt_chan)
/* Try to locate a physical channel to be used for this transfer. If all are taken return NULL and the requester will have to cope by using some fallback PIO mode or retrying later.  */
static struct pl08x_phy_chan* pl08x_get_phy_channel(struct pl08x_driver_data *pl08x, struct pl08x_dma_chan *virt_chan)
{
	struct pl08x_phy_chan *ch = NULL;
	unsigned long flags;
	int i;
	for (i = 0; i < pl08x->vd->channels; i++) {
		ch = &pl08x->phy_chans[i];
		spin_lock_irqsave(&ch->lock, flags);
		if (!ch->locked && !ch->serving) {
			ch->serving = virt_chan;
			spin_unlock_irqrestore(&ch->lock, flags);
			break;
		}
		spin_unlock_irqrestore(&ch->lock, flags);
	}
	if (i == pl08x->vd->channels) {
		return NULL;
	}
	return ch;
}