Skip to content

Commit fa021ce

Browse files
ahunter6storulf
authored andcommitted
mmc: core: Simplify card drive strength mask
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> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent b4f30a1 commit fa021ce

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

drivers/mmc/core/sd.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ int mmc_sd_switch_hs(struct mmc_card *card)
387387
static int sd_select_driver_type(struct mmc_card *card, u8 *status)
388388
{
389389
int host_drv_type = SD_DRIVER_TYPE_B;
390-
int card_drv_type = SD_DRIVER_TYPE_B;
391-
int drive_strength, drv_type;
390+
int card_drv_type, drive_strength, drv_type;
392391
int err;
393392

394393
if (!card->host->ops->select_drive_strength)
@@ -403,14 +402,7 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)
403402
if (card->host->caps & MMC_CAP_DRIVER_TYPE_D)
404403
host_drv_type |= SD_DRIVER_TYPE_D;
405404

406-
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A)
407-
card_drv_type |= SD_DRIVER_TYPE_A;
408-
409-
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C)
410-
card_drv_type |= SD_DRIVER_TYPE_C;
411-
412-
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D)
413-
card_drv_type |= SD_DRIVER_TYPE_D;
405+
card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B;
414406

415407
/*
416408
* The drive strength that the hardware can support

drivers/mmc/core/sdio.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ static unsigned char host_drive_to_sdio_drive(int host_strength)
403403
static void sdio_select_driver_type(struct mmc_card *card)
404404
{
405405
int host_drv_type = SD_DRIVER_TYPE_B;
406-
int card_drv_type = SD_DRIVER_TYPE_B;
407-
int drive_strength, drv_type;
406+
int card_drv_type, drive_strength, drv_type;
408407
unsigned char card_strength;
409408
int err;
410409

@@ -420,14 +419,7 @@ static void sdio_select_driver_type(struct mmc_card *card)
420419
if (card->host->caps & MMC_CAP_DRIVER_TYPE_D)
421420
host_drv_type |= SD_DRIVER_TYPE_D;
422421

423-
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A)
424-
card_drv_type |= SD_DRIVER_TYPE_A;
425-
426-
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C)
427-
card_drv_type |= SD_DRIVER_TYPE_C;
428-
429-
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D)
430-
card_drv_type |= SD_DRIVER_TYPE_D;
422+
card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B;
431423

432424
/*
433425
* The drive strength that the hardware can support

0 commit comments

Comments
 (0)