* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
@ 2015-02-05 16:24 Vitaly Andrianov
2015-02-05 17:52 ` Albert ARIBAUD
2015-04-16 8:52 ` Albert ARIBAUD
0 siblings, 2 replies; 7+ messages in thread
From: Vitaly Andrianov @ 2015-02-05 16:24 UTC (permalink / raw)
To: u-boot
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++);
+ 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
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-04-16 8:52 ` Albert ARIBAUD
1 sibling, 1 reply; 7+ messages in thread
From: Albert ARIBAUD @ 2015-02-05 17:52 UTC (permalink / raw)
To: u-boot
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.
Which mainline board needs this?
> Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
2015-02-05 17:52 ` Albert ARIBAUD
@ 2015-02-11 19:11 ` Vitaly Andrianov
2015-03-27 15:54 ` Albert ARIBAUD
0 siblings, 1 reply; 7+ messages in thread
From: Vitaly Andrianov @ 2015-02-11 19:11 UTC (permalink / raw)
To: u-boot
On 02/05/2015 12:52 PM, Albert ARIBAUD wrote:
> 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.
>
> Which mainline board needs this?
TI Keystone2 EVMs
>
>> Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
>
> Amicalement,
>
-Vitaly
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
2015-02-11 19:11 ` Vitaly Andrianov
@ 2015-03-27 15:54 ` Albert ARIBAUD
2015-03-27 19:06 ` Vitaly Andrianov
0 siblings, 1 reply; 7+ messages in thread
From: Albert ARIBAUD @ 2015-03-27 15:54 UTC (permalink / raw)
To: u-boot
Hello Vitaly,
On Wed, 11 Feb 2015 14:11:12 -0500, Vitaly Andrianov <vitalya@ti.com>
wrote:
>
>
> On 02/05/2015 12:52 PM, Albert ARIBAUD wrote:
> > 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.
> >
> > Which mainline board needs this?
>
> TI Keystone2 EVMs
Just to make sure: this is actually replacing a 'normal' function with
an inline one. So the function /was/ available before this patch,
right?
> -Vitaly
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
2015-03-27 15:54 ` Albert ARIBAUD
@ 2015-03-27 19:06 ` Vitaly Andrianov
2015-03-27 19:40 ` Albert ARIBAUD
0 siblings, 1 reply; 7+ messages in thread
From: Vitaly Andrianov @ 2015-03-27 19:06 UTC (permalink / raw)
To: u-boot
Hello Albert,
On 03/27/2015 11:54 AM, Albert ARIBAUD wrote:
> Hello Vitaly,
>
> On Wed, 11 Feb 2015 14:11:12 -0500, Vitaly Andrianov <vitalya@ti.com>
> wrote:
>>
>>
>> On 02/05/2015 12:52 PM, Albert ARIBAUD wrote:
>>> 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.
>>>
>>> Which mainline board needs this?
>>
>> TI Keystone2 EVMs
>
> Just to make sure: this is actually replacing a 'normal' function with
> an inline one. So the function /was/ available before this patch,
> right?
>
What inline function are you talking about?
I couldn't find this function for ARM. That is why I copied it from MIPS.
>> -Vitaly
>
> Amicalement,
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
2015-03-27 19:06 ` Vitaly Andrianov
@ 2015-03-27 19:40 ` Albert ARIBAUD
0 siblings, 0 replies; 7+ messages in thread
From: Albert ARIBAUD @ 2015-03-27 19:40 UTC (permalink / raw)
To: u-boot
Hello Vitaly,
On Fri, 27 Mar 2015 15:06:15 -0400, Vitaly Andrianov <vitalya@ti.com>
wrote:
> Hello Albert,
>
> On 03/27/2015 11:54 AM, Albert ARIBAUD wrote:
> > Hello Vitaly,
> >
> > On Wed, 11 Feb 2015 14:11:12 -0500, Vitaly Andrianov <vitalya@ti.com>
> > wrote:
> >>
> >>
> >> On 02/05/2015 12:52 PM, Albert ARIBAUD wrote:
> >>> 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.
> >>>
> >>> Which mainline board needs this?
> >>
> >> TI Keystone2 EVMs
> >
> > Just to make sure: this is actually replacing a 'normal' function with
> > an inline one. So the function /was/ available before this patch,
> > right?
> >
> What inline function are you talking about?
The one you are adding with this patch.
> I couldn't find this function for ARM. That is why I copied it from MIPS.
Thanks -- I had noticed that you were removing extern declarations for
find_first_zero_bit() and find_next_zero_bit() and I was surprised
that this removal was not explained in the commit message, and I had
not realized that the corresponding function definitions did not exist.
I'll apply your patch and add a note in the commit message explaining
the removal.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] arm: implement find_next_zero_bit function
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-04-16 8:52 ` Albert ARIBAUD
1 sibling, 0 replies; 7+ messages in thread
From: Albert ARIBAUD @ 2015-04-16 8:52 UTC (permalink / raw)
To: u-boot
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-04-16 8:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox