summaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2005-10-30 10:15:58 +0000
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-10-30 10:15:58 +0000
commit936d8592654bb97d5706a73c0e2a6339b090f7fb (patch)
tree78282b935a267627ef7b259853aced6abb9fc566 /drivers/mmc
parent9e1d98c5d8613d917004a193d4f989a3544d8fef (diff)
downloadlinux-936d8592654bb97d5706a73c0e2a6339b090f7fb.tar.gz
linux-936d8592654bb97d5706a73c0e2a6339b090f7fb.tar.bz2
linux-936d8592654bb97d5706a73c0e2a6339b090f7fb.zip
[MMC] Use command class to determine read-only status
If a card doesn't support the "write block" command class then any attempts to open the device should reflect this by denying write access. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/mmc_block.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index fa83f15fdf16..9b629856c735 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -85,6 +85,12 @@ static void mmc_blk_put(struct mmc_blk_data *md)
up(&open_lock);
}
+static inline int mmc_blk_readonly(struct mmc_card *card)
+{
+ return mmc_card_readonly(card) ||
+ !(card->csd.cmdclass & CCC_BLOCK_WRITE);
+}
+
static int mmc_blk_open(struct inode *inode, struct file *filp)
{
struct mmc_blk_data *md;
@@ -97,7 +103,7 @@ static int mmc_blk_open(struct inode *inode, struct file *filp)
ret = 0;
if ((filp->f_mode & FMODE_WRITE) &&
- mmc_card_readonly(md->queue.card))
+ mmc_blk_readonly(md->queue.card))
ret = -EROFS;
}
@@ -410,7 +416,7 @@ static int mmc_blk_probe(struct mmc_card *card)
printk(KERN_INFO "%s: %s %s %dKiB %s\n",
md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
(card->csd.capacity << card->csd.read_blkbits) / 1024,
- mmc_card_readonly(card)?"(ro)":"");
+ mmc_blk_readonly(card)?"(ro)":"");
mmc_set_drvdata(card, md);
add_disk(md->disk);