windows: Make set_window_bytemap return standard errno
Do the error number conversion at the edges.
Change-Id: I5774065f13c8afb865926436b36ea9831f27620d
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd_msg.c b/mboxd_msg.c
index 6bf8918..e267425 100644
--- a/mboxd_msg.c
+++ b/mboxd_msg.c
@@ -422,6 +422,7 @@
union mbox_regs *req, struct mbox_msg *resp)
{
uint32_t offset, size;
+ int rc;
if (!(context->current && context->current_is_write)) {
MSG_ERR("Tried to call mark dirty without open write window\n");
@@ -460,8 +461,14 @@
offset << context->block_size_shift,
size << context->block_size_shift);
- return set_window_bytemap(context, context->current, offset, size,
+ rc = set_window_bytemap(context, context->current, offset, size,
WINDOW_DIRTY);
+ if (rc < 0) {
+ return (rc == -EACCES) ? -MBOX_R_PARAM_ERROR
+ : -MBOX_R_SYSTEM_ERROR;
+ }
+
+ return rc;
}
/*
@@ -503,7 +510,8 @@
rc = set_window_bytemap(context, context->current, offset, size,
WINDOW_ERASED);
if (rc < 0) {
- return rc;
+ return (rc == -EACCES) ? -MBOX_R_PARAM_ERROR
+ : -MBOX_R_SYSTEM_ERROR;
}
/* Write 0xFF to mem -> This ensures consistency between flash & ram */
@@ -609,10 +617,16 @@
}
/* Clear the dirty bytemap since we have written back all changes */
- return set_window_bytemap(context, context->current, 0,
+ rc = set_window_bytemap(context, context->current, 0,
context->current->size >>
context->block_size_shift,
WINDOW_CLEAN);
+ if (rc < 0) {
+ return (rc == -EACCES) ? -MBOX_R_PARAM_ERROR
+ : -MBOX_R_SYSTEM_ERROR;
+ }
+
+ return rc;
}
/*
diff --git a/mboxd_windows.c b/mboxd_windows.c
index 233bfdd..6a14e68 100644
--- a/mboxd_windows.c
+++ b/mboxd_windows.c
@@ -369,7 +369,7 @@
offset << context->block_size_shift,
size << context->block_size_shift,
cur->size << context->block_size_shift);
- return -MBOX_R_PARAM_ERROR;
+ return -EACCES;
}
memset(cur->dirty_bmap + offset, val, size);