From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/2] mci: add card_write_protected
Date: Fri, 25 Jan 2013 16:38:27 +0100 [thread overview]
Message-ID: <1359128308-31235-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20130125152819.GE26329@game.jcrosoft.org>
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>
---
drivers/mci/mci-core.c | 6 ++++++
include/mci.h | 2 ++
2 files changed, 8 insertions(+)
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 @@ 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);
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 @@ struct mci_host {
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 */
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-01-25 15:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 15:28 [for next PATCH 0/2] MMC: introduce write protect support Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:38 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-01-25 15:38 ` [PATCH 2/2] atmel_mci: add write protect detection support Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1359128308-31235-1-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox