drivers: vendor_storage: add retry when emmc initialize failed
authorwlq <wlq@rock-chips.com>
Tue, 23 May 2017 11:32:42 +0000 (19:32 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 25 May 2017 02:00:26 +0000 (10:00 +0800)
Change-Id: I28202c5e3a4eb9ab58a430f40ff5e969fd110f54
Signed-off-by: Wu Liangqing <wlq@rock-chips.com>
drivers/soc/rockchip/sdmmc_vendor_storage.c

index a0b546226efbede2aeaa49cf655c712196956626..fa00a3dd0c3662d303cde6bd33e890d0ac0719f4 100644 (file)
@@ -99,7 +99,7 @@ static int emmc_vendor_storage_init(void)
 
        g_vendor = kmalloc(sizeof(*g_vendor), GFP_KERNEL | GFP_DMA);
        if (!g_vendor)
-               return -1;
+               return -ENOMEM;
 
        max_ver = 0;
        max_index = 0;
@@ -149,7 +149,7 @@ static int emmc_vendor_read(u32 id, void *pbuf, u32 size)
        u32 i;
 
        if (!g_vendor)
-               return -1;
+               return -ENOMEM;
 
        for (i = 0; i < g_vendor->item_num; i++) {
                if (g_vendor->item[i].id == id) {
@@ -560,11 +560,17 @@ static struct miscdevice vender_storage_dev = {
 
 static int vendor_init_thread(void *arg)
 {
-       int ret;
+       int ret, try_count = 5;
+
+       do {
+               ret = emmc_vendor_storage_init();
+               if (!ret) {
+                       break;
+               }
+               /* sleep 500ms wait emmc initialize completed */
+               msleep(500);
+       } while (try_count--);
 
-       /* sleep 500ms wait emmc initialize completed */
-       msleep(500);
-       ret = emmc_vendor_storage_init();
        if (!ret) {
                ret = misc_register(&vender_storage_dev);
                rk_vendor_register(emmc_vendor_read, emmc_vendor_write);