MLK-11911-7 mxc IPUv3: common: Convert macro tri_cur_buf_mask/shift to function
authorLiu Ying <Ying.Liu@freescale.com>
Fri, 27 Nov 2015 06:29:53 +0000 (14:29 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:17 +0000 (14:49 -0500)
This patch converts macro tri_cur_buf_mask/shift to function to address the
following issue reported by Coverity:
Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
result_independent_of_operands: dma_chan * 2 != 63 is always true regardless of
the values of its operands. This occurs as the logical first operand of '?:'.

Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
drivers/mxc/ipu3/ipu_common.c

index 8ba5f99..605b38f 100644 (file)
@@ -117,10 +117,22 @@ static inline int _ipu_is_sync_irq(uint32_t irq)
                (reg_num == 14) || (reg_num == 15));
 }
 
+static inline uint32_t tri_cur_buf_mask(uint32_t dma_chan)
+{
+       uint32_t mask = 1UL << ((dma_chan * 2) & 0x1F);
+
+       return mask * 3;
+}
+
+static inline uint32_t tri_cur_buf_shift(uint32_t dma_chan)
+{
+       uint32_t mask = 1UL << ((dma_chan * 2) & 0x1F);
+
+       return ffs(mask) - 1;
+}
+
 #define idma_is_valid(ch)      (ch != NO_DMA)
 #define idma_mask(ch)          (idma_is_valid(ch) ? (1UL << (ch & 0x1F)) : 0)
-#define tri_cur_buf_mask(ch)   (idma_mask(ch*2) * 3)
-#define tri_cur_buf_shift(ch)  (ffs(idma_mask(ch*2)) - 1)
 
 static inline bool idma_is_set(struct ipu_soc *ipu, uint32_t reg, uint32_t dma)
 {