public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [MMC] Use command class to determine read-only status.
@ 2005-10-28  7:36 Pierre Ossman
  2005-10-28 20:14 ` Russell King
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Ossman @ 2005-10-28  7:36 UTC (permalink / raw)
  To: rmk+lkml; +Cc: Pierre Ossman, linux-kernel

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>
---

 drivers/mmc/mmc_block.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -97,7 +97,8 @@ static int mmc_blk_open(struct inode *in
 		ret = 0;
 
 		if ((filp->f_mode & FMODE_WRITE) &&
-			mmc_card_readonly(md->queue.card))
+			(!(md->queue.card->csd.cmdclass & CCC_BLOCK_WRITE) ||
+			mmc_card_readonly(md->queue.card)))
 			ret = -EROFS;
 	}
 
@@ -407,10 +408,12 @@ static int mmc_blk_probe(struct mmc_card
 	if (err)
 		goto out;
 
-	printk(KERN_INFO "%s: %s %s %dKiB %s\n",
+	printk(KERN_INFO "%s: %s %s %dKiB",
 		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)":"");
+		(card->csd.capacity << card->csd.read_blkbits) / 1024);
+	if (mmc_card_readonly(card) || !(card->csd.cmdclass & CCC_BLOCK_WRITE))
+		printk("(ro)");
+	printk("\n");
 
 	mmc_set_drvdata(card, md);
 	add_disk(md->disk);


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-30 10:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-28  7:36 [PATCH] [MMC] Use command class to determine read-only status Pierre Ossman
2005-10-28 20:14 ` Russell King
2005-10-29 22:39   ` Pierre Ossman
2005-10-30 10:16     ` Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox