All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero
@ 2011-05-27  8:44 matt mooney
  2011-05-27  8:44 ` [PATCH 2/6] staging: usbip: userspace: move header includes out utils.h matt mooney
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: matt mooney @ 2011-05-27  8:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: usbip-devel, linux-kernel

bzero is and has been deprecated since POSIX.1-2001.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 drivers/staging/usbip/userspace/configure.ac       |    4 ++--
 .../staging/usbip/userspace/libsrc/usbip_common.h  |    1 -
 .../staging/usbip/userspace/libsrc/vhci_driver.c   |    2 +-
 .../staging/usbip/userspace/src/usbip_network.c    |    4 ++--
 drivers/staging/usbip/userspace/src/usbipd.c       |   14 +++++++-------
 drivers/staging/usbip/userspace/src/utils.c        |    2 +-
 6 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac
index e7d801b..06fb95d 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -29,7 +29,7 @@ AC_PROG_MAKE_SET
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h dnl
-		  string.h strings.h sys/socket.h syslog.h unistd.h])
+		  string.h sys/socket.h syslog.h unistd.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_INT32_T
@@ -41,7 +41,7 @@ AC_TYPE_UINT8_T
 
 # Checks for library functions.
 AC_FUNC_REALLOC
-AC_CHECK_FUNCS([bzero memset mkdir regcomp socket strchr strerror strstr dnl
+AC_CHECK_FUNCS([memset mkdir regcomp socket strchr strerror strstr dnl
 		strtoul])
 
 AC_CHECK_HEADER([sysfs/libsysfs.h],
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index 2c58af5..b38396f 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <strings.h>
 
 #include <sysfs/libsysfs.h>
 #include <netdb.h>
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index f2030b1..386f63b 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -52,7 +52,7 @@ static int parse_status(char *value)
 
 
 	for (int i = 0; i < vhci_driver->nports; i++)
-		bzero(&vhci_driver->idev[i], sizeof(struct usbip_imported_device));
+		memset(&vhci_driver->idev[i], 0, sizeof(vhci_driver->idev[i]));
 
 
 	/* skip a header line */
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c
index ef93b02..0e0de56 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.c
+++ b/drivers/staging/usbip/userspace/src/usbip_network.c
@@ -100,7 +100,7 @@ int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status)
 	int ret;
 	struct op_common op_common;
 
-	bzero(&op_common, sizeof(op_common));
+	memset(&op_common, 0, sizeof(op_common));
 
 	op_common.version	= USBIP_VERSION;
 	op_common.code		= code;
@@ -122,7 +122,7 @@ int usbip_recv_op_common(int sockfd, uint16_t *code)
 	int ret;
 	struct op_common op_common;
 
-	bzero(&op_common, sizeof(op_common));
+	memset(&op_common, 0, sizeof(op_common));
 
 	ret = usbip_recv(sockfd, (void *) &op_common, sizeof(op_common));
 	if (ret < 0) {
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c
index ccc7dfd..12ff00b 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -10,7 +10,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <netdb.h>
-#include <strings.h>
+#include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -100,7 +100,7 @@ static int recv_request_devlist(int sockfd)
 	int ret;
 	struct op_devlist_request req;
 
-	bzero(&req, sizeof(req));
+	memset(&req, 0, sizeof(req));
 
 	ret = usbip_recv(sockfd, (void *) &req, sizeof(req));
 	if (ret < 0) {
@@ -127,8 +127,8 @@ static int recv_request_import(int sockfd)
 	int found = 0;
 	int error = 0;
 
-	bzero(&req, sizeof(req));
-	bzero(&reply, sizeof(reply));
+	memset(&req, 0, sizeof(req));
+	memset(&reply, 0, sizeof(reply));
 
 	ret = usbip_recv(sockfd, (void *) &req, sizeof(req));
 	if (ret < 0) {
@@ -244,7 +244,7 @@ static struct addrinfo *my_getaddrinfo(char *host, int ai_family)
 	int ret;
 	struct addrinfo hints, *ai_head;
 
-	bzero(&hints, sizeof(hints));
+	memset(&hints, 0, sizeof(hints));
 
 	hints.ai_family   = ai_family;
 	hints.ai_socktype = SOCK_STREAM;
@@ -337,7 +337,7 @@ static int my_accept(int lsock)
 	char host[NI_MAXHOST], port[NI_MAXSERV];
 	int ret;
 
-	bzero(&ss, sizeof(ss));
+	memset(&ss, 0, sizeof(ss));
 
 	csock = accept(lsock, (struct sockaddr *) &ss, &len);
 	if (csock < 0) {
@@ -380,7 +380,7 @@ static void set_signal(void)
 {
 	struct sigaction act;
 
-	bzero(&act, sizeof(act));
+	memset(&act, 0, sizeof(act));
 	act.sa_handler = signal_handler;
 	sigemptyset(&act.sa_mask);
 	sigaction(SIGTERM, &act, NULL);
diff --git a/drivers/staging/usbip/userspace/src/utils.c b/drivers/staging/usbip/userspace/src/utils.c
index 6f91557..35b05e4 100644
--- a/drivers/staging/usbip/userspace/src/utils.c
+++ b/drivers/staging/usbip/userspace/src/utils.c
@@ -64,7 +64,7 @@ int read_integer(char *path)
 	int fd;
 	int ret = 0;
 
-	bzero(buff, sizeof(buff));
+	memset(buff, 0, sizeof(buff));
 
 	fd = open(path, O_RDONLY);
 	if (fd < 0)
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] staging: usbip: userspace: move header includes out utils.h
  2011-05-27  8:44 [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero matt mooney
@ 2011-05-27  8:44 ` matt mooney
  2011-05-27  8:44 ` [PATCH 3/6] staging: usbip: change the busid size matt mooney
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: matt mooney @ 2011-05-27  8:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: usbip-devel, linux-kernel

The includes have been moved out of utils.h to their respective source
files where they are suppose to be. An include guard is also added to
utils.h

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 drivers/staging/usbip/userspace/src/usbip_bind.c |    3 +-
 drivers/staging/usbip/userspace/src/utils.c      |    6 ++++-
 drivers/staging/usbip/userspace/src/utils.h      |   25 +++------------------
 3 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/drivers/staging/usbip/userspace/src/usbip_bind.c
index 26cfbad..9869db2 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_bind.c
@@ -18,11 +18,12 @@
 
 #include <sysfs/libsysfs.h>
 
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 
-#include <getopt.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include <unistd.h>
 
 #include "usbip_common.h"
diff --git a/drivers/staging/usbip/userspace/src/utils.c b/drivers/staging/usbip/userspace/src/utils.c
index 35b05e4..6dbfdbd 100644
--- a/drivers/staging/usbip/userspace/src/utils.c
+++ b/drivers/staging/usbip/userspace/src/utils.c
@@ -4,9 +4,13 @@
  */
 
 #include <sysfs/libsysfs.h>
+
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+
 #include <fcntl.h>
 #include <libgen.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "usbip_common.h"
diff --git a/drivers/staging/usbip/userspace/src/utils.h b/drivers/staging/usbip/userspace/src/utils.h
index 423716d..36ee8d5 100644
--- a/drivers/staging/usbip/userspace/src/utils.h
+++ b/drivers/staging/usbip/userspace/src/utils.h
@@ -1,26 +1,7 @@
+#ifndef __UTILS_H
+#define __UTILS_H
 
-#ifdef HAVE_CONFIG_H
-#include "../config.h"
-#endif
-
-#define _GNU_SOURCE
-#include <string.h>
-#include <sys/un.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <sysfs/libsysfs.h>
-#include <glib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
 #include <stdlib.h>
-#include <time.h>
-#include <errno.h>
-
-
 
 /* Be sync to kernel header */
 #define BUS_ID_SIZE 20
@@ -37,3 +18,5 @@ int write_bConfigurationValue(char *busid, int config);
 int read_bDeviceClass(char *busid);
 int readline(int sockfd, char *str, int strlen);
 int writeline(int sockfd, char *buff, int bufflen);
+
+#endif /* __UTILS_H */
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] staging: usbip: change the busid size
  2011-05-27  8:44 [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero matt mooney
  2011-05-27  8:44 ` [PATCH 2/6] staging: usbip: userspace: move header includes out utils.h matt mooney
@ 2011-05-27  8:44 ` matt mooney
  2011-05-27  8:44 ` [PATCH 4/6] staging: usbip: userspace: usbip_list.c: refactor local USB device listing matt mooney
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: matt mooney @ 2011-05-27  8:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: usbip-devel, linux-kernel

Change busid size to correspond with SYSFS_BUS_ID_SIZE, which was
already being used in most cases. This eliminates the need to define
BUS_ID_SIZE in the userspace code.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 drivers/staging/usbip/stub.h                     |    3 ++-
 drivers/staging/usbip/userspace/src/usbip_bind.c |   14 ++++++++------
 drivers/staging/usbip/userspace/src/utils.c      |    8 ++++----
 drivers/staging/usbip/userspace/src/utils.h      |    3 ---
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index 2cc596e..132adc5 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -76,7 +76,8 @@ struct stub_unlink {
 	__u32 status;
 };
 
-#define BUSID_SIZE 20
+/* same as SYSFS_BUS_ID_SIZE */
+#define BUSID_SIZE 32
 
 struct bus_id_priv {
 	char name[BUSID_SIZE];
diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/drivers/staging/usbip/userspace/src/usbip_bind.c
index 9869db2..978b7aa 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_bind.c
@@ -57,7 +57,7 @@ static int unbind_interface_busid(char *busid)
 		return -1;
 	}
 
-	ret = write(fd, busid, strnlen(busid, BUS_ID_SIZE));
+	ret = write(fd, busid, strnlen(busid, SYSFS_BUS_ID_SIZE));
 	if (ret < 0) {
 		dbg("write to unbind_path failed: %d", ret);
 		close(fd);
@@ -71,10 +71,11 @@ static int unbind_interface_busid(char *busid)
 
 static int unbind_interface(char *busid, int configvalue, int interface)
 {
-	char inf_busid[BUS_ID_SIZE];
+	char inf_busid[SYSFS_BUS_ID_SIZE];
 	dbg("unbinding interface");
 
-	snprintf(inf_busid, BUS_ID_SIZE, "%s:%d.%d", busid, configvalue, interface);
+	snprintf(inf_busid, SYSFS_BUS_ID_SIZE, "%s:%d.%d", busid, configvalue,
+		 interface);
 
 	return unbind_interface_busid(inf_busid);
 }
@@ -148,7 +149,7 @@ static int bind_interface_busid(char *busid, char *driver)
 	if (fd < 0)
 		return -1;
 
-	ret = write(fd, busid, strnlen(busid, BUS_ID_SIZE));
+	ret = write(fd, busid, strnlen(busid, SYSFS_BUS_ID_SIZE));
 	if (ret < 0) {
 		close(fd);
 		return -1;
@@ -161,9 +162,10 @@ static int bind_interface_busid(char *busid, char *driver)
 
 static int bind_interface(char *busid, int configvalue, int interface, char *driver)
 {
-	char inf_busid[BUS_ID_SIZE];
+	char inf_busid[SYSFS_BUS_ID_SIZE];
 
-	snprintf(inf_busid, BUS_ID_SIZE, "%s:%d.%d", busid, configvalue, interface);
+	snprintf(inf_busid, SYSFS_BUS_ID_SIZE, "%s:%d.%d", busid, configvalue,
+		 interface);
 
 	return bind_interface_busid(inf_busid, driver);
 }
diff --git a/drivers/staging/usbip/userspace/src/utils.c b/drivers/staging/usbip/userspace/src/utils.c
index 6dbfdbd..1da1109 100644
--- a/drivers/staging/usbip/userspace/src/utils.c
+++ b/drivers/staging/usbip/userspace/src/utils.c
@@ -20,7 +20,7 @@ int modify_match_busid(char *busid, int add)
 {
 	int fd;
 	int ret;
-	char buff[BUS_ID_SIZE + 4];
+	char buff[SYSFS_BUS_ID_SIZE + 4];
 	char sysfs_mntpath[SYSFS_PATH_MAX];
 	char match_busid_path[SYSFS_PATH_MAX];
 
@@ -35,7 +35,7 @@ int modify_match_busid(char *busid, int add)
 		 SYSFS_DRIVERS_NAME, USBIP_HOST_DRV_NAME);
 
 	/* BUS_IS_SIZE includes NULL termination? */
-	if (strnlen(busid, BUS_ID_SIZE) > BUS_ID_SIZE - 1) {
+	if (strnlen(busid, SYSFS_BUS_ID_SIZE) > SYSFS_BUS_ID_SIZE - 1) {
 		dbg("busid is too long");
 		return -1;
 	}
@@ -45,9 +45,9 @@ int modify_match_busid(char *busid, int add)
 		return -1;
 
 	if (add)
-		snprintf(buff, BUS_ID_SIZE + 4, "add %s", busid);
+		snprintf(buff, SYSFS_BUS_ID_SIZE + 4, "add %s", busid);
 	else
-		snprintf(buff, BUS_ID_SIZE + 4, "del %s", busid);
+		snprintf(buff, SYSFS_BUS_ID_SIZE + 4, "del %s", busid);
 
 	dbg("write \"%s\" to %s", buff, match_busid_path);
 
diff --git a/drivers/staging/usbip/userspace/src/utils.h b/drivers/staging/usbip/userspace/src/utils.h
index 36ee8d5..b50e95a 100644
--- a/drivers/staging/usbip/userspace/src/utils.h
+++ b/drivers/staging/usbip/userspace/src/utils.h
@@ -3,9 +3,6 @@
 
 #include <stdlib.h>
 
-/* Be sync to kernel header */
-#define BUS_ID_SIZE 20
-
 int modify_match_busid(char *busid, int add);
 int read_string(char *path, char *, size_t len);
 int read_integer(char *path);
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/6] staging: usbip: userspace: usbip_list.c: refactor local USB device listing
  2011-05-27  8:44 [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero matt mooney
  2011-05-27  8:44 ` [PATCH 2/6] staging: usbip: userspace: move header includes out utils.h matt mooney
  2011-05-27  8:44 ` [PATCH 3/6] staging: usbip: change the busid size matt mooney
@ 2011-05-27  8:44 ` matt mooney
  2011-05-27  8:44 ` [PATCH 5/6] staging: usbip: userspace: rename usbip device and interface matt mooney
  2011-05-27  8:44 ` [PATCH 6/6] staging: usbip: userspace: usbip_list.c: cleanup exported device functions matt mooney
  4 siblings, 0 replies; 6+ messages in thread
From: matt mooney @ 2011-05-27  8:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: usbip-devel, linux-kernel

Combines the different list display types for local devices into one
function. Removes dependence on utils.h, which only exists as a way to
circumvent libsysfs and will be removed. The devices are now sorted as
an added benefit of this refactor.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 drivers/staging/usbip/userspace/src/usbip_list.c |  180 ++++++++++------------
 1 files changed, 83 insertions(+), 97 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index 72236ae..4bbfae8 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -23,17 +23,15 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
-#include <dirent.h>
 #include <getopt.h>
 #include <netdb.h>
-#include <regex.h>
 #include <unistd.h>
 
 #include "usbip_common.h"
 #include "usbip_network.h"
-#include "utils.h"
 #include "usbip.h"
 
 static const char usbip_list_usage_string[] =
@@ -149,113 +147,104 @@ static int show_exported_devices(char *host)
 	return 0;
 }
 
-static int is_usb_device(char *busid)
+static void print_device(char *busid, char *vendor, char *product,
+			 bool parsable)
 {
-	int ret;
-
-	regex_t regex;
-	regmatch_t pmatch[1];
-
-	ret = regcomp(&regex, "^[0-9]+-[0-9]+(\\.[0-9]+)*$", REG_NOSUB|REG_EXTENDED);
-	if (ret < 0)
-		err("regcomp: %s\n", strerror(errno));
-
-	ret = regexec(&regex, busid, 0, pmatch, 0);
-	if (ret)
-		return 0;	/* not matched */
-
-	return 1;
+	if (parsable)
+		printf("busid=%s#usbid=%.4s:%.4s#", busid, vendor, product);
+	else
+		printf(" - busid %s (%.4s:%.4s)\n", busid, vendor, product);
 }
 
-static int show_devices(void)
+static void print_interface(char *busid, char *driver, bool parsable)
 {
-	DIR *dir;
-
-	dir = opendir("/sys/bus/usb/devices/");
-	if (!dir)
-		err("opendir: %s", strerror(errno));
-
-	printf("List USB devices\n");
-	for (;;) {
-		struct dirent *dirent;
-		char *busid;
-
-		dirent = readdir(dir);
-		if (!dirent)
-			break;
-
-		busid = dirent->d_name;
-
-		if (is_usb_device(busid)) {
-			char name[100] = {'\0'};
-			char driver[100] =  {'\0'};
-			int conf, ninf = 0;
-			int i;
-
-			conf = read_bConfigurationValue(busid);
-			ninf = read_bNumInterfaces(busid);
-
-			getdevicename(busid, name, sizeof(name));
-
-			printf(" - busid %s (%s)\n", busid, name);
-
-			for (i = 0; i < ninf; i++) {
-				getdriver(busid, conf, i, driver,
-					  sizeof(driver));
-				printf("         %s:%d.%d -> %s\n", busid, conf,
-				       i, driver);
-			}
-			printf("\n");
-		}
-	}
-
-	closedir(dir);
-
-	return 0;
+	if (parsable)
+		printf("%s=%s#", busid, driver);
+	else
+		printf("%9s%s -> %s\n", "", busid, driver);
 }
 
-static int show_devices2(void)
+static int is_device(void *x)
 {
-	DIR *dir;
+	struct sysfs_attribute *devpath;
+	struct sysfs_device *dev = x;
+	int ret = 0;
 
-	dir = opendir("/sys/bus/usb/devices/");
-	if (!dir)
-		err("opendir: %s", strerror(errno));
+	devpath = sysfs_get_device_attr(dev, "devpath");
+	if (devpath && *devpath->value != '0')
+		ret = 1;
 
-	for (;;) {
-		struct dirent *dirent;
-		char *busid;
+	return ret;
+}
 
-		dirent = readdir(dir);
-		if (!dirent)
-			break;
+static int devcmp(void *a, void *b)
+{
+	return strcmp(a, b);
+}
 
-		busid = dirent->d_name;
+static int list_devices(bool parsable)
+{
+	char bus_type[] = "usb";
+	char busid[SYSFS_BUS_ID_SIZE];
+	struct sysfs_bus *ubus;
+	struct sysfs_device *dev;
+	struct sysfs_device *intf;
+	struct sysfs_attribute *idVendor;
+	struct sysfs_attribute *idProduct;
+	struct sysfs_attribute *bConfValue;
+	struct sysfs_attribute *bNumIntfs;
+	struct dlist *devlist;
+	int i;
+	int ret = -1;
 
-		if (is_usb_device(busid)) {
-			char name[100] = {'\0'};
-			char driver[100] =  {'\0'};
-			int conf, ninf = 0;
-			int i;
+	ubus = sysfs_open_bus(bus_type);
+	if (!ubus) {
+		err("sysfs_open_bus: %s", strerror(errno));
+		return -1;
+	}
 
-			conf = read_bConfigurationValue(busid);
-			ninf = read_bNumInterfaces(busid);
+	devlist = sysfs_get_bus_devices(ubus);
+	if (!devlist) {
+		err("sysfs_get_bus_devices: %s", strerror(errno));
+		goto err_out;
+	}
 
-			getdevicename(busid, name, sizeof(name));
+	/* remove interfaces and root hubs from device list */
+	dlist_filter_sort(devlist, is_device, devcmp);
 
-			printf("busid=%s#usbid=%s#", busid, name);
+	if (!parsable) {
+		printf("Local USB devices\n");
+		printf("=================\n");
+	}
+	dlist_for_each_data(devlist, dev, struct sysfs_device) {
+		idVendor   = sysfs_get_device_attr(dev, "idVendor");
+		idProduct  = sysfs_get_device_attr(dev, "idProduct");
+		bConfValue = sysfs_get_device_attr(dev, "bConfigurationValue");
+		bNumIntfs  = sysfs_get_device_attr(dev, "bNumInterfaces");
+		if (!idVendor || !idProduct || !bConfValue || !bNumIntfs)
+			goto err_out;
 
-			for (i = 0; i < ninf; i++) {
-				getdriver(busid, conf, i, driver, sizeof(driver));
-				printf("%s:%d.%d=%s#", busid, conf, i, driver);
-			}
-			printf("\n");
+		print_device(dev->bus_id, idVendor->value, idProduct->value,
+			     parsable);
+
+		for (i = 0; i < atoi(bNumIntfs->value); i++) {
+			snprintf(busid, sizeof(busid), "%s:%.1s.%d",
+				 dev->bus_id, bConfValue->value, i);
+			intf = sysfs_open_device(bus_type, busid);
+			if (!intf)
+				goto err_out;
+			print_interface(busid, intf->driver_name, parsable);
+			sysfs_close_device(intf);
 		}
+		printf("\n");
 	}
 
-	closedir(dir);
+	ret = 0;
 
-	return 0;
+err_out:
+	sysfs_close_bus(ubus);
+
+	return ret;
 }
 
 int usbip_list(int argc, char *argv[])
@@ -266,12 +255,12 @@ int usbip_list(int argc, char *argv[])
 		{ "local", no_argument, NULL, 'l' },
 		{ NULL, 0, NULL, 0 }
 	};
-	bool is_parsable = false;
+	bool parsable = false;
 	int opt;
 	int ret = -1;
 
 	if (usbip_names_init(USBIDS_FILE))
-		err("failed to open %s\n", USBIDS_FILE);
+		err("failed to open %s", USBIDS_FILE);
 
 	for (;;) {
 		opt = getopt_long(argc, argv, "pr:l", opts, NULL);
@@ -281,16 +270,13 @@ int usbip_list(int argc, char *argv[])
 
 		switch (opt) {
 		case 'p':
-			is_parsable = true;
+			parsable = true;
 			break;
 		case 'r':
 			ret = show_exported_devices(optarg);
 			goto out;
 		case 'l':
-			if (is_parsable)
-				ret = show_devices2();
-			else
-				ret = show_devices();
+			ret = list_devices(parsable);
 			goto out;
 		default:
 			goto err_out;
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] staging: usbip: userspace: rename usbip device and interface
  2011-05-27  8:44 [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero matt mooney
                   ` (2 preceding siblings ...)
  2011-05-27  8:44 ` [PATCH 4/6] staging: usbip: userspace: usbip_list.c: refactor local USB device listing matt mooney
@ 2011-05-27  8:44 ` matt mooney
  2011-05-27  8:44 ` [PATCH 6/6] staging: usbip: userspace: usbip_list.c: cleanup exported device functions matt mooney
  4 siblings, 0 replies; 6+ messages in thread
From: matt mooney @ 2011-05-27  8:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: usbip-devel, linux-kernel

Add prefix of usbip_ to internal usb device and interface to avoid
confusion with the kernel types. This also identifies the types as
being part of the usbip library.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 .../staging/usbip/userspace/libsrc/stub_driver.c   |    5 +++--
 .../staging/usbip/userspace/libsrc/stub_driver.h   |    4 ++--
 .../staging/usbip/userspace/libsrc/usbip_common.c  |    9 +++++----
 .../staging/usbip/userspace/libsrc/usbip_common.h  |   13 +++++++------
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |    2 +-
 drivers/staging/usbip/userspace/src/usbip_attach.c |    2 +-
 drivers/staging/usbip/userspace/src/usbip_list.c   |    8 ++++----
 .../staging/usbip/userspace/src/usbip_network.c    |   16 ++++++++--------
 .../staging/usbip/userspace/src/usbip_network.h    |   20 ++++++++++----------
 drivers/staging/usbip/userspace/src/usbipd.c       |    6 +++---
 10 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/stub_driver.c b/drivers/staging/usbip/userspace/libsrc/stub_driver.c
index 0355604..4d4d171 100644
--- a/drivers/staging/usbip/userspace/libsrc/stub_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/stub_driver.c
@@ -43,7 +43,7 @@ static struct sysfs_driver *open_sysfs_stub_driver(void)
 #define SYSFS_OPEN_RETRIES 100
 
 /* only the first interface value is true! */
-static int32_t read_attr_usbip_status(struct usb_device *udev)
+static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
 {
 	char attrpath[SYSFS_PATH_MAX];
 	struct sysfs_attribute *attr;
@@ -145,7 +145,8 @@ static struct usbip_exported_device *usbip_exported_device_new(char *sdevpath)
 		goto err;
 
 	/* reallocate buffer to include usb interface data */
-	size_t size = sizeof(*edev) + edev->udev.bNumInterfaces * sizeof(struct usb_interface);
+	size_t size = sizeof(*edev) + edev->udev.bNumInterfaces *
+		sizeof(struct usbip_usb_interface);
 	edev = (struct usbip_exported_device *) realloc(edev, size);
 	if (!edev) {
 		err("alloc device");
diff --git a/drivers/staging/usbip/userspace/libsrc/stub_driver.h b/drivers/staging/usbip/userspace/libsrc/stub_driver.h
index 3107d18..332ebc5 100644
--- a/drivers/staging/usbip/userspace/libsrc/stub_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/stub_driver.h
@@ -19,8 +19,8 @@ struct usbip_exported_device {
 	struct sysfs_device *sudev;
 
 	int32_t status;
-	struct usb_device    udev;
-	struct usb_interface uinf[];
+	struct usbip_usb_device    udev;
+	struct usbip_usb_interface uinf[];
 };
 
 
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
index a128a92..e9d0614 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
@@ -64,7 +64,7 @@ const char *usbip_speed_string(int num)
 #define DBG_UINF_INTEGER(name)\
 	dbg("%-20s = %x", to_string(name), (int) uinf->name)
 
-void dump_usb_interface(struct usb_interface *uinf)
+void dump_usb_interface(struct usbip_usb_interface *uinf)
 {
 	char buff[100];
 	usbip_names_get_class(buff, sizeof(buff),
@@ -74,7 +74,7 @@ void dump_usb_interface(struct usb_interface *uinf)
 	dbg("%-20s = %s", "Interface(C/SC/P)", buff);
 }
 
-void dump_usb_device(struct usb_device *udev)
+void dump_usb_device(struct usbip_usb_device *udev)
 {
 	char buff[100];
 
@@ -181,7 +181,7 @@ err:
 	do { (object)->name = (type) read_attr_value(dev, to_string(name), format); } while (0)
 
 
-int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev)
+int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev)
 {
 	uint32_t busnum, devnum;
 
@@ -209,7 +209,8 @@ int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev)
 	return 0;
 }
 
-int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf)
+int read_usb_interface(struct usbip_usb_device *udev, int i,
+		       struct usbip_usb_interface *uinf)
 {
 	char busid[SYSFS_BUS_ID_SIZE];
 	struct sysfs_device *sif;
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index b38396f..32b27ed 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -104,7 +104,7 @@ extern int usbip_use_debug ;
 #define BUG()	do { err("sorry, it's a bug"); abort(); } while (0)
 
 
-struct usb_interface {
+struct usbip_usb_interface {
 	uint8_t bInterfaceClass;
 	uint8_t bInterfaceSubClass;
 	uint8_t bInterfaceProtocol;
@@ -113,7 +113,7 @@ struct usb_interface {
 
 
 
-struct usb_device {
+struct usbip_usb_device {
 	char path[SYSFS_PATH_MAX];
 	char busid[SYSFS_BUS_ID_SIZE];
 
@@ -135,11 +135,12 @@ struct usb_device {
 
 #define to_string(s)	#s
 
-void dump_usb_interface(struct usb_interface *);
-void dump_usb_device(struct usb_device *);
-int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev);
+void dump_usb_interface(struct usbip_usb_interface *);
+void dump_usb_device(struct usbip_usb_device *);
+int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev);
 int read_attr_value(struct sysfs_device *dev, const char *name, const char *format);
-int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf);
+int read_usb_interface(struct usbip_usb_device *udev, int i,
+		       struct usbip_usb_interface *uinf);
 
 const char *usbip_speed_string(int num);
 const char *usbip_status_string(int32_t status);
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 3395586..a2f7db1 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -27,7 +27,7 @@ struct usbip_imported_device {
 
 	/* usbip_class_device list */
 	struct dlist *cdev_list;
-	struct usb_device udev;
+	struct usbip_usb_device udev;
 };
 
 struct usbip_vhci_driver {
diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c
index 671d23c..189238b 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_attach.c
@@ -73,7 +73,7 @@ static int record_connection(char *host, char *port, char *busid, int rhport)
 	return 0;
 }
 
-static int import_device(int sockfd, struct usb_device *udev)
+static int import_device(int sockfd, struct usbip_usb_device *udev)
 {
 	int rc;
 	int port;
diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index 4bbfae8..e69c457 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -77,13 +77,13 @@ static int query_exported_devices(int sockfd)
 	for (unsigned int i=0; i < rep.ndev; i++) {
 		char product_name[100];
 		char class_name[100];
-		struct usb_device udev;
+		struct usbip_usb_device udev;
 
 		memset(&udev, 0, sizeof(udev));
 
 		ret = usbip_recv(sockfd, (void *) &udev, sizeof(udev));
 		if (ret < 0) {
-			err("recv usb_device[%d]", i);
+			err("recv usbip_usb_device[%d]", i);
 			return -1;
 		}
 		pack_usb_device(0, &udev);
@@ -99,11 +99,11 @@ static int query_exported_devices(int sockfd)
 		printf("%8s: %s\n", " ", class_name);
 
 		for (int j=0; j < udev.bNumInterfaces; j++) {
-			struct usb_interface uinf;
+			struct usbip_usb_interface uinf;
 
 			ret = usbip_recv(sockfd, (void *) &uinf, sizeof(uinf));
 			if (ret < 0) {
-				err("recv usb_interface[%d]", j);
+				err("recv usbip_usb_interface[%d]", j);
 				return -1;
 			}
 
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c
index 0e0de56..26e95bd 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.c
+++ b/drivers/staging/usbip/userspace/src/usbip_network.c
@@ -4,10 +4,10 @@
  */
 
 #include <sys/socket.h>
-#include <arpa/inet.h>
 
 #include <string.h>
 
+#include <arpa/inet.h>
 #include <netdb.h>
 #include <netinet/tcp.h>
 #include <unistd.h>
@@ -39,7 +39,7 @@ void pack_uint16_t(int pack, uint16_t *num)
 	*num = i;
 }
 
-void pack_usb_device(int pack, struct usb_device *udev)
+void pack_usb_device(int pack, struct usbip_usb_device *udev)
 {
 	pack_uint32_t(pack, &udev->busnum);
 	pack_uint32_t(pack, &udev->devnum);
@@ -51,7 +51,7 @@ void pack_usb_device(int pack, struct usb_device *udev)
 }
 
 void pack_usb_interface(int pack __attribute__((unused)),
-			struct usb_interface *udev __attribute__((unused)))
+			struct usbip_usb_interface *udev __attribute__((unused)))
 {
 	/* uint8_t members need nothing */
 }
@@ -102,15 +102,15 @@ int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status)
 
 	memset(&op_common, 0, sizeof(op_common));
 
-	op_common.version	= USBIP_VERSION;
-	op_common.code		= code;
-	op_common.status	= status;
+	op_common.version = USBIP_VERSION;
+	op_common.code    = code;
+	op_common.status  = status;
 
 	PACK_OP_COMMON(1, &op_common);
 
 	ret = usbip_send(sockfd, (void *) &op_common, sizeof(op_common));
 	if (ret < 0) {
-		err("send op_common");
+		err("usbip_send has failed");
 		return -1;
 	}
 
@@ -126,7 +126,7 @@ int usbip_recv_op_common(int sockfd, uint16_t *code)
 
 	ret = usbip_recv(sockfd, (void *) &op_common, sizeof(op_common));
 	if (ret < 0) {
-		err("recv op_common, %d", ret);
+		err("usbip_recv has failed ret=%d", ret);
 		goto err;
 	}
 
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/drivers/staging/usbip/userspace/src/usbip_network.h
index 82b0811..07274df 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.h
+++ b/drivers/staging/usbip/userspace/src/usbip_network.h
@@ -56,8 +56,8 @@ struct op_devinfo_request {
 } __attribute__((packed));
 
 struct op_devinfo_reply {
-	struct usb_device udev;
-	struct usb_interface uinf[];
+	struct usbip_usb_device udev;
+	struct usbip_usb_interface uinf[];
 } __attribute__((packed));
 
 /* ---------------------------------------------------------------------- */
@@ -71,8 +71,8 @@ struct op_import_request {
 } __attribute__((packed));
 
 struct op_import_reply {
-	struct usb_device udev;
-//	struct usb_interface uinf[];
+	struct usbip_usb_device udev;
+//	struct usbip_usb_interface uinf[];
 } __attribute__((packed));
 
 #define PACK_OP_IMPORT_REQUEST(pack, request)  do {\
@@ -89,7 +89,7 @@ struct op_import_reply {
 #define OP_REP_EXPORT	(OP_REPLY   | OP_EXPORT)
 
 struct op_export_request {
-	struct usb_device udev;
+	struct usbip_usb_device udev;
 } __attribute__((packed));
 
 struct op_export_reply {
@@ -111,7 +111,7 @@ struct op_export_reply {
 #define OP_REP_UNEXPORT	(OP_REPLY   | OP_UNEXPORT)
 
 struct op_unexport_request {
-	struct usb_device udev;
+	struct usbip_usb_device udev;
 } __attribute__((packed));
 
 struct op_unexport_reply {
@@ -156,8 +156,8 @@ struct op_devlist_reply {
 } __attribute__((packed));
 
 struct op_devlist_reply_extra {
-	struct usb_device    udev;
-	struct usb_interface uinf[];
+	struct usbip_usb_device    udev;
+	struct usbip_usb_interface uinf[];
 } __attribute__((packed));
 
 #define PACK_OP_DEVLIST_REQUEST(pack, request)  do {\
@@ -169,8 +169,8 @@ struct op_devlist_reply_extra {
 
 void pack_uint32_t(int pack, uint32_t *num);
 void pack_uint16_t(int pack, uint16_t *num);
-void pack_usb_device(int pack, struct usb_device *udev);
-void pack_usb_interface(int pack, struct usb_interface *uinf);
+void pack_usb_device(int pack, struct usbip_usb_device *udev);
+void pack_usb_interface(int pack, struct usbip_usb_interface *uinf);
 
 ssize_t usbip_recv(int sockfd, void *buff, size_t bufflen);
 ssize_t usbip_send(int sockfd, void *buff, size_t bufflen);
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c
index 12ff00b..332f9e6 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -64,7 +64,7 @@ static int send_reply_devlist(int sockfd)
 	}
 
 	dlist_for_each_data(stub_driver->edev_list, edev, struct usbip_exported_device) {
-		struct usb_device pdu_udev;
+		struct usbip_usb_device pdu_udev;
 
 		dump_usb_device(&edev->udev);
 		memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
@@ -77,7 +77,7 @@ static int send_reply_devlist(int sockfd)
 		}
 
 		for (int i=0; i < edev->udev.bNumInterfaces; i++) {
-			struct usb_interface pdu_uinf;
+			struct usbip_usb_interface pdu_uinf;
 
 			dump_usb_interface(&edev->uinf[i]);
 			memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
@@ -167,7 +167,7 @@ static int recv_request_import(int sockfd)
 	}
 
 	if (!error) {
-		struct usb_device pdu_udev;
+		struct usbip_usb_device pdu_udev;
 
 		memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
 		pack_usb_device(1, &pdu_udev);
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] staging: usbip: userspace: usbip_list.c: cleanup exported device functions
  2011-05-27  8:44 [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero matt mooney
                   ` (3 preceding siblings ...)
  2011-05-27  8:44 ` [PATCH 5/6] staging: usbip: userspace: rename usbip device and interface matt mooney
@ 2011-05-27  8:44 ` matt mooney
  4 siblings, 0 replies; 6+ messages in thread
From: matt mooney @ 2011-05-27  8:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: usbip-devel, linux-kernel

Rename functions and cleanup coding style.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 drivers/staging/usbip/userspace/src/usbip_list.c |   90 ++++++++++------------
 1 files changed, 42 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index e69c457..03f6210 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -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);
@@ -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);
@@ -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;
 }
 
@@ -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);
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-27  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27  8:44 [PATCH 1/6] staging: usbip: userspace: use memset instead of bzero matt mooney
2011-05-27  8:44 ` [PATCH 2/6] staging: usbip: userspace: move header includes out utils.h matt mooney
2011-05-27  8:44 ` [PATCH 3/6] staging: usbip: change the busid size matt mooney
2011-05-27  8:44 ` [PATCH 4/6] staging: usbip: userspace: usbip_list.c: refactor local USB device listing matt mooney
2011-05-27  8:44 ` [PATCH 5/6] staging: usbip: userspace: rename usbip device and interface matt mooney
2011-05-27  8:44 ` [PATCH 6/6] staging: usbip: userspace: usbip_list.c: cleanup exported device functions matt mooney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.