mmc: improve error code feedback
Now that we use "normal" error codes, improve the reporting and response to error codes in the core. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This commit is contained in:
parent
17b0429dde
commit
adf66a0dc5
@ -176,13 +176,19 @@ static int mmc_read_ext_csd(struct mmc_card *card)
|
|||||||
ext_csd = kmalloc(512, GFP_KERNEL);
|
ext_csd = kmalloc(512, GFP_KERNEL);
|
||||||
if (!ext_csd) {
|
if (!ext_csd) {
|
||||||
printk(KERN_ERR "%s: could not allocate a buffer to "
|
printk(KERN_ERR "%s: could not allocate a buffer to "
|
||||||
"receive the ext_csd. mmc v4 cards will be "
|
"receive the ext_csd.\n", mmc_hostname(card->host));
|
||||||
"treated as v3.\n", mmc_hostname(card->host));
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mmc_send_ext_csd(card, ext_csd);
|
err = mmc_send_ext_csd(card, ext_csd);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
/*
|
||||||
|
* We all hosts that cannot perform the command
|
||||||
|
* to fail more gracefully
|
||||||
|
*/
|
||||||
|
if (err != -EINVAL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* High capacity cards should have this "magic" size
|
* High capacity cards should have this "magic" size
|
||||||
* stored in their CSD.
|
* stored in their CSD.
|
||||||
@ -199,6 +205,7 @@ static int mmc_read_ext_csd(struct mmc_card *card)
|
|||||||
mmc_hostname(card->host));
|
mmc_hostname(card->host));
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,8 +276,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (oldcard) {
|
if (oldcard) {
|
||||||
if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0)
|
if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) {
|
||||||
|
err = -ENOENT;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
card = oldcard;
|
card = oldcard;
|
||||||
} else {
|
} else {
|
||||||
@ -278,8 +287,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
|
|||||||
* Allocate card structure.
|
* Allocate card structure.
|
||||||
*/
|
*/
|
||||||
card = mmc_alloc_card(host);
|
card = mmc_alloc_card(host);
|
||||||
if (IS_ERR(card))
|
if (IS_ERR(card)) {
|
||||||
|
err = PTR_ERR(card);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
card->type = MMC_TYPE_MMC;
|
card->type = MMC_TYPE_MMC;
|
||||||
card->rca = 1;
|
card->rca = 1;
|
||||||
@ -304,10 +315,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
|
|||||||
goto free_card;
|
goto free_card;
|
||||||
|
|
||||||
err = mmc_decode_csd(card);
|
err = mmc_decode_csd(card);
|
||||||
if (err < 0)
|
if (err)
|
||||||
goto free_card;
|
goto free_card;
|
||||||
err = mmc_decode_cid(card);
|
err = mmc_decode_cid(card);
|
||||||
if (err < 0)
|
if (err)
|
||||||
goto free_card;
|
goto free_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +390,7 @@ free_card:
|
|||||||
mmc_remove_card(card);
|
mmc_remove_card(card);
|
||||||
err:
|
err:
|
||||||
|
|
||||||
return -EIO;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -587,6 +598,6 @@ err:
|
|||||||
printk(KERN_ERR "%s: error %d whilst initialising MMC card\n",
|
printk(KERN_ERR "%s: error %d whilst initialising MMC card\n",
|
||||||
mmc_hostname(host), err);
|
mmc_hostname(host), err);
|
||||||
|
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,10 +213,18 @@ static int mmc_read_switch(struct mmc_card *card)
|
|||||||
|
|
||||||
err = mmc_sd_switch(card, 0, 0, 1, status);
|
err = mmc_sd_switch(card, 0, 0, 1, status);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
/*
|
||||||
|
* We all hosts that cannot perform the command
|
||||||
|
* to fail more gracefully
|
||||||
|
*/
|
||||||
|
if (err != -EINVAL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
printk(KERN_WARNING "%s: problem reading switch "
|
printk(KERN_WARNING "%s: problem reading switch "
|
||||||
"capabilities, performance might suffer.\n",
|
"capabilities, performance might suffer.\n",
|
||||||
mmc_hostname(card->host));
|
mmc_hostname(card->host));
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,8 +332,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (oldcard) {
|
if (oldcard) {
|
||||||
if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0)
|
if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) {
|
||||||
|
err = -ENOENT;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
card = oldcard;
|
card = oldcard;
|
||||||
} else {
|
} else {
|
||||||
@ -333,8 +343,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
|
|||||||
* Allocate card structure.
|
* Allocate card structure.
|
||||||
*/
|
*/
|
||||||
card = mmc_alloc_card(host);
|
card = mmc_alloc_card(host);
|
||||||
if (IS_ERR(card))
|
if (IS_ERR(card)) {
|
||||||
|
err = PTR_ERR(card);
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
card->type = MMC_TYPE_SD;
|
card->type = MMC_TYPE_SD;
|
||||||
memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
|
memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
|
||||||
@ -358,7 +370,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
|
|||||||
goto free_card;
|
goto free_card;
|
||||||
|
|
||||||
err = mmc_decode_csd(card);
|
err = mmc_decode_csd(card);
|
||||||
if (err < 0)
|
if (err)
|
||||||
goto free_card;
|
goto free_card;
|
||||||
|
|
||||||
mmc_decode_cid(card);
|
mmc_decode_cid(card);
|
||||||
@ -449,7 +461,7 @@ free_card:
|
|||||||
mmc_remove_card(card);
|
mmc_remove_card(card);
|
||||||
err:
|
err:
|
||||||
|
|
||||||
return -EIO;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -666,6 +678,6 @@ err:
|
|||||||
printk(KERN_ERR "%s: error %d whilst initialising SD card\n",
|
printk(KERN_ERR "%s: error %d whilst initialising SD card\n",
|
||||||
mmc_hostname(host), err);
|
mmc_hostname(host), err);
|
||||||
|
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user