]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
clk: sunxi: Fix incorrect usage of round_down()
authorRikard Falkeborn <rikard.falkeborn@gmail.com>
Tue, 17 Mar 2020 21:13:32 +0000 (22:13 +0100)
committerKhalid Elmously <khalid.elmously@canonical.com>
Sat, 8 Aug 2020 05:53:12 +0000 (01:53 -0400)
BugLink: https://bugs.launchpad.net/bugs/1885322
[ Upstream commit ee25d9742dabed3fd18158b518f846abeb70f319 ]

round_down() can only round to powers of 2. If round_down() is asked
to round to something that is not a power of 2, incorrect results are
produced. The incorrect results can be both too large and too small.

Instead, use rounddown() which can round to any number.

Fixes: 6a721db180a2 ("clk: sunxi: Add A31 clocks support")
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
drivers/clk/sunxi/clk-sunxi.c

index 27201fd26e4422b7bd5eba152be7e0693029c95a..e1aa1fbac48a07b55b0a25c1fd9d22c3406007ee 100644 (file)
@@ -90,7 +90,7 @@ static void sun6i_a31_get_pll1_factors(struct factors_request *req)
         * Round down the frequency to the closest multiple of either
         * 6 or 16
         */
-       u32 round_freq_6 = round_down(freq_mhz, 6);
+       u32 round_freq_6 = rounddown(freq_mhz, 6);
        u32 round_freq_16 = round_down(freq_mhz, 16);
 
        if (round_freq_6 > round_freq_16)