mei: use only one buffer in callback

The callback structure is used exclusively for reading or writing
therefore there is no reason to hold both response and request buffers
in the callback structure

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tomas Winkler
2015-02-10 10:39:42 +02:00
committed by Greg Kroah-Hartman
parent 331e418701
commit 5db7514d93
7 changed files with 31 additions and 63 deletions

View File

@@ -134,19 +134,17 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,
cl->reading_state = MEI_READING;
if (cb->response_buffer.size == 0 ||
cb->response_buffer.data == NULL) {
if (cb->buf.size == 0 || cb->buf.data == NULL) {
cl_err(dev, cl, "response buffer is not allocated.\n");
list_move_tail(&cb->list, &complete_list->list);
cb->status = -ENOMEM;
goto out;
}
if (cb->response_buffer.size < mei_hdr->length + cb->buf_idx) {
if (cb->buf.size < mei_hdr->length + cb->buf_idx) {
cl_dbg(dev, cl, "message overflow. size %d len %d idx %ld\n",
cb->response_buffer.size, mei_hdr->length, cb->buf_idx);
buffer = krealloc(cb->response_buffer.data,
mei_hdr->length + cb->buf_idx,
cb->buf.size, mei_hdr->length, cb->buf_idx);
buffer = krealloc(cb->buf.data, mei_hdr->length + cb->buf_idx,
GFP_KERNEL);
if (!buffer) {
@@ -154,11 +152,11 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,
list_move_tail(&cb->list, &complete_list->list);
goto out;
}
cb->response_buffer.data = buffer;
cb->response_buffer.size = mei_hdr->length + cb->buf_idx;
cb->buf.data = buffer;
cb->buf.size = mei_hdr->length + cb->buf_idx;
}
buffer = cb->response_buffer.data + cb->buf_idx;
buffer = cb->buf.data + cb->buf_idx;
mei_read_slots(dev, buffer, mei_hdr->length);
cb->buf_idx += mei_hdr->length;