Commit 46683f3da191a4c2156d5473c23b9923c461912c

Authored by Kever Yang
Committed by Simon Glass
1 parent 5c928d0204

mmc-uclass: correct the device number

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>

Showing 2 changed files with 9 additions and 3 deletions Side-by-side Diff

drivers/mmc/mmc-uclass.c
... ... @@ -111,18 +111,18 @@
111 111  
112 112 int get_mmc_num(void)
113 113 {
114   - return max(blk_find_max_devnum(IF_TYPE_MMC), 0);
  114 + return max((blk_find_max_devnum(IF_TYPE_MMC) + 1), 0);
115 115 }
116 116  
117 117 int mmc_get_next_devnum(void)
118 118 {
119 119 int ret;
120 120  
121   - ret = get_mmc_num();
  121 + ret = blk_find_max_devnum(IF_TYPE_MMC);
122 122 if (ret < 0)
123 123 return ret;
124 124  
125   - return ret + 1;
  125 + return ret;
126 126 }
127 127  
128 128 struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
... ... @@ -503,6 +503,12 @@
503 503 struct mmc *find_mmc_device(int dev_num);
504 504 int mmc_set_dev(int dev_num);
505 505 void print_mmc_devices(char separator);
  506 +
  507 +/**
  508 + * get_mmc_num() - get the total MMC device number
  509 + *
  510 + * @return 0 if there is no MMC device, else the number of devices
  511 + */
506 512 int get_mmc_num(void);
507 513 int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf,
508 514 enum mmc_hwpart_conf_mode mode);