summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Handley <dan.handley@arm.com>2014-08-04 18:31:43 +0100
committerDan Handley <dan.handley@arm.com>2014-08-14 11:16:15 +0100
commit6d16ce0bfee7101a125fc5545ca12e19c3d47cd1 (patch)
tree68ed031855818bd54b86a8e6447ae9a5dabf1b94 /lib
parentcae3ef992e24b9ceb2ba1cd7d2ef0c6faaf29e0a (diff)
Remove redundant io_init() function
The intent of io_init() was to allow platform ports to provide a data object (io_plat_data_t) to the IO storage framework to allocate into. The abstraction was incomplete because io_plat_data_t uses a platform defined constant and the IO storage framework internally allocates other arrays using platform defined constants. This change simplifies the implementation by instantiating the supporting objects in the IO storage framework itself. There is now no need for the platform to call io_init(). The FVP port has been updated accordingly. THIS CHANGE REQUIRES ALL PLATFORM PORTS THAT USE THE IO STORAGE FRAMEWORK TO BE UDPATED. Change-Id: Ib48ac334de9e538064734334c773f8b43df3a7dc
Diffstat (limited to 'lib')
-rw-r--r--lib/io_storage.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/lib/io_storage.c b/lib/io_storage.c
index 204310a4..a3a8186d 100644
--- a/lib/io_storage.c
+++ b/lib/io_storage.c
@@ -31,13 +31,10 @@
#include <assert.h>
#include <io_driver.h>
#include <io_storage.h>
+#include <platform_def.h>
#include <stddef.h>
-#define MAX_DEVICES(plat_data) \
- (sizeof((plat_data)->devices)/sizeof((plat_data)->devices[0]))
-
-
/* Storage for a fixed maximum number of IO entities, definable by platform */
static io_entity_t entity_pool[MAX_IO_HANDLES];
@@ -48,9 +45,11 @@ static io_entity_t *entity_map[MAX_IO_HANDLES];
/* Track number of allocated entities */
static unsigned int entity_count;
+/* Array of fixed maximum of registered devices, definable by platform */
+static const io_dev_info_t *devices[MAX_IO_DEVICES];
-/* Used to keep a reference to platform-specific data */
-static io_plat_data_t *platform_data;
+/* Number of currently registered devices */
+static unsigned int dev_count;
#if DEBUG /* Extra validation functions only used in debug builds */
@@ -167,27 +166,15 @@ static int free_entity(const io_entity_t *entity)
/* Exported API */
-
-/* Initialise the IO layer */
-void io_init(io_plat_data_t *data)
-{
- assert(data != NULL);
- platform_data = data;
-}
-
-
/* Register a device driver */
int io_register_device(const io_dev_info_t *dev_info)
{
int result = IO_FAIL;
assert(dev_info != NULL);
- assert(platform_data != NULL);
-
- unsigned int dev_count = platform_data->dev_count;
- if (dev_count < MAX_DEVICES(platform_data)) {
- platform_data->devices[dev_count] = dev_info;
- platform_data->dev_count++;
+ if (dev_count < MAX_IO_DEVICES) {
+ devices[dev_count] = dev_info;
+ dev_count++;
result = IO_SUCCESS;
} else {
result = IO_RESOURCES_EXHAUSTED;