Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>

authored by

Viresh Kumar and committed by
Greg Kroah-Hartman
b2abeaa1 769cb837

+30 -30
+4 -4
drivers/staging/greybus/Documentation/firmware/firmware-management
··· 104 104 105 105 106 106 struct fw_mgmt_ioc_get_intf_version { 107 - __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; 107 + __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE]; 108 108 __u16 major; 109 109 __u16 minor; 110 110 } __attribute__ ((__packed__)); 111 111 112 112 struct fw_mgmt_ioc_get_backend_version { 113 - __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; 113 + __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE]; 114 114 __u16 major; 115 115 __u16 minor; 116 116 __u8 status; 117 117 } __attribute__ ((__packed__)); 118 118 119 119 struct fw_mgmt_ioc_intf_load_and_validate { 120 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 120 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 121 121 __u8 load_method; 122 122 __u8 status; 123 123 __u16 major; ··· 125 125 } __packed; 126 126 127 127 struct fw_mgmt_ioc_backend_fw_update { 128 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 128 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 129 129 __u8 status; 130 130 } __packed; 131 131
+3 -3
drivers/staging/greybus/Documentation/firmware/firmware.c
··· 108 108 intf_load.minor = 0; 109 109 110 110 strncpy((char *)&intf_load.firmware_tag, firmware_tag, 111 - GB_FIRMWARE_U_TAG_MAX_LEN); 111 + GB_FIRMWARE_U_TAG_MAX_SIZE); 112 112 113 113 ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load); 114 114 if (ret < 0) { ··· 146 146 printf("Getting Backend Firmware Version\n"); 147 147 148 148 strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag, 149 - GB_FIRMWARE_U_TAG_MAX_LEN); 149 + GB_FIRMWARE_U_TAG_MAX_SIZE); 150 150 151 151 retry_fw_version: 152 152 ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info); ··· 174 174 printf("Updating Backend Firmware\n"); 175 175 176 176 strncpy((char *)&backend_update.firmware_tag, firmware_tag, 177 - GB_FIRMWARE_U_TAG_MAX_LEN); 177 + GB_FIRMWARE_U_TAG_MAX_SIZE); 178 178 179 179 retry_fw_update: 180 180 backend_update.status = 0;
+1 -1
drivers/staging/greybus/firmware.h
··· 15 15 #define FW_NAME_PREFIX "gmp_" 16 16 17 17 /* Length of the string in format: "FW_NAME_PREFIX""%08x_%08x_%08x_%08x_%s.tftf" */ 18 - #define FW_NAME_LEN 56 18 + #define FW_NAME_SIZE 56 19 19 20 20 /* Firmware Management Protocol specific functions */ 21 21 int fw_mgmt_init(void);
+2 -2
drivers/staging/greybus/fw-download.c
··· 23 23 u8 firmware_id; 24 24 bool disabled; 25 25 bool timedout; 26 - char name[FW_NAME_LEN]; 26 + char name[FW_NAME_SIZE]; 27 27 const struct firmware *fw; 28 28 struct list_head node; 29 29 ··· 239 239 tag = (const char *)request->firmware_tag; 240 240 241 241 /* firmware_tag should be null-terminated */ 242 - if (strnlen(tag, GB_FIRMWARE_TAG_MAX_LEN) == GB_FIRMWARE_TAG_MAX_LEN) { 242 + if (strnlen(tag, GB_FIRMWARE_TAG_MAX_SIZE) == GB_FIRMWARE_TAG_MAX_SIZE) { 243 243 dev_err(fw_download->parent, 244 244 "firmware-tag is not null-terminated\n"); 245 245 return -EINVAL;
+9 -9
drivers/staging/greybus/fw-management.c
··· 122 122 fw_info->minor = le16_to_cpu(response.minor); 123 123 124 124 strncpy(fw_info->firmware_tag, response.firmware_tag, 125 - GB_FIRMWARE_TAG_MAX_LEN); 125 + GB_FIRMWARE_TAG_MAX_SIZE); 126 126 127 127 /* 128 128 * The firmware-tag should be NULL terminated, otherwise throw error but 129 129 * don't fail. 130 130 */ 131 - if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { 131 + if (fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { 132 132 dev_err(fw_mgmt->parent, 133 133 "fw-version: firmware-tag is not NULL terminated\n"); 134 - fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] = '\0'; 134 + fw_info->firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] = '\0'; 135 135 } 136 136 137 137 return 0; ··· 151 151 } 152 152 153 153 request.load_method = load_method; 154 - strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_LEN); 154 + strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE); 155 155 156 156 /* 157 157 * The firmware-tag should be NULL terminated, otherwise throw error and 158 158 * fail. 159 159 */ 160 - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { 160 + if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { 161 161 dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); 162 162 return -EINVAL; 163 163 } ··· 249 249 int ret; 250 250 251 251 strncpy(request.firmware_tag, fw_info->firmware_tag, 252 - GB_FIRMWARE_TAG_MAX_LEN); 252 + GB_FIRMWARE_TAG_MAX_SIZE); 253 253 254 254 /* 255 255 * The firmware-tag should be NULL terminated, otherwise throw error and 256 256 * fail. 257 257 */ 258 - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { 258 + if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { 259 259 dev_err(fw_mgmt->parent, "backend-version: firmware-tag is not NULL terminated\n"); 260 260 return -EINVAL; 261 261 } ··· 302 302 struct gb_fw_mgmt_backend_fw_update_request request; 303 303 int ret; 304 304 305 - strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_LEN); 305 + strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE); 306 306 307 307 /* 308 308 * The firmware-tag should be NULL terminated, otherwise throw error and 309 309 * fail. 310 310 */ 311 - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_LEN - 1] != '\0') { 311 + if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { 312 312 dev_err(fw_mgmt->parent, "backend-update: firmware-tag is not NULL terminated\n"); 313 313 return -EINVAL; 314 314 }
+5 -5
drivers/staging/greybus/greybus_firmware.h
··· 57 57 #include <linux/ioctl.h> 58 58 #include <linux/types.h> 59 59 60 - #define GB_FIRMWARE_U_TAG_MAX_LEN 10 60 + #define GB_FIRMWARE_U_TAG_MAX_SIZE 10 61 61 62 62 #define GB_FW_U_LOAD_METHOD_UNIPRO 0x01 63 63 #define GB_FW_U_LOAD_METHOD_INTERNAL 0x02 ··· 83 83 84 84 /* IOCTL support */ 85 85 struct fw_mgmt_ioc_get_intf_version { 86 - __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; 86 + __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE]; 87 87 __u16 major; 88 88 __u16 minor; 89 89 } __attribute__ ((__packed__)); 90 90 91 91 struct fw_mgmt_ioc_get_backend_version { 92 - __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; 92 + __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE]; 93 93 __u16 major; 94 94 __u16 minor; 95 95 __u8 status; 96 96 } __attribute__ ((__packed__)); 97 97 98 98 struct fw_mgmt_ioc_intf_load_and_validate { 99 - __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; 99 + __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE]; 100 100 __u8 load_method; 101 101 __u8 status; 102 102 __u16 major; ··· 104 104 } __attribute__ ((__packed__)); 105 105 106 106 struct fw_mgmt_ioc_backend_fw_update { 107 - __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN]; 107 + __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE]; 108 108 __u8 status; 109 109 } __attribute__ ((__packed__)); 110 110
+6 -6
drivers/staging/greybus/greybus_protocols.h
··· 276 276 #define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE 0x02 277 277 #define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE 0x03 278 278 279 - #define GB_FIRMWARE_TAG_MAX_LEN 10 279 + #define GB_FIRMWARE_TAG_MAX_SIZE 10 280 280 281 281 /* firmware download find firmware request/response */ 282 282 struct gb_fw_download_find_firmware_request { 283 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 283 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 284 284 } __packed; 285 285 286 286 struct gb_fw_download_find_firmware_response { ··· 340 340 341 341 /* firmware management interface firmware version request has no payload */ 342 342 struct gb_fw_mgmt_interface_fw_version_response { 343 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 343 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 344 344 __le16 major; 345 345 __le16 minor; 346 346 } __packed; ··· 349 349 struct gb_fw_mgmt_load_and_validate_fw_request { 350 350 __u8 request_id; 351 351 __u8 load_method; 352 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 352 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 353 353 } __packed; 354 354 /* firmware management load and validate firmware response has no payload*/ 355 355 ··· 364 364 365 365 /* firmware management backend firmware version request/response */ 366 366 struct gb_fw_mgmt_backend_fw_version_request { 367 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 367 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 368 368 } __packed; 369 369 370 370 struct gb_fw_mgmt_backend_fw_version_response { ··· 376 376 /* firmware management backend firmware update request */ 377 377 struct gb_fw_mgmt_backend_fw_update_request { 378 378 __u8 request_id; 379 - __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN]; 379 + __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; 380 380 } __packed; 381 381 /* firmware management backend firmware update response has no payload */ 382 382