Skip to content

Commit 0e7264c

Browse files
andy-shevVinod Koul
authored andcommitted
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>
1 parent 61cc13a commit 0e7264c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎drivers/dma/at_hdmac.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,16 +778,14 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
778778
*/
779779
static int
780780
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)
782782
{
783783
if (period_len > (ATC_BTSIZE_MAX << reg_width))
784784
goto err_out;
785785
if (unlikely(period_len & ((1 << reg_width) - 1)))
786786
goto err_out;
787787
if (unlikely(buf_addr & ((1 << reg_width) - 1)))
788788
goto err_out;
789-
if (unlikely(!(direction & (DMA_DEV_TO_MEM | DMA_MEM_TO_DEV))))
790-
goto err_out;
791789

792790
return 0;
793791

@@ -886,14 +884,16 @@ atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
886884
return NULL;
887885
}
888886

887+
if (unlikely(!is_slave_direction(direction)))
888+
goto err_out;
889+
889890
if (sconfig->direction == DMA_MEM_TO_DEV)
890891
reg_width = convert_buswidth(sconfig->dst_addr_width);
891892
else
892893
reg_width = convert_buswidth(sconfig->src_addr_width);
893894

894895
/* Check for too big/unaligned periods and unaligned DMA buffer */
895-
if (atc_dma_cyclic_check_values(reg_width, buf_addr,
896-
period_len, direction))
896+
if (atc_dma_cyclic_check_values(reg_width, buf_addr, period_len))
897897
goto err_out;
898898

899899
/* build cyclic linked list */

0 commit comments

Comments
 (0)