phy: qcom-apq8064: fix possible timeout without check
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Wed, 16 Jul 2014 08:18:43 +0000 (09:18 +0100)
committerKishon Vijay Abraham I <kishon@ti.com>
Tue, 22 Jul 2014 07:16:12 +0000 (12:46 +0530)
This patch fixes a possible timeout in poll loop without actually
checking the register before return. In theory the there is a possibility
of loop being scheduled after a long lock/delay, which would then force
the loop to exit without actually checking the register.

Reported-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/phy/phy-qcom-apq8064-sata.c

index d7c01aa1f8d745e73a2e371fb08d4cd8c4601936..b3ef7d805765507260dc8735667216ef43706b97 100644 (file)
@@ -91,7 +91,7 @@ static int read_poll_timeout(void __iomem *addr, u32 mask)
                 usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50);
        } while (!time_after(jiffies, timeout));
 
-       return -ETIMEDOUT;
+       return (readl_relaxed(addr) & mask) ? 0 : -ETIMEDOUT;
 }
 
 static int qcom_apq8064_sata_phy_init(struct phy *generic_phy)