* [PATCH] Support for read-only MMC cards
@ 2005-06-04 19:54 Pierre Ossman
2005-06-04 19:58 ` Russell King
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Ossman @ 2005-06-04 19:54 UTC (permalink / raw)
To: LKML, Russell King
[-- 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);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support for read-only MMC cards
2005-06-04 19:54 [PATCH] Support for read-only MMC cards Pierre Ossman
@ 2005-06-04 19:58 ` Russell King
2005-06-04 20:05 ` Pierre Ossman
0 siblings, 1 reply; 7+ messages in thread
From: Russell King @ 2005-06-04 19:58 UTC (permalink / raw)
To: Pierre Ossman; +Cc: LKML
On Sat, Jun 04, 2005 at 09:54:53PM +0200, Pierre Ossman wrote:
> If the card does not support the write commands then only allow
> read-only access.
> @@ -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 (!())
> + printk(" (ro)");
> + printk("\n");
I'd prefer this to be:
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,
card->csd.cmdclass & CCC_BLOCK_WRITE ? "" : " (ro)");
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support for read-only MMC cards
2005-06-04 19:58 ` Russell King
@ 2005-06-04 20:05 ` Pierre Ossman
2005-06-04 20:07 ` Russell King
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Ossman @ 2005-06-04 20:05 UTC (permalink / raw)
To: Russell King; +Cc: LKML
Russell King wrote:
>
>I'd prefer this to be:
>
> 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,
> card->csd.cmdclass & CCC_BLOCK_WRITE ? "" : " (ro)");
>
>
>
I'd rather not since the SD patches have a similar test but on a
different condition. It makes the [SD] patch a bit easier to follow when
trying to determine what it does. Since it doesn't seem to be getting
included anytime soon I'm trying to do what I can to keep it maintainable.
Rgds
Pierre
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support for read-only MMC cards
2005-06-04 20:05 ` Pierre Ossman
@ 2005-06-04 20:07 ` Russell King
2005-06-04 20:14 ` Pierre Ossman
0 siblings, 1 reply; 7+ messages in thread
From: Russell King @ 2005-06-04 20:07 UTC (permalink / raw)
To: Pierre Ossman; +Cc: LKML
On Sat, Jun 04, 2005 at 10:05:00PM +0200, Pierre Ossman wrote:
> Russell King wrote:
> >I'd prefer this to be:
> >
> > 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,
> > card->csd.cmdclass & CCC_BLOCK_WRITE ? "" : " (ro)");
> >
> >
> >
>
> I'd rather not since the SD patches have a similar test but on a
> different condition.
That's just a case of adding another %s and ?:. I'd really prefer it
to be done this way.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support for read-only MMC cards
2005-06-04 20:07 ` Russell King
@ 2005-06-04 20:14 ` Pierre Ossman
2005-06-04 20:16 ` Russell King
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Ossman @ 2005-06-04 20:14 UTC (permalink / raw)
To: Russell King; +Cc: LKML
Russell King wrote:
>On Sat, Jun 04, 2005 at 10:05:00PM +0200, Pierre Ossman wrote:
>
>
>>Russell King wrote:
>>
>>
>>>I'd prefer this to be:
>>>
>>> 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,
>>> card->csd.cmdclass & CCC_BLOCK_WRITE ? "" : " (ro)");
>>>
>>>
>>>
>>>
>>>
>>I'd rather not since the SD patches have a similar test but on a
>>different condition.
>>
>>
>
>That's just a case of adding another %s and ?:. I'd really prefer it
>to be done this way.
>
>
>
Well that would turn out something like:
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,
(!(card->csd.cmdclass & CCC_BLOCK_WRITE) ||
mmc_card_readonly(card)) ? " (ro)" : "");
which is a bit messy IMHO.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support for read-only MMC cards
2005-06-04 20:14 ` Pierre Ossman
@ 2005-06-04 20:16 ` Russell King
2005-06-04 20:24 ` Pierre Ossman
0 siblings, 1 reply; 7+ messages in thread
From: Russell King @ 2005-06-04 20:16 UTC (permalink / raw)
To: Pierre Ossman; +Cc: LKML
On Sat, Jun 04, 2005 at 10:14:15PM +0200, Pierre Ossman wrote:
> Well that would turn out something like:
>
> 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,
> (!(card->csd.cmdclass & CCC_BLOCK_WRITE) ||
> mmc_card_readonly(card)) ? " (ro)" : "");
>
> which is a bit messy IMHO.
Can't we set mmc_card_readonly status if !CCC_BLOCK_WRITE ? Would that
not simplify the code in the open method as well?
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Support for read-only MMC cards
2005-06-04 20:16 ` Russell King
@ 2005-06-04 20:24 ` Pierre Ossman
0 siblings, 0 replies; 7+ messages in thread
From: Pierre Ossman @ 2005-06-04 20:24 UTC (permalink / raw)
To: Russell King; +Cc: LKML
Russell King wrote:
>Can't we set mmc_card_readonly status if !CCC_BLOCK_WRITE ? Would that
>not simplify the code in the open method as well?
>
>
>
Well, that depends on what we want mmc_card_readonly to signify. My
thought was that it meant the entire card was read only (as should be
the case with the external ro-switch on SD cards). This might not be the
same thing as that the card lacks block writes. E.g. there are cards
with combined I/O and storage functionality.
For most cases the lack of CCC_BLOCK_WRITE will mean read-only for
everything that the card can do. But I'm not convinced that's the case
for all cards. The fact that there are command classes for streamed
writes should indicate possible corner cases.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-06-04 20:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-04 19:54 [PATCH] Support for read-only MMC cards Pierre Ossman
2005-06-04 19:58 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox