diff options
author | Shawn Lin <shawn.lin@rock-chips.com> | 2016-02-02 14:11:25 +0800 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2016-02-29 11:03:11 +0100 |
commit | 8a629d26f02351539dd1760c75656065b881cd9a (patch) | |
tree | 93c57647f17e72bfb773e240146a5aa76e70eee1 | |
parent | 345efee3541f5931fbbd0f0bcebe9baa3ff2f5c2 (diff) | |
download | linux-8a629d26f02351539dd1760c75656065b881cd9a.tar.bz2 |
mmc: dw_mmc: fix num_slots setting
This patch make num_slots to 1 if pdata->num_slot is not
defined. Meanwhile, we need to make sure num_slots should
not larger that the supported slots
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r-- | drivers/mmc/host/dw_mmc.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 0394ea8eadef..242f9a0769bd 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2879,12 +2879,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) return ERR_PTR(-ENOMEM); /* find out number of slots supported */ - if (of_property_read_u32(dev->of_node, "num-slots", - &pdata->num_slots)) { - dev_info(dev, - "num-slots property not found, assuming 1 slot is available\n"); - pdata->num_slots = 1; - } + of_property_read_u32(np, "num-slots", &pdata->num_slots); if (of_property_read_u32(np, "fifo-depth", &pdata->fifo_depth)) dev_info(dev, @@ -2960,12 +2955,6 @@ int dw_mci_probe(struct dw_mci *host) } } - if (host->pdata->num_slots < 1) { - dev_err(host->dev, - "Platform data must supply num_slots.\n"); - return -ENODEV; - } - host->biu_clk = devm_clk_get(host->dev, "biu"); if (IS_ERR(host->biu_clk)) { dev_dbg(host->dev, "biu clock not available\n"); @@ -3124,7 +3113,15 @@ int dw_mci_probe(struct dw_mci *host) if (host->pdata->num_slots) host->num_slots = host->pdata->num_slots; else - host->num_slots = SDMMC_GET_SLOT_NUM(mci_readl(host, HCON)); + host->num_slots = 1; + + if (host->num_slots < 1 || + host->num_slots > SDMMC_GET_SLOT_NUM(mci_readl(host, HCON))) { + dev_err(host->dev, + "Platform data must supply correct num_slots.\n"); + ret = -ENODEV; + goto err_clk_ciu; + } /* * Enable interrupts for command done, data over, data empty, |