[U-Boot] [PATCH v3 2/3] MMC: Add support for PL180 ARM mmc device

Andy Fleming afleming at gmail.com
Wed Apr 13 13:04:53 CEST 2011


On Wed, Mar 2, 2011 at 11:22 PM,  <matt.waddel at linaro.org> wrote:

> +
> +static int convert_from_bytes_to_power_of_two(unsigned int x)
> +{
> +       int y = 0;
> +       y = (x & 0xAAAA) ? 1 : 0;
> +       y |= ((x & 0xCCCC) ? 1 : 0) << 1;
> +       y |= ((x & 0xF0F0) ? 1 : 0) << 2;
> +       y |= ((x & 0xFF00) ? 1 : 0) << 3;
> +
> +       return y;
> +}


Let's not try to be this clever.  U-Boot already has a function that
tells you which power of two a number corresponds to.  Unless the
caller of this will be highly sensitive to several cycles that you may
gain from knowing that the input is already a power-of-two, there's
just no cause to creating a separate implementation of ffs().

Other than that, it looks fine, and as soon as you respin, I'll add it
to the mmc tree.

Andy


More information about the U-Boot mailing list