Commit a1473732 authored by Ulf Hansson's avatar Ulf Hansson

mmc: core: Re-factor code for sending CID

Instead of having the caller to check for SPI mode, let's leave that to
internals of mmc_send_cid(). In this way the code gets cleaner and it
becomes clear what is specific to SPI and non-SPI mode.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
parent 3df66e77
...@@ -1556,10 +1556,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -1556,10 +1556,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
/* /*
* Fetch CID from card. * Fetch CID from card.
*/ */
if (mmc_host_is_spi(host)) err = mmc_send_cid(host, cid);
err = mmc_send_cid(host, cid);
else
err = mmc_all_send_cid(host, cid);
if (err) if (err)
goto err; goto err;
......
...@@ -207,7 +207,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) ...@@ -207,7 +207,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
return err; return err;
} }
int mmc_all_send_cid(struct mmc_host *host, u32 *cid) static int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
{ {
int err; int err;
struct mmc_command cmd = {}; struct mmc_command cmd = {};
...@@ -334,7 +334,7 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd) ...@@ -334,7 +334,7 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd)
return ret; return ret;
} }
int mmc_send_cid(struct mmc_host *host, u32 *cid) static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid)
{ {
int ret, i; int ret, i;
__be32 *cid_tmp; __be32 *cid_tmp;
...@@ -355,6 +355,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid) ...@@ -355,6 +355,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid)
return ret; return ret;
} }
int mmc_send_cid(struct mmc_host *host, u32 *cid)
{
if (mmc_host_is_spi(host))
return mmc_spi_send_cid(host, cid);
return mmc_all_send_cid(host, cid);
}
int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd)
{ {
int err; int err;
......
...@@ -22,7 +22,6 @@ int mmc_deselect_cards(struct mmc_host *host); ...@@ -22,7 +22,6 @@ int mmc_deselect_cards(struct mmc_host *host);
int mmc_set_dsr(struct mmc_host *host); int mmc_set_dsr(struct mmc_host *host);
int mmc_go_idle(struct mmc_host *host); int mmc_go_idle(struct mmc_host *host);
int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
int mmc_all_send_cid(struct mmc_host *host, u32 *cid);
int mmc_set_relative_addr(struct mmc_card *card); int mmc_set_relative_addr(struct mmc_card *card);
int mmc_send_csd(struct mmc_card *card, u32 *csd); int mmc_send_csd(struct mmc_card *card, u32 *csd);
int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries); int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries);
......
...@@ -788,11 +788,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr) ...@@ -788,11 +788,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
} }
} }
if (mmc_host_is_spi(host)) err = mmc_send_cid(host, cid);
err = mmc_send_cid(host, cid);
else
err = mmc_all_send_cid(host, cid);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment