public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Ossman <drzeus@drzeus.cx>
To: rmk+lkml@arm.linux.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [MMC] Use command class to determine read-only status.
Date: Sun, 30 Oct 2005 00:39:58 +0200	[thread overview]
Message-ID: <4363FA3E.3000701@drzeus.cx> (raw)
In-Reply-To: <20051028201455.GI4464@flint.arm.linux.org.uk>

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

Russell King wrote:
> On Fri, Oct 28, 2005 at 09:36:05AM +0200, Pierre Ossman wrote:
>> 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.
> 
> I'd rather we kept printk messages as one printk if at all possible.
> How about encapsulating both of these conditions into an inline
> function:
> 

Ok with me. New patch included.

[-- Attachment #2: mmc-readonly-ccc.patch --]
[-- Type: text/x-patch, Size: 1368 bytes --]

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

 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
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -85,6 +85,12 @@ static void mmc_blk_put(struct mmc_blk_d
 	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 *in
 		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
 	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);

  reply	other threads:[~2005-10-29 22:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2005-10-30 10:16     ` Russell King

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=4363FA3E.3000701@drzeus.cx \
    --to=drzeus@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