On 03/30/2017 06:28 PM, Yuyang Du wrote:
> The commit 0775a9cbc694e8c72 ("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 <[email protected]>
Thanks for the review.
> Signed-off-by: Yuyang Du <[email protected]>
Greg,
Please pick this up:
Acked-by: Shuah Khan <[email protected]>
thanks,
-- Shuah
> ---
> tools/usb/usbip/libsrc/vhci_driver.c | 28 +++++-----------------------
> 1 file changed, 5 insertions(+), 23 deletions(-)
>
> diff --git a/tools/usb/usbip/libsrc/vhci_driver.c
> b/tools/usb/usbip/libsrc/vhci_driver.c
> index ad92047..f659c14 100644
> --- a/tools/usb/usbip/libsrc/vhci_driver.c
> +++ b/tools/usb/usbip/libsrc/vhci_driver.c
> @@ -123,33 +123,15 @@ static int refresh_imported_device_list(void)
>
> static int get_nports(void)
> {
> - char *c;
> - int nports = 0;
> - const char *attr_status;
> + const char *attr_nports;
>
> - attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device,
> - "status");
> - if (!attr_status) {
> - err("udev_device_get_sysattr_value failed");
> + attr_nports = udev_device_get_sysattr_value(vhci_driver->hc_device,
> "nports");
> + if (!attr_nports) {
> + err("udev_device_get_sysattr_value nports failed");
> return -1;
> }
>
> - /* skip a header line */
> - 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;
> + return (int)strtoul(attr_nports, NULL, 10);
> }
>
> /*
>
--
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