diff options
author | Johannes Berg <johannes.berg@intel.com> | 2015-09-16 06:21:32 -0400 |
---|---|---|
committer | Luca Coelho <luciano.coelho@intel.com> | 2015-10-05 07:33:33 -0400 |
commit | d3f555f493b037eb688adda6d8a682e9b69211ed (patch) | |
tree | 2e34e363f78349433d4a651b1ef0ee26155f651b | |
parent | fe96cc73c9f405a0bdc90504048235dfd0384582 (diff) |
iwlwifi: size firmware flags memory correctly
Instead of relying on a hard-coded constant of a maximum of 64 API and
capability bits, add a new enum value after the others that will then
always track the number of used bits in the API/capabilities. We thus
no longer need to maintain the maximum number, and on 32-bit platforms
even (currently) reduce the number of bits kept in memory.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-drv.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-fw-file.h | 19 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-fw.h | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index a86aa5bcee7d..463cadfbfccb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c | |||
@@ -450,7 +450,7 @@ static int iwl_set_ucode_api_flags(struct iwl_drv *drv, const u8 *data, | |||
450 | u32 api_flags = le32_to_cpu(ucode_api->api_flags); | 450 | u32 api_flags = le32_to_cpu(ucode_api->api_flags); |
451 | int i; | 451 | int i; |
452 | 452 | ||
453 | if (api_index >= IWL_API_MAX_BITS / 32) { | 453 | if (api_index >= DIV_ROUND_UP(NUM_IWL_UCODE_TLV_API, 32)) { |
454 | IWL_ERR(drv, "api_index larger than supported by driver\n"); | 454 | IWL_ERR(drv, "api_index larger than supported by driver\n"); |
455 | /* don't return an error so we can load FW that has more bits */ | 455 | /* don't return an error so we can load FW that has more bits */ |
456 | return 0; | 456 | return 0; |
@@ -472,7 +472,7 @@ static int iwl_set_ucode_capabilities(struct iwl_drv *drv, const u8 *data, | |||
472 | u32 api_flags = le32_to_cpu(ucode_capa->api_capa); | 472 | u32 api_flags = le32_to_cpu(ucode_capa->api_capa); |
473 | int i; | 473 | int i; |
474 | 474 | ||
475 | if (api_index >= IWL_CAPABILITIES_MAX_BITS / 32) { | 475 | if (api_index >= DIV_ROUND_UP(NUM_IWL_UCODE_TLV_CAPA, 32)) { |
476 | IWL_ERR(drv, "api_index larger than supported by driver\n"); | 476 | IWL_ERR(drv, "api_index larger than supported by driver\n"); |
477 | /* don't return an error so we can load FW that has more bits */ | 477 | /* don't return an error so we can load FW that has more bits */ |
478 | return 0; | 478 | return 0; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw-file.h b/drivers/net/wireless/iwlwifi/iwl-fw-file.h index 352d245765e7..72ddd4a163e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw-file.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw-file.h | |||
@@ -254,6 +254,8 @@ typedef unsigned int __bitwise__ iwl_ucode_tlv_api_t; | |||
254 | * instead of 3. | 254 | * instead of 3. |
255 | * @IWL_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size | 255 | * @IWL_UCODE_TLV_API_TX_POWER_CHAIN: TX power API has larger command size |
256 | * (command version 3) that supports per-chain limits | 256 | * (command version 3) that supports per-chain limits |
257 | * | ||
258 | * @NUM_IWL_UCODE_TLV_API: number of bits used | ||
257 | */ | 259 | */ |
258 | enum iwl_ucode_tlv_api { | 260 | enum iwl_ucode_tlv_api { |
259 | IWL_UCODE_TLV_API_BT_COEX_SPLIT = (__force iwl_ucode_tlv_api_t)3, | 261 | IWL_UCODE_TLV_API_BT_COEX_SPLIT = (__force iwl_ucode_tlv_api_t)3, |
@@ -264,6 +266,12 @@ enum iwl_ucode_tlv_api { | |||
264 | IWL_UCODE_TLV_API_NEW_VERSION = (__force iwl_ucode_tlv_api_t)20, | 266 | IWL_UCODE_TLV_API_NEW_VERSION = (__force iwl_ucode_tlv_api_t)20, |
265 | IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY = (__force iwl_ucode_tlv_api_t)24, | 267 | IWL_UCODE_TLV_API_EXT_SCAN_PRIORITY = (__force iwl_ucode_tlv_api_t)24, |
266 | IWL_UCODE_TLV_API_TX_POWER_CHAIN = (__force iwl_ucode_tlv_api_t)27, | 268 | IWL_UCODE_TLV_API_TX_POWER_CHAIN = (__force iwl_ucode_tlv_api_t)27, |
269 | |||
270 | NUM_IWL_UCODE_TLV_API | ||
271 | #ifdef __CHECKER__ | ||
272 | /* sparse says it cannot increment the previous enum member */ | ||
273 | = 128 | ||
274 | #endif | ||
267 | }; | 275 | }; |
268 | 276 | ||
269 | typedef unsigned int __bitwise__ iwl_ucode_tlv_capa_t; | 277 | typedef unsigned int __bitwise__ iwl_ucode_tlv_capa_t; |
@@ -298,6 +306,8 @@ typedef unsigned int __bitwise__ iwl_ucode_tlv_capa_t; | |||
298 | * is supported. | 306 | * is supported. |
299 | * @IWL_UCODE_TLV_CAPA_BT_COEX_RRC: supports BT Coex RRC | 307 | * @IWL_UCODE_TLV_CAPA_BT_COEX_RRC: supports BT Coex RRC |
300 | * @IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan | 308 | * @IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT: supports gscan |
309 | * | ||
310 | * @NUM_IWL_UCODE_TLV_CAPA: number of bits used | ||
301 | */ | 311 | */ |
302 | enum iwl_ucode_tlv_capa { | 312 | enum iwl_ucode_tlv_capa { |
303 | IWL_UCODE_TLV_CAPA_D0I3_SUPPORT = (__force iwl_ucode_tlv_capa_t)0, | 313 | IWL_UCODE_TLV_CAPA_D0I3_SUPPORT = (__force iwl_ucode_tlv_capa_t)0, |
@@ -320,6 +330,12 @@ enum iwl_ucode_tlv_capa { | |||
320 | IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC = (__force iwl_ucode_tlv_capa_t)29, | 330 | IWL_UCODE_TLV_CAPA_LAR_MULTI_MCC = (__force iwl_ucode_tlv_capa_t)29, |
321 | IWL_UCODE_TLV_CAPA_BT_COEX_RRC = (__force iwl_ucode_tlv_capa_t)30, | 331 | IWL_UCODE_TLV_CAPA_BT_COEX_RRC = (__force iwl_ucode_tlv_capa_t)30, |
322 | IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT = (__force iwl_ucode_tlv_capa_t)31, | 332 | IWL_UCODE_TLV_CAPA_GSCAN_SUPPORT = (__force iwl_ucode_tlv_capa_t)31, |
333 | |||
334 | NUM_IWL_UCODE_TLV_CAPA | ||
335 | #ifdef __CHECKER__ | ||
336 | /* sparse says it cannot increment the previous enum member */ | ||
337 | = 128 | ||
338 | #endif | ||
323 | }; | 339 | }; |
324 | 340 | ||
325 | /* The default calibrate table size if not specified by firmware file */ | 341 | /* The default calibrate table size if not specified by firmware file */ |
@@ -330,9 +346,6 @@ enum iwl_ucode_tlv_capa { | |||
330 | /* The default max probe length if not specified by the firmware file */ | 346 | /* The default max probe length if not specified by the firmware file */ |
331 | #define IWL_DEFAULT_MAX_PROBE_LENGTH 200 | 347 | #define IWL_DEFAULT_MAX_PROBE_LENGTH 200 |
332 | 348 | ||
333 | #define IWL_API_MAX_BITS 64 | ||
334 | #define IWL_CAPABILITIES_MAX_BITS 64 | ||
335 | |||
336 | /* | 349 | /* |
337 | * For 16.0 uCode and above, there is no differentiation between sections, | 350 | * For 16.0 uCode and above, there is no differentiation between sections, |
338 | * just an offset to the HW address. | 351 | * just an offset to the HW address. |
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index 45e732150d28..84ec0cefb62a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h | |||
@@ -105,8 +105,8 @@ struct iwl_ucode_capabilities { | |||
105 | u32 n_scan_channels; | 105 | u32 n_scan_channels; |
106 | u32 standard_phy_calibration_size; | 106 | u32 standard_phy_calibration_size; |
107 | u32 flags; | 107 | u32 flags; |
108 | unsigned long _api[BITS_TO_LONGS(IWL_API_MAX_BITS)]; | 108 | unsigned long _api[BITS_TO_LONGS(NUM_IWL_UCODE_TLV_API)]; |
109 | unsigned long _capa[BITS_TO_LONGS(IWL_CAPABILITIES_MAX_BITS)]; | 109 | unsigned long _capa[BITS_TO_LONGS(NUM_IWL_UCODE_TLV_CAPA)]; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | static inline bool | 112 | static inline bool |