diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-07-14 16:13:07 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-12-02 21:24:02 -0500 |
commit | ce3d6e7d4200617e6086c1a83220cf6efd3c92cf (patch) | |
tree | 3a1b1c793176d19b5c3f37184ba8ccff43372aca | |
parent | 19c5b89d8d582cce9a90335de212cf477fe15b95 (diff) |
vmci: get rid of qp_memcpy_from_queue()
switch both of its users to qp_memcpy_from_queue_iov() - just
make it take iov_iter * instead of msghdr * and arrange for a
iov_iter for it in all cases.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/misc/vmw_vmci/vmci_queue_pair.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c index 7387dedcda67..a0c10f8cba30 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c @@ -441,13 +441,11 @@ static int __qp_memcpy_from_queue(void *dest, to_copy = size - bytes_copied; if (is_iovec) { - struct msghdr *msg = dest; + struct iov_iter *to = dest; int err; - /* The iovec will track bytes_copied internally. */ - err = memcpy_to_msg(msg, (u8 *)va + page_offset, - to_copy); - if (err != 0) { + err = copy_to_iter((u8 *)va + page_offset, to_copy, to); + if (err != to_copy) { if (kernel_if->host) kunmap(kernel_if->u.h.page[page_index]); return VMCI_ERROR_INVALID_ARGS; @@ -577,15 +575,6 @@ static int qp_memcpy_to_queue(struct vmci_queue *queue, (u8 *)src + src_offset, size, false); } -static int qp_memcpy_from_queue(void *dest, - size_t dest_offset, - const struct vmci_queue *queue, - u64 queue_offset, size_t size) -{ - return __qp_memcpy_from_queue((u8 *)dest + dest_offset, - queue, queue_offset, size, false); -} - /* * Copies from a given iovec from a VMCI Queue. */ @@ -3159,18 +3148,22 @@ ssize_t vmci_qpair_dequeue(struct vmci_qp *qpair, int buf_type) { ssize_t result; + struct iov_iter to; + struct kvec v = {.iov_base = buf, .iov_len = buf_size}; if (!qpair || !buf) return VMCI_ERROR_INVALID_ARGS; + iov_iter_kvec(&to, READ | ITER_KVEC, &v, 1, buf_size); + qp_lock(qpair); do { result = qp_dequeue_locked(qpair->produce_q, qpair->consume_q, qpair->consume_q_size, - buf, buf_size, - qp_memcpy_from_queue, true); + &to, buf_size, + qp_memcpy_from_queue_iov, true); if (result == VMCI_ERROR_QUEUEPAIR_NOT_READY && !qp_wait_for_ready_queue(qpair)) @@ -3200,19 +3193,23 @@ ssize_t vmci_qpair_peek(struct vmci_qp *qpair, size_t buf_size, int buf_type) { + struct iov_iter to; + struct kvec v = {.iov_base = buf, .iov_len = buf_size}; ssize_t result; if (!qpair || !buf) return VMCI_ERROR_INVALID_ARGS; + iov_iter_kvec(&to, READ | ITER_KVEC, &v, 1, buf_size); + qp_lock(qpair); do { result = qp_dequeue_locked(qpair->produce_q, qpair->consume_q, qpair->consume_q_size, - buf, buf_size, - qp_memcpy_from_queue, false); + &to, buf_size, + qp_memcpy_from_queue_iov, false); if (result == VMCI_ERROR_QUEUEPAIR_NOT_READY && !qp_wait_for_ready_queue(qpair)) @@ -3295,7 +3292,7 @@ ssize_t vmci_qpair_dequev(struct vmci_qp *qpair, result = qp_dequeue_locked(qpair->produce_q, qpair->consume_q, qpair->consume_q_size, - msg, msg_data_left(msg), + &msg->msg_iter, msg_data_left(msg), qp_memcpy_from_queue_iov, true); @@ -3339,7 +3336,7 @@ ssize_t vmci_qpair_peekv(struct vmci_qp *qpair, result = qp_dequeue_locked(qpair->produce_q, qpair->consume_q, qpair->consume_q_size, - msg, msg_data_left(msg), + &msg->msg_iter, msg_data_left(msg), qp_memcpy_from_queue_iov, false); |