Skip to content

Commit

Permalink
mmc: remove custom error codes
Browse files Browse the repository at this point in the history
Convert the MMC layer to use standard error codes and not its own,
incompatible values.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
  • Loading branch information
Pierre Ossman committed Sep 23, 2007
1 parent b7e113d commit 17b0429
Show file tree
Hide file tree
Showing 16 changed files with 203 additions and 202 deletions.
4 changes: 2 additions & 2 deletions drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;

err = mmc_wait_for_cmd(card->host, &cmd, 0);
if ((err != MMC_ERR_NONE) || !(cmd.resp[0] & R1_APP_CMD))
if (err || !(cmd.resp[0] & R1_APP_CMD))
return (u32)-1;

memset(&cmd, 0, sizeof(struct mmc_command));
Expand Down Expand Up @@ -192,7 +192,7 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)

mmc_wait_for_req(card->host, &mrq);

if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE)
if (cmd.error || data.error)
return (u32)-1;

blocks = ntohl(blocks);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ void mmc_rescan(struct work_struct *work)
mmc_send_if_cond(host, host->ocr_avail);

err = mmc_send_app_op_cond(host, 0, &ocr);
if (err == MMC_ERR_NONE) {
if (!err) {
if (mmc_attach_sd(host, ocr))
mmc_power_off(host);
} else {
Expand All @@ -607,7 +607,7 @@ void mmc_rescan(struct work_struct *work)
* searching for MMC cards.
*/
err = mmc_send_op_cond(host, 0, &ocr);
if (err == MMC_ERR_NONE) {
if (!err) {
if (mmc_attach_mmc(host, ocr))
mmc_power_off(host);
} else {
Expand Down
36 changes: 18 additions & 18 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ static int mmc_read_ext_csd(struct mmc_card *card)

BUG_ON(!card);

err = MMC_ERR_FAILED;
err = -EIO;

if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
return MMC_ERR_NONE;
return 0;

/*
* As the ext_csd is so large and mostly unused, we don't store the
Expand All @@ -178,11 +178,11 @@ static int mmc_read_ext_csd(struct mmc_card *card)
printk(KERN_ERR "%s: could not allocate a buffer to "
"receive the ext_csd. mmc v4 cards will be "
"treated as v3.\n", mmc_hostname(card->host));
return MMC_ERR_FAILED;
return -ENOMEM;
}

err = mmc_send_ext_csd(card, ext_csd);
if (err != MMC_ERR_NONE) {
if (err) {
/*
* High capacity cards should have this "magic" size
* stored in their CSD.
Expand All @@ -197,7 +197,7 @@ static int mmc_read_ext_csd(struct mmc_card *card)
"EXT_CSD, performance might "
"suffer.\n",
mmc_hostname(card->host));
err = MMC_ERR_NONE;
err = 0;
}
goto out;
}
Expand Down Expand Up @@ -258,14 +258,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,

/* The extra bit indicates that we support high capacity */
err = mmc_send_op_cond(host, ocr | (1 << 30), NULL);
if (err != MMC_ERR_NONE)
if (err)
goto err;

/*
* Fetch CID from card.
*/
err = mmc_all_send_cid(host, cid);
if (err != MMC_ERR_NONE)
if (err)
goto err;

if (oldcard) {
Expand All @@ -290,7 +290,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
* Set card RCA.
*/
err = mmc_set_relative_addr(card);
if (err != MMC_ERR_NONE)
if (err)
goto free_card;

mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
Expand All @@ -300,7 +300,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
* Fetch CSD from card.
*/
err = mmc_send_csd(card, card->raw_csd);
if (err != MMC_ERR_NONE)
if (err)
goto free_card;

err = mmc_decode_csd(card);
Expand All @@ -315,15 +315,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
* Select card, as all following commands rely on that.
*/
err = mmc_select_card(card);
if (err != MMC_ERR_NONE)
if (err)
goto free_card;

if (!oldcard) {
/*
* Fetch and process extened CSD.
*/
err = mmc_read_ext_csd(card);
if (err != MMC_ERR_NONE)
if (err)
goto free_card;
}

Expand All @@ -334,7 +334,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
(host->caps & MMC_CAP_MMC_HIGHSPEED)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING, 1);
if (err != MMC_ERR_NONE)
if (err)
goto free_card;

mmc_card_set_highspeed(card);
Expand Down Expand Up @@ -363,7 +363,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
(host->caps & MMC_CAP_4_BIT_DATA)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
if (err != MMC_ERR_NONE)
if (err)
goto free_card;

mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
Expand All @@ -372,14 +372,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
if (!oldcard)
host->card = card;

return MMC_ERR_NONE;
return 0;

free_card:
if (!oldcard)
mmc_remove_card(card);
err:

return MMC_ERR_FAILED;
return -EIO;
}

/*
Expand Down Expand Up @@ -413,7 +413,7 @@ static void mmc_detect(struct mmc_host *host)

mmc_release_host(host);

if (err != MMC_ERR_NONE) {
if (err) {
mmc_remove(host);

mmc_claim_host(host);
Expand Down Expand Up @@ -502,7 +502,7 @@ static void mmc_resume(struct mmc_host *host)
err = mmc_init_card(host, host->ocr, host->card);
mmc_release_host(host);

if (err != MMC_ERR_NONE) {
if (err) {
mmc_remove(host);

mmc_claim_host(host);
Expand Down Expand Up @@ -565,7 +565,7 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
* Detect and init the card.
*/
err = mmc_init_card(host, host->ocr, NULL);
if (err != MMC_ERR_NONE)
if (err)
goto err;

mmc_release_host(host);
Expand Down
34 changes: 17 additions & 17 deletions drivers/mmc/core/mmc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
}

err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
if (err != MMC_ERR_NONE)
if (err)
return err;

return MMC_ERR_NONE;
return 0;
}

int mmc_select_card(struct mmc_card *card)
Expand Down Expand Up @@ -99,13 +99,13 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)

for (i = 100; i; i--) {
err = mmc_wait_for_cmd(host, &cmd, 0);
if (err != MMC_ERR_NONE)
if (err)
break;

if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0)
break;

err = MMC_ERR_TIMEOUT;
err = -ETIMEDOUT;

mmc_delay(10);
}
Expand All @@ -131,12 +131,12 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;

err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
if (err != MMC_ERR_NONE)
if (err)
return err;

memcpy(cid, cmd.resp, sizeof(u32) * 4);

return MMC_ERR_NONE;
return 0;
}

int mmc_set_relative_addr(struct mmc_card *card)
Expand All @@ -154,10 +154,10 @@ int mmc_set_relative_addr(struct mmc_card *card)
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;

err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
if (err != MMC_ERR_NONE)
if (err)
return err;

return MMC_ERR_NONE;
return 0;
}

int mmc_send_csd(struct mmc_card *card, u32 *csd)
Expand All @@ -176,12 +176,12 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd)
cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;

err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
if (err != MMC_ERR_NONE)
if (err)
return err;

memcpy(csd, cmd.resp, sizeof(u32) * 4);

return MMC_ERR_NONE;
return 0;
}

int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd)
Expand Down Expand Up @@ -218,12 +218,12 @@ int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd)

mmc_wait_for_req(card->host, &mrq);

if (cmd.error != MMC_ERR_NONE)
if (cmd.error)
return cmd.error;
if (data.error != MMC_ERR_NONE)
if (data.error)
return data.error;

return MMC_ERR_NONE;
return 0;
}

int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
Expand All @@ -244,10 +244,10 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;

err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
if (err != MMC_ERR_NONE)
if (err)
return err;

return MMC_ERR_NONE;
return 0;
}

int mmc_send_status(struct mmc_card *card, u32 *status)
Expand All @@ -265,12 +265,12 @@ int mmc_send_status(struct mmc_card *card, u32 *status)
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;

err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
if (err != MMC_ERR_NONE)
if (err)
return err;

if (status)
*status = cmd.resp[0];

return MMC_ERR_NONE;
return 0;
}

Loading

0 comments on commit 17b0429

Please sign in to comment.