Commit b2abeaa1 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: firmware: s/_LEN/_SIZE

Alex Elder pointed out that the macros also count the trailing NULL
('\0') character and so it should be using SIZE instead of LEN.

This patch makes that change.
Reported-by: default avatarAlex Elder <alex.elder@linaro.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 769cb837
...@@ -104,20 +104,20 @@ Following are the IOCTLs and their data structures available to the user: ...@@ -104,20 +104,20 @@ Following are the IOCTLs and their data structures available to the user:
struct fw_mgmt_ioc_get_intf_version { struct fw_mgmt_ioc_get_intf_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major; __u16 major;
__u16 minor; __u16 minor;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct fw_mgmt_ioc_get_backend_version { struct fw_mgmt_ioc_get_backend_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major; __u16 major;
__u16 minor; __u16 minor;
__u8 status; __u8 status;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct fw_mgmt_ioc_intf_load_and_validate { struct fw_mgmt_ioc_intf_load_and_validate {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
__u8 load_method; __u8 load_method;
__u8 status; __u8 status;
__u16 major; __u16 major;
...@@ -125,7 +125,7 @@ struct fw_mgmt_ioc_intf_load_and_validate { ...@@ -125,7 +125,7 @@ struct fw_mgmt_ioc_intf_load_and_validate {
} __packed; } __packed;
struct fw_mgmt_ioc_backend_fw_update { struct fw_mgmt_ioc_backend_fw_update {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
__u8 status; __u8 status;
} __packed; } __packed;
......
...@@ -108,7 +108,7 @@ static int update_intf_firmware(int fd) ...@@ -108,7 +108,7 @@ static int update_intf_firmware(int fd)
intf_load.minor = 0; intf_load.minor = 0;
strncpy((char *)&intf_load.firmware_tag, firmware_tag, strncpy((char *)&intf_load.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN); GB_FIRMWARE_U_TAG_MAX_SIZE);
ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load); ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load);
if (ret < 0) { if (ret < 0) {
...@@ -146,7 +146,7 @@ static int update_backend_firmware(int fd) ...@@ -146,7 +146,7 @@ static int update_backend_firmware(int fd)
printf("Getting Backend Firmware Version\n"); printf("Getting Backend Firmware Version\n");
strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag, strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN); GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_version: retry_fw_version:
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info); ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info);
...@@ -174,7 +174,7 @@ static int update_backend_firmware(int fd) ...@@ -174,7 +174,7 @@ static int update_backend_firmware(int fd)
printf("Updating Backend Firmware\n"); printf("Updating Backend Firmware\n");
strncpy((char *)&backend_update.firmware_tag, firmware_tag, strncpy((char *)&backend_update.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN); GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_update: retry_fw_update:
backend_update.status = 0; backend_update.status = 0;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define FW_NAME_PREFIX "gmp_" #define FW_NAME_PREFIX "gmp_"
/* Length of the string in format: "FW_NAME_PREFIX""%08x_%08x_%08x_%08x_%s.tftf" */ /* Length of the string in format: "FW_NAME_PREFIX""%08x_%08x_%08x_%08x_%s.tftf" */
#define FW_NAME_LEN 56 #define FW_NAME_SIZE 56
/* Firmware Management Protocol specific functions */ /* Firmware Management Protocol specific functions */
int fw_mgmt_init(void); int fw_mgmt_init(void);
......
...@@ -23,7 +23,7 @@ struct fw_request { ...@@ -23,7 +23,7 @@ struct fw_request {
u8 firmware_id; u8 firmware_id;
bool disabled; bool disabled;
bool timedout; bool timedout;
char name[FW_NAME_LEN]; char name[FW_NAME_SIZE];
const struct firmware *fw; const struct firmware *fw;
struct list_head node; struct list_head node;
...@@ -239,7 +239,7 @@ static int fw_download_find_firmware(struct gb_operation *op) ...@@ -239,7 +239,7 @@ static int fw_download_find_firmware(struct gb_operation *op)
tag = (const char *)request->firmware_tag; tag = (const char *)request->firmware_tag;
/* firmware_tag should be null-terminated */ /* firmware_tag should be null-terminated */
if (strnlen(tag, GB_FIRMWARE_TAG_MAX_LEN) == GB_FIRMWARE_TAG_MAX_LEN) { if (strnlen(tag, GB_FIRMWARE_TAG_MAX_SIZE) == GB_FIRMWARE_TAG_MAX_SIZE) {
dev_err(fw_download->parent, dev_err(fw_download->parent,
"firmware-tag is not null-terminated\n"); "firmware-tag is not null-terminated\n");
return -EINVAL; return -EINVAL;
......
...@@ -122,16 +122,16 @@ static int fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt, ...@@ -122,16 +122,16 @@ static int fw_mgmt_interface_fw_version_operation(struct fw_mgmt *fw_mgmt,
fw_info->minor = le16_to_cpu(response.minor); fw_info->minor = le16_to_cpu(response.minor);
strncpy(fw_info->firmware_tag, response.firmware_tag, strncpy(fw_info->firmware_tag, response.firmware_tag,
GB_FIRMWARE_TAG_MAX_LEN); GB_FIRMWARE_TAG_MAX_SIZE);
/* /*
* The firmware-tag should be NULL terminated, otherwise throw error but * The firmware-tag should be NULL terminated, otherwise throw error but
* don't fail. * don't fail.
*/ */
if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, dev_err(fw_mgmt->parent,
"fw-version: firmware-tag is not NULL terminated\n"); "fw-version: firmware-tag is not NULL terminated\n");
fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] = '\0'; fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] = '\0';
} }
return 0; return 0;
...@@ -151,13 +151,13 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, ...@@ -151,13 +151,13 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt,
} }
request.load_method = load_method; request.load_method = load_method;
strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_LEN); strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE);
/* /*
* The firmware-tag should be NULL terminated, otherwise throw error and * The firmware-tag should be NULL terminated, otherwise throw error and
* fail. * fail.
*/ */
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n");
return -EINVAL; return -EINVAL;
} }
...@@ -249,13 +249,13 @@ static int fw_mgmt_backend_fw_version_operation(struct fw_mgmt *fw_mgmt, ...@@ -249,13 +249,13 @@ static int fw_mgmt_backend_fw_version_operation(struct fw_mgmt *fw_mgmt,
int ret; int ret;
strncpy(request.firmware_tag, fw_info->firmware_tag, strncpy(request.firmware_tag, fw_info->firmware_tag,
GB_FIRMWARE_TAG_MAX_LEN); GB_FIRMWARE_TAG_MAX_SIZE);
/* /*
* The firmware-tag should be NULL terminated, otherwise throw error and * The firmware-tag should be NULL terminated, otherwise throw error and
* fail. * fail.
*/ */
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, "backend-version: firmware-tag is not NULL terminated\n"); dev_err(fw_mgmt->parent, "backend-version: firmware-tag is not NULL terminated\n");
return -EINVAL; return -EINVAL;
} }
...@@ -302,13 +302,13 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt, ...@@ -302,13 +302,13 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt,
struct gb_fw_mgmt_backend_fw_update_request request; struct gb_fw_mgmt_backend_fw_update_request request;
int ret; int ret;
strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_LEN); strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE);
/* /*
* The firmware-tag should be NULL terminated, otherwise throw error and * The firmware-tag should be NULL terminated, otherwise throw error and
* fail. * fail.
*/ */
if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') {
dev_err(fw_mgmt->parent, "backend-update: firmware-tag is not NULL terminated\n"); dev_err(fw_mgmt->parent, "backend-update: firmware-tag is not NULL terminated\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/types.h> #include <linux/types.h>
#define GB_FIRMWARE_U_TAG_MAX_LEN 10 #define GB_FIRMWARE_U_TAG_MAX_SIZE 10
#define GB_FW_U_LOAD_METHOD_UNIPRO 0x01 #define GB_FW_U_LOAD_METHOD_UNIPRO 0x01
#define GB_FW_U_LOAD_METHOD_INTERNAL 0x02 #define GB_FW_U_LOAD_METHOD_INTERNAL 0x02
...@@ -83,20 +83,20 @@ ...@@ -83,20 +83,20 @@
/* IOCTL support */ /* IOCTL support */
struct fw_mgmt_ioc_get_intf_version { struct fw_mgmt_ioc_get_intf_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major; __u16 major;
__u16 minor; __u16 minor;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct fw_mgmt_ioc_get_backend_version { struct fw_mgmt_ioc_get_backend_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u16 major; __u16 major;
__u16 minor; __u16 minor;
__u8 status; __u8 status;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct fw_mgmt_ioc_intf_load_and_validate { struct fw_mgmt_ioc_intf_load_and_validate {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u8 load_method; __u8 load_method;
__u8 status; __u8 status;
__u16 major; __u16 major;
...@@ -104,7 +104,7 @@ struct fw_mgmt_ioc_intf_load_and_validate { ...@@ -104,7 +104,7 @@ struct fw_mgmt_ioc_intf_load_and_validate {
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct fw_mgmt_ioc_backend_fw_update { struct fw_mgmt_ioc_backend_fw_update {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
__u8 status; __u8 status;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
......
...@@ -276,11 +276,11 @@ struct gb_apb_request_cport_flags { ...@@ -276,11 +276,11 @@ struct gb_apb_request_cport_flags {
#define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE 0x02 #define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE 0x02
#define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE 0x03 #define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE 0x03
#define GB_FIRMWARE_TAG_MAX_LEN 10 #define GB_FIRMWARE_TAG_MAX_SIZE 10
/* firmware download find firmware request/response */ /* firmware download find firmware request/response */
struct gb_fw_download_find_firmware_request { struct gb_fw_download_find_firmware_request {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed; } __packed;
struct gb_fw_download_find_firmware_response { struct gb_fw_download_find_firmware_response {
...@@ -340,7 +340,7 @@ struct gb_fw_download_release_firmware_request { ...@@ -340,7 +340,7 @@ struct gb_fw_download_release_firmware_request {
/* firmware management interface firmware version request has no payload */ /* firmware management interface firmware version request has no payload */
struct gb_fw_mgmt_interface_fw_version_response { struct gb_fw_mgmt_interface_fw_version_response {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
__le16 major; __le16 major;
__le16 minor; __le16 minor;
} __packed; } __packed;
...@@ -349,7 +349,7 @@ struct gb_fw_mgmt_interface_fw_version_response { ...@@ -349,7 +349,7 @@ struct gb_fw_mgmt_interface_fw_version_response {
struct gb_fw_mgmt_load_and_validate_fw_request { struct gb_fw_mgmt_load_and_validate_fw_request {
__u8 request_id; __u8 request_id;
__u8 load_method; __u8 load_method;
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed; } __packed;
/* firmware management load and validate firmware response has no payload*/ /* firmware management load and validate firmware response has no payload*/
...@@ -364,7 +364,7 @@ struct gb_fw_mgmt_loaded_fw_request { ...@@ -364,7 +364,7 @@ struct gb_fw_mgmt_loaded_fw_request {
/* firmware management backend firmware version request/response */ /* firmware management backend firmware version request/response */
struct gb_fw_mgmt_backend_fw_version_request { struct gb_fw_mgmt_backend_fw_version_request {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed; } __packed;
struct gb_fw_mgmt_backend_fw_version_response { struct gb_fw_mgmt_backend_fw_version_response {
...@@ -376,7 +376,7 @@ struct gb_fw_mgmt_backend_fw_version_response { ...@@ -376,7 +376,7 @@ struct gb_fw_mgmt_backend_fw_version_response {
/* firmware management backend firmware update request */ /* firmware management backend firmware update request */
struct gb_fw_mgmt_backend_fw_update_request { struct gb_fw_mgmt_backend_fw_update_request {
__u8 request_id; __u8 request_id;
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE];
} __packed; } __packed;
/* firmware management backend firmware update response has no payload */ /* firmware management backend firmware update response has no payload */
......
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