All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prashanth Bhat <prashanth.bhat@manipal.net>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>
Subject: Re: [PATCH] mmc: mmc_add_card(): fix missing break in switch statement
Date: Wed, 04 May 2011 22:06:20 +0530	[thread overview]
Message-ID: <4DC18084.8060905@manipal.net> (raw)
In-Reply-To: <20110504112305.GC15486@rere.qmqm.pl>

Interesting coincidence that the value of MMC_TYPE_SD and MMC_TYPE_SDIO 
and MMC_TYPE_SD_COMBO have the relationship that SD_COMBO is the bitwise 
OR of the other two. However, this seems to be more of a coincidence 
than intentional. The #defines were clearly meant to be numeric values 
rather than bit-masks.

#define MMC_TYPE_MMC            0               /* MMC card */
#define MMC_TYPE_SD             1               /* SD card */
#define MMC_TYPE_SDIO           2               /* SDIO card */
#define MMC_TYPE_SD_COMBO       3               /* SD combo (IO+mem) card */


Using the bit-mask approach therefore doesn't feel like the natural way 
to me. Perhaps the #defines could be changed to

#define MMC_TYPE_MMC            (1 << 0)               /* MMC card */
#define MMC_TYPE_SD               (1 << 1)               /* SD card */
#define MMC_TYPE_SDIO            (1 << 2)               /* SDIO card */
#define MMC_TYPE_SD_COMBO       (MMC_TYPE_SD | MMC_TYPE_SDIO)    /* SD 
combo (IO+mem) card */

Thanks,
Prashanth

On Wednesday 04 May 2011 04:53 PM, Michał Mirosław wrote:
> On Tue, May 03, 2011 at 05:00:03PM +0530, Prashanth Bhat wrote:
>    
>> To be more specific, I would think that the code change required in
>> include/linux/mmc/card.h is:
>>
>> #define mmc_card_mmc(c)         ((c)->type == MMC_TYPE_MMC)
>> - #define mmc_card_sd(c)          ((c)->type == MMC_TYPE_SD)
>> - #define mmc_card_sdio(c)        ((c)->type == MMC_TYPE_SDIO)
>>
>> + #define mmc_card_sd(c)          ((c)->type == MMC_TYPE_SD ||
>> (c)->type == MMC_TYPE_SD_COMBO)
>> + #define mmc_card_sdio(c)        ((c)->type == MMC_TYPE_SDIO ||
>> (c)->type == MMC_TYPE_SD_COMBO)
>>      
> You can actually use (c->type&  MMC_TYPE_SD) and (c->type&  MMC_TYPE_SDIO).
> Unless there will be more types of SD cards (unlikely) this way
> will generate less code on average.
>
> Best Regards,
> Michał Mirosław
>
>
>    


  reply	other threads:[~2011-05-04 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-09  6:16 [PATCH] mmc: mmc_add_card(): fix missing break in switch statement Michał Mirosław
2011-04-09 14:08 ` Chris Ball
2011-05-03 11:20 ` Prashanth Bhat
2011-05-03 11:30   ` Prashanth Bhat
2011-05-04 11:23     ` Michał Mirosław
2011-05-04 16:36       ` Prashanth Bhat [this message]
2011-05-04 16:42         ` Michał Mirosław

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=4DC18084.8060905@manipal.net \
    --to=prashanth.bhat@manipal.net \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.