usb: usbip tool: Fix get_nports()
The commit 0775a9cbc6 ("usbip: vhci extension: modifications
to vhci driver") introduced multiple controllers, and nports as a sys
file, and claimed to read the nports from it, but it didn't.
In addition, the get_nports() has been so wrong that even with 8 port
lines for instance, it gets 7 (I am guessing it is due to a '\n' mess).
Nevertheless, we fix it by reading the nports attribute.
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Yuyang Du <yuyang.du@intel.com>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
69307ccb9a
commit
37e47d5cfe
@@ -123,33 +123,15 @@ static int refresh_imported_device_list(void)
|
|||||||
|
|
||||||
static int get_nports(void)
|
static int get_nports(void)
|
||||||
{
|
{
|
||||||
char *c;
|
const char *attr_nports;
|
||||||
int nports = 0;
|
|
||||||
const char *attr_status;
|
|
||||||
|
|
||||||
attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device,
|
attr_nports = udev_device_get_sysattr_value(vhci_driver->hc_device, "nports");
|
||||||
"status");
|
if (!attr_nports) {
|
||||||
if (!attr_status) {
|
err("udev_device_get_sysattr_value nports failed");
|
||||||
err("udev_device_get_sysattr_value failed");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip a header line */
|
return (int)strtoul(attr_nports, NULL, 10);
|
||||||
c = strchr(attr_status, '\n');
|
|
||||||
if (!c)
|
|
||||||
return 0;
|
|
||||||
c++;
|
|
||||||
|
|
||||||
while (*c != '\0') {
|
|
||||||
/* go to the next line */
|
|
||||||
c = strchr(c, '\n');
|
|
||||||
if (!c)
|
|
||||||
return nports;
|
|
||||||
c++;
|
|
||||||
nports += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nports;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user