Skip to content

Commit 1f797ed

Browse files
Linus Walleijstorulf
authored andcommitted
mmc: block: Refactor mmc_blk_part_switch()
Instead of passing a struct mmc_blk_data * to mmc_blk_part_switch() let's pass the actual partition type we want to switch to. This is necessary in order not to have a block device with a backing mmc_blk_data and request queue and all for every hardware partition, such as RPMB. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 61fe0e2 commit 1f797ed

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/mmc/core/block.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ module_param(perdev_minors, int, 0444);
127127
MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
128128

129129
static inline int mmc_blk_part_switch(struct mmc_card *card,
130-
struct mmc_blk_data *md);
130+
unsigned int part_type);
131131

132132
static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
133133
{
@@ -488,7 +488,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
488488

489489
mrq.cmd = &cmd;
490490

491-
err = mmc_blk_part_switch(card, md);
491+
err = mmc_blk_part_switch(card, md->part_type);
492492
if (err)
493493
return err;
494494

@@ -768,29 +768,29 @@ static int mmc_blk_part_switch_post(struct mmc_card *card,
768768
}
769769

770770
static inline int mmc_blk_part_switch(struct mmc_card *card,
771-
struct mmc_blk_data *md)
771+
unsigned int part_type)
772772
{
773773
int ret = 0;
774774
struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev);
775775

776-
if (main_md->part_curr == md->part_type)
776+
if (main_md->part_curr == part_type)
777777
return 0;
778778

779779
if (mmc_card_mmc(card)) {
780780
u8 part_config = card->ext_csd.part_config;
781781

782-
ret = mmc_blk_part_switch_pre(card, md->part_type);
782+
ret = mmc_blk_part_switch_pre(card, part_type);
783783
if (ret)
784784
return ret;
785785

786786
part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK;
787-
part_config |= md->part_type;
787+
part_config |= part_type;
788788

789789
ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
790790
EXT_CSD_PART_CONFIG, part_config,
791791
card->ext_csd.part_time);
792792
if (ret) {
793-
mmc_blk_part_switch_post(card, md->part_type);
793+
mmc_blk_part_switch_post(card, part_type);
794794
return ret;
795795
}
796796

@@ -799,7 +799,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card,
799799
ret = mmc_blk_part_switch_post(card, main_md->part_curr);
800800
}
801801

802-
main_md->part_curr = md->part_type;
802+
main_md->part_curr = part_type;
803803
return ret;
804804
}
805805

@@ -1142,7 +1142,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
11421142
int part_err;
11431143

11441144
main_md->part_curr = main_md->part_type;
1145-
part_err = mmc_blk_part_switch(host->card, md);
1145+
part_err = mmc_blk_part_switch(host->card, md->part_type);
11461146
if (part_err) {
11471147
/*
11481148
* We have failed to get back into the correct
@@ -1181,6 +1181,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
11811181
struct mmc_queue_req *mq_rq;
11821182
struct mmc_card *card = mq->card;
11831183
struct mmc_blk_data *md = mq->blkdata;
1184+
struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev);
11841185
struct mmc_blk_ioc_data **idata;
11851186
u8 **ext_csd;
11861187
u32 status;
@@ -1199,7 +1200,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
11991200
}
12001201
/* Always switch back to main area after RPMB access */
12011202
if (md->area_type & MMC_BLK_DATA_AREA_RPMB)
1202-
mmc_blk_part_switch(card, dev_get_drvdata(&card->dev));
1203+
mmc_blk_part_switch(card, main_md->part_type);
12031204
break;
12041205
case MMC_DRV_OP_BOOT_WP:
12051206
ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
@@ -1959,7 +1960,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
19591960
/* claim host only for the first request */
19601961
mmc_get_card(card);
19611962

1962-
ret = mmc_blk_part_switch(card, md);
1963+
ret = mmc_blk_part_switch(card, md->part_type);
19631964
if (ret) {
19641965
if (req) {
19651966
blk_end_request_all(req, BLK_STS_IOERR);
@@ -2493,7 +2494,7 @@ static void mmc_blk_remove(struct mmc_card *card)
24932494
mmc_blk_remove_parts(card, md);
24942495
pm_runtime_get_sync(&card->dev);
24952496
mmc_claim_host(card->host);
2496-
mmc_blk_part_switch(card, md);
2497+
mmc_blk_part_switch(card, md->part_type);
24972498
mmc_release_host(card->host);
24982499
if (card->type != MMC_TYPE_SD_COMBO)
24992500
pm_runtime_disable(&card->dev);

0 commit comments

Comments
 (0)