Re: [PATCH 1/3] include/linux: move for_each_bit() macros from bitops.h to find.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 18, 2021 at 12:57:33PM -0700, Yury Norov wrote:
> for_each_bit() macros depend on find_bit() machinery, and so the
> proper place for them is the find.h header.

Fine with me.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

> Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
> ---
>  include/linux/bitops.h | 34 ----------------------------------
>  include/linux/find.h   | 34 ++++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 34 deletions(-)
> 
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index 26bf15e6cd35..31ae1ae1a974 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -31,40 +31,6 @@ extern unsigned long __sw_hweight64(__u64 w);
>   */
>  #include <asm/bitops.h>
>  
> -#define for_each_set_bit(bit, addr, size) \
> -	for ((bit) = find_first_bit((addr), (size));		\
> -	     (bit) < (size);					\
> -	     (bit) = find_next_bit((addr), (size), (bit) + 1))
> -
> -/* same as for_each_set_bit() but use bit as value to start with */
> -#define for_each_set_bit_from(bit, addr, size) \
> -	for ((bit) = find_next_bit((addr), (size), (bit));	\
> -	     (bit) < (size);					\
> -	     (bit) = find_next_bit((addr), (size), (bit) + 1))
> -
> -#define for_each_clear_bit(bit, addr, size) \
> -	for ((bit) = find_first_zero_bit((addr), (size));	\
> -	     (bit) < (size);					\
> -	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
> -
> -/* same as for_each_clear_bit() but use bit as value to start with */
> -#define for_each_clear_bit_from(bit, addr, size) \
> -	for ((bit) = find_next_zero_bit((addr), (size), (bit));	\
> -	     (bit) < (size);					\
> -	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
> -
> -/**
> - * for_each_set_clump8 - iterate over bitmap for each 8-bit clump with set bits
> - * @start: bit offset to start search and to store the current iteration offset
> - * @clump: location to store copy of current 8-bit clump
> - * @bits: bitmap address to base the search on
> - * @size: bitmap size in number of bits
> - */
> -#define for_each_set_clump8(start, clump, bits, size) \
> -	for ((start) = find_first_clump8(&(clump), (bits), (size)); \
> -	     (start) < (size); \
> -	     (start) = find_next_clump8(&(clump), (bits), (size), (start) + 8))
> -
>  static inline int get_bitmask_order(unsigned int count)
>  {
>  	int order;
> diff --git a/include/linux/find.h b/include/linux/find.h
> index 6048f8c97418..4500e8ab93e2 100644
> --- a/include/linux/find.h
> +++ b/include/linux/find.h
> @@ -279,4 +279,38 @@ unsigned long find_next_bit_le(const void *addr, unsigned
>  #error "Please fix <asm/byteorder.h>"
>  #endif
>  
> +#define for_each_set_bit(bit, addr, size) \
> +	for ((bit) = find_first_bit((addr), (size));		\
> +	     (bit) < (size);					\
> +	     (bit) = find_next_bit((addr), (size), (bit) + 1))
> +
> +/* same as for_each_set_bit() but use bit as value to start with */
> +#define for_each_set_bit_from(bit, addr, size) \
> +	for ((bit) = find_next_bit((addr), (size), (bit));	\
> +	     (bit) < (size);					\
> +	     (bit) = find_next_bit((addr), (size), (bit) + 1))
> +
> +#define for_each_clear_bit(bit, addr, size) \
> +	for ((bit) = find_first_zero_bit((addr), (size));	\
> +	     (bit) < (size);					\
> +	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
> +
> +/* same as for_each_clear_bit() but use bit as value to start with */
> +#define for_each_clear_bit_from(bit, addr, size) \
> +	for ((bit) = find_next_zero_bit((addr), (size), (bit));	\
> +	     (bit) < (size);					\
> +	     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
> +
> +/**
> + * for_each_set_clump8 - iterate over bitmap for each 8-bit clump with set bits
> + * @start: bit offset to start search and to store the current iteration offset
> + * @clump: location to store copy of current 8-bit clump
> + * @bits: bitmap address to base the search on
> + * @size: bitmap size in number of bits
> + */
> +#define for_each_set_clump8(start, clump, bits, size) \
> +	for ((start) = find_first_clump8(&(clump), (bits), (size)); \
> +	     (start) < (size); \
> +	     (start) = find_next_clump8(&(clump), (bits), (size), (start) + 8))
> +
>  #endif /*__LINUX_FIND_H_ */
> -- 
> 2.30.2
> 

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux