Skip to content

Commit 3beb0ab

Browse files
sh043leeUlf Hansson
authored andcommitted
mmc: core: Use mmc_card_* macro and add a new for the sd_combo type
Add mmc_card_sd_combo() macro for sd combo type card and use the mmc_card_* macro to simplify code instead of comparing card->type. Signed-off-by: Seunghui Lee <sh043.lee@samsung.com> Link: https://lore.kernel.org/r/20220713033635.28432-2-sh043.lee@samsung.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 54c16b5 commit 3beb0ab

5 files changed

Lines changed: 14 additions & 13 deletions

File tree

drivers/mmc/core/block.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,7 @@ static int mmc_blk_probe(struct mmc_card *card)
29882988
* Don't enable runtime PM for SD-combo cards here. Leave that
29892989
* decision to be taken during the SDIO init sequence instead.
29902990
*/
2991-
if (card->type != MMC_TYPE_SD_COMBO) {
2991+
if (!mmc_card_sd_combo(card)) {
29922992
pm_runtime_set_active(&card->dev);
29932993
pm_runtime_enable(&card->dev);
29942994
}
@@ -3015,7 +3015,7 @@ static void mmc_blk_remove(struct mmc_card *card)
30153015
mmc_blk_part_switch(card, md->part_type);
30163016
mmc_release_host(card->host);
30173017
}
3018-
if (card->type != MMC_TYPE_SD_COMBO)
3018+
if (!mmc_card_sd_combo(card))
30193019
pm_runtime_disable(&card->dev);
30203020
pm_runtime_put_noidle(&card->dev);
30213021
mmc_blk_remove_req(md);

drivers/mmc/core/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
8585
return retval;
8686
}
8787

88-
if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) {
88+
if (mmc_card_sdio(card) || mmc_card_sd_combo(card)) {
8989
retval = add_uevent_var(env, "SDIO_ID=%04X:%04X",
9090
card->cis.vendor, card->cis.device);
9191
if (retval)
@@ -107,7 +107,7 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
107107
* SDIO (non-combo) cards are not handled by mmc_block driver and do not
108108
* have accessible CID register which used by mmc_card_name() function.
109109
*/
110-
if (card->type == MMC_TYPE_SDIO)
110+
if (mmc_card_sdio(card))
111111
return 0;
112112

113113
retval = add_uevent_var(env, "MMC_NAME=%s", mmc_card_name(card));

drivers/mmc/core/sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static umode_t sd_std_is_visible(struct kobject *kobj, struct attribute *attr,
793793
attr == &dev_attr_info2.attr ||
794794
attr == &dev_attr_info3.attr ||
795795
attr == &dev_attr_info4.attr
796-
) && card->type != MMC_TYPE_SD_COMBO)
796+
) &&!mmc_card_sd_combo(card))
797797
return 0;
798798

799799
return attr->mode;

drivers/mmc/core/sdio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static int sdio_disable_4bit_bus(struct mmc_card *card)
335335
{
336336
int err;
337337

338-
if (card->type == MMC_TYPE_SDIO)
338+
if (mmc_card_sdio(card))
339339
goto out;
340340

341341
if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
@@ -360,7 +360,7 @@ static int sdio_enable_4bit_bus(struct mmc_card *card)
360360
err = sdio_enable_wide(card);
361361
if (err <= 0)
362362
return err;
363-
if (card->type == MMC_TYPE_SDIO)
363+
if (mmc_card_sdio(card))
364364
goto out;
365365

366366
if (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4) {
@@ -415,7 +415,7 @@ static int sdio_enable_hs(struct mmc_card *card)
415415
int ret;
416416

417417
ret = mmc_sdio_switch_hs(card, true);
418-
if (ret <= 0 || card->type == MMC_TYPE_SDIO)
418+
if (ret <= 0 || mmc_card_sdio(card))
419419
return ret;
420420

421421
ret = mmc_sd_switch_hs(card);
@@ -441,7 +441,7 @@ static unsigned mmc_sdio_get_max_clock(struct mmc_card *card)
441441
max_dtr = card->cis.max_dtr;
442442
}
443443

444-
if (card->type == MMC_TYPE_SD_COMBO)
444+
if (mmc_card_sd_combo(card))
445445
max_dtr = min(max_dtr, mmc_sd_get_max_clock(card));
446446

447447
return max_dtr;
@@ -689,15 +689,15 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
689689
mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) {
690690
card->type = MMC_TYPE_SD_COMBO;
691691

692-
if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO ||
692+
if (oldcard && (!mmc_card_sd_combo(oldcard) ||
693693
memcmp(card->raw_cid, oldcard->raw_cid, sizeof(card->raw_cid)) != 0)) {
694694
err = -ENOENT;
695695
goto mismatch;
696696
}
697697
} else {
698698
card->type = MMC_TYPE_SDIO;
699699

700-
if (oldcard && oldcard->type != MMC_TYPE_SDIO) {
700+
if (oldcard && !mmc_card_sdio(oldcard)) {
701701
err = -ENOENT;
702702
goto mismatch;
703703
}
@@ -754,7 +754,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
754754
/*
755755
* Read CSD, before selecting the card
756756
*/
757-
if (!oldcard && card->type == MMC_TYPE_SD_COMBO) {
757+
if (!oldcard && mmc_card_sd_combo(card)) {
758758
err = mmc_sd_get_csd(card);
759759
if (err)
760760
goto remove;
@@ -827,7 +827,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
827827

828828
mmc_fixup_device(card, sdio_fixup_methods);
829829

830-
if (card->type == MMC_TYPE_SD_COMBO) {
830+
if (mmc_card_sd_combo(card)) {
831831
err = mmc_sd_setup_card(host, card, oldcard != NULL);
832832
/* handle as SDIO-only card if memory init failed */
833833
if (err) {

include/linux/mmc/card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,5 +348,6 @@ bool mmc_card_is_blockaddr(struct mmc_card *card);
348348
#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
349349
#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
350350
#define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO)
351+
#define mmc_card_sd_combo(c) ((c)->type == MMC_TYPE_SD_COMBO)
351352

352353
#endif /* LINUX_MMC_CARD_H */

0 commit comments

Comments
 (0)