Commit be280fdd authored by Dan Carpenter's avatar Dan Carpenter Committed by Thomas Zimmermann

drm/ast: astdp: fix loop timeout check

This code has an issue because it loops until "i" is set to UINT_MAX but
the test for failure assumes that "i" is set to zero.  The result is that
it will only print an error message if we succeed on the very last try.
Reformat the loop to count forwards instead of backwards.

Fixes: 22814751 ("drm/ast: astdp: Perform link training during atomic_enable")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/1ba8da25-2d09-4924-a4ff-c0714bfbb192@stanley.mountain
parent b7ecc44a
...@@ -146,18 +146,19 @@ void ast_dp_power_on_off(struct drm_device *dev, bool on) ...@@ -146,18 +146,19 @@ void ast_dp_power_on_off(struct drm_device *dev, bool on)
void ast_dp_link_training(struct ast_device *ast) void ast_dp_link_training(struct ast_device *ast)
{ {
struct drm_device *dev = &ast->base; struct drm_device *dev = &ast->base;
unsigned int i = 10; int i;
while (i--) { for (i = 0; i < 10; i++) {
u8 vgacrdc = ast_get_index_reg(ast, AST_IO_VGACRI, 0xdc); u8 vgacrdc;
if (vgacrdc & AST_IO_VGACRDC_LINK_SUCCESS)
break;
if (i) if (i)
msleep(100); msleep(100);
vgacrdc = ast_get_index_reg(ast, AST_IO_VGACRI, 0xdc);
if (vgacrdc & AST_IO_VGACRDC_LINK_SUCCESS)
return;
} }
if (!i) drm_err(dev, "Link training failed\n");
drm_err(dev, "Link training failed\n");
} }
void ast_dp_set_on_off(struct drm_device *dev, bool on) void ast_dp_set_on_off(struct drm_device *dev, bool on)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment