Add support for libusb_get_port_number() to the LibUSB v1.0 API.

Approved by:	re (kostikbel)
Requested by:	swills
MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2016-06-16 12:14:19 +00:00
parent 78a6a430ca
commit 0f2c706643
3 changed files with 16 additions and 1 deletions

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 16, 2016
.Dd June 17, 2016
.Dt LIBUSB 3
.Os
.Sh NAME
@ -106,6 +106,12 @@ counter decremented once.
Returns the number of the bus contained by the device
.Fa dev .
.Pp
.Ft uint8_t
.Fn libusb_get_port_number "libusb_device *dev"
Returns the port number which the device given by
.Fa dev
is attached to.
.Pp
.Ft int
.Fn libusb_get_port_numbers "libusb_device *dev" "uint8_t *buf" "uint8_t bufsize"
Stores, in the buffer

View File

@ -406,6 +406,7 @@ void libusb_exit(struct libusb_context *ctx);
ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list);
void libusb_free_device_list(libusb_device ** list, int unref_devices);
uint8_t libusb_get_bus_number(libusb_device * dev);
uint8_t libusb_get_port_number(libusb_device * dev);
int libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize);
int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf, uint8_t bufsize);
uint8_t libusb_get_device_address(libusb_device * dev);

View File

@ -308,6 +308,14 @@ libusb_get_bus_number(libusb_device *dev)
return (libusb20_dev_get_bus_number(dev->os_priv));
}
uint8_t
libusb_get_port_number(libusb_device *dev)
{
if (dev == NULL)
return (0); /* should not happen */
return (libusb20_dev_get_parent_port(dev->os_priv));
}
int
libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize)
{