]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
dmaengine: Refactor dmaengine_check_align() to be bit operations only
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 26 Feb 2020 10:18:38 +0000 (12:18 +0200)
committerVinod Koul <vkoul@kernel.org>
Mon, 2 Mar 2020 07:18:13 +0000 (12:48 +0530)
There is no need to have branch and temporary variable in the function.
Simple convert it to be a set of bit and arithmetic operations.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20200226101842.29426-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
include/linux/dmaengine.h

index 64461fc64e1bd2dddddf77f80388f7fb513cf094..9f3f5582816ae366e60610b7d155d02034e59033 100644 (file)
@@ -1155,14 +1155,7 @@ static inline dma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc
 static inline bool dmaengine_check_align(enum dmaengine_alignment align,
                                         size_t off1, size_t off2, size_t len)
 {
-       size_t mask;
-
-       if (!align)
-               return true;
-       mask = (1 << align) - 1;
-       if (mask & (off1 | off2 | len))
-               return false;
-       return true;
+       return !(((1 << align) - 1) & (off1 | off2 | len));
 }
 
 static inline bool is_dma_copy_aligned(struct dma_device *dev, size_t off1,