sometimes mmc is not formatted when try to format 54/15154/1
authorjy910.yun <jy910.yun@samsung.com>
Wed, 29 May 2013 09:23:58 +0000 (18:23 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Thu, 16 Jan 2014 13:37:25 +0000 (14:37 +0100)
Change-Id: I3d454ce54bd9398dc8c889b09966844f08fdea58
Signed-off-by: jy910.yun <jy910.yun@samsung.com>
src/mmc/mmc-handler.c

index cdbe35c..f95813d 100644 (file)
@@ -360,14 +360,27 @@ static int mmc_format(int blknum)
 
        snprintf(dev_mmcblk, sizeof(dev_mmcblk), "%s%d", MMC_DEV, blknum);
        snprintf(dev_mmcblkp, sizeof(dev_mmcblkp), "%sp1", dev_mmcblk);
+
+       /* in case of no partition */
        if (access(dev_mmcblkp, R_OK) < 0) {
                _I("%s is not valid, create the primary partition", dev_mmcblkp);
+
+               /* format default dev partition */
+               r = mmc_format_exec(dev_mmcblk);
+               if (r != 0) {
+                       _E("format_mmc(%s) fail", dev_mmcblk);
+                       return r;
+               }
+
+               /* create partition */
                r = create_partition(dev_mmcblk);
                if (r != 0) {
                        _E("create_partition failed");
                        return r;
                }
        }
+
+       /* format first partition */
        r = mmc_format_exec(dev_mmcblkp);
        if (r != 0) {
                _E("format_mmc fail");
@@ -530,7 +543,6 @@ int ss_mmc_removed(void)
 int ss_mmc_inserted(void)
 {
        int mmc_status;
-       int ret;
 
        if (mmc_disabled) {
                _I("mmc is blocked!");
@@ -546,9 +558,7 @@ int ss_mmc_inserted(void)
                return 0;
        }
 
-       ret = mmc_mount();
-
-       return ret;
+       return mmc_mount();
 }
 
 static int ss_mmc_unmounted(int argc, char **argv)