From 35e98e5588d09145f7d0d4d98624f6b75321a187 Mon Sep 17 00:00:00 2001 From: Dan Handley Date: Wed, 9 Apr 2014 13:13:04 +0100 Subject: Make use of user/system includes more consistent Make codebase consistent in its use of #include "" syntax for user includes and #include <> syntax for system includes. Fixes ARM-software/tf-issues#65 Change-Id: If2f7c4885173b1fd05ac2cde5f1c8a07000c7a33 --- drivers/io/io_memmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/io/io_memmap.c') diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index 40b8e9ab..5685be19 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -30,9 +30,9 @@ #include #include -#include "io_storage.h" -#include "io_driver.h" -#include "debug.h" +#include +#include +#include /* As we need to be able to keep state for seek, only one file can be open * at a time. Make this a structure and point to the entity->info. When we -- cgit From fb037bfb7cbf7b404c069b4ebac5a10059d948b1 Mon Sep 17 00:00:00 2001 From: Dan Handley Date: Thu, 10 Apr 2014 15:37:22 +0100 Subject: Always use named structs in header files Add tag names to all unnamed structs in header files. This allows forward declaration of structs, which is necessary to reduce header file nesting (to be implemented in a subsequent commit). Also change the typedef names across the codebase to use the _t suffix to be more conformant with the Linux coding style. The coding style actually prefers us not to use typedefs at all but this is considered a step too far for Trusted Firmware. Also change the IO framework structs defintions to use typedef'd structs to be consistent with the rest of the codebase. Change-Id: I722b2c86fc0d92e4da3b15e5cab20373dd26786f --- drivers/io/io_memmap.c | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'drivers/io/io_memmap.c') diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index 5685be19..2e70e969 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -45,28 +45,28 @@ typedef struct { int in_use; size_t base; size_t file_pos; -} file_state; +} file_state_t; -static file_state current_file = {0}; +static file_state_t current_file = {0}; /* Identify the device type as memmap */ -io_type device_type_memmap(void) +io_type_t device_type_memmap(void) { return IO_TYPE_MEMMAP; } /* Memmap device functions */ -static int memmap_dev_open(void *spec, struct io_dev_info **dev_info); -static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity); -static int memmap_block_seek(struct io_entity *entity, int mode, +static int memmap_dev_open(void *spec, io_dev_info_t **dev_info); +static int memmap_block_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity); +static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset); -static int memmap_block_read(struct io_entity *entity, void *buffer, +static int memmap_block_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read); -static int memmap_block_write(struct io_entity *entity, const void *buffer, +static int memmap_block_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written); -static int memmap_block_close(struct io_entity *entity); -static int memmap_dev_close(struct io_dev_info *dev_info); +static int memmap_block_close(io_entity_t *entity); +static int memmap_dev_close(io_dev_info_t *dev_info); static struct io_dev_connector memmap_dev_connector = { @@ -95,7 +95,7 @@ static struct io_dev_info memmap_dev_info = { /* Open a connection to the memmap device */ static int memmap_dev_open(void *spec __attribute__((unused)), - struct io_dev_info **dev_info) + io_dev_info_t **dev_info) { assert(dev_info != NULL); *dev_info = &memmap_dev_info; @@ -106,7 +106,7 @@ static int memmap_dev_open(void *spec __attribute__((unused)), /* Close a connection to the memmap device */ -static int memmap_dev_close(struct io_dev_info *dev_info) +static int memmap_dev_close(io_dev_info_t *dev_info) { /* NOP */ /* TODO: Consider tracking open files and cleaning them up here */ @@ -116,11 +116,11 @@ static int memmap_dev_close(struct io_dev_info *dev_info) /* Open a file on the memmap device */ /* TODO: Can we do any sensible limit checks on requested memory */ -static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, - struct io_entity *entity) +static int memmap_block_open(io_dev_info_t *dev_info, const void *spec, + io_entity_t *entity) { int result = IO_FAIL; - const io_block_spec *block_spec = (io_block_spec *)spec; + const io_block_spec_t *block_spec = (io_block_spec_t *)spec; /* Since we need to track open state for seek() we only allow one open * spec at a time. When we have dynamic memory we can malloc and set @@ -146,7 +146,7 @@ static int memmap_block_open(struct io_dev_info *dev_info, const void *spec, /* Seek to a particular file offset on the memmap device */ -static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) +static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset) { int result = IO_FAIL; @@ -155,7 +155,7 @@ static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) assert(entity != NULL); /* TODO: can we do some basic limit checks on seek? */ - ((file_state *)entity->info)->file_pos = offset; + ((file_state_t *)entity->info)->file_pos = offset; result = IO_SUCCESS; } else { result = IO_FAIL; @@ -166,16 +166,16 @@ static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset) /* Read data from a file on the memmap device */ -static int memmap_block_read(struct io_entity *entity, void *buffer, +static int memmap_block_read(io_entity_t *entity, void *buffer, size_t length, size_t *length_read) { - file_state *fp; + file_state_t *fp; assert(entity != NULL); assert(buffer != NULL); assert(length_read != NULL); - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; memcpy(buffer, (void *)(fp->base + fp->file_pos), length); @@ -188,16 +188,16 @@ static int memmap_block_read(struct io_entity *entity, void *buffer, /* Write data to a file on the memmap device */ -static int memmap_block_write(struct io_entity *entity, const void *buffer, +static int memmap_block_write(io_entity_t *entity, const void *buffer, size_t length, size_t *length_written) { - file_state *fp; + file_state_t *fp; assert(entity != NULL); assert(buffer != NULL); assert(length_written != NULL); - fp = (file_state *)entity->info; + fp = (file_state_t *)entity->info; memcpy((void *)(fp->base + fp->file_pos), buffer, length); @@ -211,7 +211,7 @@ static int memmap_block_write(struct io_entity *entity, const void *buffer, /* Close a file on the memmap device */ -static int memmap_block_close(struct io_entity *entity) +static int memmap_block_close(io_entity_t *entity) { assert(entity != NULL); @@ -227,7 +227,7 @@ static int memmap_block_close(struct io_entity *entity) /* Exported functions */ /* Register the memmap driver with the IO abstraction */ -int register_io_dev_memmap(struct io_dev_connector **dev_con) +int register_io_dev_memmap(io_dev_connector_t **dev_con) { int result = IO_FAIL; assert(dev_con != NULL); -- cgit From 97043ac98e13a726dbf8b3b41654dca759e3da2c Mon Sep 17 00:00:00 2001 From: Dan Handley Date: Wed, 9 Apr 2014 13:14:54 +0100 Subject: Reduce deep nesting of header files Reduce the number of header files included from other header files as much as possible without splitting the files. Use forward declarations where possible. This allows removal of some unnecessary "#ifndef __ASSEMBLY__" statements. Also, review the .c and .S files for which header files really need including and reorder the #include statements alphabetically. Fixes ARM-software/tf-issues#31 Change-Id: Iec92fb976334c77453e010b60bcf56f3be72bd3e --- drivers/io/io_memmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/io/io_memmap.c') diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index 2e70e969..a40e6120 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -29,10 +29,10 @@ */ #include -#include -#include -#include #include +#include +#include +#include /* As we need to be able to keep state for seek, only one file can be open * at a time. Make this a structure and point to the entity->info. When we -- cgit