mmc: dw_mmc: exynos: fix the finding clock sample value
[platform/kernel/linux-rpi.git] / drivers / mmc / host / dw_mmc-exynos.c
index 0c75810..1f8a3c0 100644 (file)
@@ -464,6 +464,18 @@ static s8 dw_mci_exynos_get_best_clksmpl(u8 candiates)
                }
        }
 
+       /*
+        * If there is no cadiates value, then it needs to return -EIO.
+        * If there are candiates values and don't find bset clk sample value,
+        * then use a first candiates clock sample value.
+        */
+       for (i = 0; i < iter; i++) {
+               __c = ror8(candiates, i);
+               if ((__c & 0x1) == 0x1) {
+                       loc = i;
+                       goto out;
+               }
+       }
 out:
        return loc;
 }
@@ -494,6 +506,8 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
                priv->tuned_sample = found;
        } else {
                ret = -EIO;
+               dev_warn(&mmc->class_dev,
+                       "There is no candiates value about clksmpl!\n");
        }
 
        return ret;