summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-04-16 11:16:52 +0200
committerNico Huber <nico.h@gmx.de>2021-04-18 17:07:26 +0000
commitb4a63e9616a4696174ba7102a38483b0f1738601 (patch)
treec60cc7c196863f5b35a4196f1d78710d643544f3
parent1ce155d5d547a1d152ad28c7609b4634f28f6b94 (diff)
downloadflashrom-b4a63e9616a4696174ba7102a38483b0f1738601.tar.gz
flashrom-b4a63e9616a4696174ba7102a38483b0f1738601.tar.bz2
flashrom-b4a63e9616a4696174ba7102a38483b0f1738601.zip
ene_lpc.c: Clean up cosmetics
Reflow long lines, drop unnecessary parentheses, add spaces after `if` and `while` keywords and add braces to a single-statement `else if` block that follows a multi-statement `if` block. TEST=Build with `make distclean && make VERSION=none -j` with and without this patch, the flashrom executable does not change. Change-Id: Iaa5277b12fca192c46c11f5e0f375dc43d06bf5c Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/52413 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--ene_lpc.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/ene_lpc.c b/ene_lpc.c
index 56d65807b..993ef4d10 100644
--- a/ene_lpc.c
+++ b/ene_lpc.c
@@ -166,7 +166,7 @@ static void ec_command(const ene_chip_t *chip, uint8_t cmd, uint8_t data)
gettimeofday(&begin, NULL);
while (INB(chip->port_ec_command) & MASK_INPUT_BUFFER_FULL) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >= EC_COMMAND_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_COMMAND_TIMEOUT) {
msg_pdbg("%s: buf not empty\n", __func__);
return;
}
@@ -178,11 +178,9 @@ static void ec_command(const ene_chip_t *chip, uint8_t cmd, uint8_t data)
if (chip->chip_id == ENE_KB932) {
/* Spin wait for EC input buffer empty */
gettimeofday(&begin, NULL);
- while (INB(chip->port_ec_command) &
- MASK_INPUT_BUFFER_FULL) {
+ while (INB(chip->port_ec_command) & MASK_INPUT_BUFFER_FULL) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >=
- EC_COMMAND_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_COMMAND_TIMEOUT) {
msg_pdbg("%s: buf not empty\n", __func__);
return;
}
@@ -295,9 +293,9 @@ static int ene_spi_wait(const ene_chip_t *chip)
struct timeval begin, now;
gettimeofday(&begin, NULL);
- while(ene_read(chip, REG_SPI_CONFIG) & CFG_STATUS) {
+ while (ene_read(chip, REG_SPI_CONFIG) & CFG_STATUS) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >= EC_COMMAND_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_COMMAND_TIMEOUT) {
msg_pdbg("%s: spi busy\n", __func__);
return 1;
}
@@ -318,17 +316,14 @@ static int ene_pause_ec(ene_lpc_data_t *ctx_data)
gettimeofday(&begin, NULL);
/* Spin wait for EC ready */
- while (ene_read(chip, chip->ec_status_buf) !=
- chip->ec_is_pausing) {
+ while (ene_read(chip, chip->ec_status_buf) != chip->ec_is_pausing) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >=
- EC_COMMAND_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_COMMAND_TIMEOUT) {
msg_pdbg("%s: unable to pause ec\n", __func__);
return -1;
}
}
-
gettimeofday(&ctx_data->pause_begin, NULL);
ctx_data->ec_state = EC_STATE_IDLE;
return 0;
@@ -346,11 +341,9 @@ static int ene_resume_ec(ene_lpc_data_t *ctx_data)
ene_write(chip, REG_EC_EXTCMD, 0xff);
gettimeofday(&begin, NULL);
- while (ene_read(chip, chip->ec_status_buf) !=
- chip->ec_is_running) {
+ while (ene_read(chip, chip->ec_status_buf) != chip->ec_is_running) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >=
- EC_COMMAND_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_COMMAND_TIMEOUT) {
msg_pdbg("%s: unable to resume ec\n", __func__);
return -1;
}
@@ -364,11 +357,9 @@ static int ene_pause_timeout_check(ene_lpc_data_t *ctx_data)
{
struct timeval pause_now;
gettimeofday(&pause_now, NULL);
- if ((pause_now.tv_sec - ctx_data->pause_begin.tv_sec) >=
- EC_PAUSE_TIMEOUT) {
- if(ene_resume_ec(ctx_data) == 0)
+ if (pause_now.tv_sec - ctx_data->pause_begin.tv_sec >= EC_PAUSE_TIMEOUT) {
+ if (ene_resume_ec(ctx_data) == 0)
ene_pause_ec(ctx_data);
-
}
return 0;
}
@@ -385,11 +376,9 @@ static int ene_reset_ec(ene_lpc_data_t *ctx_data)
ec_command(chip, chip->ec_reset_cmd, chip->ec_reset_data);
/* Spin wait for EC ready */
- while (ene_read(chip, chip->ec_status_buf) !=
- chip->ec_is_stopping) {
+ while (ene_read(chip, chip->ec_status_buf) != chip->ec_is_stopping) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >=
- EC_COMMAND_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_COMMAND_TIMEOUT) {
msg_pdbg("%s: unable to reset ec\n", __func__);
return -1;
}
@@ -440,9 +429,9 @@ static int ene_spi_send_command(const struct flashctx *flash,
ctx_data->ec_state = EC_STATE_IDLE;
return 1;
}
- }
- else if(chip->chip_id == ENE_KB94X && ctx_data->ec_state == EC_STATE_IDLE)
+ } else if (chip->chip_id == ENE_KB94X && ctx_data->ec_state == EC_STATE_IDLE) {
ene_pause_timeout_check(ctx_data);
+ }
ene_spi_start(chip);
@@ -487,19 +476,16 @@ static int ene_leave_flash_mode(void *data)
gettimeofday(&begin, NULL);
/* EC restart */
- while (ene_read(chip, chip->ec_status_buf) !=
- chip->ec_is_running) {
+ while (ene_read(chip, chip->ec_status_buf) != chip->ec_is_running) {
gettimeofday(&now, NULL);
- if ((now.tv_sec - begin.tv_sec) >=
- EC_RESTART_TIMEOUT) {
+ if (now.tv_sec - begin.tv_sec >= EC_RESTART_TIMEOUT) {
msg_pdbg("%s: ec restart busy\n", __func__);
rv = 1;
goto exit;
}
}
msg_pdbg("%s: send ec restart\n", __func__);
- ec_command(chip, chip->ec_restart_cmd,
- chip->ec_restart_data);
+ ec_command(chip, chip->ec_restart_cmd, chip->ec_restart_data);
ctx_data->ec_state = EC_STATE_NORMAL;
rv = 0;