diff options
Diffstat (limited to 'drivers/dma/ste_dma40.c')
-rw-r--r-- | drivers/dma/ste_dma40.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 623779e580c3..e317debdbe5a 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
@@ -639,19 +639,18 @@ static int d40_lcla_alloc_one(struct d40_chan *d40c, | |||
639 | unsigned long flags; | 639 | unsigned long flags; |
640 | int i; | 640 | int i; |
641 | int ret = -EINVAL; | 641 | int ret = -EINVAL; |
642 | int p; | ||
643 | 642 | ||
644 | spin_lock_irqsave(&d40c->base->lcla_pool.lock, flags); | 643 | spin_lock_irqsave(&d40c->base->lcla_pool.lock, flags); |
645 | 644 | ||
646 | p = d40c->phy_chan->num * D40_LCLA_LINK_PER_EVENT_GRP; | ||
647 | |||
648 | /* | 645 | /* |
649 | * Allocate both src and dst at the same time, therefore the half | 646 | * Allocate both src and dst at the same time, therefore the half |
650 | * start on 1 since 0 can't be used since zero is used as end marker. | 647 | * start on 1 since 0 can't be used since zero is used as end marker. |
651 | */ | 648 | */ |
652 | for (i = 1 ; i < D40_LCLA_LINK_PER_EVENT_GRP / 2; i++) { | 649 | for (i = 1 ; i < D40_LCLA_LINK_PER_EVENT_GRP / 2; i++) { |
653 | if (!d40c->base->lcla_pool.alloc_map[p + i]) { | 650 | int idx = d40c->phy_chan->num * D40_LCLA_LINK_PER_EVENT_GRP + i; |
654 | d40c->base->lcla_pool.alloc_map[p + i] = d40d; | 651 | |
652 | if (!d40c->base->lcla_pool.alloc_map[idx]) { | ||
653 | d40c->base->lcla_pool.alloc_map[idx] = d40d; | ||
655 | d40d->lcla_alloc++; | 654 | d40d->lcla_alloc++; |
656 | ret = i; | 655 | ret = i; |
657 | break; | 656 | break; |
@@ -676,10 +675,10 @@ static int d40_lcla_free_all(struct d40_chan *d40c, | |||
676 | spin_lock_irqsave(&d40c->base->lcla_pool.lock, flags); | 675 | spin_lock_irqsave(&d40c->base->lcla_pool.lock, flags); |
677 | 676 | ||
678 | for (i = 1 ; i < D40_LCLA_LINK_PER_EVENT_GRP / 2; i++) { | 677 | for (i = 1 ; i < D40_LCLA_LINK_PER_EVENT_GRP / 2; i++) { |
679 | if (d40c->base->lcla_pool.alloc_map[d40c->phy_chan->num * | 678 | int idx = d40c->phy_chan->num * D40_LCLA_LINK_PER_EVENT_GRP + i; |
680 | D40_LCLA_LINK_PER_EVENT_GRP + i] == d40d) { | 679 | |
681 | d40c->base->lcla_pool.alloc_map[d40c->phy_chan->num * | 680 | if (d40c->base->lcla_pool.alloc_map[idx] == d40d) { |
682 | D40_LCLA_LINK_PER_EVENT_GRP + i] = NULL; | 681 | d40c->base->lcla_pool.alloc_map[idx] = NULL; |
683 | d40d->lcla_alloc--; | 682 | d40d->lcla_alloc--; |
684 | if (d40d->lcla_alloc == 0) { | 683 | if (d40d->lcla_alloc == 0) { |
685 | ret = 0; | 684 | ret = 0; |