Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Vinod Koul
0e7264cc 61cc13a5

+5 -5
+5 -5
drivers/dma/at_hdmac.c
··· 778 778 */ 779 779 static int 780 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 783 if (period_len > (ATC_BTSIZE_MAX << reg_width)) 784 784 goto err_out; 785 785 if (unlikely(period_len & ((1 << reg_width) - 1))) 786 786 goto err_out; 787 787 if (unlikely(buf_addr & ((1 << reg_width) - 1))) 788 - goto err_out; 789 - if (unlikely(!(direction & (DMA_DEV_TO_MEM | DMA_MEM_TO_DEV)))) 790 788 goto err_out; 791 789 792 790 return 0; ··· 884 886 return NULL; 885 887 } 886 888 889 + if (unlikely(!is_slave_direction(direction))) 890 + goto err_out; 891 + 887 892 if (sconfig->direction == DMA_MEM_TO_DEV) 888 893 reg_width = convert_buswidth(sconfig->dst_addr_width); 889 894 else 890 895 reg_width = convert_buswidth(sconfig->src_addr_width); 891 896 892 897 /* Check for too big/unaligned periods and unaligned DMA buffer */ 893 - if (atc_dma_cyclic_check_values(reg_width, buf_addr, 894 - period_len, direction)) 898 + if (atc_dma_cyclic_check_values(reg_width, buf_addr, period_len)) 895 899 goto err_out; 896 900 897 901 /* build cyclic linked list */