Skip to contentSkip to conversation

greybus: gb-beagleplay: Add error handling for gb_greybus_init

PATCH In review Wentao Liang 2 participants 2 messages Jan 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 greybus: gb-beagleplay: Add error handling for gb_greybus_init

Add error handling for the gb_greybus_init(bg) function call during the firmware reflash process to maintain consistency in error handling throughout the codebase. If initialization fails, log an error and return FW_UPLOAD_ERR_RW_ERROR.

Fixes 0cf7befa3ea2 ("greybus: gb-beagleplay: Add firmware upload API")
---
 drivers/greybus/gb-beagleplay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/greybus/gb-beagleplay.c +3 -1
index 473ac3f2d382..da31f1131afc 100644
@@ -912,7 +912,9 @@ static enum fw_upload_err cc1352_prepare(struct fw_upload *fw_upload,
 		cc1352_bootloader_reset(bg);
 		WRITE_ONCE(bg->flashing_mode, false);
 		msleep(200);
-		gb_greybus_init(bg);
+		if (gb_greybus_init(bg) < 0)
+			return dev_err_probe(&bg->sd->dev, FW_UPLOAD_ERR_RW_ERROR,
+					     "Failed to initialize greybus");
 		gb_beagleplay_start_svc(bg);
 		return FW_UPLOAD_ERR_FW_INVALID;
 	}
Signature · 1 line
2.42.0.windows.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Wentao Liang

Add error handling for the gb_greybus_init(bg) function call during the firmware reflash process to maintain consistency in error handling throughout the codebase. If initialization fails, log an error and return FW_UPLOAD_ERR_RW_ERROR.

Fixes 0cf7befa3ea2 ("greybus: gb-beagleplay: Add firmware upload API")
---
  drivers/greybus/gb-beagleplay.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/greybus/gb-beagleplay.c +0 -0
index 473ac3f2d382..da31f1131afc 100644

drivers/greybus/gb-beagleplay.c static enum fw_upload_err cc1352_prepare(struct fw_upload *fw_upload, · line 920

Quoted 10 lines
drivers/greybus/gb-beagleplay.c +3 -1
@@ -912,7 +912,9 @@ static enum fw_upload_err cc1352_prepare(struct fw_upload *fw_upload,
  		cc1352_bootloader_reset(bg);
  		WRITE_ONCE(bg->flashing_mode, false);
  		msleep(200);
-		gb_greybus_init(bg);
+		if (gb_greybus_init(bg) < 0)
+			return dev_err_probe(&bg->sd->dev, FW_UPLOAD_ERR_RW_ERROR,
+					     "Failed to initialize greybus");
  		gb_beagleplay_start_svc(bg);
  		return FW_UPLOAD_ERR_FW_INVALID;
  	}

Looks good to me.