]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: mmc: Adjust mmc_switch_part() to use a struct mmc
authorSimon Glass <sjg@chromium.org>
Sun, 1 May 2016 19:52:37 +0000 (13:52 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 17 May 2016 15:54:43 +0000 (09:54 -0600)
Instead of looking up the MMC device by number, just pass it in. This makes
it possible to use this function with driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/mmc/mmc.c

index 48aedc212c31e46fe0492a807c2911932a241eb7..4ba13a14e85e03783df790e7b62842489988b15b 100644 (file)
@@ -560,14 +560,10 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
        return 0;
 }
 
-int mmc_switch_part(int dev_num, unsigned int part_num)
+static int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
 {
-       struct mmc *mmc = find_mmc_device(dev_num);
        int ret;
 
-       if (!mmc)
-               return -1;
-
        ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
                         (mmc->part_config & ~PART_ACCESS_MASK)
                         | (part_num & PART_ACCESS_MASK));
@@ -578,7 +574,7 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
         */
        if ((ret == 0) || ((ret == -ENODEV) && (part_num == 0))) {
                ret = mmc_set_capacity(mmc, part_num);
-               mmc->block_dev.hwpart = part_num;
+               mmc_get_blk_desc(mmc)->hwpart = part_num;
        }
 
        return ret;
@@ -598,7 +594,7 @@ static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
        if (mmc->part_config == MMCPART_NOAVAILABLE)
                return -EMEDIUMTYPE;
 
-       ret = mmc_switch_part(desc->devnum, hwpart);
+       ret = mmc_switch_part(mmc, hwpart);
        if (ret)
                return ret;
 
@@ -619,7 +615,7 @@ int mmc_select_hwpart(int dev_num, int hwpart)
        if (mmc->part_config == MMCPART_NOAVAILABLE)
                return -EMEDIUMTYPE;
 
-       ret = mmc_switch_part(dev_num, hwpart);
+       ret = mmc_switch_part(mmc, hwpart);
        if (ret)
                return ret;