All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: implement find_next_zero_bit function
Date: Thu, 16 Apr 2015 10:52:44 +0200	[thread overview]
Message-ID: <20150416105244.55c2cbbb@lilith> (raw)
In-Reply-To: <1423153486-21686-1-git-send-email-vitalya@ti.com>

Hello Vitaly,

On Thu, 5 Feb 2015 11:24:46 -0500, Vitaly Andrianov <vitalya@ti.com>
wrote:
> This commit copies implementation of the find_next_zero_bit() from
> git://git.denx.de/u-boot.git/arch/mips/include/asm/bitops.h. v2014.07
> 
> The function is required to enable MCAST_TFTP support for ARM platforms.
> 
> Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
> ---
> 
>  arch/arm/include/asm/bitops.h | 43 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 40 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
> index 597dafb..9b78043 100644
> --- a/arch/arm/include/asm/bitops.h
> +++ b/arch/arm/include/asm/bitops.h
> @@ -95,9 +95,6 @@ static inline int __test_and_change_bit(int nr, volatile void *addr)
>  	return (old & mask) != 0;
>  }
>  
> -extern int find_first_zero_bit(void * addr, unsigned size);
> -extern int find_next_zero_bit(void * addr, int size, int offset);
> -
>  /*
>   * This routine doesn't need to be atomic.
>   */
> @@ -129,6 +126,43 @@ static inline unsigned long ffz(unsigned long word)
>  	return k;
>  }
>  
> +static inline int find_next_zero_bit(void *addr, int size, int offset)
> +{
> +	unsigned long *p = ((unsigned long *)addr) + (offset >> 5);
> +	unsigned long result = offset & ~31UL;
> +	unsigned long tmp;
> +
> +	if (offset >= size)
> +		return size;
> +	size -= result;
> +	offset &= 31UL;
> +	if (offset) {
> +		tmp = *(p++);
> +		tmp |= ~0UL >> (32-offset);
> +		if (size < 32)
> +			goto found_first;
> +		if (~tmp)
> +			goto found_middle;
> +		size -= 32;
> +		result += 32;
> +	}
> +	while (size & ~31UL) {
> +		tmp = *(p++);arm: implement find_next_zero_bit function
> +		if (~tmp)
> +			goto found_middle;
> +		result += 32;
> +		size -= 32;
> +	}
> +	if (!size)
> +		return result;
> +	tmp = *p;
> +
> +found_first:
> +	tmp |= ~0UL >> size;
> +found_middle:
> +	return result + ffz(tmp);
> +}
> +
>  /*
>   * hweightN: returns the hamming weight (i.e. the number
>   * of bits set) of a N-bit word
> @@ -138,6 +172,9 @@ static inline unsigned long ffz(unsigned long word)
>  #define hweight16(x) generic_hweight16(x)
>  #define hweight8(x) generic_hweight8(x)
>  
> +#define find_first_zero_bit(addr, size) \
> +	find_next_zero_bit((addr), (size), 0)
> +
>  #define ext2_set_bit			test_and_set_bit
>  #define ext2_clear_bit			test_and_clear_bit
>  #define ext2_test_bit			test_bit
> -- 
> 1.9.1
> 

Applied to u-boot-arm/master, thanks!

Amicalement,
-- 
Albert.

      parent reply	other threads:[~2015-04-16  8:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 16:24 [U-Boot] [PATCH] arm: implement find_next_zero_bit function Vitaly Andrianov
2015-02-05 17:52 ` Albert ARIBAUD
2015-02-11 19:11   ` Vitaly Andrianov
2015-03-27 15:54     ` Albert ARIBAUD
2015-03-27 19:06       ` Vitaly Andrianov
2015-03-27 19:40         ` Albert ARIBAUD
2015-04-16  8:52 ` Albert ARIBAUD [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150416105244.55c2cbbb@lilith \
    --to=albert.u.boot@aribaud.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.