OSDN Git Service

mmc: core: Simplify card drive strength mask
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 6 Feb 2015 12:12:53 +0000 (14:12 +0200)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 28 Apr 2015 17:10:46 +0000 (01:10 +0800)
Card drive strength selection uses a callback to
which a mask of supported drive strengths is passed.
Currently, the bits are checked against the values
in the SD specifications. That is not necessary
because the callback will anyway match the mask
against a valid value. Simplify by taking the mask
as is but still ensuring that the default mandatory
value (type B) is always supported.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
drivers/mmc/core/sd.c
drivers/mmc/core/sdio.c

index cbee29a..fab83e8 100644 (file)
@@ -387,8 +387,7 @@ out:
 static int sd_select_driver_type(struct mmc_card *card, u8 *status)
 {
        int host_drv_type = SD_DRIVER_TYPE_B;
-       int card_drv_type = SD_DRIVER_TYPE_B;
-       int drive_strength, drv_type;
+       int card_drv_type, drive_strength, drv_type;
        int err;
 
        if (!card->host->ops->select_drive_strength)
@@ -403,14 +402,7 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)
        if (card->host->caps & MMC_CAP_DRIVER_TYPE_D)
                host_drv_type |= SD_DRIVER_TYPE_D;
 
-       if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A)
-               card_drv_type |= SD_DRIVER_TYPE_A;
-
-       if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C)
-               card_drv_type |= SD_DRIVER_TYPE_C;
-
-       if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D)
-               card_drv_type |= SD_DRIVER_TYPE_D;
+       card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B;
 
        /*
         * The drive strength that the hardware can support
index 89607ce..065f29a 100644 (file)
@@ -403,8 +403,7 @@ static unsigned char host_drive_to_sdio_drive(int host_strength)
 static void sdio_select_driver_type(struct mmc_card *card)
 {
        int host_drv_type = SD_DRIVER_TYPE_B;
-       int card_drv_type = SD_DRIVER_TYPE_B;
-       int drive_strength, drv_type;
+       int card_drv_type, drive_strength, drv_type;
        unsigned char card_strength;
        int err;
 
@@ -420,14 +419,7 @@ static void sdio_select_driver_type(struct mmc_card *card)
        if (card->host->caps & MMC_CAP_DRIVER_TYPE_D)
                host_drv_type |= SD_DRIVER_TYPE_D;
 
-       if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A)
-               card_drv_type |= SD_DRIVER_TYPE_A;
-
-       if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C)
-               card_drv_type |= SD_DRIVER_TYPE_C;
-
-       if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D)
-               card_drv_type |= SD_DRIVER_TYPE_D;
+       card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B;
 
        /*
         * The drive strength that the hardware can support