wacom-usb: prefix errors that occur when writing to the device

Make it easier to locate errors that occur when writing to the device.
This commit is contained in:
Aaron Skomra 2022-10-26 19:11:50 -07:00 committed by Mario Limonciello
parent c647d0d0f6
commit 189686368a
4 changed files with 57 additions and 19 deletions

View File

@ -111,14 +111,18 @@ fu_wac_module_bluetooth_id6_write_firmware(FuDevice *device,
/* get default image */ /* get default image */
fw = fu_firmware_get_bytes(firmware, error); fw = fu_firmware_get_bytes(firmware, error);
if (fw == NULL) if (fw == NULL) {
g_prefix_error(error, "wacom bluetooth-id6 module failed to get bytes: ");
return FALSE; return FALSE;
}
/* build each data packet */ /* build each data packet */
data = g_bytes_get_data(fw, &len); data = g_bytes_get_data(fw, &len);
blocks = fu_wac_module_bluetooth_id6_parse_blocks(data, len, error); blocks = fu_wac_module_bluetooth_id6_parse_blocks(data, len, error);
if (blocks == NULL) if (blocks == NULL) {
g_prefix_error(error, "wacom bluetooth-id6 module failed to parse blocks: ");
return FALSE; return FALSE;
}
/* start, which will erase the module */ /* start, which will erase the module */
if (!fu_wac_module_set_feature(self, if (!fu_wac_module_set_feature(self,
@ -126,8 +130,10 @@ fu_wac_module_bluetooth_id6_write_firmware(FuDevice *device,
blob_start, blob_start,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_ERASE_TIMEOUT, FU_WAC_MODULE_ERASE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom bluetooth-id6 module failed to erase: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* data */ /* data */
@ -148,8 +154,10 @@ fu_wac_module_bluetooth_id6_write_firmware(FuDevice *device,
blob_chunk, blob_chunk,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_WRITE_TIMEOUT, FU_WAC_MODULE_WRITE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom bluetooth-id6 module failed to write: ");
return FALSE; return FALSE;
}
/* update progress */ /* update progress */
fu_progress_set_percentage_full(fu_progress_get_child(progress), fu_progress_set_percentage_full(fu_progress_get_child(progress),
@ -164,8 +172,10 @@ fu_wac_module_bluetooth_id6_write_firmware(FuDevice *device,
NULL, NULL,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_COMMIT_TIMEOUT, FU_WAC_MODULE_COMMIT_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom bluetooth-id6 module failed to end: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* success */ /* success */

View File

@ -136,14 +136,18 @@ fu_wac_module_bluetooth_write_firmware(FuDevice *device,
/* get default image */ /* get default image */
fw = fu_firmware_get_bytes(firmware, error); fw = fu_firmware_get_bytes(firmware, error);
if (fw == NULL) if (fw == NULL) {
g_prefix_error(error, "wacom bluetooth module failed to get bytes: ");
return FALSE; return FALSE;
}
/* build each data packet */ /* build each data packet */
data = g_bytes_get_data(fw, &len); data = g_bytes_get_data(fw, &len);
blocks = fu_wac_module_bluetooth_parse_blocks(data, len, TRUE, error); blocks = fu_wac_module_bluetooth_parse_blocks(data, len, TRUE, error);
if (blocks == NULL) if (blocks == NULL) {
g_prefix_error(error, "wacom bluetooth module failed to parse: ");
return FALSE; return FALSE;
}
/* start, which will erase the module */ /* start, which will erase the module */
if (!fu_wac_module_set_feature(self, if (!fu_wac_module_set_feature(self,
@ -151,8 +155,10 @@ fu_wac_module_bluetooth_write_firmware(FuDevice *device,
blob_start, blob_start,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_ERASE_TIMEOUT, FU_WAC_MODULE_ERASE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom bluetooth module failed to erase: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* data */ /* data */
@ -173,8 +179,10 @@ fu_wac_module_bluetooth_write_firmware(FuDevice *device,
blob_chunk, blob_chunk,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_WRITE_TIMEOUT, FU_WAC_MODULE_WRITE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom bluetooth module failed to write: ");
return FALSE; return FALSE;
}
/* update progress */ /* update progress */
fu_progress_set_percentage_full(fu_progress_get_child(progress), fu_progress_set_percentage_full(fu_progress_get_child(progress),
@ -189,8 +197,10 @@ fu_wac_module_bluetooth_write_firmware(FuDevice *device,
NULL, NULL,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_FINISH_TIMEOUT, FU_WAC_MODULE_FINISH_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom bluetooth module failed to end: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* success */ /* success */

View File

@ -84,14 +84,18 @@ fu_wac_module_scaler_write_firmware(FuDevice *device,
/* get default image */ /* get default image */
fw = fu_firmware_get_bytes(firmware, error); fw = fu_firmware_get_bytes(firmware, error);
if (fw == NULL) if (fw == NULL) {
g_prefix_error(error, "wacom scaler module failed to get bytes: ");
return FALSE; return FALSE;
}
/* build each data packet */ /* build each data packet */
data = g_bytes_get_data(fw, &len); data = g_bytes_get_data(fw, &len);
blocks = fu_wac_module_scaler_parse_blocks(data, len, error); blocks = fu_wac_module_scaler_parse_blocks(data, len, error);
if (blocks == NULL) if (blocks == NULL) {
g_prefix_error(error, "wacom scaler module failed to parse blocks: ");
return FALSE; return FALSE;
}
/* start, which will erase the module */ /* start, which will erase the module */
if (!fu_wac_module_set_feature(self, if (!fu_wac_module_set_feature(self,
@ -99,8 +103,10 @@ fu_wac_module_scaler_write_firmware(FuDevice *device,
blob_start, blob_start,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_ERASE_TIMEOUT, FU_WAC_MODULE_ERASE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom scaler module failed to erase: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
@ -122,8 +128,10 @@ fu_wac_module_scaler_write_firmware(FuDevice *device,
blob_chunk, blob_chunk,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_WRITE_TIMEOUT, FU_WAC_MODULE_WRITE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom scaler module failed to write: ");
return FALSE; return FALSE;
}
/* update progress */ /* update progress */
fu_progress_set_percentage_full(fu_progress_get_child(progress), fu_progress_set_percentage_full(fu_progress_get_child(progress),
i + 1, i + 1,
@ -137,8 +145,10 @@ fu_wac_module_scaler_write_firmware(FuDevice *device,
NULL, NULL,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_COMMIT_TIMEOUT, FU_WAC_MODULE_COMMIT_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom scaler module failed to end: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* success */ /* success */

View File

@ -41,8 +41,10 @@ fu_wac_module_touch_write_firmware(FuDevice *device,
/* build each data packet */ /* build each data packet */
fw = fu_firmware_get_bytes(firmware, error); fw = fu_firmware_get_bytes(firmware, error);
if (fw == NULL) if (fw == NULL) {
g_prefix_error(error, "wacom touch module failed to get bytes: ");
return FALSE; return FALSE;
}
chunks = fu_chunk_array_new_from_bytes(fw, chunks = fu_chunk_array_new_from_bytes(fw,
fu_firmware_get_addr(firmware), fu_firmware_get_addr(firmware),
0x0, /* page_sz */ 0x0, /* page_sz */
@ -54,8 +56,10 @@ fu_wac_module_touch_write_firmware(FuDevice *device,
NULL, NULL,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_ERASE_TIMEOUT, FU_WAC_MODULE_ERASE_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom touch module failed to erase: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* data */ /* data */
@ -77,8 +81,10 @@ fu_wac_module_touch_write_firmware(FuDevice *device,
fu_chunk_get_data_sz(chk), fu_chunk_get_data_sz(chk),
0x0, /* src */ 0x0, /* src */
fu_chunk_get_data_sz(chk), fu_chunk_get_data_sz(chk),
error)) error)) {
g_prefix_error(error, "wacom touch module failed to memcpy: ");
return FALSE; return FALSE;
}
blob_chunk = g_bytes_new(buf, sizeof(buf)); blob_chunk = g_bytes_new(buf, sizeof(buf));
if (!fu_wac_module_set_feature(self, if (!fu_wac_module_set_feature(self,
FU_WAC_MODULE_COMMAND_DATA, FU_WAC_MODULE_COMMAND_DATA,
@ -103,8 +109,10 @@ fu_wac_module_touch_write_firmware(FuDevice *device,
NULL, NULL,
fu_progress_get_child(progress), fu_progress_get_child(progress),
FU_WAC_MODULE_FINISH_TIMEOUT, FU_WAC_MODULE_FINISH_TIMEOUT,
error)) error)) {
g_prefix_error(error, "wacom touch module failed to end: ");
return FALSE; return FALSE;
}
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* success */ /* success */