clk: iproc: round clock rate to the closest
authorLori Hikichi <lhikichi@broadcom.com>
Fri, 12 Jun 2020 22:52:12 +0000 (15:52 -0700)
committerStephen Boyd <sboyd@kernel.org>
Fri, 24 Jul 2020 08:54:18 +0000 (01:54 -0700)
Change from 'DIV_ROUND_UP' to 'DIV_ROUND_CLOSEST' when calculating the
clock divisor in the iProc ASIU clock driver to allow to get to the
closest clock rate.

Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support")
Signed-off-by: Lori Hikichi <lhikichi@broadcom.com>
Signed-off-by: Ray Jui <ray.jui@broadcom.com>
Link: https://lore.kernel.org/r/20200612225212.124301-1-ray.jui@broadcom.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/bcm/clk-iproc-asiu.c

index 6fb8af506777d9dd666f0560f4630cb1d4c074ea..e062dd4992ea5e2aec2d4de10f72b575e2c27db9 100644 (file)
@@ -119,7 +119,7 @@ static long iproc_asiu_clk_round_rate(struct clk_hw *hw, unsigned long rate,
        if (rate == *parent_rate)
                return *parent_rate;
 
-       div = DIV_ROUND_UP(*parent_rate, rate);
+       div = DIV_ROUND_CLOSEST(*parent_rate, rate);
        if (div < 2)
                return *parent_rate;
 
@@ -145,7 +145,7 @@ static int iproc_asiu_clk_set_rate(struct clk_hw *hw, unsigned long rate,
                return 0;
        }
 
-       div = DIV_ROUND_UP(parent_rate, rate);
+       div = DIV_ROUND_CLOSEST(parent_rate, rate);
        if (div < 2)
                return -EINVAL;