From d0a66796aad3d2637f76700908d096fe9f6e424d Mon Sep 17 00:00:00 2001 From: kfx Date: Sat, 2 Nov 2013 14:45:25 +0800 Subject: [PATCH] emmc: fixed bug 'failed to check sd card partition' BUG: if CONFIG_EMMC_RK is defined but storage memory is FLASH, it will fail to check sd card partition emmc failed to load ==> sdcard's disk->first_minor = 0 ==> sdcard's msdos_partition return 0 WARN: if disk's flags: 2(include/linux/genhd.h) is defined in new kernel version, it maybe a problem! --- drivers/mmc/card/block.c | 4 ++++ fs/partitions/msdos.c | 4 ++-- fs/partitions/mtdpart.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index d2dfeaa9fe2c..87b361f94b4b 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -1756,6 +1756,10 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, md->disk->driverfs_dev = parent; set_disk_ro(md->disk, md->read_only || default_ro); md->disk->flags = GENHD_FL_EXT_DEVT; +#ifdef CONFIG_EMMC_RK + if(HOST_IS_EMMC(card->host)) + md->disk->flags |= 2; /* 2 is unused flags in 'include/linux/genhd.h' */ +#endif /* * As discussed on lkml, GENHD_FL_REMOVABLE should: diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c index 8b098c1b1d2b..649d27be8af8 100644 --- a/fs/partitions/msdos.c +++ b/fs/partitions/msdos.c @@ -441,8 +441,8 @@ int msdos_partition(struct parsed_partitions *state) struct fat_boot_sector *fb; int slot; #ifdef CONFIG_EMMC_RK - //if card is emmc, msdos_partition return false - if(state->bdev->bd_disk->major == MMC_BLOCK_MAJOR &&state->bdev->bd_disk->first_minor == 0) + //if card is emmc(flag:2 is set in 'drivers/mmc/card/block.c'), return false + if(state->bdev->bd_disk->flags & 2) return 0; #endif diff --git a/fs/partitions/mtdpart.c b/fs/partitions/mtdpart.c index b4b353ac7b7b..c45c31ac05cf 100644 --- a/fs/partitions/mtdpart.c +++ b/fs/partitions/mtdpart.c @@ -337,7 +337,7 @@ int mtdpart_partition(struct parsed_partitions *state) if(n < SECTOR_1G) return 0; - if (state->bdev->bd_disk->major != MMC_BLOCK_MAJOR || state->bdev->bd_disk->first_minor != 0) + if (!(state->bdev->bd_disk->flags & 2)) return 0; cmdline = strstr(saved_command_line, "mtdparts=") + 9; -- 2.34.1