@@ -68,9 +68,9 @@ extern "C" {
68
68
* Static Function Declarations
69
69
******************************************************/
70
70
uint32_t ext_wifi_fw_host_get_resource_block (whd_driver_t whd_drv , whd_resource_type_t type ,
71
- uint32_t blockno , const uint8_t * * data , uint32_t * size_out );
71
+ uint32_t blockno , const uint8_t * * data , uint32_t * size_out );
72
72
resource_result_t ext_wifi_fw_resource_read (const resource_hnd_t * resource , uint32_t offset , uint32_t maxsize , uint32_t * size ,
73
- void * buffer );
73
+ void * buffer );
74
74
75
75
extern uint32_t host_platform_resource_size (whd_driver_t whd_drv , whd_resource_type_t resource , uint32_t * size_out );
76
76
extern uint32_t host_get_resource_block_size (whd_driver_t whd_drv , whd_resource_type_t type , uint32_t * size_out );
@@ -119,29 +119,28 @@ void *dynamic_nvram_image = &wifi_nvram_image;
119
119
120
120
void try_init_external_handles ()
121
121
{
122
- if (!external_handles_initialized )
123
- {
122
+ if (!external_handles_initialized ) {
124
123
#if defined(WLAN_MFG_FIRMWARE )
125
- wifi_mfg_firmware_image_external = (resource_hnd_t ){
124
+ wifi_mfg_firmware_image_external = (resource_hnd_t ) {
126
125
RESOURCE_IN_EXTERNAL_STORAGE ,
127
126
wifi_mfg_firmware_image .size ,
128
- { .external_storage_context = (void * ) (wifi_mfg_firmware_image .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
127
+ { .external_storage_context = (void * )(wifi_mfg_firmware_image .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
129
128
};
130
- wifi_mfg_firmware_clm_blob_external = (resource_hnd_t ){
129
+ wifi_mfg_firmware_clm_blob_external = (resource_hnd_t ) {
131
130
RESOURCE_IN_EXTERNAL_STORAGE ,
132
131
wifi_mfg_firmware_clm_blob .size ,
133
- { .external_storage_context = (void * ) (wifi_mfg_firmware_clm_blob .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
132
+ { .external_storage_context = (void * )(wifi_mfg_firmware_clm_blob .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
134
133
};
135
134
#else
136
- wifi_firmware_image_external = (resource_hnd_t ){
135
+ wifi_firmware_image_external = (resource_hnd_t ) {
137
136
RESOURCE_IN_EXTERNAL_STORAGE ,
138
137
wifi_firmware_image .size ,
139
- { .external_storage_context = (void * ) (wifi_firmware_image .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
138
+ { .external_storage_context = (void * )(wifi_firmware_image .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
140
139
};
141
- wifi_firmware_clm_blob_external = (resource_hnd_t ){
140
+ wifi_firmware_clm_blob_external = (resource_hnd_t ) {
142
141
RESOURCE_IN_EXTERNAL_STORAGE ,
143
142
wifi_firmware_clm_blob .size ,
144
- { .external_storage_context = (void * ) (wifi_firmware_clm_blob .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
143
+ { .external_storage_context = (void * )(wifi_firmware_clm_blob .val .mem .data - (uint32_t ) CY_WIFI_FW_SECTION_START ) }
145
144
};
146
145
#endif /* defined(WLAN_MFG_FIRMWARE) */
147
146
external_handles_initialized = true;
@@ -158,65 +157,53 @@ void cy_ext_wifi_fw_resources_update_handles(void *image_addr, unsigned long ima
158
157
}
159
158
160
159
resource_result_t ext_wifi_fw_resource_read (const resource_hnd_t * resource , uint32_t offset , uint32_t maxsize , uint32_t * size ,
161
- void * buffer )
160
+ void * buffer )
162
161
{
163
- if (offset > resource -> size )
164
- {
162
+ if (offset > resource -> size ) {
165
163
return RESOURCE_OFFSET_TOO_BIG ;
166
164
}
167
165
168
166
* size = MIN (maxsize , resource -> size - offset );
169
167
170
- if (resource -> location == RESOURCE_IN_MEMORY )
171
- {
168
+ if (resource -> location == RESOURCE_IN_MEMORY ) {
172
169
memcpy (buffer , & resource -> val .mem .data [offset ], * size );
173
- }
174
- else if (resource -> location == RESOURCE_IN_EXTERNAL_STORAGE )
175
- {
170
+ } else if (resource -> location == RESOURCE_IN_EXTERNAL_STORAGE ) {
176
171
return platform_read_external_resource (resource , offset , maxsize , size , buffer );
177
172
}
178
173
#ifdef USES_RESOURCE_GENERIC_FILESYSTEM
179
- else
180
- {
174
+ else {
181
175
wiced_file_t file_handle ;
182
176
uint64_t size64 ;
183
177
uint64_t maxsize64 = maxsize ;
184
178
if (WICED_SUCCESS !=
185
- wiced_filesystem_file_open (& resource_fs_handle , & file_handle , resource -> val .fs .filename ,
186
- WICED_FILESYSTEM_OPEN_FOR_READ ) )
187
- {
179
+ wiced_filesystem_file_open (& resource_fs_handle , & file_handle , resource -> val .fs .filename ,
180
+ WICED_FILESYSTEM_OPEN_FOR_READ )) {
188
181
return RESOURCE_FILE_OPEN_FAIL ;
189
182
}
190
- if (WICED_SUCCESS != wiced_filesystem_file_seek (& file_handle , (offset + resource -> val .fs .offset ), SEEK_SET ) )
191
- {
183
+ if (WICED_SUCCESS != wiced_filesystem_file_seek (& file_handle , (offset + resource -> val .fs .offset ), SEEK_SET )) {
192
184
return RESOURCE_FILE_SEEK_FAIL ;
193
185
}
194
- if (WICED_SUCCESS != wiced_filesystem_file_read (& file_handle , buffer , maxsize64 , & size64 ) )
195
- {
196
- wiced_filesystem_file_close (& file_handle );
186
+ if (WICED_SUCCESS != wiced_filesystem_file_read (& file_handle , buffer , maxsize64 , & size64 )) {
187
+ wiced_filesystem_file_close (& file_handle );
197
188
return RESOURCE_FILE_READ_FAIL ;
198
189
}
199
190
* size = (uint32_t )size64 ;
200
- wiced_filesystem_file_close (& file_handle );
191
+ wiced_filesystem_file_close (& file_handle );
201
192
}
202
193
#elif USES_RESOURCE_FILESYSTEM
203
- else
204
- {
194
+ else {
205
195
wicedfs_file_t file_hnd ;
206
196
207
- if (0 != wicedfs_fopen (& resource_fs_handle , & file_hnd , resource -> val .fs .filename ) )
208
- {
197
+ if (0 != wicedfs_fopen (& resource_fs_handle , & file_hnd , resource -> val .fs .filename )) {
209
198
return RESOURCE_FILE_OPEN_FAIL ;
210
199
}
211
200
212
- if (0 != wicedfs_fseek (& file_hnd , (long )(offset + resource -> val .fs .offset ), SEEK_SET ) )
213
- {
201
+ if (0 != wicedfs_fseek (& file_hnd , (long )(offset + resource -> val .fs .offset ), SEEK_SET )) {
214
202
wicedfs_fclose (& file_hnd );
215
203
return RESOURCE_FILE_SEEK_FAIL ;
216
204
}
217
205
218
- if (* size != wicedfs_fread (buffer , 1 , * size , & file_hnd ) )
219
- {
206
+ if (* size != wicedfs_fread (buffer , 1 , * size , & file_hnd )) {
220
207
wicedfs_fclose (& file_hnd );
221
208
return RESOURCE_FILE_READ_FAIL ;
222
209
}
@@ -228,7 +215,7 @@ resource_result_t ext_wifi_fw_resource_read(const resource_hnd_t *resource, uint
228
215
}
229
216
230
217
uint32_t ext_wifi_fw_host_get_resource_block (whd_driver_t whd_drv , whd_resource_type_t type ,
231
- uint32_t blockno , const uint8_t * * data , uint32_t * size_out )
218
+ uint32_t blockno , const uint8_t * * data , uint32_t * size_out )
232
219
{
233
220
uint32_t resource_size ;
234
221
uint32_t block_size ;
@@ -244,17 +231,14 @@ uint32_t ext_wifi_fw_host_get_resource_block(whd_driver_t whd_drv, whd_resource_
244
231
memset (whd_r_buffer , 0 , block_size );
245
232
read_pos = blockno * block_size ;
246
233
247
- if (blockno >= block_count )
248
- {
234
+ if (blockno >= block_count ) {
249
235
return WHD_BADARG ;
250
236
}
251
237
252
- if (type == WHD_RESOURCE_WLAN_FIRMWARE )
253
- {
254
- result = ext_wifi_fw_resource_read ( (const resource_hnd_t * )& WIFI_FIRMWARE_IMAGE , read_pos , block_size , size_out ,
255
- whd_r_buffer );
256
- if (result != WHD_SUCCESS )
257
- {
238
+ if (type == WHD_RESOURCE_WLAN_FIRMWARE ) {
239
+ result = ext_wifi_fw_resource_read ((const resource_hnd_t * )& WIFI_FIRMWARE_IMAGE , read_pos , block_size , size_out ,
240
+ whd_r_buffer );
241
+ if (result != WHD_SUCCESS ) {
258
242
return result ;
259
243
}
260
244
* data = (uint8_t * )& whd_r_buffer ;
@@ -267,26 +251,18 @@ uint32_t ext_wifi_fw_host_get_resource_block(whd_driver_t whd_drv, whd_resource_
267
251
* For sending the entire buffer in single block set size out as following
268
252
* *size_out = (uint32_t)resource_get_size(&wifi_firmware_image);
269
253
*/
270
- }
271
- else if (type == WHD_RESOURCE_WLAN_NVRAM )
272
- {
273
- if (NVRAM_SIZE - read_pos > block_size )
274
- {
254
+ } else if (type == WHD_RESOURCE_WLAN_NVRAM ) {
255
+ if (NVRAM_SIZE - read_pos > block_size ) {
275
256
* size_out = block_size ;
276
- }
277
- else
278
- {
257
+ } else {
279
258
* size_out = NVRAM_SIZE - read_pos ;
280
259
}
281
- * data = ( (uint8_t * )NVRAM_IMAGE_VARIABLE ) + read_pos ;
282
- }
283
- else
284
- {
285
- result = ext_wifi_fw_resource_read ( (const resource_hnd_t * )& WIFI_FIRMWARE_CLM_BLOB , read_pos , block_size ,
286
- size_out ,
287
- whd_r_buffer );
288
- if (result != WHD_SUCCESS )
289
- {
260
+ * data = ((uint8_t * )NVRAM_IMAGE_VARIABLE ) + read_pos ;
261
+ } else {
262
+ result = ext_wifi_fw_resource_read ((const resource_hnd_t * )& WIFI_FIRMWARE_CLM_BLOB , read_pos , block_size ,
263
+ size_out ,
264
+ whd_r_buffer );
265
+ if (result != WHD_SUCCESS ) {
290
266
return result ;
291
267
}
292
268
* data = (uint8_t * )& whd_r_buffer ;
@@ -305,8 +281,7 @@ uint32_t ext_wifi_fw_host_get_resource_block(whd_driver_t whd_drv, whd_resource_
305
281
return WHD_SUCCESS ;
306
282
}
307
283
308
- whd_resource_source_t cy_ext_wifi_fw_resource_ops =
309
- {
284
+ whd_resource_source_t cy_ext_wifi_fw_resource_ops = {
310
285
.whd_resource_size = host_platform_resource_size ,
311
286
.whd_get_resource_block_size = host_get_resource_block_size ,
312
287
.whd_get_resource_no_of_blocks = host_get_resource_no_of_blocks ,
0 commit comments