emmc: fixed bug 'failed to check sd card partition'
authorkfx <kfx@rock-chips.com>
Sat, 2 Nov 2013 06:45:25 +0000 (14:45 +0800)
committerkfx <kfx@rock-chips.com>
Sat, 2 Nov 2013 06:45:25 +0000 (14:45 +0800)
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
fs/partitions/msdos.c
fs/partitions/mtdpart.c

index d2dfeaa9fe2c4753c0097fdf442fee69dbed0943..87b361f94b4be46b7cc68219f4dcd3b967ac77e1 100644 (file)
@@ -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:
index 8b098c1b1d2bdd56006950fa8d08e2c611f2e30a..649d27be8af883ccb7eebd995579e156b58d14cc 100644 (file)
@@ -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
 
index b4b353ac7b7b64f7071a3125a8fc8ed8b230f2d7..c45c31ac05cf356ee7d7d1ad0acd3d4083db11f2 100644 (file)
@@ -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;