[U-Boot] [PATCH v2 02/30] Add ALIGN_DOWN() to find next smallest alignment

Simon Glass sjg at chromium.org
Tue Nov 25 03:31:59 CET 2014


Hi,

On 14 November 2014 at 18:18, Simon Glass <sjg at chromium.org> wrote:
> We have an ALIGN() macro - add a comment as to what this does. Also add a
> new ALIGN_DOWN() macro, which aligns a value to the next smallest multiple.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2: None
>
>  include/common.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/include/common.h b/include/common.h
> index ecf7fca..28fba79 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -970,9 +970,24 @@ static inline phys_addr_t map_to_sysmem(const void *ptr)
>  }                                                      \
>  )
>
> +/**
> + * ALIGN() - return an aligned value not less than the given value
> + *
> + * @x: Value to align
> + * @a: Alignment to use, e.g. 4 to align to multiples of 4
> + */
>  #define ALIGN(x,a)             __ALIGN_MASK((x),(typeof(x))(a)-1)
> +
>  #define __ALIGN_MASK(x,mask)   (((x)+(mask))&~(mask))
>
> +/**
> + * ALIGN_DOWN() - return an aligned value not greater than the given value
> + *
> + * @x: Value to align
> + * @a: Alignment to use, e.g. 4 to align to multiples of 4
> + */
> +#define ALIGN_DOWN(x, a)       ((x) & ~((typeof(x))(a) - 1UL))
> +
>  /*
>   * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture.  It
>   * is used to align DMA buffers.

I'm going to drop this patch, since Masahiro's clean-up has been applied.

Regards,
Simon


More information about the U-Boot mailing list