Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d7fdbe2 authored by Maxime Ripard's avatar Maxime Ripard Committed by Nicolas Ferre
Browse files

ARM: at91: PIT: Use DIV_ROUND_CLOSEST to compute the cycles



Until now, the pit_cycle computation was dividing the rate by HZ, rounding to
the closest integer, but without using the appropriate macro.

Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: default avatarBoris BREZILLON <boris.brezillon@free-electrons.com>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
parent 1bd59dbe
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -252,7 +252,7 @@ void __init at91sam926x_pit_init(void)
	if (IS_ERR(mck))
	if (IS_ERR(mck))
		panic("AT91: PIT: Unable to get mck clk\n");
		panic("AT91: PIT: Unable to get mck clk\n");
	pit_rate = clk_get_rate(mck) / 16;
	pit_rate = clk_get_rate(mck) / 16;
	pit_cycle = (pit_rate + HZ/2) / HZ;
	pit_cycle = DIV_ROUND_CLOSEST(pit_rate, HZ);
	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);


	/* Initialize and enable the timer */
	/* Initialize and enable the timer */