diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2018-07-23 06:21:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-24 08:16:57 -0400 |
commit | a1c4d08b6b95a0e296285ee53cc1438b3f168f98 (patch) | |
tree | e1821fb291409d88c6d8cb2cd8b5f12ab0d0ca6e /drivers/misc | |
parent | 8c8d964ce90f16877b76c3f00b27165bf865af69 (diff) |
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: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/mei/client.c | 33 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 2 |
2 files changed, 20 insertions, 15 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index ca917b84ca5e..207d2f5d5702 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -1540,6 +1540,22 @@ nortpm: | |||
1540 | } | 1540 | } |
1541 | 1541 | ||
1542 | /** | 1542 | /** |
1543 | * mei_msg_hdr_init - initialize mei message header | ||
1544 | * | ||
1545 | * @mei_hdr: mei message header | ||
1546 | * @cb: message callback structure | ||
1547 | */ | ||
1548 | static void mei_msg_hdr_init(struct mei_msg_hdr *mei_hdr, struct mei_cl_cb *cb) | ||
1549 | { | ||
1550 | mei_hdr->host_addr = mei_cl_host_addr(cb->cl); | ||
1551 | mei_hdr->me_addr = mei_cl_me_id(cb->cl); | ||
1552 | mei_hdr->length = 0; | ||
1553 | mei_hdr->reserved = 0; | ||
1554 | mei_hdr->msg_complete = 0; | ||
1555 | mei_hdr->internal = cb->internal; | ||
1556 | } | ||
1557 | |||
1558 | /** | ||
1543 | * mei_cl_irq_write - write a message to device | 1559 | * mei_cl_irq_write - write a message to device |
1544 | * from the interrupt thread context | 1560 | * from the interrupt thread context |
1545 | * | 1561 | * |
@@ -1579,12 +1595,6 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, | |||
1579 | return 0; | 1595 | return 0; |
1580 | } | 1596 | } |
1581 | 1597 | ||
1582 | mei_hdr.host_addr = mei_cl_host_addr(cl); | ||
1583 | mei_hdr.me_addr = mei_cl_me_id(cl); | ||
1584 | mei_hdr.reserved = 0; | ||
1585 | mei_hdr.msg_complete = 0; | ||
1586 | mei_hdr.internal = cb->internal; | ||
1587 | |||
1588 | len = buf->size - cb->buf_idx; | 1598 | len = buf->size - cb->buf_idx; |
1589 | hbuf_slots = mei_hbuf_empty_slots(dev); | 1599 | hbuf_slots = mei_hbuf_empty_slots(dev); |
1590 | if (hbuf_slots < 0) { | 1600 | if (hbuf_slots < 0) { |
@@ -1593,6 +1603,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, | |||
1593 | } | 1603 | } |
1594 | hbuf_len = mei_slots2data(hbuf_slots) - sizeof(struct mei_msg_hdr); | 1604 | hbuf_len = mei_slots2data(hbuf_slots) - sizeof(struct mei_msg_hdr); |
1595 | 1605 | ||
1606 | mei_msg_hdr_init(&mei_hdr, cb); | ||
1607 | |||
1596 | /** | 1608 | /** |
1597 | * Split the message only if we can write the whole host buffer | 1609 | * Split the message only if we can write the whole host buffer |
1598 | * otherwise wait for next time the host buffer is empty. | 1610 | * 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, | |||
1616 | cl->status = 0; | 1628 | cl->status = 0; |
1617 | cl->writing_state = MEI_WRITING; | 1629 | cl->writing_state = MEI_WRITING; |
1618 | cb->buf_idx += mei_hdr.length; | 1630 | cb->buf_idx += mei_hdr.length; |
1619 | cb->completed = mei_hdr.msg_complete == 1; | ||
1620 | 1631 | ||
1621 | if (first_chunk) { | 1632 | if (first_chunk) { |
1622 | if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) { | 1633 | 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) | |||
1680 | cb->buf_idx = 0; | 1691 | cb->buf_idx = 0; |
1681 | cl->writing_state = MEI_IDLE; | 1692 | cl->writing_state = MEI_IDLE; |
1682 | 1693 | ||
1683 | mei_hdr.host_addr = mei_cl_host_addr(cl); | ||
1684 | mei_hdr.me_addr = mei_cl_me_id(cl); | ||
1685 | mei_hdr.reserved = 0; | ||
1686 | mei_hdr.msg_complete = 0; | ||
1687 | mei_hdr.internal = cb->internal; | ||
1688 | 1694 | ||
1689 | rets = mei_cl_tx_flow_ctrl_creds(cl); | 1695 | rets = mei_cl_tx_flow_ctrl_creds(cl); |
1690 | if (rets < 0) | 1696 | if (rets < 0) |
1691 | goto err; | 1697 | goto err; |
1692 | 1698 | ||
1699 | mei_msg_hdr_init(&mei_hdr, cb); | ||
1700 | |||
1693 | if (rets == 0) { | 1701 | if (rets == 0) { |
1694 | cl_dbg(dev, cl, "No flow control credentials: not sending.\n"); | 1702 | cl_dbg(dev, cl, "No flow control credentials: not sending.\n"); |
1695 | rets = len; | 1703 | rets = len; |
@@ -1726,7 +1734,6 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) | |||
1726 | 1734 | ||
1727 | cl->writing_state = MEI_WRITING; | 1735 | cl->writing_state = MEI_WRITING; |
1728 | cb->buf_idx = mei_hdr.length; | 1736 | cb->buf_idx = mei_hdr.length; |
1729 | cb->completed = mei_hdr.msg_complete == 1; | ||
1730 | 1737 | ||
1731 | out: | 1738 | out: |
1732 | if (mei_hdr.msg_complete) | 1739 | if (mei_hdr.msg_complete) |
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index fa543dcfc111..e9f37085a628 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -175,7 +175,6 @@ struct mei_cl; | |||
175 | * @status: io status of the cb | 175 | * @status: io status of the cb |
176 | * @internal: communication between driver and FW flag | 176 | * @internal: communication between driver and FW flag |
177 | * @blocking: transmission blocking mode | 177 | * @blocking: transmission blocking mode |
178 | * @completed: the transfer or reception has completed | ||
179 | */ | 178 | */ |
180 | struct mei_cl_cb { | 179 | struct mei_cl_cb { |
181 | struct list_head list; | 180 | struct list_head list; |
@@ -187,7 +186,6 @@ struct mei_cl_cb { | |||
187 | int status; | 186 | int status; |
188 | u32 internal:1; | 187 | u32 internal:1; |
189 | u32 blocking:1; | 188 | u32 blocking:1; |
190 | u32 completed:1; | ||
191 | }; | 189 | }; |
192 | 190 | ||
193 | /** | 191 | /** |