17 Jul, 2019

1 commit

  • BIT(), GENMASK(), etc. are useful to define register bits of hardware.
    However, low-level code is often written in assembly, where they are
    not available due to the hard-coded 1UL, 0UL.

    In fact, in-kernel headers such as arch/arm64/include/asm/sysreg.h
    use _BITUL() instead of BIT() so that the register bit macros are
    available in assembly.

    Using macros in include/uapi/linux/const.h have two reasons:

    [1] For use in uapi headers
    We should use underscore-prefixed variants for user-space.

    [2] For use in assembly code
    Since _BITUL() uses UL(1) instead of 1UL, it can be used as an
    alternative of BIT().

    For [2], it is pretty easy to change BIT() etc. for use in assembly.

    This allows to replace _BUTUL() in kernel-space headers with BIT().

    Link: http://lkml.kernel.org/r/20190609153941.17249-1-yamada.masahiro@socionext.com
    Signed-off-by: Masahiro Yamada
    Cc: Catalin Marinas
    Cc: Christian Borntraeger
    Cc: Heiko Carstens
    Cc: Vasily Gorbik
    Cc: Vineet Gupta
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masahiro Yamada
     

21 Jun, 2018

1 commit

  • In preparation for implementing the asm-generic atomic bitops in terms
    of atomic_long_*(), we need to prevent implementations from
    pulling in . A common reason for this include is for the
    BITS_PER_BYTE definition, so move this and some other BIT() and masking
    macros into a new header file, .

    Signed-off-by: Will Deacon
    Acked-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: yamada.masahiro@socionext.com
    Link: https://lore.kernel.org/lkml/1529412794-17720-4-git-send-email-will.deacon@arm.com
    Signed-off-by: Ingo Molnar

    Will Deacon