summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2015-02-04 16:07:43 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-02-09 13:55:25 +1100
commit91b9a6f43ab16a66c4fe792a5d2615eea8a5620c (patch)
tree2efe60ff6f3d2f8777c3504134fff0f43bf5008a /core
parent38bb327d1ad3d5971dc7ddab4ad6d2386e5f6036 (diff)
downloadblackbird-skiboot-91b9a6f43ab16a66c4fe792a5d2615eea8a5620c.tar.gz
blackbird-skiboot-91b9a6f43ab16a66c4fe792a5d2615eea8a5620c.zip
ipmi: Add a function to (re)initialise a message without allocation
Currently the only functions we have for initialising ipmi messages with the correct values also allocate memory for the message. In some cases we want to reuse previously allocated messages to avoid continually freeing/allocating memory. This patch introduces a function which (re)initialises a previously allocated message and converts existing instances of this behaviour over to the new function. Signed-off-by: Alistair Popple <alistair@popple.id.au> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r--core/ipmi.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/core/ipmi.c b/core/ipmi.c
index 76b9a338..5caf0578 100644
--- a/core/ipmi.c
+++ b/core/ipmi.c
@@ -30,6 +30,22 @@ void ipmi_free_msg(struct ipmi_msg *msg)
msg->backend->free_msg(msg);
}
+void ipmi_init_msg(struct ipmi_msg *msg, int interface,
+ uint32_t code, void (*complete)(struct ipmi_msg *),
+ void *user_data, size_t req_size, size_t resp_size)
+{
+ /* We don't actually support multiple interfaces at the moment. */
+ assert(interface == IPMI_DEFAULT_INTERFACE);
+
+ msg->backend = ipmi_backend;
+ msg->cmd = IPMI_CMD(code);
+ msg->netfn = IPMI_NETFN(code) << 2;
+ msg->req_size = req_size;
+ msg->resp_size = resp_size;
+ msg->complete = complete;
+ msg->user_data = user_data;
+}
+
struct ipmi_msg *ipmi_mkmsg_simple(uint32_t code, void *req_data, size_t req_size)
{
return ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, code, ipmi_free_msg, NULL,
@@ -43,20 +59,12 @@ struct ipmi_msg *ipmi_mkmsg(int interface, uint32_t code,
{
struct ipmi_msg *msg;
- /* We don't actually support multiple interfaces at the moment. */
- assert(interface == IPMI_DEFAULT_INTERFACE);
-
msg = ipmi_backend->alloc_msg(req_size, resp_size);
if (!msg)
return NULL;
- msg->backend = ipmi_backend;
- msg->cmd = IPMI_CMD(code);
- msg->netfn = IPMI_NETFN(code) << 2;
- msg->req_size = req_size;
- msg->resp_size = resp_size;
- msg->complete = complete;
- msg->user_data = user_data;
+ ipmi_init_msg(msg, interface, code, complete, user_data, req_size,
+ resp_size);
/* Commands are free to over ride this if they want to handle errors */
msg->error = ipmi_free_msg;
OpenPOWER on IntegriCloud