@@ -68,9 +68,9 @@ extern "C" {
6868* Static Function Declarations
6969******************************************************/
7070uint32_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 );
7272resource_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 );
7474
7575extern uint32_t host_platform_resource_size (whd_driver_t whd_drv , whd_resource_type_t resource , uint32_t * size_out );
7676extern 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;
119119
120120void try_init_external_handles ()
121121{
122- if (!external_handles_initialized )
123- {
122+ if (!external_handles_initialized ) {
124123#if defined(WLAN_MFG_FIRMWARE )
125- wifi_mfg_firmware_image_external = (resource_hnd_t ){
124+ wifi_mfg_firmware_image_external = (resource_hnd_t ) {
126125 RESOURCE_IN_EXTERNAL_STORAGE ,
127126 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 ) }
129128 };
130- wifi_mfg_firmware_clm_blob_external = (resource_hnd_t ){
129+ wifi_mfg_firmware_clm_blob_external = (resource_hnd_t ) {
131130 RESOURCE_IN_EXTERNAL_STORAGE ,
132131 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 ) }
134133 };
135134#else
136- wifi_firmware_image_external = (resource_hnd_t ){
135+ wifi_firmware_image_external = (resource_hnd_t ) {
137136 RESOURCE_IN_EXTERNAL_STORAGE ,
138137 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 ) }
140139 };
141- wifi_firmware_clm_blob_external = (resource_hnd_t ){
140+ wifi_firmware_clm_blob_external = (resource_hnd_t ) {
142141 RESOURCE_IN_EXTERNAL_STORAGE ,
143142 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 ) }
145144 };
146145#endif /* defined(WLAN_MFG_FIRMWARE) */
147146 external_handles_initialized = true;
@@ -158,65 +157,53 @@ void cy_ext_wifi_fw_resources_update_handles(void *image_addr, unsigned long ima
158157}
159158
160159resource_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 )
162161{
163- if (offset > resource -> size )
164- {
162+ if (offset > resource -> size ) {
165163 return RESOURCE_OFFSET_TOO_BIG ;
166164 }
167165
168166 * size = MIN (maxsize , resource -> size - offset );
169167
170- if (resource -> location == RESOURCE_IN_MEMORY )
171- {
168+ if (resource -> location == RESOURCE_IN_MEMORY ) {
172169 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 ) {
176171 return platform_read_external_resource (resource , offset , maxsize , size , buffer );
177172 }
178173#ifdef USES_RESOURCE_GENERIC_FILESYSTEM
179- else
180- {
174+ else {
181175 wiced_file_t file_handle ;
182176 uint64_t size64 ;
183177 uint64_t maxsize64 = maxsize ;
184178 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 )) {
188181 return RESOURCE_FILE_OPEN_FAIL ;
189182 }
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 )) {
192184 return RESOURCE_FILE_SEEK_FAIL ;
193185 }
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 );
197188 return RESOURCE_FILE_READ_FAIL ;
198189 }
199190 * size = (uint32_t )size64 ;
200- wiced_filesystem_file_close (& file_handle );
191+ wiced_filesystem_file_close (& file_handle );
201192 }
202193#elif USES_RESOURCE_FILESYSTEM
203- else
204- {
194+ else {
205195 wicedfs_file_t file_hnd ;
206196
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 )) {
209198 return RESOURCE_FILE_OPEN_FAIL ;
210199 }
211200
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 )) {
214202 wicedfs_fclose (& file_hnd );
215203 return RESOURCE_FILE_SEEK_FAIL ;
216204 }
217205
218- if (* size != wicedfs_fread (buffer , 1 , * size , & file_hnd ) )
219- {
206+ if (* size != wicedfs_fread (buffer , 1 , * size , & file_hnd )) {
220207 wicedfs_fclose (& file_hnd );
221208 return RESOURCE_FILE_READ_FAIL ;
222209 }
@@ -228,7 +215,7 @@ resource_result_t ext_wifi_fw_resource_read(const resource_hnd_t *resource, uint
228215}
229216
230217uint32_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 )
232219{
233220 uint32_t resource_size ;
234221 uint32_t block_size ;
@@ -244,17 +231,14 @@ uint32_t ext_wifi_fw_host_get_resource_block(whd_driver_t whd_drv, whd_resource_
244231 memset (whd_r_buffer , 0 , block_size );
245232 read_pos = blockno * block_size ;
246233
247- if (blockno >= block_count )
248- {
234+ if (blockno >= block_count ) {
249235 return WHD_BADARG ;
250236 }
251237
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 ) {
258242 return result ;
259243 }
260244 * 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_
267251 * For sending the entire buffer in single block set size out as following
268252 * *size_out = (uint32_t)resource_get_size(&wifi_firmware_image);
269253 */
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 ) {
275256 * size_out = block_size ;
276- }
277- else
278- {
257+ } else {
279258 * size_out = NVRAM_SIZE - read_pos ;
280259 }
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 ) {
290266 return result ;
291267 }
292268 * 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_
305281 return WHD_SUCCESS ;
306282}
307283
308- whd_resource_source_t cy_ext_wifi_fw_resource_ops =
309- {
284+ whd_resource_source_t cy_ext_wifi_fw_resource_ops = {
310285 .whd_resource_size = host_platform_resource_size ,
311286 .whd_get_resource_block_size = host_get_resource_block_size ,
312287 .whd_get_resource_no_of_blocks = host_get_resource_no_of_blocks ,
0 commit comments