diff options
author | johpow01 <john.powell@arm.com> | 2020-07-01 17:09:57 -0500 |
---|---|---|
committer | johpow01 <john.powell@arm.com> | 2020-07-16 13:10:23 -0500 |
commit | d471bd9cfc58bce8efa8fa2d355a20950022f44d (patch) | |
tree | 00e6bd011906fbe4b5f8703454be0f2c776e90f6 /drivers/io/io_memmap.c | |
parent | 8d5db315d32fd304e4f9ade13d7b62df91c88cb1 (diff) | |
download | platform_external_arm-trusted-firmware-d471bd9cfc58bce8efa8fa2d355a20950022f44d.tar.gz platform_external_arm-trusted-firmware-d471bd9cfc58bce8efa8fa2d355a20950022f44d.tar.bz2 platform_external_arm-trusted-firmware-d471bd9cfc58bce8efa8fa2d355a20950022f44d.zip |
IO Driver Misra Cleanup
This patch cleans up MISRA C violations in the IO driver files. Some
things did not make sense to fix or would require sweeping changes
but the simple issues have been resolved.
Defects Fixed
File Line Rule
drivers/io/io_fip.c 39 MISRA C-2012 Rule 5.6 (required)
drivers/io/io_fip.c 52 MISRA C-2012 Rule 8.9 (advisory)
drivers/io/io_fip.c 60 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_fip.c 285 MISRA C-2012 Rule 8.9 (advisory)
drivers/io/io_fip.c 336 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_fip.c 340 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_fip.c 342 MISRA C-2012 Rule 15.4 (advisory)
drivers/io/io_memmap.c 30 MISRA C-2012 Rule 5.6 (required)
drivers/io/io_memmap.c 32 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_memmap.c 85 MISRA C-2012 Rule 11.8 (required)
drivers/io/io_semihosting.c 66 MISRA C-2012 Rule 11.8 (required)
drivers/io/io_storage.c 73 MISRA C-2012 Rule 5.9 (advisory)
drivers/io/io_storage.c 116 MISRA C-2012 Rule 13.4 (advisory)
Signed-off-by: John Powell <john.powell@arm.com>
Change-Id: Id9b1b2b684588d4eaab674ed4ed04f3950dd21f4
Diffstat (limited to 'drivers/io/io_memmap.c')
-rw-r--r-- | drivers/io/io_memmap.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index eed50cc08..eb69163b7 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -27,9 +27,9 @@ typedef struct { uintptr_t base; unsigned long long file_pos; unsigned long long size; -} file_state_t; +} memmap_file_state_t; -static file_state_t current_file = {0}; +static memmap_file_state_t current_memmap_file = {0}; /* Identify the device type as memmap */ static io_type_t device_type_memmap(void) @@ -71,7 +71,7 @@ static const io_dev_funcs_t memmap_dev_funcs = { /* No state associated with this device so structure can be const */ -static const io_dev_info_t memmap_dev_info = { +static io_dev_info_t memmap_dev_info = { .funcs = &memmap_dev_funcs, .info = (uintptr_t)NULL }; @@ -82,8 +82,7 @@ static int memmap_dev_open(const uintptr_t dev_spec __unused, io_dev_info_t **dev_info) { assert(dev_info != NULL); - *dev_info = (io_dev_info_t *)&memmap_dev_info; /* cast away const */ - + *dev_info = &memmap_dev_info; return 0; } @@ -109,16 +108,16 @@ static int memmap_block_open(io_dev_info_t *dev_info, const uintptr_t spec, * spec at a time. When we have dynamic memory we can malloc and set * entity->info. */ - if (current_file.in_use == 0) { + if (current_memmap_file.in_use == 0) { assert(block_spec != NULL); assert(entity != NULL); - current_file.in_use = 1; - current_file.base = block_spec->offset; + current_memmap_file.in_use = 1; + current_memmap_file.base = block_spec->offset; /* File cursor offset for seek and incremental reads etc. */ - current_file.file_pos = 0; - current_file.size = block_spec->length; - entity->info = (uintptr_t)¤t_file; + current_memmap_file.file_pos = 0; + current_memmap_file.size = block_spec->length; + entity->info = (uintptr_t)¤t_memmap_file; result = 0; } else { WARN("A Memmap device is already active. Close first.\n"); @@ -133,13 +132,13 @@ static int memmap_block_seek(io_entity_t *entity, int mode, signed long long offset) { int result = -ENOENT; - file_state_t *fp; + memmap_file_state_t *fp; /* We only support IO_SEEK_SET for the moment. */ if (mode == IO_SEEK_SET) { assert(entity != NULL); - fp = (file_state_t *) entity->info; + fp = (memmap_file_state_t *) entity->info; /* Assert that new file position is valid */ assert((offset >= 0) && @@ -160,7 +159,7 @@ static int memmap_block_len(io_entity_t *entity, size_t *length) assert(entity != NULL); assert(length != NULL); - *length = (size_t)((file_state_t *)entity->info)->size; + *length = (size_t)((memmap_file_state_t *)entity->info)->size; return 0; } @@ -170,13 +169,13 @@ static int memmap_block_len(io_entity_t *entity, size_t *length) static int memmap_block_read(io_entity_t *entity, uintptr_t buffer, size_t length, size_t *length_read) { - file_state_t *fp; + memmap_file_state_t *fp; unsigned long long pos_after; assert(entity != NULL); assert(length_read != NULL); - fp = (file_state_t *) entity->info; + fp = (memmap_file_state_t *) entity->info; /* Assert that file position is valid for this read operation */ pos_after = fp->file_pos + length; @@ -198,13 +197,13 @@ static int memmap_block_read(io_entity_t *entity, uintptr_t buffer, static int memmap_block_write(io_entity_t *entity, const uintptr_t buffer, size_t length, size_t *length_written) { - file_state_t *fp; + memmap_file_state_t *fp; unsigned long long pos_after; assert(entity != NULL); assert(length_written != NULL); - fp = (file_state_t *) entity->info; + fp = (memmap_file_state_t *) entity->info; /* Assert that file position is valid for this write operation */ pos_after = fp->file_pos + length; @@ -230,7 +229,7 @@ static int memmap_block_close(io_entity_t *entity) entity->info = 0; /* This would be a mem free() if we had malloc.*/ - zeromem((void *)¤t_file, sizeof(current_file)); + zeromem((void *)¤t_memmap_file, sizeof(current_memmap_file)); return 0; } |