diff options
author | Pierre Ossman <drzeus@drzeus.cx> | 2005-10-30 05:15:58 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-10-30 05:15:58 -0500 |
commit | 936d8592654bb97d5706a73c0e2a6339b090f7fb (patch) | |
tree | 78282b935a267627ef7b259853aced6abb9fc566 | |
parent | 9e1d98c5d8613d917004a193d4f989a3544d8fef (diff) |
[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>
-rw-r--r-- | drivers/mmc/mmc_block.c | 10 |
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) | |||
85 | up(&open_lock); | 85 | up(&open_lock); |
86 | } | 86 | } |
87 | 87 | ||
88 | static inline int mmc_blk_readonly(struct mmc_card *card) | ||
89 | { | ||
90 | return mmc_card_readonly(card) || | ||
91 | !(card->csd.cmdclass & CCC_BLOCK_WRITE); | ||
92 | } | ||
93 | |||
88 | static int mmc_blk_open(struct inode *inode, struct file *filp) | 94 | static int mmc_blk_open(struct inode *inode, struct file *filp) |
89 | { | 95 | { |
90 | struct mmc_blk_data *md; | 96 | struct mmc_blk_data *md; |
@@ -97,7 +103,7 @@ static int mmc_blk_open(struct inode *inode, struct file *filp) | |||
97 | ret = 0; | 103 | ret = 0; |
98 | 104 | ||
99 | if ((filp->f_mode & FMODE_WRITE) && | 105 | if ((filp->f_mode & FMODE_WRITE) && |
100 | mmc_card_readonly(md->queue.card)) | 106 | mmc_blk_readonly(md->queue.card)) |
101 | ret = -EROFS; | 107 | ret = -EROFS; |
102 | } | 108 | } |
103 | 109 | ||
@@ -410,7 +416,7 @@ static int mmc_blk_probe(struct mmc_card *card) | |||
410 | printk(KERN_INFO "%s: %s %s %dKiB %s\n", | 416 | printk(KERN_INFO "%s: %s %s %dKiB %s\n", |
411 | md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), | 417 | md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), |
412 | (card->csd.capacity << card->csd.read_blkbits) / 1024, | 418 | (card->csd.capacity << card->csd.read_blkbits) / 1024, |
413 | mmc_card_readonly(card)?"(ro)":""); | 419 | mmc_blk_readonly(card)?"(ro)":""); |
414 | 420 | ||
415 | mmc_set_drvdata(card, md); | 421 | mmc_set_drvdata(card, md); |
416 | add_disk(md->disk); | 422 | add_disk(md->disk); |