sh: stylistic improvements for the DMA driver
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
cfe4f2751e
commit
86d61b33e4
|
@ -80,17 +80,17 @@ static int sh_dmae_rst(int id)
|
||||||
unsigned short dmaor;
|
unsigned short dmaor;
|
||||||
|
|
||||||
sh_dmae_ctl_stop(id);
|
sh_dmae_ctl_stop(id);
|
||||||
dmaor = (dmaor_read_reg(id)|DMAOR_INIT);
|
dmaor = dmaor_read_reg(id) | DMAOR_INIT;
|
||||||
|
|
||||||
dmaor_write_reg(id, dmaor);
|
dmaor_write_reg(id, dmaor);
|
||||||
if ((dmaor_read_reg(id) & (DMAOR_AE | DMAOR_NMIF))) {
|
if (dmaor_read_reg(id) & (DMAOR_AE | DMAOR_NMIF)) {
|
||||||
pr_warning(KERN_ERR "dma-sh: Can't initialize DMAOR.\n");
|
pr_warning(KERN_ERR "dma-sh: Can't initialize DMAOR.\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dmae_is_idle(struct sh_dmae_chan *sh_chan)
|
static int dmae_is_busy(struct sh_dmae_chan *sh_chan)
|
||||||
{
|
{
|
||||||
u32 chcr = sh_dmae_readl(sh_chan, CHCR);
|
u32 chcr = sh_dmae_readl(sh_chan, CHCR);
|
||||||
if (chcr & CHCR_DE) {
|
if (chcr & CHCR_DE) {
|
||||||
|
@ -110,15 +110,14 @@ static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs hw)
|
||||||
{
|
{
|
||||||
sh_dmae_writel(sh_chan, hw.sar, SAR);
|
sh_dmae_writel(sh_chan, hw.sar, SAR);
|
||||||
sh_dmae_writel(sh_chan, hw.dar, DAR);
|
sh_dmae_writel(sh_chan, hw.dar, DAR);
|
||||||
sh_dmae_writel(sh_chan,
|
sh_dmae_writel(sh_chan, hw.tcr >> calc_xmit_shift(sh_chan), TCR);
|
||||||
(hw.tcr >> calc_xmit_shift(sh_chan)), TCR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmae_start(struct sh_dmae_chan *sh_chan)
|
static void dmae_start(struct sh_dmae_chan *sh_chan)
|
||||||
{
|
{
|
||||||
u32 chcr = sh_dmae_readl(sh_chan, CHCR);
|
u32 chcr = sh_dmae_readl(sh_chan, CHCR);
|
||||||
|
|
||||||
chcr |= (CHCR_DE|CHCR_IE);
|
chcr |= CHCR_DE | CHCR_IE;
|
||||||
sh_dmae_writel(sh_chan, chcr, CHCR);
|
sh_dmae_writel(sh_chan, chcr, CHCR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ static void dmae_halt(struct sh_dmae_chan *sh_chan)
|
||||||
|
|
||||||
static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
|
static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
|
||||||
{
|
{
|
||||||
int ret = dmae_is_idle(sh_chan);
|
int ret = dmae_is_busy(sh_chan);
|
||||||
/* When DMA was working, can not set data to CHCR */
|
/* When DMA was working, can not set data to CHCR */
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -149,7 +148,7 @@ static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val)
|
||||||
{
|
{
|
||||||
u32 addr;
|
u32 addr;
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
int ret = dmae_is_idle(sh_chan);
|
int ret = dmae_is_busy(sh_chan);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -388,7 +387,7 @@ static void sh_chan_xfer_ld_queue(struct sh_dmae_chan *sh_chan)
|
||||||
struct sh_dmae_regs hw;
|
struct sh_dmae_regs hw;
|
||||||
|
|
||||||
/* DMA work check */
|
/* DMA work check */
|
||||||
if (dmae_is_idle(sh_chan))
|
if (dmae_is_busy(sh_chan))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Find the first un-transfer desciptor */
|
/* Find the first un-transfer desciptor */
|
||||||
|
@ -497,6 +496,7 @@ static void dmae_do_tasklet(unsigned long data)
|
||||||
struct sh_dmae_chan *sh_chan = (struct sh_dmae_chan *)data;
|
struct sh_dmae_chan *sh_chan = (struct sh_dmae_chan *)data;
|
||||||
struct sh_desc *desc, *_desc, *cur_desc = NULL;
|
struct sh_desc *desc, *_desc, *cur_desc = NULL;
|
||||||
u32 sar_buf = sh_dmae_readl(sh_chan, SAR);
|
u32 sar_buf = sh_dmae_readl(sh_chan, SAR);
|
||||||
|
|
||||||
list_for_each_entry_safe(desc, _desc,
|
list_for_each_entry_safe(desc, _desc,
|
||||||
&sh_chan->ld_queue, node) {
|
&sh_chan->ld_queue, node) {
|
||||||
if ((desc->hw.sar + desc->hw.tcr) == sar_buf) {
|
if ((desc->hw.sar + desc->hw.tcr) == sar_buf) {
|
||||||
|
@ -543,8 +543,8 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id)
|
||||||
/* alloc channel */
|
/* alloc channel */
|
||||||
new_sh_chan = kzalloc(sizeof(struct sh_dmae_chan), GFP_KERNEL);
|
new_sh_chan = kzalloc(sizeof(struct sh_dmae_chan), GFP_KERNEL);
|
||||||
if (!new_sh_chan) {
|
if (!new_sh_chan) {
|
||||||
dev_err(shdev->common.dev, "No free memory for allocating "
|
dev_err(shdev->common.dev,
|
||||||
"dma channels!\n");
|
"No free memory for allocating dma channels!\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,8 +586,8 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id)
|
||||||
"sh-dmae%d", new_sh_chan->id);
|
"sh-dmae%d", new_sh_chan->id);
|
||||||
|
|
||||||
/* set up channel irq */
|
/* set up channel irq */
|
||||||
err = request_irq(irq, &sh_dmae_interrupt,
|
err = request_irq(irq, &sh_dmae_interrupt, irqflags,
|
||||||
irqflags, new_sh_chan->dev_id, new_sh_chan);
|
new_sh_chan->dev_id, new_sh_chan);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(shdev->common.dev, "DMA channel %d request_irq error "
|
dev_err(shdev->common.dev, "DMA channel %d request_irq error "
|
||||||
"with return %d\n", id, err);
|
"with return %d\n", id, err);
|
||||||
|
@ -691,8 +691,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ecnt = 0 ; ecnt < ARRAY_SIZE(eirq); ecnt++) {
|
for (ecnt = 0 ; ecnt < ARRAY_SIZE(eirq); ecnt++) {
|
||||||
err = request_irq(eirq[ecnt], sh_dmae_err,
|
err = request_irq(eirq[ecnt], sh_dmae_err, irqflags,
|
||||||
irqflags, "DMAC Address Error", shdev);
|
"DMAC Address Error", shdev);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "DMA device request_irq"
|
dev_err(&pdev->dev, "DMA device request_irq"
|
||||||
"error (irq %d) with return %d\n",
|
"error (irq %d) with return %d\n",
|
||||||
|
|
Loading…
Reference in New Issue