mmc: core: Fetch and decode EXT_CSD from mmc_read_ext_csd()
As a step in cleaning up code around reading/decoding EXT_CSD, convert the current mmc_read_ext_csd(), to handle both fetching the EXT_CSD and decoding its data. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
148bcab28f
commit
076ec38a58
1 changed files with 17 additions and 13 deletions
|
@ -388,7 +388,7 @@ static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd)
|
||||||
/*
|
/*
|
||||||
* Decode extended CSD.
|
* Decode extended CSD.
|
||||||
*/
|
*/
|
||||||
static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
|
static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
|
||||||
{
|
{
|
||||||
int err = 0, idx;
|
int err = 0, idx;
|
||||||
unsigned int part_size;
|
unsigned int part_size;
|
||||||
|
@ -637,6 +637,20 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mmc_read_ext_csd(struct mmc_card *card)
|
||||||
|
{
|
||||||
|
u8 *ext_csd = NULL;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = mmc_get_ext_csd(card, &ext_csd);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = mmc_decode_ext_csd(card, ext_csd);
|
||||||
|
kfree(ext_csd);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)
|
static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)
|
||||||
{
|
{
|
||||||
u8 *bw_ext_csd;
|
u8 *bw_ext_csd;
|
||||||
|
@ -1259,7 +1273,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
|
||||||
int err;
|
int err;
|
||||||
u32 cid[4];
|
u32 cid[4];
|
||||||
u32 rocr;
|
u32 rocr;
|
||||||
u8 *ext_csd = NULL;
|
|
||||||
|
|
||||||
BUG_ON(!host);
|
BUG_ON(!host);
|
||||||
WARN_ON(!host->claimed);
|
WARN_ON(!host->claimed);
|
||||||
|
@ -1368,14 +1381,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oldcard) {
|
if (!oldcard) {
|
||||||
/*
|
/* Read extended CSD. */
|
||||||
* Fetch and process extended CSD.
|
err = mmc_read_ext_csd(card);
|
||||||
*/
|
|
||||||
|
|
||||||
err = mmc_get_ext_csd(card, &ext_csd);
|
|
||||||
if (err)
|
|
||||||
goto free_card;
|
|
||||||
err = mmc_read_ext_csd(card, ext_csd);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto free_card;
|
goto free_card;
|
||||||
|
|
||||||
|
@ -1552,15 +1559,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
|
||||||
if (!oldcard)
|
if (!oldcard)
|
||||||
host->card = card;
|
host->card = card;
|
||||||
|
|
||||||
kfree(ext_csd);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
free_card:
|
free_card:
|
||||||
if (!oldcard)
|
if (!oldcard)
|
||||||
mmc_remove_card(card);
|
mmc_remove_card(card);
|
||||||
err:
|
err:
|
||||||
kfree(ext_csd);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue