fix: add missing function implementation
authorStanislaw Wadas <s.wadas@samsung.com>
Tue, 6 Oct 2015 10:15:20 +0000 (12:15 +0200)
committerStanislaw Wadas <s.wadas@samsung.com>
Thu, 22 Oct 2015 09:34:19 +0000 (11:34 +0200)
add libhusb_get_port_numbers() implementation

Change-Id: I66199bfdf173c3f234c168ce7dc3eb7e77f46a1b
Signed-off-by: Stanislaw Wadas <s.wadas@samsung.com>
src/libhusb.c

index 06443c190b2c0de8f7c07383e4ee53b84a4b4579..f2119d245f48c60a732215d07158803f4bbda803 100644 (file)
@@ -271,13 +271,22 @@ uint8_t libhusb_get_address(libhusb_device *dev)
 
 int libhusb_get_port_numbers(libhusb_device *dev, uint8_t* port_numbers, int port_numbers_len)
 {
-       int port_num = 0;
+       /* As per the USB 3.0 specs, the current maximum limit for the depth is 7 */
+       uint8_t p_numbers[8];
+       int ret = 0;
+       int i;
+
+       if (port_numbers_len <= 0)
+               return LIBHUSB_ERROR_INVALID_PARAM;
 
        assert(dev);
 
-       /* TODO implement */
+       ret = libusb_get_port_numbers(dev->lusb_dev, p_numbers, port_numbers_len);
 
-       return port_num;
+       for (i = 0; i < ret; i++)
+               port_numbers[i] = p_numbers[i];
+
+       return ret;
 }
 
 ssize_t libhusb_get_devices(libhusb_context *context, libhusb_device ***devs)