summaryrefslogtreecommitdiffstats
path: root/mboxd_msg.c
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2017-04-10 23:51:07 +0930
committerAndrew Jeffery <andrew@aj.id.au>2017-04-26 11:34:00 +0930
commit913740f0284d6b84519f0afc62e2878ff06bce09 (patch)
tree0f85b20ef5f5e899cb92fc154fd4fc243db65cc6 /mboxd_msg.c
parent55dede6b30694145ac0d8e79cc13172077183f17 (diff)
downloadphosphor-mboxd-913740f0284d6b84519f0afc62e2878ff06bce09.tar.gz
phosphor-mboxd-913740f0284d6b84519f0afc62e2878ff06bce09.zip
mboxd_msg: Split init function to enable testing
Allows passing a dev node path through. Change-Id: Ice3fd8157366b4687fd7f3aac72619a1f0a67fff Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'mboxd_msg.c')
-rw-r--r--mboxd_msg.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mboxd_msg.c b/mboxd_msg.c
index a5bcf62..cdd8b69 100644
--- a/mboxd_msg.c
+++ b/mboxd_msg.c
@@ -792,15 +792,15 @@ int dispatch_mbox(struct mbox_context *context)
return handle_mbox_req(context, &req);
}
-int init_mbox_dev(struct mbox_context *context)
+int __init_mbox_dev(struct mbox_context *context, const char *path)
{
int fd;
/* Open MBOX Device */
- fd = open(MBOX_HOST_PATH, O_RDWR | O_NONBLOCK);
+ fd = open(path, O_RDWR | O_NONBLOCK);
if (fd < 0) {
MSG_ERR("Couldn't open %s with flags O_RDWR: %s\n",
- MBOX_HOST_PATH, strerror(errno));
+ path, strerror(errno));
return -errno;
}
@@ -809,6 +809,11 @@ int init_mbox_dev(struct mbox_context *context)
return 0;
}
+int init_mbox_dev(struct mbox_context *context)
+{
+ return __init_mbox_dev(context, MBOX_HOST_PATH);
+}
+
void free_mbox_dev(struct mbox_context *context)
{
close(context->fds[MBOX_FD].fd);
OpenPOWER on IntegriCloud