Re: [PATCH 5/6] usb: usbip tool: Fix refresh_imported_device_list()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




+ Shuah Khan

On 03/23/2017 03:46 AM, Yuyang Du wrote:
The commit 0775a9cbc694e8c7 ("usbip: vhci extension: modifications
to vhci driver") introduced multiple controllers, but the status
of the ports are only extracted from the first status file, fix it.

Signed-off-by: Yuyang Du <yuyang.du@xxxxxxxxx>
---
 tools/usb/usbip/libsrc/vhci_driver.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index d335f04..1c0e7f0 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -35,14 +35,11 @@
 	return NULL;
 }

-
-

Unrelated (put to separate commit)

 static int parse_status(const char *value)
 {
 	int ret = 0;
 	char *c;

-

The same here.

 	for (int i = 0; i < vhci_driver->nports; i++)
 		memset(&vhci_driver->idev[i], 0, sizeof(vhci_driver->idev[i]));

@@ -107,18 +104,33 @@ static int parse_status(const char *value)
 	return 0;
 }

+#define MAX_STATUS_NAME 16
+
 static int refresh_imported_device_list(void)
 {
 	const char *attr_status;
+	char status[MAX_STATUS_NAME+1] = "status";
+	int i, ret;

-	attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device,
-					       "status");
-	if (!attr_status) {
-		err("udev_device_get_sysattr_value failed");
-		return -1;
+	for (i = 0; i < vhci_driver->ncontrollers; i++) {
+		if (i > 0)
+			snprintf(status, MAX_STATUS_NAME+1, "status.%d", i);

s/MAX_STATUS_NAME+1/sizeof(status)

+
+		attr_status = udev_device_get_sysattr_value(vhci_driver->hc_device,
+							    status);
+		if (!attr_status) {
+			err("udev_device_get_sysattr_value failed");
+			return -1;
+		}
+
+		dbg("controller %d", i);
+
+		ret = parse_status(attr_status);
+		if (ret != 0)
+			return ret;
 	}

-	return parse_status(attr_status);
+	return 0;
 }

As now we have multiple controllers I would be more than happy if we could fix functions like this one to take a controller as a parameter and invoke commands on it instead hardcoding loops like this one with some unclear conditions like if (i > 0).

Best regards,
--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux