Commit 33fe4d97 authored by Matthias Schiffer's avatar Matthias Schiffer Committed by Dmitry Torokhov

Input: synaptics-rmi4 - introduce rmi_f34v7_check_command_status() helper

Add a function that waits for the last command to complete and checks
the status, and use it where appropriate. This prepares for the subsequent
fix of the completion condition in rmi_f34_attention(), which would
previously lead to a timeout instead of a more detailed error message
whenever a command was unsuccessful with v7/v8 bootloaders.
Signed-off-by: default avatarMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20220608124808.51402-3-matthias.schiffer@ew.tq-group.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 28f677e9
...@@ -72,6 +72,24 @@ static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms) ...@@ -72,6 +72,24 @@ static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms)
return 0; return 0;
} }
static int rmi_f34v7_check_command_status(struct f34_data *f34, int timeout_ms)
{
int ret;
ret = rmi_f34v7_wait_for_idle(f34, timeout_ms);
if (ret < 0)
return ret;
ret = rmi_f34v7_read_flash_status(f34);
if (ret < 0)
return ret;
if (f34->v7.flash_status != 0x00)
return -EIO;
return 0;
}
static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34, static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34,
u8 cmd) u8 cmd)
{ {
...@@ -318,6 +336,10 @@ static int rmi_f34v7_read_partition_table(struct f34_data *f34) ...@@ -318,6 +336,10 @@ static int rmi_f34v7_read_partition_table(struct f34_data *f34)
return ret; return ret;
} }
/*
* rmi_f34v7_check_command_status() can't be used here, as this
* function is called before IRQs are available
*/
timeout = msecs_to_jiffies(F34_WRITE_WAIT_MS); timeout = msecs_to_jiffies(F34_WRITE_WAIT_MS);
while (time_before(jiffies, timeout)) { while (time_before(jiffies, timeout)) {
usleep_range(5000, 6000); usleep_range(5000, 6000);
...@@ -674,7 +696,7 @@ static int rmi_f34v7_erase_config(struct f34_data *f34) ...@@ -674,7 +696,7 @@ static int rmi_f34v7_erase_config(struct f34_data *f34)
break; break;
} }
ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_ERASE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -693,7 +715,7 @@ static int rmi_f34v7_erase_guest_code(struct f34_data *f34) ...@@ -693,7 +715,7 @@ static int rmi_f34v7_erase_guest_code(struct f34_data *f34)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_ERASE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -712,7 +734,7 @@ static int rmi_f34v7_erase_all(struct f34_data *f34) ...@@ -712,7 +734,7 @@ static int rmi_f34v7_erase_all(struct f34_data *f34)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_ERASE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -787,7 +809,7 @@ static int rmi_f34v7_read_blocks(struct f34_data *f34, ...@@ -787,7 +809,7 @@ static int rmi_f34v7_read_blocks(struct f34_data *f34,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -871,7 +893,7 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34, ...@@ -871,7 +893,7 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
return ret; return ret;
} }
ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -944,7 +966,7 @@ static int rmi_f34v7_write_flash_config(struct f34_data *f34) ...@@ -944,7 +966,7 @@ static int rmi_f34v7_write_flash_config(struct f34_data *f34)
rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
"%s: Erase flash config command written\n", __func__); "%s: Erase flash config command written\n", __func__);
ret = rmi_f34v7_wait_for_idle(f34, F34_WRITE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_WRITE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1297,7 +1319,7 @@ static int rmi_f34v7_enter_flash_prog(struct f34_data *f34) ...@@ -1297,7 +1319,7 @@ static int rmi_f34v7_enter_flash_prog(struct f34_data *f34)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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