cregit-Linux how code gets into the kernel

Release 4.11 arch/arm/kernel/dma.c

Directory: arch/arm/kernel
/*
 *  linux/arch/arm/kernel/dma.c
 *
 *  Copyright (C) 1995-2000 Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *  Front-end to the DMA handling.  This handles the allocation/freeing
 *  of DMA channels, and provides a unified interface to the machines
 *  DMA facilities.
 */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/errno.h>
#include <linux/scatterlist.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>

#include <asm/dma.h>

#include <asm/mach/dma.h>


DEFINE_RAW_SPINLOCK(dma_spin_lock);

EXPORT_SYMBOL(dma_spin_lock);


static dma_t *dma_chan[MAX_DMA_CHANNELS];


static inline dma_t *dma_channel(unsigned int chan) { if (chan >= MAX_DMA_CHANNELS) return NULL; return dma_chan[chan]; }

Contributors

PersonTokensPropCommitsCommitProp
Russell King27100.00%2100.00%
Total27100.00%2100.00%


int __init isa_dma_add(unsigned int chan, dma_t *dma) { if (!dma->d_ops) return -EINVAL; sg_init_table(&dma->buf, 1); if (dma_chan[chan]) return -EBUSY; dma_chan[chan] = dma; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Russell King56100.00%3100.00%
Total56100.00%3100.00%

/* * Request DMA channel * * On certain platforms, we have to allocate an interrupt as well... */
int request_dma(unsigned int chan, const char *device_id) { dma_t *dma = dma_channel(chan); int ret; if (!dma) goto bad_dma; if (xchg(&dma->lock, 1) != 0) goto busy; dma->device_id = device_id; dma->active = 0; dma->invalid = 1; ret = 0; if (dma->d_ops->request) ret = dma->d_ops->request(chan, dma); if (ret) xchg(&dma->lock, 0); return ret; bad_dma: pr_err("dma: trying to allocate DMA%d\n", chan); return -EINVAL; busy: return -EBUSY; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)12092.31%350.00%
Russell King107.69%350.00%
Total130100.00%6100.00%

EXPORT_SYMBOL(request_dma); /* * Free DMA channel * * On certain platforms, we have to free interrupt as well... */
void free_dma(unsigned int chan) { dma_t *dma = dma_channel(chan); if (!dma) goto bad_dma; if (dma->active) { pr_err("dma%d: freeing active DMA\n", chan); dma->d_ops->disable(chan, dma); dma->active = 0; } if (xchg(&dma->lock, 0) != 0) { if (dma->d_ops->free) dma->d_ops->free(chan, dma); return; } pr_err("dma%d: trying to free free DMA\n", chan); return; bad_dma: pr_err("dma: trying to free DMA%d\n", chan); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9686.49%350.00%
Russell King1513.51%350.00%
Total111100.00%6100.00%

EXPORT_SYMBOL(free_dma); /* Set DMA Scatter-Gather list */
void set_dma_sg (unsigned int chan, struct scatterlist *sg, int nr_sg) { dma_t *dma = dma_channel(chan); if (dma->active) pr_err("dma%d: altering DMA SG while DMA active\n", chan); dma->sg = sg; dma->sgcount = nr_sg; dma->invalid = 1; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3764.91%450.00%
Russell King2035.09%450.00%
Total57100.00%8100.00%

EXPORT_SYMBOL(set_dma_sg); /* Set DMA address * * Copy address to the structure, and set the invalid bit */
void __set_dma_addr (unsigned int chan, void *addr) { dma_t *dma = dma_channel(chan); if (dma->active) pr_err("dma%d: altering DMA address while DMA active\n", chan); dma->sg = NULL; dma->addr = addr; dma->invalid = 1; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3667.92%444.44%
Russell King1732.08%555.56%
Total53100.00%9100.00%

EXPORT_SYMBOL(__set_dma_addr); /* Set DMA byte count * * Copy address to the structure, and set the invalid bit */
void set_dma_count (unsigned int chan, unsigned long count) { dma_t *dma = dma_channel(chan); if (dma->active) pr_err("dma%d: altering DMA count while DMA active\n", chan); dma->sg = NULL; dma->count = count; dma->invalid = 1; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4177.36%450.00%
Russell King1222.64%450.00%
Total53100.00%8100.00%

EXPORT_SYMBOL(set_dma_count); /* Set DMA direction mode */
void set_dma_mode (unsigned int chan, unsigned int mode) { dma_t *dma = dma_channel(chan); if (dma->active) pr_err("dma%d: altering DMA mode while DMA active\n", chan); dma->dma_mode = mode; dma->invalid = 1; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3574.47%342.86%
Russell King1225.53%457.14%
Total47100.00%7100.00%

EXPORT_SYMBOL(set_dma_mode); /* Enable DMA channel */
void enable_dma (unsigned int chan) { dma_t *dma = dma_channel(chan); if (!dma->lock) goto free_dma; if (dma->active == 0) { dma->active = 1; dma->d_ops->enable(chan, dma); } return; free_dma: pr_err("dma%d: trying to enable free DMA\n", chan); BUG(); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)5885.29%350.00%
Russell King1014.71%350.00%
Total68100.00%6100.00%

EXPORT_SYMBOL(enable_dma); /* Disable DMA channel */
void disable_dma (unsigned int chan) { dma_t *dma = dma_channel(chan); if (!dma->lock) goto free_dma; if (dma->active == 1) { dma->active = 0; dma->d_ops->disable(chan, dma); } return; free_dma: pr_err("dma%d: trying to disable free DMA\n", chan); BUG(); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)5885.29%350.00%
Russell King1014.71%350.00%
Total68100.00%6100.00%

EXPORT_SYMBOL(disable_dma); /* * Is the specified DMA channel active? */
int dma_channel_active(unsigned int chan) { dma_t *dma = dma_channel(chan); return dma->active; }

Contributors

PersonTokensPropCommitsCommitProp
Russell King23100.00%3100.00%
Total23100.00%3100.00%

EXPORT_SYMBOL(dma_channel_active);
void set_dma_page(unsigned int chan, char pagenr) { pr_err("dma%d: trying to set_dma_page\n", chan); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1473.68%250.00%
Russell King526.32%250.00%
Total19100.00%4100.00%

EXPORT_SYMBOL(set_dma_page);
void set_dma_speed(unsigned int chan, int cycle_ns) { dma_t *dma = dma_channel(chan); int ret = 0; if (dma->d_ops->setspeed) ret = dma->d_ops->setspeed(chan, dma, cycle_ns); dma->speed = ret; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4785.45%250.00%
Russell King814.55%250.00%
Total55100.00%4100.00%

EXPORT_SYMBOL(set_dma_speed);
int get_dma_residue(unsigned int chan) { dma_t *dma = dma_channel(chan); int ret = 0; if (dma->d_ops->residue) ret = dma->d_ops->residue(chan, dma); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3982.98%360.00%
Russell King817.02%240.00%
Total47100.00%5100.00%

EXPORT_SYMBOL(get_dma_residue); #ifdef CONFIG_PROC_FS
static int proc_dma_show(struct seq_file *m, void *v) { int i; for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) { dma_t *dma = dma_channel(i); if (dma && dma->lock) seq_printf(m, "%2d: %s\n", i, dma->device_id); } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Russell King66100.00%1100.00%
Total66100.00%1100.00%


static int proc_dma_open(struct inode *inode, struct file *file) { return single_open(file, proc_dma_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Russell King26100.00%1100.00%
Total26100.00%1100.00%

static const struct file_operations proc_dma_operations = { .open = proc_dma_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, };
static int __init proc_dma_init(void) { proc_create("dma", 0, NULL, &proc_dma_operations); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Russell King24100.00%1100.00%
Total24100.00%1100.00%

__initcall(proc_dma_init); #endif

Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)61356.60%731.82%
Russell King46643.03%1359.09%
Thomas Gleixner40.37%29.09%
Total1083100.00%22100.00%
Directory: arch/arm/kernel
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.