Skip to content

Commit

Permalink
mmc: core: Re-factor code for sending CID
Browse files Browse the repository at this point in the history
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: Ulf Hansson <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Reviewed-by: Shawn Lin <[email protected]>
  • Loading branch information
storulf committed Jun 20, 2017
1 parent 3df66e7 commit a147373
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
5 changes: 1 addition & 4 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,10 +1556,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
/*
* Fetch CID from card.
*/
if (mmc_host_is_spi(host))
err = mmc_send_cid(host, cid);
else
err = mmc_all_send_cid(host, cid);
err = mmc_send_cid(host, cid);
if (err)
goto err;

Expand Down
12 changes: 10 additions & 2 deletions drivers/mmc/core/mmc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
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;
struct mmc_command cmd = {};
Expand Down Expand Up @@ -334,7 +334,7 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd)
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;
__be32 *cid_tmp;
Expand All @@ -355,6 +355,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid)
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 err;
Expand Down
1 change: 0 additions & 1 deletion drivers/mmc/core/mmc_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ int mmc_deselect_cards(struct mmc_host *host);
int mmc_set_dsr(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_all_send_cid(struct mmc_host *host, u32 *cid);
int mmc_set_relative_addr(struct mmc_card *card);
int mmc_send_csd(struct mmc_card *card, u32 *csd);
int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries);
Expand Down
6 changes: 1 addition & 5 deletions drivers/mmc/core/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
else
err = mmc_all_send_cid(host, cid);

err = mmc_send_cid(host, cid);
return err;
}

Expand Down

0 comments on commit a147373

Please sign in to comment.