aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-12-21 03:53:10 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-12-26 21:35:37 -0500
commit3995d1610713c1a62af687872e460c3dca82d17c (patch)
tree779e09b1024fd98563df2b46e2f87e1417545935 /drivers/usb
parent4113e47b3d0931879d75dc5ad7c4c294651b3c1d (diff)
usbip_recv(): switch to sock_recvmsg()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/usbip/usbip_common.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index 8b232290be6b..f123bfee5d1b 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -327,13 +327,11 @@ EXPORT_SYMBOL_GPL(usbip_dump_header);
327int usbip_recv(struct socket *sock, void *buf, int size) 327int usbip_recv(struct socket *sock, void *buf, int size)
328{ 328{
329 int result; 329 int result;
330 struct msghdr msg; 330 struct kvec iov = {.iov_base = buf, .iov_len = size};
331 struct kvec iov; 331 struct msghdr msg = {.msg_flags = MSG_NOSIGNAL};
332 int total = 0; 332 int total = 0;
333 333
334 /* for blocks of if (usbip_dbg_flag_xmit) */ 334 iov_iter_kvec(&msg.msg_iter, READ|ITER_KVEC, &iov, 1, size);
335 char *bp = buf;
336 int osize = size;
337 335
338 usbip_dbg_xmit("enter\n"); 336 usbip_dbg_xmit("enter\n");
339 337
@@ -344,26 +342,18 @@ int usbip_recv(struct socket *sock, void *buf, int size)
344 } 342 }
345 343
346 do { 344 do {
345 int sz = msg_data_left(&msg);
347 sock->sk->sk_allocation = GFP_NOIO; 346 sock->sk->sk_allocation = GFP_NOIO;
348 iov.iov_base = buf; 347
349 iov.iov_len = size; 348 result = sock_recvmsg(sock, &msg, MSG_WAITALL);
350 msg.msg_name = NULL;
351 msg.msg_namelen = 0;
352 msg.msg_control = NULL;
353 msg.msg_controllen = 0;
354 msg.msg_flags = MSG_NOSIGNAL;
355
356 result = kernel_recvmsg(sock, &msg, &iov, 1, size, MSG_WAITALL);
357 if (result <= 0) { 349 if (result <= 0) {
358 pr_debug("receive sock %p buf %p size %u ret %d total %d\n", 350 pr_debug("receive sock %p buf %p size %u ret %d total %d\n",
359 sock, buf, size, result, total); 351 sock, buf + total, sz, result, total);
360 goto err; 352 goto err;
361 } 353 }
362 354
363 size -= result;
364 buf += result;
365 total += result; 355 total += result;
366 } while (size > 0); 356 } while (msg_data_left(&msg));
367 357
368 if (usbip_dbg_flag_xmit) { 358 if (usbip_dbg_flag_xmit) {
369 if (!in_interrupt()) 359 if (!in_interrupt())
@@ -372,9 +362,9 @@ int usbip_recv(struct socket *sock, void *buf, int size)
372 pr_debug("interrupt :"); 362 pr_debug("interrupt :");
373 363
374 pr_debug("receiving....\n"); 364 pr_debug("receiving....\n");
375 usbip_dump_buffer(bp, osize); 365 usbip_dump_buffer(buf, size);
376 pr_debug("received, osize %d ret %d size %d total %d\n", 366 pr_debug("received, osize %d ret %d size %zd total %d\n",
377 osize, result, size, total); 367 size, result, msg_data_left(&msg), total);
378 } 368 }
379 369
380 return total; 370 return total;