Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281425
b: refs/heads/master
c: 5a08c52
h: refs/heads/master
i:
  281423: 62da7cf
v: v3
  • Loading branch information
Bart Westgeest authored and Greg Kroah-Hartman committed Dec 22, 2011
1 parent 6883bed commit c3bbade
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 49 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7933514043d42e69663a5123a53fab50eb0b4aba
refs/heads/master: 5a08c5267e45fe936452051a8c126e8418984eb7
2 changes: 1 addition & 1 deletion trunk/drivers/staging/usbip/stub_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static void stub_rx_pdu(struct usbip_device *ud)
memset(&pdu, 0, sizeof(pdu));

/* 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)) {
dev_err(dev, "recv a header, %d\n", ret);
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
Expand Down
61 changes: 17 additions & 44 deletions trunk/drivers/staging/usbip/usbip_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu)
}
EXPORT_SYMBOL_GPL(usbip_dump_header);

/* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */
int usbip_xmit(int send, struct socket *sock, char *buf, int size,
int msg_flags)
/* Receive data over TCP/IP. */
int usbip_recv(struct socket *sock, void *buf, int size)
{
int result;
struct msghdr msg;
Expand All @@ -355,19 +354,6 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size,
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 {
sock->sk->sk_allocation = GFP_NOIO;
iov.iov_base = buf;
Expand All @@ -377,50 +363,38 @@ int usbip_xmit(int send, struct socket *sock, char *buf, int size,
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_namelen = 0;
msg.msg_flags = 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);
msg.msg_flags = MSG_NOSIGNAL;

result = kernel_recvmsg(sock, &msg, &iov, 1, size, MSG_WAITALL);
if (result <= 0) {
pr_debug("%s sock %p buf %p size %u ret %d total %d\n",
send ? "send" : "receive", sock, buf, size,
result, total);
pr_debug("receive sock %p buf %p size %u ret %d total %d\n",
sock, buf, size, result, total);
goto err;
}

size -= result;
buf += result;
total += result;

} while (size > 0);

if (usbip_dbg_flag_xmit) {
if (!send) {
if (!in_interrupt())
pr_debug("%-10s:", current->comm);
else
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 (!in_interrupt())
pr_debug("%-10s:", current->comm);
else
pr_debug("interrupt :");

if (send)
pr_debug("send, total %d\n", total);
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);
}

return total;

err:
return result;
}
EXPORT_SYMBOL_GPL(usbip_xmit);
EXPORT_SYMBOL_GPL(usbip_recv);

struct socket *sockfd_to_socket(unsigned int sockfd)
{
Expand Down Expand Up @@ -712,7 +686,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
if (!buff)
return -ENOMEM;

ret = usbip_xmit(0, ud->tcp_socket, buff, size, 0);
ret = usbip_recv(ud->tcp_socket, buff, size);
if (ret != size) {
dev_err(&urb->dev->dev, "recv iso_frame_descriptor, %d\n",
ret);
Expand Down Expand Up @@ -823,8 +797,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
if (!(size > 0))
return 0;

ret = usbip_xmit(0, ud->tcp_socket, (char *)urb->transfer_buffer,
size, 0);
ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size);
if (ret != size) {
dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret);
if (ud->side == USBIP_STUB) {
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/staging/usbip/usbip_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ void setreuse(struct socket *);
void usbip_dump_urb(struct urb *purb);
void usbip_dump_header(struct usbip_header *pdu);

int usbip_xmit(int send, struct socket *sock, char *buf, int size,
int msg_flags);
int usbip_recv(struct socket *sock, void *buf, int size);
struct socket *sockfd_to_socket(unsigned int sockfd);

void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/staging/usbip/vhci_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static void vhci_rx_pdu(struct usbip_device *ud)
memset(&pdu, 0, sizeof(pdu));

/* 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 == -ECONNRESET)
pr_info("connection reset by peer\n");
Expand Down

0 comments on commit c3bbade

Please sign in to comment.