This field is read from the newly added ncontroller sysfs.
Signed-off-by: Yuyang Du <[email protected]>
---
tools/usb/usbip/libsrc/vhci_driver.c | 18 +++++++++++++++++-
tools/usb/usbip/libsrc/vhci_driver.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c
b/tools/usb/usbip/libsrc/vhci_driver.c
index 4228b98..d335f04 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -134,6 +134,20 @@ static int get_nports(void)
return strtoul(attr_nports, NULL, 10);
}
+static int get_ncontrollers(void)
+{
+ const char *attr_ncontrollers;
+
+ attr_ncontrollers =
udev_device_get_sysattr_value(vhci_driver->hc_device,
+ "ncontrollers");
+ if (!attr_ncontrollers) {
+ err("udev_device_get_sysattr_value ncontrollers failed");
+ return -1;
+ }
+
+ return strtoul(attr_ncontrollers, NULL, 10);
+}
+
/*
* Read the given port's record.
*
@@ -220,9 +234,11 @@ int usbip_vhci_driver_open(void)
}
vhci_driver->nports = get_nports();
-
dbg("available ports: %d", vhci_driver->nports);
+ vhci_driver->ncontrollers = get_ncontrollers();
+ dbg("available controllers: %d", vhci_driver->ncontrollers);
+
if (refresh_imported_device_list())
goto err;
diff --git a/tools/usb/usbip/libsrc/vhci_driver.h
b/tools/usb/usbip/libsrc/vhci_driver.h
index fa2316c..33add14 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.h
+++ b/tools/usb/usbip/libsrc/vhci_driver.h
@@ -31,6 +31,7 @@ struct usbip_vhci_driver {
/* /sys/devices/platform/vhci_hcd */
struct udev_device *hc_device;
+ int ncontrollers;
int nports;
struct usbip_imported_device idev[MAXNPORT];
};
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html