Commit a1c4d08b authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

mei: add mei_msg_hdr_init wrapper.



Wrap the mei header boilerplate initialization code in
mei_msg_hdr_init function. On the way remove 'completed'
field from mei_cl_cb structure as this information
is already included in the header and is local to particular
fragment.

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8c8d964c
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -1539,6 +1539,22 @@ nortpm:
	return rets;
}

/**
 * mei_msg_hdr_init - initialize mei message header
 *
 * @mei_hdr: mei message header
 * @cb: message callback structure
 */
static void mei_msg_hdr_init(struct mei_msg_hdr *mei_hdr, struct mei_cl_cb *cb)
{
	mei_hdr->host_addr = mei_cl_host_addr(cb->cl);
	mei_hdr->me_addr = mei_cl_me_id(cb->cl);
	mei_hdr->length = 0;
	mei_hdr->reserved = 0;
	mei_hdr->msg_complete = 0;
	mei_hdr->internal = cb->internal;
}

/**
 * mei_cl_irq_write - write a message to device
 *	from the interrupt thread context
@@ -1579,12 +1595,6 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
		return 0;
	}

	mei_hdr.host_addr = mei_cl_host_addr(cl);
	mei_hdr.me_addr = mei_cl_me_id(cl);
	mei_hdr.reserved = 0;
	mei_hdr.msg_complete = 0;
	mei_hdr.internal = cb->internal;

	len = buf->size - cb->buf_idx;
	hbuf_slots = mei_hbuf_empty_slots(dev);
	if (hbuf_slots < 0) {
@@ -1593,6 +1603,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
	}
	hbuf_len = mei_slots2data(hbuf_slots) - sizeof(struct mei_msg_hdr);

	mei_msg_hdr_init(&mei_hdr, cb);

	/**
	 * Split the message only if we can write the whole host buffer
	 * otherwise wait for next time the host buffer is empty.
@@ -1616,7 +1628,6 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
	cl->status = 0;
	cl->writing_state = MEI_WRITING;
	cb->buf_idx += mei_hdr.length;
	cb->completed = mei_hdr.msg_complete == 1;

	if (first_chunk) {
		if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) {
@@ -1680,16 +1691,13 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
	cb->buf_idx = 0;
	cl->writing_state = MEI_IDLE;

	mei_hdr.host_addr = mei_cl_host_addr(cl);
	mei_hdr.me_addr = mei_cl_me_id(cl);
	mei_hdr.reserved = 0;
	mei_hdr.msg_complete = 0;
	mei_hdr.internal = cb->internal;

	rets = mei_cl_tx_flow_ctrl_creds(cl);
	if (rets < 0)
		goto err;

	mei_msg_hdr_init(&mei_hdr, cb);

	if (rets == 0) {
		cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
		rets = len;
@@ -1726,7 +1734,6 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)

	cl->writing_state = MEI_WRITING;
	cb->buf_idx = mei_hdr.length;
	cb->completed = mei_hdr.msg_complete == 1;

out:
	if (mei_hdr.msg_complete)
+0 −2
Original line number Diff line number Diff line
@@ -175,7 +175,6 @@ struct mei_cl;
 * @status: io status of the cb
 * @internal: communication between driver and FW flag
 * @blocking: transmission blocking mode
 * @completed: the transfer or reception has completed
 */
struct mei_cl_cb {
	struct list_head list;
@@ -187,7 +186,6 @@ struct mei_cl_cb {
	int status;
	u32 internal:1;
	u32 blocking:1;
	u32 completed:1;
};

/**