diff mbox series

[v1,1/4] dmaengine: Refactor dmaengine_check_align() to be bit operations only

Message ID 20200226101842.29426-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Headers show
Series [v1,1/4] dmaengine: Refactor dmaengine_check_align() to be bit operations only | expand

Commit Message

Andy Shevchenko Feb. 26, 2020, 10:18 a.m. UTC
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>
---
 include/linux/dmaengine.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Peter Ujfalusi Feb. 26, 2020, 12:35 p.m. UTC | #1
On 2/26/20 12:18 PM, Andy Shevchenko wrote:
> 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.

Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/dmaengine.h | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 64461fc64e1b..9f3f5582816a 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -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,
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul March 2, 2020, 7:18 a.m. UTC | #2
On 26-02-20, 12:18, Andy Shevchenko wrote:
> 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.

Applied, thanks
diff mbox series

Patch

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 64461fc64e1b..9f3f5582816a 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -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,