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: Arjan Mels <arjan.mels@nxp.com>,
	usbip-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH 1/6] staging: usbip: userspace: set kernel module names in one place
Date: Thu, 26 May 2011 06:17:08 -0700	[thread overview]
Message-ID: <d8bbe57055b9f7b97349a6fdeb6253fe759f8cb2.1306414175.git.mfm@muteddisk.com> (raw)
In-Reply-To: <cover.1306414175.git.mfm@muteddisk.com>

Move kernel module name setting to usbip_common.h so that macros can
be used instead of hard coding the names in multiple places.

Signed-off-by: matt mooney <mfm@muteddisk.com>
---
 .../staging/usbip/userspace/libsrc/stub_driver.c   |   12 ++++------
 .../staging/usbip/userspace/libsrc/usbip_common.h  |    6 ++++-
 .../staging/usbip/userspace/libsrc/vhci_driver.c   |    8 ++----
 drivers/staging/usbip/userspace/src/bind-driver.c  |   23 +++++++++++++------
 4 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/usbip/userspace/libsrc/stub_driver.c b/drivers/staging/usbip/userspace/libsrc/stub_driver.c
index cc33643..0355604 100644
--- a/drivers/staging/usbip/userspace/libsrc/stub_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/stub_driver.c
@@ -8,10 +8,6 @@
 
 #include "usbip.h"
 
-/* kernel module name */
-static const char *usbip_stub_driver_name = "usbip-host";
-
-
 struct usbip_stub_driver *stub_driver;
 
 static struct sysfs_driver *open_sysfs_stub_driver(void)
@@ -31,11 +27,12 @@ static struct sysfs_driver *open_sysfs_stub_driver(void)
 
 	snprintf(stub_driver_path, SYSFS_PATH_MAX, "%s/%s/usb/%s/%s",
 			sysfs_mntpath, SYSFS_BUS_NAME, SYSFS_DRIVERS_NAME,
-			usbip_stub_driver_name);
+			USBIP_HOST_DRV_NAME);
 
 	stub_driver = sysfs_open_driver_path(stub_driver_path);
 	if (!stub_driver) {
-		err("usbip-core.ko and usbip-host.ko must be loaded");
+		err(USBIP_CORE_MOD_NAME ".ko and " USBIP_HOST_DRV_NAME
+		    ".ko must be loaded");
 		return NULL;
 	}
 
@@ -200,7 +197,8 @@ static int refresh_exported_devices(void)
 
 	suinf_list = sysfs_get_driver_devices(stub_driver->sysfs_driver);
 	if (!suinf_list) {
-		printf("Bind usbip-host.ko to a usb device to be exportable!\n");
+		info("bind " USBIP_HOST_DRV_NAME ".ko to a usb device to be "
+		     "exportable!\n");
 		goto bye;
 	}
 
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
index c254b54..2c58af5 100644
--- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h
+++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
@@ -26,7 +26,11 @@
 #define VHCI_STATE_PATH "/var/run/vhci_hcd"
 #endif
 
-//#include <linux/usb_ch9.h>
+/* kernel module names */
+#define USBIP_CORE_MOD_NAME	"usbip-core"
+#define USBIP_HOST_DRV_NAME	"usbip-host"
+#define USBIP_VHCI_DRV_NAME	"vhci_hcd"
+
 enum usb_device_speed {
 	USB_SPEED_UNKNOWN = 0,                  /* enumerating */
 	USB_SPEED_LOW, USB_SPEED_FULL,          /* usb 1.1 */
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index db43f8d..aa439c6 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -5,9 +5,6 @@
 
 #include "usbip.h"
 
-
-static const char vhci_driver_name[] = "vhci_hcd";
-
 struct usbip_vhci_driver *vhci_driver;
 
 static struct usbip_imported_device *imported_device_init(struct usbip_imported_device *idev, char *busid)
@@ -277,12 +274,13 @@ static int get_hc_busid(char *sysfs_mntpath, char *hc_busid)
 
         snprintf(sdriver_path, SYSFS_PATH_MAX, "%s/%s/platform/%s/%s",
                                 sysfs_mntpath, SYSFS_BUS_NAME, SYSFS_DRIVERS_NAME,
-                                vhci_driver_name);
+                                USBIP_VHCI_DRV_NAME);
 
         sdriver = sysfs_open_driver_path(sdriver_path);
         if (!sdriver) {
 		info("%s is not found", sdriver_path);
-                info("load usbip-core.ko and vhci-hcd.ko !");
+                info("please load " USBIP_CORE_MOD_NAME ".ko and "
+		     USBIP_VHCI_DRV_NAME ".ko!");
                 return -1;
         }
 
diff --git a/drivers/staging/usbip/userspace/src/bind-driver.c b/drivers/staging/usbip/userspace/src/bind-driver.c
index dcc540a..1396ff9 100644
--- a/drivers/staging/usbip/userspace/src/bind-driver.c
+++ b/drivers/staging/usbip/userspace/src/bind-driver.c
@@ -3,13 +3,12 @@
  * Copyright (C) 2005-2007 Takahiro Hirofuchi
  */
 
-#include "utils.h"
-
 #define _GNU_SOURCE
 #include <getopt.h>
 #include <glib.h>
 
-
+#include "usbip.h"
+#include "utils.h"
 
 static const struct option longopts[] = {
 	{"usbip",	required_argument,	NULL, 'u'},
@@ -27,9 +26,6 @@ static const struct option longopts[] = {
 	{NULL,		0,			NULL,  0}
 };
 
-static const char match_busid_path[] = "/sys/bus/usb/drivers/usbip-host/match_busid";
-
-
 static void show_help(void)
 {
 	printf("Usage: usbip_bind_driver [OPTION]\n");
@@ -51,6 +47,18 @@ static int modify_match_busid(char *busid, int add)
 	int fd;
 	int ret;
 	char buff[BUS_ID_SIZE + 4];
+	char sysfs_mntpath[SYSFS_PATH_MAX];
+	char match_busid_path[SYSFS_PATH_MAX];
+
+	ret = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX);
+	if (ret < 0) {
+		err("sysfs must be mounted");
+		return -1;
+	}
+
+	snprintf(match_busid_path, sizeof(match_busid_path),
+		 "%s/%s/usb/%s/%s/match_busid", sysfs_mntpath, SYSFS_BUS_NAME,
+		 SYSFS_DRIVERS_NAME, USBIP_HOST_DRV_NAME);
 
 	/* BUS_IS_SIZE includes NULL termination? */
 	if (strnlen(busid, BUS_ID_SIZE) > BUS_ID_SIZE - 1) {
@@ -228,7 +236,8 @@ static int bind_to_usbip(char *busid)
 	for (i = 0; i < ninterface; i++) {
 		int ret;
 
-		ret = bind_interface(busid, configvalue, i, "usbip-host");
+		ret = bind_interface(busid, configvalue, i,
+				     USBIP_HOST_DRV_NAME);
 		if (ret < 0) {
 			g_warning("bind usbip at %s:%d.%d, failed",
 					busid, configvalue, i);
-- 
1.7.5.1


  reply	other threads:[~2011-05-26 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 13:17 [PATCH 0/6] usbip: userspace improvements matt mooney
2011-05-26 13:17 ` matt mooney [this message]
2011-05-26 13:17 ` [PATCH 2/6] staging: usbip: userspace: change struct class_device to usbip_class_device matt mooney
2011-05-26 13:17 ` [PATCH 3/6] staging: usbip: userspace: vhci_driver: parameterize path names matt mooney
2011-05-26 13:17 ` [PATCH 4/6] staging: usbip: userspace tools v1.0.0 matt mooney
2011-05-26 13:17 ` [PATCH 5/6] staging: usbip: userspace: usbipd.c: add header into source file matt mooney
2011-05-26 13:17 ` [PATCH 6/6] staging: usbip: userspace: usbip_network: rename and cleanup function 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=d8bbe57055b9f7b97349a6fdeb6253fe759f8cb2.1306414175.git.mfm@muteddisk.com \
    --to=mfm@muteddisk.com \
    --cc=arjan.mels@nxp.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®