From e098e244a25017d8298d63a8bf04e9151b52ac3a Mon Sep 17 00:00:00 2001 From: Juan Castillo Date: Mon, 2 Nov 2015 10:47:01 +0000 Subject: Remove deprecated IO return definitions Patch 7e26fe1f deprecates IO specific return definitions in favour of standard errno codes. This patch removes those definitions and its usage from the IO framework, IO drivers and IO platform layer. Following this patch, standard errno codes must be used when checking the return value of an IO function. Change-Id: Id6e0e9d0a7daf15a81ec598cf74de83d5768650f --- drivers/io/io_semihosting.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'drivers/io/io_semihosting.c') diff --git a/drivers/io/io_semihosting.c b/drivers/io/io_semihosting.c index 8e62be1d..63d0f68e 100644 --- a/drivers/io/io_semihosting.c +++ b/drivers/io/io_semihosting.c @@ -84,10 +84,9 @@ static const io_dev_info_t sh_dev_info = { static int sh_dev_open(const uintptr_t dev_spec __unused, io_dev_info_t **dev_info) { - int result = IO_SUCCESS; assert(dev_info != NULL); *dev_info = (io_dev_info_t *)&sh_dev_info; /* cast away const */ - return result; + return 0; } @@ -95,7 +94,7 @@ static int sh_dev_open(const uintptr_t dev_spec __unused, static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)), const uintptr_t spec, io_entity_t *entity) { - int result = IO_FAIL; + int result = -ENOENT; long sh_result = -1; const io_file_spec_t *file_spec = (const io_file_spec_t *)spec; @@ -106,9 +105,7 @@ static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)), if (sh_result > 0) { entity->info = (uintptr_t)sh_result; - result = IO_SUCCESS; - } else { - result = IO_FAIL; + result = 0; } return result; } @@ -117,7 +114,6 @@ static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)), /* Seek to a particular file offset on the semi-hosting device */ static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset) { - int result = IO_FAIL; long file_handle, sh_result; assert(entity != NULL); @@ -126,16 +122,14 @@ static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset) sh_result = semihosting_file_seek(file_handle, offset); - result = (sh_result == 0) ? IO_SUCCESS : IO_FAIL; - - return result; + return (sh_result == 0) ? 0 : -ENOENT; } /* Return the size of a file on the semi-hosting device */ static int sh_file_len(io_entity_t *entity, size_t *length) { - int result = IO_FAIL; + int result = -ENOENT; assert(entity != NULL); assert(length != NULL); @@ -144,7 +138,7 @@ static int sh_file_len(io_entity_t *entity, size_t *length) long sh_result = semihosting_file_length(sh_handle); if (sh_result >= 0) { - result = IO_SUCCESS; + result = 0; *length = (size_t)sh_result; } @@ -156,7 +150,7 @@ static int sh_file_len(io_entity_t *entity, size_t *length) static int sh_file_read(io_entity_t *entity, uintptr_t buffer, size_t length, size_t *length_read) { - int result = IO_FAIL; + int result = -ENOENT; long sh_result = -1; size_t bytes = length; long file_handle; @@ -171,9 +165,8 @@ static int sh_file_read(io_entity_t *entity, uintptr_t buffer, size_t length, if (sh_result >= 0) { *length_read = (bytes != length) ? bytes : length; - result = IO_SUCCESS; - } else - result = IO_FAIL; + result = 0; + } return result; } @@ -197,14 +190,13 @@ static int sh_file_write(io_entity_t *entity, const uintptr_t buffer, *length_written = length - bytes; - return (sh_result == 0) ? IO_SUCCESS : IO_FAIL; + return (sh_result == 0) ? 0 : -ENOENT; } /* Close a file on the semi-hosting device */ static int sh_file_close(io_entity_t *entity) { - int result = IO_FAIL; long sh_result = -1; long file_handle; @@ -214,9 +206,7 @@ static int sh_file_close(io_entity_t *entity) sh_result = semihosting_file_close(file_handle); - result = (sh_result >= 0) ? IO_SUCCESS : IO_FAIL; - - return result; + return (sh_result >= 0) ? 0 : -ENOENT; } @@ -225,11 +215,11 @@ static int sh_file_close(io_entity_t *entity) /* Register the semi-hosting driver with the IO abstraction */ int register_io_dev_sh(const io_dev_connector_t **dev_con) { - int result = IO_FAIL; + int result; assert(dev_con != NULL); result = io_register_device(&sh_dev_info); - if (result == IO_SUCCESS) + if (result == 0) *dev_con = &sh_dev_connector; return result; -- cgit v1.2.3