aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/libusb20_ugen20.c
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2018-03-23 09:40:41 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2018-03-23 09:40:41 +0000
commitfd2ef04fdb3bac6e2fbcd02f380d1215716d06c5 (patch)
treef165c76a8e1954af570839d4040e5333bd21cf96 /lib/libusb/libusb20_ugen20.c
parent266796e885807f714161259105e42fe1474e469d (diff)
downloadsrc-fd2ef04fdb3bac6e2fbcd02f380d1215716d06c5.tar.gz
src-fd2ef04fdb3bac6e2fbcd02f380d1215716d06c5.zip
Allow the libusb20_dev_get_port_path() function to be called when the
USB device is closed. This fixes a compatibility issue with upstream libusb. Found by: romain@ MFC after: 1 week
Notes
Notes: svn path=/head/; revision=331419
Diffstat (limited to 'lib/libusb/libusb20_ugen20.c')
-rw-r--r--lib/libusb/libusb20_ugen20.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index a4fac6067d07..d28e674c1fe3 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -79,7 +79,6 @@ static libusb20_reset_device_t ugen20_reset_device;
static libusb20_check_connected_t ugen20_check_connected;
static libusb20_set_power_mode_t ugen20_set_power_mode;
static libusb20_get_power_mode_t ugen20_get_power_mode;
-static libusb20_get_port_path_t ugen20_get_port_path;
static libusb20_get_power_usage_t ugen20_get_power_usage;
static libusb20_kernel_driver_active_t ugen20_kernel_driver_active;
static libusb20_detach_kernel_driver_t ugen20_detach_kernel_driver;
@@ -136,6 +135,7 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
const char *tmp = id;
struct usb_device_descriptor ddesc;
struct usb_device_info devinfo;
+ struct usb_device_port_path udpp;
uint32_t plugtime;
char buf[64];
int f;
@@ -219,6 +219,13 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
pdev->device_address, devinfo.udi_vendor,
devinfo.udi_product, pdev->bus_number);
+ /* get device port path, if any */
+ if (ioctl(f, IOUSB(USB_GET_DEV_PORT_PATH), &udpp) == 0 &&
+ udpp.udp_port_level < LIBUSB20_DEVICE_PORT_PATH_MAX) {
+ memcpy(pdev->port_path, udpp.udp_port_no, udpp.udp_port_level);
+ pdev->port_level = udpp.udp_port_level;
+ }
+
error = 0;
done:
close(f);
@@ -651,22 +658,6 @@ ugen20_get_power_mode(struct libusb20_device *pdev, uint8_t *power_mode)
}
static int
-ugen20_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize)
-{
- struct usb_device_port_path udpp;
-
- if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_DEV_PORT_PATH), &udpp))
- return (LIBUSB20_ERROR_OTHER);
-
- if (udpp.udp_port_level > bufsize)
- return (LIBUSB20_ERROR_OVERFLOW);
-
- memcpy(buf, udpp.udp_port_no, udpp.udp_port_level);
-
- return (udpp.udp_port_level); /* success */
-}
-
-static int
ugen20_get_power_usage(struct libusb20_device *pdev, uint16_t *power_usage)
{
int temp;