dma_chan_pause的源代码
时间: 2023-06-25 09:08:31 浏览: 63
下面是dma_chan_pause函数的源代码,该函数的作用是暂停DMA传输通道:
```c
/**
* dma_chan_pause - pause the DMA channel
* @chan: dma channel to be paused
*
* This function pauses a DMA channel. If the channel is already paused,
* this function has no effect.
*/
void dma_chan_pause(struct dma_chan *chan)
{
unsigned long flags;
spin_lock_irqsave(&chan->lock, flags);
if (chan->paused) {
spin_unlock_irqrestore(&chan->lock, flags);
return;
}
if (chan->device->device_prep_dma_pause) {
chan->device->device_prep_dma_pause(chan);
chan->paused = true;
}
spin_unlock_irqrestore(&chan->lock, flags);
}
```
该函数首先使用自旋锁来保护DMA通道,然后检查通道是否已经暂停,如果已经暂停,则直接返回。如果没有暂停,则调用设备特定的device_prep_dma_pause函数并将通道标记为已暂停。最后,释放锁并返回。