Re: [PATCH] [MMC] Use command class to determine read-only status.

From: Russell King
Date: Fri Oct 28 2005 - 15:15:18 EST


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:

static inline int mmc_blk_readonly(struct mmc_card *card)
{
return mmc_card_readonly(card) ||
!(card->csd.cmdclass & CCC_BLOCK_WRITE);
}

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

+ mmc_blk_readonly(md->queue.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)" : "");

As a bonus, I think this makes the code a lot more readable... but
then I am biased. 8)

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/