static dma_t dma_chan[MAX_DMA_CHANNELS];
+static inline dma_t *dma_channel(unsigned int chan)
+{
+ dma_t *dma = dma_chan + chan;
+
+ if (chan >= MAX_DMA_CHANNELS || !dma->d_ops)
+ return NULL;
+
+ return dma;
+}
+
/*
* Request DMA channel
*
*/
int request_dma(unsigned int chan, const char *device_id)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
int ret;
- if (chan >= MAX_DMA_CHANNELS || !dma->d_ops)
+ if (!dma)
goto bad_dma;
if (xchg(&dma->lock, 1) != 0)
*/
void free_dma(unsigned int chan)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
- if (chan >= MAX_DMA_CHANNELS || !dma->d_ops)
+ if (!dma)
goto bad_dma;
if (dma->active) {
*/
void set_dma_sg (unsigned int chan, struct scatterlist *sg, int nr_sg)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
if (dma->active)
printk(KERN_ERR "dma%d: altering DMA SG while "
*/
void __set_dma_addr (unsigned int chan, void *addr)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
if (dma->active)
printk(KERN_ERR "dma%d: altering DMA address while "
*/
void set_dma_count (unsigned int chan, unsigned long count)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
if (dma->active)
printk(KERN_ERR "dma%d: altering DMA count while "
*/
void set_dma_mode (unsigned int chan, dmamode_t mode)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
if (dma->active)
printk(KERN_ERR "dma%d: altering DMA mode while "
*/
void enable_dma (unsigned int chan)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
if (!dma->lock)
goto free_dma;
*/
void disable_dma (unsigned int chan)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
if (!dma->lock)
goto free_dma;
*/
int dma_channel_active(unsigned int chan)
{
- return dma_chan[chan].active;
+ dma_t *dma = dma_channel(chan);
+ return dma->active;
}
EXPORT_SYMBOL(dma_channel_active);
void set_dma_speed(unsigned int chan, int cycle_ns)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
int ret = 0;
if (dma->d_ops->setspeed)
int get_dma_residue(unsigned int chan)
{
- dma_t *dma = dma_chan + chan;
+ dma_t *dma = dma_channel(chan);
int ret = 0;
if (dma->d_ops->residue)
arch_dma_init(dma_chan);
return 0;
}
-
core_initcall(init_dma);