summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mci-core.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-01-25 16:38:27 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-01-27 12:17:28 +0100
commit20615ac8c9ea6ef14ee31bb01cfd8f9d0e9fbaef (patch)
tree3493546b8d84521b07b6b718fee2c1038d497fa7 /drivers/mci/mci-core.c
parent456fae022798fd9142a0ac255890e1622463e10c (diff)
downloadbarebox-20615ac8c9ea6ef14ee31bb01cfd8f9d0e9fbaef.tar.gz
barebox-20615ac8c9ea6ef14ee31bb01cfd8f9d0e9fbaef.tar.xz
mci: add card_write_protected
Currently there is no common way for the mci host driver to tell that thee car is write protected. This adds a card_write_protected callback which is used by the framework to tell whether it's protected or not. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/mci-core.c')
-rw-r--r--drivers/mci/mci-core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index fd052f16da..a269aee4e8 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1111,8 +1111,14 @@ static int __maybe_unused mci_sd_write(struct block_device *blk,
const void *buffer, int block, int num_blocks)
{
struct mci *mci = container_of(blk, struct mci, blk);
+ struct mci_host *host = mci->host;
int rc;
+ if (host->card_write_protected && host->card_write_protected(host)) {
+ dev_err(mci->mci_dev, "card write protected\n");
+ return -EPERM;
+ }
+
dev_dbg(mci->mci_dev, "%s: Write %d block(s), starting at %d\n",
__func__, num_blocks, block);