mmc: return meaningful error codes from mmc_select_hwpart
Rather than just returning -1 everywhere, try to return something meaningful from mmc_select_hwpart(). Note that most other MMC functions don't do this, including functions called from mmc_select_hwpart(), so I'm not sure how effective this will be. Still, it's one less place with hard-coded -1. Suggested-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
This commit is contained in:
parent
e153b13c8e
commit
d4622df342
|
@ -10,6 +10,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <mmc.h>
|
#include <mmc.h>
|
||||||
#include <part.h>
|
#include <part.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
@ -564,19 +565,19 @@ int mmc_select_hwpart(int dev_num, int hwpart)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!mmc)
|
if (!mmc)
|
||||||
return -1;
|
return -ENODEV;
|
||||||
|
|
||||||
if (mmc->part_num == hwpart)
|
if (mmc->part_num == hwpart)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (mmc->part_config == MMCPART_NOAVAILABLE) {
|
if (mmc->part_config == MMCPART_NOAVAILABLE) {
|
||||||
printf("Card doesn't support part_switch\n");
|
printf("Card doesn't support part_switch\n");
|
||||||
return -1;
|
return -EMEDIUMTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mmc_switch_part(dev_num, hwpart);
|
ret = mmc_switch_part(dev_num, hwpart);
|
||||||
if (ret)
|
if (ret)
|
||||||
return -1;
|
return ret;
|
||||||
|
|
||||||
mmc->part_num = hwpart;
|
mmc->part_num = hwpart;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue