summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-08-09 23:47:29 +0930
committerAndrew Jeffery <andrew@aj.id.au>2018-09-12 15:05:51 +0930
commit8eab21516a6c4395c6f4f4d630e00c04f6ece6cf (patch)
tree8abbe44bc5600ea5124088002aa66ee8a773e745
parent2f1477c4377f9cf32fb4ee8ee981047c108d8c39 (diff)
downloadphosphor-mboxbridge-8eab21516a6c4395c6f4f4d630e00c04f6ece6cf.tar.gz
phosphor-mboxbridge-8eab21516a6c4395c6f4f4d630e00c04f6ece6cf.zip
mboxd: Cleanup errnos not captured by tests
Change-Id: I95d1eee536e4113867fceb5dcda45e15dc032002 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--flash.c16
-rw-r--r--lpc.c4
-rw-r--r--vpnor/flash.cpp14
-rw-r--r--vpnor/mboxd_pnor_partition_table.cpp6
-rw-r--r--windows.c8
5 files changed, 24 insertions, 24 deletions
diff --git a/flash.c b/flash.c
index 6fb9c2c..ee527dc 100644
--- a/flash.c
+++ b/flash.c
@@ -135,7 +135,7 @@ int flash_set_bytemap(struct mbox_context *context, uint32_t offset,
uint32_t count, uint8_t val)
{
if ((offset + count) > context->flash_size) {
- return -MBOX_R_PARAM_ERROR;
+ return -EINVAL;
}
MSG_DBG("Set flash bytemap @ 0x%.8x for 0x%.8x to %s\n",
@@ -186,7 +186,7 @@ int flash_erase(struct mbox_context *context, uint32_t offset, uint32_t count)
if (rc < 0) {
MSG_ERR("Couldn't erase flash at 0x%.8x\n",
erase_info.start);
- return -MBOX_R_SYSTEM_ERROR;
+ return -errno;
}
/* Mark ERASED where we just erased */
flash_set_bytemap(context, erase_info.start,
@@ -206,7 +206,7 @@ int flash_erase(struct mbox_context *context, uint32_t offset, uint32_t count)
if (rc < 0) {
MSG_ERR("Couldn't erase flash at 0x%.8x\n",
erase_info.start);
- return -MBOX_R_SYSTEM_ERROR;
+ return -errno;
}
/* Mark ERASED where we just erased */
flash_set_bytemap(context, erase_info.start, erase_info.length,
@@ -239,7 +239,7 @@ int64_t flash_copy(struct mbox_context *context, uint32_t offset, void *mem,
if (lseek(context->fds[MTD_FD].fd, offset, SEEK_SET) != offset) {
MSG_ERR("Couldn't seek flash at pos: %u %s\n", offset,
strerror(errno));
- return -MBOX_R_SYSTEM_ERROR;
+ return -errno;
}
do {
@@ -248,14 +248,14 @@ int64_t flash_copy(struct mbox_context *context, uint32_t offset, void *mem,
if (size_read < 0) {
MSG_ERR("Couldn't copy mtd into ram: %s\n",
strerror(errno));
- return -MBOX_R_SYSTEM_ERROR;
+ return -errno;
}
size -= size_read;
mem += size_read;
} while (size && size_read);
- return size_read ? mem - start : -MBOX_R_SYSTEM_ERROR;
+ return size_read ? mem - start : -EIO;
}
/*
@@ -278,7 +278,7 @@ int flash_write(struct mbox_context *context, uint32_t offset, void *buf,
if (lseek(context->fds[MTD_FD].fd, offset, SEEK_SET) != offset) {
MSG_ERR("Couldn't seek flash at pos: %u %s\n", offset,
strerror(errno));
- return -MBOX_R_SYSTEM_ERROR;
+ return -errno;
}
while (count) {
@@ -286,7 +286,7 @@ int flash_write(struct mbox_context *context, uint32_t offset, void *buf,
if (rc < 0) {
MSG_ERR("Couldn't write to flash, write lost: %s\n",
strerror(errno));
- return -MBOX_R_WRITE_ERROR;
+ return -errno;
}
/* Mark *NOT* erased where we just wrote */
flash_set_bytemap(context, offset + buf_offset, rc,
diff --git a/lpc.c b/lpc.c
index 4b9d384..f64e5d1 100644
--- a/lpc.c
+++ b/lpc.c
@@ -119,7 +119,7 @@ int lpc_map_flash(struct mbox_context *context)
/* Don't let the host access flash while we're suspended */
if (context->state & STATE_SUSPENDED) {
MSG_ERR("Can't point lpc mapping to flash while suspended\n");
- return -MBOX_R_PARAM_ERROR;
+ return -EBUSY;
}
MSG_INFO("Pointing HOST LPC bus at the flash\n");
@@ -130,7 +130,7 @@ int lpc_map_flash(struct mbox_context *context)
== -1) {
MSG_ERR("Failed to point the LPC BUS at the actual flash: %s\n",
strerror(errno));
- return -MBOX_R_SYSTEM_ERROR;
+ return -errno;
}
context->state = ACTIVE_MAPS_FLASH;
diff --git a/vpnor/flash.cpp b/vpnor/flash.cpp
index 3756141..f7e0713 100644
--- a/vpnor/flash.cpp
+++ b/vpnor/flash.cpp
@@ -126,7 +126,7 @@ int64_t flash_copy(struct mbox_context* context, uint32_t offset, void* mem,
if (!(context && context->vpnor && context->vpnor->table))
{
MSG_ERR("Trying to copy data with uninitialised context!\n");
- return -MBOX_R_SYSTEM_ERROR;
+ return -EINVAL;
}
table = context->vpnor->table;
@@ -171,7 +171,7 @@ int64_t flash_copy(struct mbox_context* context, uint32_t offset, void* mem,
{
MSG_ERR("%s\n", e.what());
phosphor::logging::commit<err::InternalFailure>();
- rc = -MBOX_R_SYSTEM_ERROR;
+ rc = -EIO;
}
return rc;
}
@@ -193,7 +193,7 @@ int flash_write(struct mbox_context* context, uint32_t offset, void* buf,
if (!(context && context->vpnor && context->vpnor->table))
{
MSG_ERR("Trying to write data with uninitialised context!\n");
- return -MBOX_R_SYSTEM_ERROR;
+ return -EINVAL;
}
vpnor::partition::Table* table = context->vpnor->table;
@@ -206,7 +206,7 @@ int flash_write(struct mbox_context* context, uint32_t offset, void* buf,
MSG_ERR("Unreachable: Host attempted to write to read-only "
"partition %s\n",
part.data.name);
- return -MBOX_R_WRITE_ERROR;
+ return -EPERM;
}
MSG_DBG("Write flash @ 0x%.8x for 0x%.8x from %p\n", offset, count,
@@ -219,18 +219,18 @@ int flash_write(struct mbox_context* context, uint32_t offset, void* buf,
MSG_ERR("Unreachable: Host attempted to write %" PRIu32
" bytes to unmapped offset 0x%" PRIx32 "\n",
count, offset);
- return -MBOX_R_WRITE_ERROR;
+ return -EACCES;
}
catch (const vpnor::OutOfBoundsOffset& e)
{
MSG_ERR("%s\n", e.what());
- return -MBOX_R_PARAM_ERROR;
+ return -EINVAL;
}
catch (const std::exception& e)
{
MSG_ERR("%s\n", e.what());
phosphor::logging::commit<err::InternalFailure>();
- return -MBOX_R_SYSTEM_ERROR;
+ return -EIO;
}
return 0;
}
diff --git a/vpnor/mboxd_pnor_partition_table.cpp b/vpnor/mboxd_pnor_partition_table.cpp
index f787fc8..329e065 100644
--- a/vpnor/mboxd_pnor_partition_table.cpp
+++ b/vpnor/mboxd_pnor_partition_table.cpp
@@ -57,7 +57,7 @@ int init_vpnor_from_paths(struct mbox_context *context)
{
MSG_ERR("%s\n", e.what());
phosphor::logging::commit<err::InternalFailure>();
- return -MBOX_R_SYSTEM_ERROR;
+ return -EINVAL;
}
}
@@ -112,13 +112,13 @@ int vpnor_copy_bootloader_partition(const struct mbox_context *context)
catch (err::InternalFailure &e)
{
phosphor::logging::commit<err::InternalFailure>();
- return -MBOX_R_SYSTEM_ERROR;
+ return -EIO;
}
catch (vpnor::ReasonedError &e)
{
MSG_ERR("%s\n", e.what());
phosphor::logging::commit<err::InternalFailure>();
- return -MBOX_R_SYSTEM_ERROR;
+ return -EIO;
}
return 0;
diff --git a/windows.c b/windows.c
index 26fd37b..a126365 100644
--- a/windows.c
+++ b/windows.c
@@ -189,7 +189,7 @@ int window_flush_v1(struct mbox_context *context,
low_mem.mem = malloc(low_mem.size);
if (!low_mem.mem) {
MSG_ERR("Unable to allocate memory\n");
- return -MBOX_R_SYSTEM_ERROR;
+ return -ENOMEM;
}
rc = flash_copy(context, low_mem.flash_offset,
low_mem.mem, low_mem.size);
@@ -203,7 +203,7 @@ int window_flush_v1(struct mbox_context *context,
high_mem.mem = malloc(high_mem.size);
if (!high_mem.mem) {
MSG_ERR("Unable to allocate memory\n");
- rc = -MBOX_R_SYSTEM_ERROR;
+ rc = -ENOMEM;
goto out;
}
rc = flash_copy(context, high_mem.flash_offset,
@@ -322,7 +322,7 @@ int window_flush(struct mbox_context *context, uint32_t offset,
default:
/* We shouldn't be able to get here */
MSG_ERR("Write from window with invalid type: %d\n", type);
- return -MBOX_R_SYSTEM_ERROR;
+ return -EPERM;
}
return 0;
@@ -594,7 +594,7 @@ int windows_create_map(struct mbox_context *context,
if (offset > context->flash_size) {
MSG_ERR("Tried to open read window past flash limit\n");
- return -MBOX_R_PARAM_ERROR;
+ return -EINVAL;
} else if ((offset + cur->size) > context->flash_size) {
/*
* There is V1 skiboot implementations out there which don't
OpenPOWER on IntegriCloud