mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: matt mooney <mfm@muteddisk.com>
To: Greg Kroah-Hartman <greg@kroah.com>
Cc: usbip-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH 3/6] staging: usbip: change the busid size
Date: Fri, 27 May 2011 01:44:12 -0700	[thread overview]
Message-ID: <e7709711985d6b7818b7ada55628bdb32fef8e33.1306485772.git.mfm@muteddisk.com> (raw)
In-Reply-To: <ec9a733eb388e3057d46ca451448e23ca24bd7e9.1306485772.git.mfm@muteddisk.com>

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


  parent reply	other threads:[~2011-05-27  8:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7709711985d6b7818b7ada55628bdb32fef8e33.1306485772.git.mfm@muteddisk.com \
    --to=mfm@muteddisk.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=usbip-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®