summaryrefslogtreecommitdiff
path: root/libusb/core.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-02-17 13:17:55 +0100
committerPeter Stuge <peter@stuge.se>2011-09-15 15:16:04 +0200
commitc8c40bcbd22abca922ff31c4ed6a75fd7af78b59 (patch)
treed32b0dfe25e9f3147d21d90ecd14f10fae483135 /libusb/core.c
parent0db8cba7f2c372f0127c7df9724e5a35e93f2069 (diff)
downloadlibusbx-c8c40bcbd22abca922ff31c4ed6a75fd7af78b59.tar.gz
Add new API function libusb_get_device_speed()
Reworked version of my earlier patch, largely modelled after (if not copy and pasted from) Trygve Laugstøl's <trygvis@inamo.no> similar commit 5a6541e0d80fb1f21e2b960bc2337a612f9d74fb in git://git.libusb.org/libusb-trygvis.git http://git.libusb.org/libusb-trygvis.git http://git.libusb.org/?p=libusb-trygvis.git;a=commitdiff;h=5a6541e0d This patch does not add any OS specific code. The supporting code in each backend follows in separate patches. References #45. Signed-off-By: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'libusb/core.c')
-rw-r--r--libusb/core.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libusb/core.c b/libusb/core.c
index 1dedb17..072d050 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -523,6 +523,7 @@ struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
dev->ctx = ctx;
dev->refcnt = 1;
dev->session_data = session_id;
+ dev->speed = LIBUSB_SPEED_UNKNOWN;
memset(&dev->os_priv, 0, priv_size);
usbi_mutex_lock(&ctx->usb_devs_lock);
@@ -680,6 +681,17 @@ uint8_t API_EXPORTED libusb_get_device_address(libusb_device *dev)
return dev->device_address;
}
+/** \ingroup dev
+ * Get the negotiated connection speed for a device.
+ * \param dev a device
+ * \returns a \ref libusb_speed code, where LIBUSB_SPEED_UNKNOWN means that
+ * the OS doesn't know or doesn't support returning the negotiated speed.
+ */
+int API_EXPORTED libusb_get_device_speed(libusb_device *dev)
+{
+ return dev->speed;
+}
+
static const struct libusb_endpoint_descriptor *find_endpoint(
struct libusb_config_descriptor *config, unsigned char endpoint)
{