diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index fd052f1..a269aee 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1111,8 +1111,14 @@ 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); diff --git a/include/mci.h b/include/mci.h index c0d179b..cf9582d 100644 --- a/include/mci.h +++ b/include/mci.h @@ -302,6 +302,8 @@ int (*send_cmd)(struct mci_host*, struct mci_cmd*, struct mci_data*); /** check if a card is inserted */ int (*card_present)(struct mci_host *); + /** check if a card is write protected */ + int (*card_write_protected)(struct mci_host *); }; /** MMC/SD and interface instance information */