diff mbox

[U-Boot,04/13] include: Add ffs64 header file

Message ID 1445689693-21436-4-git-send-email-festevam@gmail.com
State Superseded
Headers show

Commit Message

Fabio Estevam Oct. 24, 2015, 12:28 p.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>

The ffs64() implementation for powerpc is not found in the Linux kernel,
so use the ffs64 header file from barebox.

Imported from barebox v2015.10.0.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/powerpc/include/asm/ffs64.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 arch/powerpc/include/asm/ffs64.h

Comments

Tom Rini Oct. 24, 2015, 1:32 p.m. UTC | #1
On Sat, Oct 24, 2015 at 10:28:04AM -0200, Fabio Estevam wrote:

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> The ffs64() implementation for powerpc is not found in the Linux kernel,
> so use the ffs64 header file from barebox.
> 
> Imported from barebox v2015.10.0.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

I'm confused.  In the kernel __ffs64 is in <linux/bitops.h>, why do we
need to do things differently here?
Fabio Estevam Oct. 24, 2015, 1:37 p.m. UTC | #2
Hi Tom,

On Sat, Oct 24, 2015 at 11:32 AM, Tom Rini <trini@konsulko.com> wrote:
> On Sat, Oct 24, 2015 at 10:28:04AM -0200, Fabio Estevam wrote:
>
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> The ffs64() implementation for powerpc is not found in the Linux kernel,
>> so use the ffs64 header file from barebox.
>>
>> Imported from barebox v2015.10.0.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>
> I'm confused.  In the kernel __ffs64 is in <linux/bitops.h>, why do we
> need to do things differently here?

It is true that kernel uses __ffs64 from <linux/bitops.h>, however in
U-boot (and barebox) there is also ffs64 for powerpc, so that's why I
added a new header for it.

We have no ffs64 in kernel, only __ffs64.

Regards,

Fabio Estevam
Fabio Estevam Oct. 24, 2015, 2:54 p.m. UTC | #3
On Sat, Oct 24, 2015 at 11:37 AM, Fabio Estevam <festevam@gmail.com> wrote:
> Hi Tom,
>
> On Sat, Oct 24, 2015 at 11:32 AM, Tom Rini <trini@konsulko.com> wrote:
>> On Sat, Oct 24, 2015 at 10:28:04AM -0200, Fabio Estevam wrote:
>>
>>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>>
>>> The ffs64() implementation for powerpc is not found in the Linux kernel,
>>> so use the ffs64 header file from barebox.
>>>
>>> Imported from barebox v2015.10.0.
>>>
>>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> I'm confused.  In the kernel __ffs64 is in <linux/bitops.h>, why do we
>> need to do things differently here?
>
> It is true that kernel uses __ffs64 from <linux/bitops.h>, however in
> U-boot (and barebox) there is also ffs64 for powerpc, so that's why I
> added a new header for it.
>
> We have no ffs64 in kernel, only __ffs64.

After thinking more about it, I think we can simply use __ffs64 for
powerpc as well.

There is no assembly optimzation for ffs64 so we can use the generic __ffs64.

Will prepare a new version doing this. Thanks
Tom Rini Oct. 24, 2015, 5:51 p.m. UTC | #4
On Sat, Oct 24, 2015 at 12:54:40PM -0200, Fabio Estevam wrote:
> On Sat, Oct 24, 2015 at 11:37 AM, Fabio Estevam <festevam@gmail.com> wrote:
> > Hi Tom,
> >
> > On Sat, Oct 24, 2015 at 11:32 AM, Tom Rini <trini@konsulko.com> wrote:
> >> On Sat, Oct 24, 2015 at 10:28:04AM -0200, Fabio Estevam wrote:
> >>
> >>> From: Fabio Estevam <fabio.estevam@freescale.com>
> >>>
> >>> The ffs64() implementation for powerpc is not found in the Linux kernel,
> >>> so use the ffs64 header file from barebox.
> >>>
> >>> Imported from barebox v2015.10.0.
> >>>
> >>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> >>
> >> I'm confused.  In the kernel __ffs64 is in <linux/bitops.h>, why do we
> >> need to do things differently here?
> >
> > It is true that kernel uses __ffs64 from <linux/bitops.h>, however in
> > U-boot (and barebox) there is also ffs64 for powerpc, so that's why I
> > added a new header for it.
> >
> > We have no ffs64 in kernel, only __ffs64.
> 
> After thinking more about it, I think we can simply use __ffs64 for
> powerpc as well.
> 
> There is no assembly optimzation for ffs64 so we can use the generic __ffs64.
> 
> Will prepare a new version doing this. Thanks

That's what I was hoping for, thanks!
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/ffs64.h b/arch/powerpc/include/asm/ffs64.h
new file mode 100644
index 0000000..620874c
--- /dev/null
+++ b/arch/powerpc/include/asm/ffs64.h
@@ -0,0 +1,12 @@ 
+/*
+ * Copyright 2013 GE Intelligent Platforms, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+#include <linux/log2.h>
+
+static inline int ffs64(u64 x)
+{
+	return __ilog2_u64(x & -x) + 1ull;
+}