提交 63311bec 编写于 作者: J Jean-Francois Moine 提交者: Ulf Hansson

mmc: sunxi: Check the value returned by clk_round_rate

clk_round_rate() may return an error. Check it.
Signed-off-by: NJean-Francois Moine <moinejf@free.fr>
Acked-by: NMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
上级 b2db9c67
...@@ -692,7 +692,8 @@ static int sunxi_mmc_clk_set_phase(struct sunxi_mmc_host *host, ...@@ -692,7 +692,8 @@ static int sunxi_mmc_clk_set_phase(struct sunxi_mmc_host *host,
static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host,
struct mmc_ios *ios) struct mmc_ios *ios)
{ {
u32 rate, rval, clock = ios->clock; long rate;
u32 rval, clock = ios->clock;
int ret; int ret;
/* 8 bit DDR requires a higher module clock */ /* 8 bit DDR requires a higher module clock */
...@@ -701,13 +702,18 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, ...@@ -701,13 +702,18 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host,
clock <<= 1; clock <<= 1;
rate = clk_round_rate(host->clk_mmc, clock); rate = clk_round_rate(host->clk_mmc, clock);
dev_dbg(mmc_dev(host->mmc), "setting clk to %d, rounded %d\n", if (rate < 0) {
dev_err(mmc_dev(host->mmc), "error rounding clk to %d: %ld\n",
clock, rate);
return rate;
}
dev_dbg(mmc_dev(host->mmc), "setting clk to %d, rounded %ld\n",
clock, rate); clock, rate);
/* setting clock rate */ /* setting clock rate */
ret = clk_set_rate(host->clk_mmc, rate); ret = clk_set_rate(host->clk_mmc, rate);
if (ret) { if (ret) {
dev_err(mmc_dev(host->mmc), "error setting clk to %d: %d\n", dev_err(mmc_dev(host->mmc), "error setting clk to %ld: %d\n",
rate, ret); rate, ret);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册