drm/bridge: tc358767: Simplify tc_poll_timeout()
Implementation of tc_poll_timeout() is almost a 100% copy-and-paste of the code for regmap_read_poll_timeout(). Replace copied code with a call to the original. While at it change tc_poll_timeout to accept "struct tc_data *" instead of "struct regmap *" for brevity. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Andrey Gusakov <andrey.gusakov@cogentembedded.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Cory Tusar <cory.tusar@zii.aero> Cc: Chris Healy <cphealy@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190619052716.16831-2-andrew.smirnov@gmail.com
This commit is contained in:
parent
28a902e6d7
commit
93a105694f
@ -255,34 +255,21 @@ static inline struct tc_data *connector_to_tc(struct drm_connector *c)
|
|||||||
goto err; \
|
goto err; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static inline int tc_poll_timeout(struct regmap *map, unsigned int addr,
|
static inline int tc_poll_timeout(struct tc_data *tc, unsigned int addr,
|
||||||
unsigned int cond_mask,
|
unsigned int cond_mask,
|
||||||
unsigned int cond_value,
|
unsigned int cond_value,
|
||||||
unsigned long sleep_us, u64 timeout_us)
|
unsigned long sleep_us, u64 timeout_us)
|
||||||
{
|
{
|
||||||
ktime_t timeout = ktime_add_us(ktime_get(), timeout_us);
|
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
int ret;
|
|
||||||
|
|
||||||
for (;;) {
|
return regmap_read_poll_timeout(tc->regmap, addr, val,
|
||||||
ret = regmap_read(map, addr, &val);
|
(val & cond_mask) == cond_value,
|
||||||
if (ret)
|
sleep_us, timeout_us);
|
||||||
break;
|
|
||||||
if ((val & cond_mask) == cond_value)
|
|
||||||
break;
|
|
||||||
if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) {
|
|
||||||
ret = regmap_read(map, addr, &val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (sleep_us)
|
|
||||||
usleep_range((sleep_us >> 2) + 1, sleep_us);
|
|
||||||
}
|
|
||||||
return ret ?: (((val & cond_mask) == cond_value) ? 0 : -ETIMEDOUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tc_aux_wait_busy(struct tc_data *tc, unsigned int timeout_ms)
|
static int tc_aux_wait_busy(struct tc_data *tc, unsigned int timeout_ms)
|
||||||
{
|
{
|
||||||
return tc_poll_timeout(tc->regmap, DP0_AUXSTATUS, AUX_BUSY, 0,
|
return tc_poll_timeout(tc, DP0_AUXSTATUS, AUX_BUSY, 0,
|
||||||
1000, 1000 * timeout_ms);
|
1000, 1000 * timeout_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,8 +576,7 @@ static int tc_aux_link_setup(struct tc_data *tc)
|
|||||||
tc_write(DP1_PLLCTRL, PLLUPDATE | PLLEN);
|
tc_write(DP1_PLLCTRL, PLLUPDATE | PLLEN);
|
||||||
tc_wait_pll_lock(tc);
|
tc_wait_pll_lock(tc);
|
||||||
|
|
||||||
ret = tc_poll_timeout(tc->regmap, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1,
|
ret = tc_poll_timeout(tc, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1, 1000);
|
||||||
1000);
|
|
||||||
if (ret == -ETIMEDOUT) {
|
if (ret == -ETIMEDOUT) {
|
||||||
dev_err(tc->dev, "Timeout waiting for PHY to become ready");
|
dev_err(tc->dev, "Timeout waiting for PHY to become ready");
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user