diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-01-10 03:52:57 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-01-12 08:07:21 -0500 |
commit | 0e7264cc79a2d5c0ffa32c08d8f1cf84b2ec4fef (patch) | |
tree | a43173aaa8ae902adb9e2ed66055f2b6d38f6b5a /drivers/dma/at_hdmac.c | |
parent | 61cc13a51bcff737ce02d2047834171c0365b00d (diff) |
dma: at_hdmac: check direction properly for cyclic transfers
dma_transfer_direction is a normal enum. It means we can't usually use the
values as bit fields. Let's adjust this check and move it above the usage of
the direction parameter, due to the nature of the following usage of it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/at_hdmac.c')
-rw-r--r-- | drivers/dma/at_hdmac.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 13a02f4425b0..6e13f262139a 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c | |||
@@ -778,7 +778,7 @@ err: | |||
778 | */ | 778 | */ |
779 | static int | 779 | static int |
780 | atc_dma_cyclic_check_values(unsigned int reg_width, dma_addr_t buf_addr, | 780 | atc_dma_cyclic_check_values(unsigned int reg_width, dma_addr_t buf_addr, |
781 | size_t period_len, enum dma_transfer_direction direction) | 781 | size_t period_len) |
782 | { | 782 | { |
783 | if (period_len > (ATC_BTSIZE_MAX << reg_width)) | 783 | if (period_len > (ATC_BTSIZE_MAX << reg_width)) |
784 | goto err_out; | 784 | goto err_out; |
@@ -786,8 +786,6 @@ atc_dma_cyclic_check_values(unsigned int reg_width, dma_addr_t buf_addr, | |||
786 | goto err_out; | 786 | goto err_out; |
787 | if (unlikely(buf_addr & ((1 << reg_width) - 1))) | 787 | if (unlikely(buf_addr & ((1 << reg_width) - 1))) |
788 | goto err_out; | 788 | goto err_out; |
789 | if (unlikely(!(direction & (DMA_DEV_TO_MEM | DMA_MEM_TO_DEV)))) | ||
790 | goto err_out; | ||
791 | 789 | ||
792 | return 0; | 790 | return 0; |
793 | 791 | ||
@@ -886,14 +884,16 @@ atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, | |||
886 | return NULL; | 884 | return NULL; |
887 | } | 885 | } |
888 | 886 | ||
887 | if (unlikely(!is_slave_direction(direction))) | ||
888 | goto err_out; | ||
889 | |||
889 | if (sconfig->direction == DMA_MEM_TO_DEV) | 890 | if (sconfig->direction == DMA_MEM_TO_DEV) |
890 | reg_width = convert_buswidth(sconfig->dst_addr_width); | 891 | reg_width = convert_buswidth(sconfig->dst_addr_width); |
891 | else | 892 | else |
892 | reg_width = convert_buswidth(sconfig->src_addr_width); | 893 | reg_width = convert_buswidth(sconfig->src_addr_width); |
893 | 894 | ||
894 | /* Check for too big/unaligned periods and unaligned DMA buffer */ | 895 | /* Check for too big/unaligned periods and unaligned DMA buffer */ |
895 | if (atc_dma_cyclic_check_values(reg_width, buf_addr, | 896 | if (atc_dma_cyclic_check_values(reg_width, buf_addr, period_len)) |
896 | period_len, direction)) | ||
897 | goto err_out; | 897 | goto err_out; |
898 | 898 | ||
899 | /* build cyclic linked list */ | 899 | /* build cyclic linked list */ |