Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 259508
b: refs/heads/master
c: 1109566
h: refs/heads/master
v: v3
  • Loading branch information
matt mooney authored and Greg Kroah-Hartman committed Jun 7, 2011
1 parent 786e299 commit 4e24a2c
Show file tree
Hide file tree
Showing 2 changed files with 43 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: 35dd0c2da61a584678a4a8425c174c7dbdd36e2b
refs/heads/master: 1109566469f7df817753939227e989c6395a7595
90 changes: 42 additions & 48 deletions trunk/drivers/staging/usbip/userspace/src/usbip_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,43 @@ void usbip_list_usage(void)
printf("usage: %s", usbip_list_usage_string);
}

static int query_exported_devices(int sockfd)
static int get_exported_devices(int sockfd)
{
int ret;
char product_name[100];
char class_name[100];
struct op_devlist_reply rep;
uint16_t code = OP_REP_DEVLIST;

memset(&rep, 0, sizeof(rep));

ret = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
if (ret < 0) {
err("send op_common");
struct usbip_usb_device udev;
struct usbip_usb_interface uintf;
unsigned int i;
int j, rc;

rc = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
if (rc < 0) {
dbg("usbip_send_op_common");
return -1;
}

ret = usbip_recv_op_common(sockfd, &code);
if (ret < 0) {
err("recv op_common");
rc = usbip_recv_op_common(sockfd, &code);
if (rc < 0) {
dbg("usbip_recv_op_common");
return -1;
}

ret = usbip_recv(sockfd, (void *) &rep, sizeof(rep));
if (ret < 0) {
err("recv op_devlist");
memset(&rep, 0, sizeof(rep));
rc = usbip_recv(sockfd, &rep, sizeof(rep));
if (rc < 0) {
dbg("usbip_recv_op_devlist");
return -1;
}

PACK_OP_DEVLIST_REPLY(0, &rep);
dbg("exportable %d devices", rep.ndev);

for (unsigned int i=0; i < rep.ndev; i++) {
char product_name[100];
char class_name[100];
struct usbip_usb_device udev;
dbg("exportable devices: %d", rep.ndev);

for (i = 0; i < rep.ndev; i++) {
memset(&udev, 0, sizeof(udev));

ret = usbip_recv(sockfd, (void *) &udev, sizeof(udev));
if (ret < 0) {
err("recv usbip_usb_device[%d]", i);
rc = usbip_recv(sockfd, &udev, sizeof(udev));
if (rc < 0) {
dbg("usbip_recv: usbip_usb_device[%d]", i);
return -1;
}
pack_usb_device(0, &udev);
Expand All @@ -93,38 +91,34 @@ static int query_exported_devices(int sockfd)
usbip_names_get_class(class_name, sizeof(class_name),
udev.bDeviceClass, udev.bDeviceSubClass,
udev.bDeviceProtocol);

printf("%8s: %s\n", udev.busid, product_name);
printf("%8s: %s\n", " ", udev.path);
printf("%8s: %s\n", " ", class_name);

for (int j=0; j < udev.bNumInterfaces; j++) {
struct usbip_usb_interface uinf;
printf("%8s: %s\n", "", udev.path);
printf("%8s: %s\n", "", class_name);

ret = usbip_recv(sockfd, (void *) &uinf, sizeof(uinf));
if (ret < 0) {
err("recv usbip_usb_interface[%d]", j);
for (j = 0; j < udev.bNumInterfaces; j++) {
rc = usbip_recv(sockfd, &uintf, sizeof(uintf));
if (rc < 0) {
dbg("usbip_recv: usbip_usb_interface[%d]", j);
return -1;
}
pack_usb_interface(0, &uintf);

pack_usb_interface(0, &uinf);
usbip_names_get_class(class_name, sizeof(class_name),
uinf.bInterfaceClass,
uinf.bInterfaceSubClass,
uinf.bInterfaceProtocol);
uintf.bInterfaceClass,
uintf.bInterfaceSubClass,
uintf.bInterfaceProtocol);
printf("%8s: %2d - %s\n", "", j, class_name);

printf("%8s: %2d - %s\n", " ", j, class_name);
}

printf("\n");
}

return rep.ndev;
return 0;
}

static int show_exported_devices(char *host)
static int list_exported_devices(char *host)
{
int ret;
int rc;
int sockfd;

sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING);
Expand All @@ -134,16 +128,16 @@ static int show_exported_devices(char *host)
return -1;
}
dbg("connected to %s port %s\n", host, USBIP_PORT_STRING);

printf("- %s\n", host);

ret = query_exported_devices(sockfd);
if (ret < 0) {
err("query");
rc = get_exported_devices(sockfd);
if (rc < 0) {
dbg("get_exported_devices failed");
return -1;
}

close(sockfd);

return 0;
}

Expand Down Expand Up @@ -273,7 +267,7 @@ int usbip_list(int argc, char *argv[])
parsable = true;
break;
case 'r':
ret = show_exported_devices(optarg);
ret = list_exported_devices(optarg);
goto out;
case 'l':
ret = list_devices(parsable);
Expand Down

0 comments on commit 4e24a2c

Please sign in to comment.