public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 3/4]: Define ffs/fls for all architectures
Date: Wed, 16 Sep 2009 21:19:03 +0200	[thread overview]
Message-ID: <200909162119.03918.sr@denx.de> (raw)
In-Reply-To: <20090915203443.70008832E864@gemini.denx.de>

Hi Simon,

On Tuesday 15 September 2009 22:34:43 Wolfgang Denk wrote:
> Dear Simon Kagstrom,
> 
> In message <20090824091012.0df5bbff@marrow.netinsight.se> you wrote:
> > Define ffs/fls for all architectures
> >
> > UBIFS requires fls(), which is not defined for arm (and some other
> > architectures) and this patch adds it. The implementation is taken from
> > Linux and is generic. ffs() is also defined for those that miss it.
> >
> > Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> > ---
> > ChangeLog:
> >     v2: Unify code style (empty line between ffs/fls)
> >     v3: Move the definition to generic code (Mike Frysinger)
> >
> >  include/asm-i386/bitops.h  |    1 +
> >  include/asm-m68k/bitops.h  |    1 +
> >  include/asm-nios/bitops.h  |    1 +
> >  include/asm-nios2/bitops.h |    1 +
> >  include/asm-ppc/bitops.h   |    2 +
> >  include/asm-sh/bitops.h    |    2 +
> >  include/linux/bitops.h     |   45
> > ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 53
> > insertions(+), 0 deletions(-)
> 
> Applied, thanks.

I'm seeing strange problem on some PPC4xx platforms (CFI FLASH driver on 
Sequoia) with recent U-Boot. Bisecting lead me to this patch. And looking at 
the PPC implementation, I can see that this can't work:

include/asm-ppc/bitops.h:
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
 	return __ilog2(x & -x) + 1;
 }
+#define ffs

So after "ffs()" is define as an inline function, you define it to nothing. I 
understand that you need a flag for include/linux/bitops.h, to decide if the 
platform version of this function should be used or the generic version:

include/linux/bitops.h:
+#ifndef ffs
+# define ffs generic_ffs
+#endif

But this only works for platforms which don't supply a platform specific ffs 
function. One way to solve this would be something like this:

include/asm-ppc/bitops.h:
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
 	return __ilog2(x & -x) + 1;
 }
+#define PLATFORM_FFS

include/linux/bitops.h:
+#ifndef PLATFORM_FFS
+# define ffs generic_ffs
+#endif


Perhaps there is an more elegant way to solve this problem. Patches welcome ;)

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

  reply	other threads:[~2009-09-16 19:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24  7:06 [U-Boot] [PATCH v4 0/4]: bitops cleanup and fixes Simon Kagstrom
2009-08-24  7:09 ` [U-Boot] [PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h Simon Kagstrom
2009-09-15 20:31   ` Wolfgang Denk
2009-08-24  7:10 ` [U-Boot] [PATCH v4 2/4]: arm: Make arm bitops endianness-independent Simon Kagstrom
2009-09-15 20:34   ` Wolfgang Denk
2009-08-24  7:10 ` [U-Boot] [PATCH v4 3/4]: Define ffs/fls for all architectures Simon Kagstrom
2009-09-15 20:34   ` Wolfgang Denk
2009-09-16 19:19     ` Stefan Roese [this message]
2009-09-17  6:45       ` Simon Kagstrom
2009-09-17  6:56         ` Stefan Roese
2009-09-17  7:13           ` Simon Kagstrom
2009-09-17  7:19             ` Stefan Roese
2009-08-24  7:10 ` [U-Boot] [PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM Simon Kagstrom
2009-09-04 21:27   ` Justin Waters
2009-09-06 14:59     ` Jean-Christophe PLAGNIOL-VILLARD
2009-09-07  6:26     ` Simon Kagstrom
2009-09-15 20:35   ` Wolfgang Denk
2009-08-31  9:32 ` [U-Boot] [PATCH v4 0/4]: bitops cleanup and fixes Simon Kagstrom
2009-09-04 20:14   ` Wolfgang Denk
2009-09-05 11:37     ` Jean-Christophe PLAGNIOL-VILLARD
2009-09-06 20:50       ` Wolfgang Denk
2009-09-06 23:01         ` Jean-Christophe PLAGNIOL-VILLARD

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=200909162119.03918.sr@denx.de \
    --to=sr@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox