diff options
-rw-r--r-- | drivers/dma/dw_dmac.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c index d3038a03503d..6b456f042557 100644 --- a/drivers/dma/dw_dmac.c +++ b/drivers/dma/dw_dmac.c | |||
@@ -191,6 +191,21 @@ static void dwc_initialize(struct dw_dma_chan *dwc) | |||
191 | 191 | ||
192 | /*----------------------------------------------------------------------*/ | 192 | /*----------------------------------------------------------------------*/ |
193 | 193 | ||
194 | static inline unsigned int dwc_fast_fls(unsigned long long v) | ||
195 | { | ||
196 | /* | ||
197 | * We can be a lot more clever here, but this should take care | ||
198 | * of the most common optimization. | ||
199 | */ | ||
200 | if (!(v & 7)) | ||
201 | return 3; | ||
202 | else if (!(v & 3)) | ||
203 | return 2; | ||
204 | else if (!(v & 1)) | ||
205 | return 1; | ||
206 | return 0; | ||
207 | } | ||
208 | |||
194 | static void dwc_dump_chan_regs(struct dw_dma_chan *dwc) | 209 | static void dwc_dump_chan_regs(struct dw_dma_chan *dwc) |
195 | { | 210 | { |
196 | dev_err(chan2dev(&dwc->chan), | 211 | dev_err(chan2dev(&dwc->chan), |
@@ -641,18 +656,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, | |||
641 | return NULL; | 656 | return NULL; |
642 | } | 657 | } |
643 | 658 | ||
644 | /* | 659 | src_width = dst_width = dwc_fast_fls(src | dest | len); |
645 | * We can be a lot more clever here, but this should take care | ||
646 | * of the most common optimization. | ||
647 | */ | ||
648 | if (!((src | dest | len) & 7)) | ||
649 | src_width = dst_width = 3; | ||
650 | else if (!((src | dest | len) & 3)) | ||
651 | src_width = dst_width = 2; | ||
652 | else if (!((src | dest | len) & 1)) | ||
653 | src_width = dst_width = 1; | ||
654 | else | ||
655 | src_width = dst_width = 0; | ||
656 | 660 | ||
657 | ctllo = DWC_DEFAULT_CTLLO(chan) | 661 | ctllo = DWC_DEFAULT_CTLLO(chan) |
658 | | DWC_CTLL_DST_WIDTH(dst_width) | 662 | | DWC_CTLL_DST_WIDTH(dst_width) |
@@ -752,14 +756,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
752 | mem = sg_dma_address(sg); | 756 | mem = sg_dma_address(sg); |
753 | len = sg_dma_len(sg); | 757 | len = sg_dma_len(sg); |
754 | 758 | ||
755 | if (!((mem | len) & 7)) | 759 | mem_width = dwc_fast_fls(mem | len); |
756 | mem_width = 3; | ||
757 | else if (!((mem | len) & 3)) | ||
758 | mem_width = 2; | ||
759 | else if (!((mem | len) & 1)) | ||
760 | mem_width = 1; | ||
761 | else | ||
762 | mem_width = 0; | ||
763 | 760 | ||
764 | slave_sg_todev_fill_desc: | 761 | slave_sg_todev_fill_desc: |
765 | desc = dwc_desc_get(dwc); | 762 | desc = dwc_desc_get(dwc); |
@@ -819,14 +816,7 @@ slave_sg_todev_fill_desc: | |||
819 | mem = sg_dma_address(sg); | 816 | mem = sg_dma_address(sg); |
820 | len = sg_dma_len(sg); | 817 | len = sg_dma_len(sg); |
821 | 818 | ||
822 | if (!((mem | len) & 7)) | 819 | mem_width = dwc_fast_fls(mem | len); |
823 | mem_width = 3; | ||
824 | else if (!((mem | len) & 3)) | ||
825 | mem_width = 2; | ||
826 | else if (!((mem | len) & 1)) | ||
827 | mem_width = 1; | ||
828 | else | ||
829 | mem_width = 0; | ||
830 | 820 | ||
831 | slave_sg_fromdev_fill_desc: | 821 | slave_sg_fromdev_fill_desc: |
832 | desc = dwc_desc_get(dwc); | 822 | desc = dwc_desc_get(dwc); |