summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2021-11-25 16:28:13 +0800
committerHung-Te Lin <hungte@chromium.org>2021-12-02 08:23:55 +0000
commit734a777d94b2f4b74cb635e6159f1440195642e9 (patch)
tree95080c2479fabfbbf0b387d6bb25a6632d1d261a /src/drivers
parent0c9b1deb63483a031d1014b615f1c207e1e250fe (diff)
downloadcoreboot-734a777d94b2f4b74cb635e6159f1440195642e9.tar.gz
coreboot-734a777d94b2f4b74cb635e6159f1440195642e9.tar.bz2
coreboot-734a777d94b2f4b74cb635e6159f1440195642e9.zip
drivers/analogix/anx7625: Utilize retry() macro
Utilize retry() macro in wait_aux_op_finish() and anx7625_init() to simplify the code. BUG=none TEST=emerge-asurada coreboot BRANCH=none Change-Id: I207e7075e8ac905efd5f201dd54658dedf531568 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/59659 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/analogix/anx7625/anx7625.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/drivers/analogix/anx7625/anx7625.c b/src/drivers/analogix/anx7625/anx7625.c
index 153266c52268..81f27d0db038 100644
--- a/src/drivers/analogix/anx7625/anx7625.c
+++ b/src/drivers/analogix/anx7625/anx7625.c
@@ -6,6 +6,7 @@
#include <edid.h>
#include <gpio.h>
#include <string.h>
+#include <types.h>
#include "anx7625.h"
@@ -133,20 +134,11 @@ static int anx7625_write_and(uint8_t bus, uint8_t saddr, uint8_t offset,
static int wait_aux_op_finish(uint8_t bus)
{
uint8_t val;
- int loop;
- int success = 0;
int ret;
- for (loop = 0; loop < 150; loop++) {
- mdelay(2);
- anx7625_reg_read(bus, RX_P0_ADDR, AP_AUX_CTRL_STATUS, &val);
- if (!(val & AP_AUX_CTRL_OP_EN)) {
- success = 1;
- break;
- }
- }
-
- if (!success) {
+ if (!retry(150,
+ (anx7625_reg_read(bus, RX_P0_ADDR, AP_AUX_CTRL_STATUS, &val),
+ !(val & AP_AUX_CTRL_OP_EN)), mdelay(2))) {
ANXERROR("Timed out waiting aux operation.\n");
return -1;
}
@@ -874,13 +866,8 @@ int anx7625_dp_get_edid(uint8_t bus, struct edid *out)
int anx7625_init(uint8_t bus)
{
int retry_hpd_change = 50;
- int retry_power_on = 3;
- while (--retry_power_on) {
- if (anx7625_power_on_init(bus) >= 0)
- break;
- }
- if (!retry_power_on) {
+ if (!retry(3, anx7625_power_on_init(bus) >= 0)) {
ANXERROR("Failed to power on.\n");
return -1;
}