Skip to content

Commit a066f90

Browse files
kmaincentkuba-moo
authored andcommitted
firmware_loader: Expand Firmware upload error codes with firmware invalid error
No error code are available to signal an invalid firmware content. Drivers that can check the firmware content validity can not return this specific failure to the user-space Expand the firmware error code with an additional code: - "firmware invalid" code which can be used when the provided firmware is invalid Sync lib/test_firmware.c file accordingly. Acked-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20231122-feature_firmware_error_code-v3-1-04ec753afb71@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b85ea95 commit a066f90

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

drivers/base/firmware_loader/sysfs_upload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static const char * const fw_upload_err_str[] = {
2727
[FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size",
2828
[FW_UPLOAD_ERR_RW_ERROR] = "read-write-error",
2929
[FW_UPLOAD_ERR_WEAROUT] = "flash-wearout",
30+
[FW_UPLOAD_ERR_FW_INVALID] = "firmware-invalid",
3031
};
3132

3233
static const char *fw_upload_progress(struct device *dev,

include/linux/firmware.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct firmware {
2727
* @FW_UPLOAD_ERR_INVALID_SIZE: invalid firmware image size
2828
* @FW_UPLOAD_ERR_RW_ERROR: read or write to HW failed, see kernel log
2929
* @FW_UPLOAD_ERR_WEAROUT: FLASH device is approaching wear-out, wait & retry
30+
* @FW_UPLOAD_ERR_FW_INVALID: invalid firmware file
3031
* @FW_UPLOAD_ERR_MAX: Maximum error code marker
3132
*/
3233
enum fw_upload_err {
@@ -38,6 +39,7 @@ enum fw_upload_err {
3839
FW_UPLOAD_ERR_INVALID_SIZE,
3940
FW_UPLOAD_ERR_RW_ERROR,
4041
FW_UPLOAD_ERR_WEAROUT,
42+
FW_UPLOAD_ERR_FW_INVALID,
4143
FW_UPLOAD_ERR_MAX
4244
};
4345

lib/test_firmware.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@ static const char * const fw_upload_err_str[] = {
11321132
[FW_UPLOAD_ERR_INVALID_SIZE] = "invalid-file-size",
11331133
[FW_UPLOAD_ERR_RW_ERROR] = "read-write-error",
11341134
[FW_UPLOAD_ERR_WEAROUT] = "flash-wearout",
1135+
[FW_UPLOAD_ERR_FW_INVALID] = "firmware-invalid",
11351136
};
11361137

11371138
static void upload_err_inject_error(struct test_firmware_upload *tst,

0 commit comments

Comments
 (0)