[U-Boot] [PATCH 1/3] spi: bfin_spi: Use DIV_ROUND_UP instead of open-coded

Sonic Zhang sonic.adi at gmail.com
Mon Jul 15 09:58:07 CEST 2013


Acked-by: Sonic Zhang <sonic.zhang at analog.com>

On Fri, Jul 12, 2013 at 5:39 PM, Axel Lin <axel.lin at ingics.com> wrote:
> Use DIV_ROUND_UP to simplify the code.
>
> Signed-off-by: Axel Lin <axel.lin at ingics.com>
> ---
>  drivers/spi/bfin_spi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
> index a9a4d92..f7192c2 100644
> --- a/drivers/spi/bfin_spi.c
> +++ b/drivers/spi/bfin_spi.c
> @@ -144,10 +144,8 @@ void spi_set_speed(struct spi_slave *slave, uint hz)
>         u32 baud;
>
>         sclk = get_sclk();
> -       baud = sclk / (2 * hz);
>         /* baud should be rounded up */
> -       if (sclk % (2 * hz))
> -               baud += 1;
> +       baud = DIV_ROUND_UP(sclk, 2 * hz);
>         if (baud < 2)
>                 baud = 2;
>         else if (baud > (u16)-1)
> --
> 1.8.1.2
>
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list