Skip to content

Commit 82c9861

Browse files
Ran astyle for mbed code format.
1 parent 782b23d commit 82c9861

File tree

3 files changed

+49
-81
lines changed

3 files changed

+49
-81
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/common/ext-wifi-fw/cy_ext_wifi_fw_reserved_region_bd.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ CyReservedRegionBlockDevice *cy_get_ext_wifi_fw_reserved_region_bd()
5353
}
5454

5555
extern "C" {
56-
extern void cy_ext_wifi_fw_resources_update_handles(void *image_addr, unsigned long image_size, void *clm_blob_addr, unsigned long clm_blob_size);
56+
extern void cy_ext_wifi_fw_resources_update_handles(void *image_addr, unsigned long image_size, void *clm_blob_addr, unsigned long clm_blob_size);
5757
}
5858

5959
int cy_update_ext_wifi_fw_location_and_size(mbed::bd_addr_t image_addr, mbed::bd_size_t image_size, mbed::bd_addr_t clm_blob_addr, mbed::bd_size_t clm_blob_size)
6060
{
6161
CyReservedRegionBlockDevice *bd = cy_get_ext_wifi_fw_reserved_region_bd();
6262
// If the reserved region end is NULL, the block device hasn't been initialized yet, so we can't perform this check
63-
if ((bd->reserved_region_end() != 0) && (image_addr + image_size > bd->reserved_region_end() || clm_blob_addr + clm_blob_size > bd->reserved_region_end()))
64-
{
63+
if ((bd->reserved_region_end() != 0) && (image_addr + image_size > bd->reserved_region_end() || clm_blob_addr + clm_blob_size > bd->reserved_region_end())) {
6564
// Should not exceed originally computed reserved region size, as this will break anything that was using the rest of external storage
6665
return -1;
6766
}

targets/TARGET_Cypress/TARGET_PSOC6/common/ext-wifi-fw/cy_ext_wifi_fw_resources.c

Lines changed: 42 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ extern "C" {
6868
* Static Function Declarations
6969
******************************************************/
7070
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);
7272
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);
7474

7575
extern uint32_t host_platform_resource_size(whd_driver_t whd_drv, whd_resource_type_t resource, uint32_t *size_out);
7676
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;
119119

120120
void 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

160159
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)
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

230217
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)
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,

targets/TARGET_Cypress/TARGET_PSOC6/common/reserved-region-bd/CyReservedRegionBlockDevice.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,12 @@ CyReservedRegionBlockDevice::CyReservedRegionBlockDevice(BlockDevice *underlying
3535
int CyReservedRegionBlockDevice::init()
3636
{
3737
int status = _underlying_bd->init();
38-
if (status == BD_ERROR_OK)
39-
{
38+
if (status == BD_ERROR_OK) {
4039
// Round up to start usable region on an erase boundary
4140
// May need to wait until after init() to determine erase size (e.g. QSPI)
42-
if (_reserved_region_size % get_erase_size() != 0)
43-
{
41+
if (_reserved_region_size % get_erase_size() != 0) {
4442
_reserved_region_end = _reserved_region_size + get_erase_size() - (_reserved_region_size % get_erase_size());
45-
}
46-
else
47-
{
43+
} else {
4844
_reserved_region_end = _reserved_region_size;
4945
}
5046
}
@@ -54,8 +50,7 @@ int CyReservedRegionBlockDevice::init()
5450
int CyReservedRegionBlockDevice::deinit()
5551
{
5652
int status = _underlying_bd->deinit();
57-
if (status == BD_ERROR_OK)
58-
{
53+
if (status == BD_ERROR_OK) {
5954
_reserved_region_end = 0;
6055
}
6156
return status;
@@ -113,8 +108,7 @@ const char *CyReservedRegionBlockDevice::get_type() const
113108

114109
int CyReservedRegionBlockDevice::reserved_read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size)
115110
{
116-
if (addr + size > _reserved_region_end || addr % get_read_size() != 0 || size % get_read_size() != 0)
117-
{
111+
if (addr + size > _reserved_region_end || addr % get_read_size() != 0 || size % get_read_size() != 0) {
118112
return BD_ERROR_DEVICE_ERROR;
119113
}
120114

0 commit comments

Comments
 (0)