The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Pierre Ossman <drzeus-list@drzeus.cx>
To: LKML <linux-kernel@vger.kernel.org>,
	Russell King <rmk+lkml@arm.linux.org.uk>
Subject: [PATCH] Support for read-only MMC cards
Date: Sat, 04 Jun 2005 21:54:53 +0200	[thread overview]
Message-ID: <42A2070D.9060608@drzeus.cx> (raw)

[-- Attachment #1: Type: text/plain, Size: 131 bytes --]

If the card does not support the write commands then only allow
read-only access.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>

[-- Attachment #2: mmc-ro_ccc.patch --]
[-- Type: text/x-patch, Size: 851 bytes --]

--- linux-2.6.11/drivers/mmc/mmc_block.c.orig	2005-06-04 21:44:20.000000000 +0200
+++ linux-2.6.11/drivers/mmc/mmc_block.c	2005-06-04 21:48:46.000000000 +0200
@@ -95,6 +95,10 @@ static int mmc_blk_open(struct inode *in
 		if (md->usage == 2)
 			check_disk_change(inode->i_bdev);
 		ret = 0;
+
+		if ((filp->f_mode & FMODE_WRITE) &&
+			!(md->queue.card->csd.cmdclass & CCC_BLOCK_WRITE))
+			ret = -EROFS;
 	}
 
 	return ret;
@@ -403,9 +407,12 @@ static int mmc_blk_probe(struct mmc_card
 	if (err)
 		goto out;
 
-	printk(KERN_INFO "%s: %s %s %dKiB\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);
+	if (!(card->csd.cmdclass & CCC_BLOCK_WRITE))
+		printk(" (ro)");
+	printk("\n");
 
 	mmc_set_drvdata(card, md);
 	add_disk(md->disk);

             reply	other threads:[~2005-06-04 19:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-04 19:54 Pierre Ossman [this message]
2005-06-04 19:58 ` [PATCH] Support for read-only MMC cards Russell King
2005-06-04 20:05   ` Pierre Ossman
2005-06-04 20:07     ` Russell King
2005-06-04 20:14       ` Pierre Ossman
2005-06-04 20:16         ` Russell King
2005-06-04 20:24           ` Pierre Ossman

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=42A2070D.9060608@drzeus.cx \
    --to=drzeus-list@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    /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