]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
mmc-uclass: correct the device number
authorKever Yang <kever.yang@rock-chips.com>
Fri, 22 Jul 2016 09:22:50 +0000 (17:22 +0800)
committerSimon Glass <sjg@chromium.org>
Sun, 31 Jul 2016 13:24:20 +0000 (07:24 -0600)
Not like the mmc-legacy which the devnum starts from 1, it starts from 0
in mmc-uclass, so the device number should be (devnum + 1) in get_mmc_num().

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Acked-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/mmc-uclass.c
include/mmc.h

index 38ced4102e1073c146759d9d030e6d930514e944..f262c6eb39882231f89cc72dbfba154b3aa7bc43 100644 (file)
@@ -111,18 +111,18 @@ struct mmc *find_mmc_device(int dev_num)
 
 int get_mmc_num(void)
 {
-       return max(blk_find_max_devnum(IF_TYPE_MMC), 0);
+       return max((blk_find_max_devnum(IF_TYPE_MMC) + 1), 0);
 }
 
 int mmc_get_next_devnum(void)
 {
        int ret;
 
-       ret = get_mmc_num();
+       ret = blk_find_max_devnum(IF_TYPE_MMC);
        if (ret < 0)
                return ret;
 
-       return ret + 1;
+       return ret;
 }
 
 struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
index 8f309f1f71c510b10b6ed81403b2b00bcf4b9c52..dd47f34e9de09c6b516c1baadfbf57f645606925 100644 (file)
@@ -503,6 +503,12 @@ void mmc_set_clock(struct mmc *mmc, uint clock);
 struct mmc *find_mmc_device(int dev_num);
 int mmc_set_dev(int dev_num);
 void print_mmc_devices(char separator);
+
+/**
+ * get_mmc_num() - get the total MMC device number
+ *
+ * @return 0 if there is no MMC device, else the number of devices
+ */
 int get_mmc_num(void);
 int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf,
                      enum mmc_hwpart_conf_mode mode);