Commit 5a08c526 authored by Bart Westgeest's avatar Bart Westgeest Committed by Greg Kroah-Hartman

staging: usbip: removed dead code from receive function

The usbip_xmit function supported sending and receiving data, however
the sending part of the function was never used/executed. Renamed the
function to usbip_recv, and removed the unused code.
Signed-off-by: default avatarBart Westgeest <bart@elbrys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 79335140
...@@ -564,7 +564,7 @@ static void stub_rx_pdu(struct usbip_device *ud) ...@@ -564,7 +564,7 @@ static void stub_rx_pdu(struct usbip_device *ud)
memset(&pdu, 0, sizeof(pdu)); memset(&pdu, 0, sizeof(pdu));
/* 1. receive a pdu header */ /* 1. receive a pdu header */
ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0); ret = usbip_recv(ud->tcp_socket, &pdu, sizeof(pdu));
if (ret != sizeof(pdu)) { if (ret != sizeof(pdu)) {
dev_err(dev, "recv a header, %d\n", ret); dev_err(dev, "recv a header, %d\n", ret);
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP); usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
......
...@@ -334,9 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu) ...@@ -334,9 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu)
} }
EXPORT_SYMBOL_GPL(usbip_dump_header); EXPORT_SYMBOL_GPL(usbip_dump_header);
/* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */ /* Receive data over TCP/IP. */
int usbip_xmit(int send, struct socket *sock, char *buf, int size, int usbip_recv(struct socket *sock, void *buf, int size)
int msg_flags)
{ {
int result; int result;
struct msghdr msg; struct msghdr msg;
...@@ -355,19 +354,6 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size, ...@@ -355,19 +354,6 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size,
return -EINVAL; return -EINVAL;
} }
if (usbip_dbg_flag_xmit) {
if (send) {
if (!in_interrupt())
pr_debug("%-10s:", current->comm);
else
pr_debug("interrupt :");
pr_debug("sending... , sock %p, buf %p, size %d, "
"msg_flags %d\n", sock, buf, size, msg_flags);
usbip_dump_buffer(buf, size);
}
}
do { do {
sock->sk->sk_allocation = GFP_NOIO; sock->sk->sk_allocation = GFP_NOIO;
iov.iov_base = buf; iov.iov_base = buf;
...@@ -377,42 +363,30 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size, ...@@ -377,42 +363,30 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size,
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_namelen = 0; msg.msg_namelen = 0;
msg.msg_flags = msg_flags | MSG_NOSIGNAL; msg.msg_flags = MSG_NOSIGNAL;
if (send)
result = kernel_sendmsg(sock, &msg, &iov, 1, size);
else
result = kernel_recvmsg(sock, &msg, &iov, 1, size,
MSG_WAITALL);
result = kernel_recvmsg(sock, &msg, &iov, 1, size, MSG_WAITALL);
if (result <= 0) { if (result <= 0) {
pr_debug("%s sock %p buf %p size %u ret %d total %d\n", pr_debug("receive sock %p buf %p size %u ret %d total %d\n",
send ? "send" : "receive", sock, buf, size, sock, buf, size, result, total);
result, total);
goto err; goto err;
} }
size -= result; size -= result;
buf += result; buf += result;
total += result; total += result;
} while (size > 0); } while (size > 0);
if (usbip_dbg_flag_xmit) { if (usbip_dbg_flag_xmit) {
if (!send) { if (!in_interrupt())
if (!in_interrupt()) pr_debug("%-10s:", current->comm);
pr_debug("%-10s:", current->comm); else
else pr_debug("interrupt :");
pr_debug("interrupt :");
pr_debug("receiving....\n");
usbip_dump_buffer(bp, osize);
pr_debug("received, osize %d ret %d size %d total %d\n",
osize, result, size, total);
}
if (send) pr_debug("receiving....\n");
pr_debug("send, total %d\n", total); usbip_dump_buffer(bp, osize);
pr_debug("received, osize %d ret %d size %d total %d\n",
osize, result, size, total);
} }
return total; return total;
...@@ -420,7 +394,7 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size, ...@@ -420,7 +394,7 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size,
err: err:
return result; return result;
} }
EXPORT_SYMBOL_GPL(usbip_xmit); EXPORT_SYMBOL_GPL(usbip_recv);
struct socket *sockfd_to_socket(unsigned int sockfd) struct socket *sockfd_to_socket(unsigned int sockfd)
{ {
...@@ -712,7 +686,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) ...@@ -712,7 +686,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
if (!buff) if (!buff)
return -ENOMEM; return -ENOMEM;
ret = usbip_xmit(0, ud->tcp_socket, buff, size, 0); ret = usbip_recv(ud->tcp_socket, buff, size);
if (ret != size) { if (ret != size) {
dev_err(&urb->dev->dev, "recv iso_frame_descriptor, %d\n", dev_err(&urb->dev->dev, "recv iso_frame_descriptor, %d\n",
ret); ret);
...@@ -823,8 +797,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb) ...@@ -823,8 +797,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
if (!(size > 0)) if (!(size > 0))
return 0; return 0;
ret = usbip_xmit(0, ud->tcp_socket, (char *)urb->transfer_buffer, ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size);
size, 0);
if (ret != size) { if (ret != size) {
dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret); dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret);
if (ud->side == USBIP_STUB) { if (ud->side == USBIP_STUB) {
......
...@@ -305,8 +305,7 @@ void setreuse(struct socket *); ...@@ -305,8 +305,7 @@ void setreuse(struct socket *);
void usbip_dump_urb(struct urb *purb); void usbip_dump_urb(struct urb *purb);
void usbip_dump_header(struct usbip_header *pdu); void usbip_dump_header(struct usbip_header *pdu);
int usbip_xmit(int send, struct socket *sock, char *buf, int size, int usbip_recv(struct socket *sock, void *buf, int size);
int msg_flags);
struct socket *sockfd_to_socket(unsigned int sockfd); struct socket *sockfd_to_socket(unsigned int sockfd);
void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd, void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
......
...@@ -206,7 +206,7 @@ static void vhci_rx_pdu(struct usbip_device *ud) ...@@ -206,7 +206,7 @@ static void vhci_rx_pdu(struct usbip_device *ud)
memset(&pdu, 0, sizeof(pdu)); memset(&pdu, 0, sizeof(pdu));
/* 1. receive a pdu header */ /* 1. receive a pdu header */
ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0); ret = usbip_recv(ud->tcp_socket, &pdu, sizeof(pdu));
if (ret < 0) { if (ret < 0) {
if (ret == -ECONNRESET) if (ret == -ECONNRESET)
pr_info("connection reset by peer\n"); pr_info("connection reset by peer\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment