Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static int get_dma_channel ( int  idx  )  [inline, static]

allocate a dma channel.

Parameters:
idx Requested channel NO.
  • MXC_INVLAID_CHANNEL System allocates a free channel which is not statically allocated.
  • Others User requests a specific channel
Returns:
  • MXC_INVLAID_CHANNEL Failure
  • Others Success

Definition at line 105 of file dma_mx2.c.

References mxc_dma_channel::dynamic, and mxc_dma_channel::lock.

Referenced by mxc_dma_request_ext().

{
      int i;
      mxc_dma_channel_t *p;

      if ((idx >= MAX_DMA_CHANNELS) && (idx != MXC_DMA_DYNAMIC_CHANNEL)) {
            return -1;
      }
      if (idx != MXC_DMA_DYNAMIC_CHANNEL) {
            p = g_dma_channels + idx;
            BUG_ON(p->dynamic != 0);
            if (xchg(&p->lock, 1) != 0) {
                  return -1;
            }
            return idx;
      }

      p = g_dma_channels;
      for (i = 0; (i < MAX_DMA_CHANNELS); i++, p++) {
            if (p->dynamic && (xchg(&p->lock, 1) == 0)) {
                  return i;
            }
      }
      return -1;
}


Generated by  Doxygen 1.6.0   Back to index