All of lore.kernel.org
 help / color / mirror / Atom feed
From: York Sun <yorksun@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v7 02/21] include: Add generic bitops headers
Date: Tue, 1 Dec 2015 09:26:59 -0800	[thread overview]
Message-ID: <565DD863.5010703@freescale.com> (raw)
In-Reply-To: <1446734622-5100-2-git-send-email-fabio.estevam@freescale.com>



On 11/05/2015 06:43 AM, Fabio Estevam wrote:
> Use the generic bitops header files from the kernel.
> 
> Imported from kernel 4.2.3.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v6:
> - Do not touch include/linux/bitops here to avoid build warnings (Daniel)
> 
>  include/asm-generic/bitops/__ffs.h | 43 ++++++++++++++++++++++++++++++++++++++
>  include/asm-generic/bitops/__fls.h | 43 ++++++++++++++++++++++++++++++++++++++
>  include/asm-generic/bitops/fls.h   | 41 ++++++++++++++++++++++++++++++++++++
>  include/asm-generic/bitops/fls64.h | 36 +++++++++++++++++++++++++++++++
>  4 files changed, 163 insertions(+)
>  create mode 100644 include/asm-generic/bitops/__ffs.h
>  create mode 100644 include/asm-generic/bitops/__fls.h
>  create mode 100644 include/asm-generic/bitops/fls.h
>  create mode 100644 include/asm-generic/bitops/fls64.h
> 

<snip>

> diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
> new file mode 100644
> index 0000000..a60a7cc
> --- /dev/null
> +++ b/include/asm-generic/bitops/__fls.h
> @@ -0,0 +1,43 @@
> +#ifndef _ASM_GENERIC_BITOPS___FLS_H_
> +#define _ASM_GENERIC_BITOPS___FLS_H_
> +
> +#include <asm/types.h>
> +
> +/**
> + * __fls - find last (most-significant) set bit in a long word
> + * @word: the word to search
> + *
> + * Undefined if no set bit exists, so code should check against 0 first.
> + */
> +static __always_inline unsigned long __fls(unsigned long word)
> +{
> +	int num = BITS_PER_LONG - 1;
> +
> +#if BITS_PER_LONG == 64
> +	if (!(word & (~0ul << 32))) {
> +		num -= 32;
> +		word <<= 32;
> +	}
> +#endif
> +	if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
> +		num -= 16;
> +		word <<= 16;
> +	}
> +	if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
> +		num -= 8;
> +		word <<= 8;
> +	}
> +	if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
> +		num -= 4;
> +		word <<= 4;
> +	}
> +	if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
> +		num -= 2;
> +		word <<= 2;
> +	}
> +	if (!(word & (~0ul << (BITS_PER_LONG-1))))
> +		num -= 1;
> +	return num;
> +}

Sorry for catching this late. All above left shift causes compiling warning on
32-bit host (ubuntu 12.04 with gcc 4.6.3)

include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of
type [enabled by default]

The root cause may be in include/configs/sandbox.h
#define CONFIG_SANDBOX_BITS_PER_LONG  64

York

  parent reply	other threads:[~2015-12-01 17:26 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 14:43 [U-Boot] [PATCH v7 01/21] include: Add log2 header from the kernel Fabio Estevam
2015-11-05 14:43 ` [U-Boot] [PATCH v7 02/21] include: Add generic bitops headers Fabio Estevam
2015-11-06 12:22   ` Tom Rini
2015-12-01 17:26   ` York Sun [this message]
2015-12-01 20:01     ` Simon Glass
2015-11-05 14:43 ` [U-Boot] [PATCH v7 03/21] ARM: Use the " Fabio Estevam
2015-11-06 12:22   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 04/21] x86: " Fabio Estevam
2015-11-06 12:22   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 05/21] m68k: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 06/21] blackfin: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 07/21] sh: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 08/21] microblaze: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 09/21] sandbox: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 10/21] sparc: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 11/21] openrisc: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 12/21] nds32: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 13/21] nios2: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 14/21] mips: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 15/21] arc: " Fabio Estevam
2015-11-06 12:23   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 16/21] avr32: " Fabio Estevam
2015-11-06 12:24   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 17/21] bitops: Add fls_long and __ffs64 Fabio Estevam
2015-11-06 12:24   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 18/21] compat: Remove is_power_of_2() definition Fabio Estevam
2015-11-06 12:24   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 19/21] powerpc: Remove __ilog2_u64 and ffs4 from bitops Fabio Estevam
2015-11-06 12:24   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 20/21] sf: Add SPI protection mechanism from the kernel Fabio Estevam
2015-11-06 12:24   ` Tom Rini
2015-11-05 14:43 ` [U-Boot] [PATCH v7 21/21] sf: Add SPI NOR protection mechanism Fabio Estevam
2015-11-06 12:24   ` Tom Rini
2015-11-11  0:09     ` Simon Glass
2015-11-11  0:29       ` Tom Rini
2015-11-11  0:51       ` Fabio Estevam
2015-11-11  2:56         ` Simon Glass
2015-11-11  9:43           ` Fabio Estevam
2015-11-11 16:25             ` Jagan Teki
2015-11-13  9:20               ` Bin Meng
2015-11-11 14:04           ` Fabio Estevam
2015-11-13 10:41             ` Bin Meng
2015-11-16  1:34               ` Simon Glass
2015-11-16  1:58                 ` Tom Rini
2015-11-16 21:07                   ` Simon Glass
2015-11-17  6:43                     ` Jagan Teki
2015-11-16 20:57                 ` Fabio Estevam
2015-11-05 15:51 ` [U-Boot] [PATCH v7 01/21] include: Add log2 header from the kernel Tom Rini
2015-11-05 15:51   ` Fabio Estevam
2015-11-05 16:35     ` Tom Rini
2015-11-05 17:53       ` Fabio Estevam
2015-11-05 19:10         ` Tom Rini
2015-11-05 20:07           ` Fabio Estevam
2015-11-06  1:40             ` Tom Rini
2015-11-06 11:08               ` Fabio Estevam
2015-11-06 12:22 ` Tom Rini

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=565DD863.5010703@freescale.com \
    --to=yorksun@freescale.com \
    --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.