summary refs log tree commit diff
path: root/usb_util/src/device.rs
diff options
context:
space:
mode:
Diffstat (limited to 'usb_util/src/device.rs')
-rw-r--r--usb_util/src/device.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/usb_util/src/device.rs b/usb_util/src/device.rs
index aad77db..3ac1403 100644
--- a/usb_util/src/device.rs
+++ b/usb_util/src/device.rs
@@ -261,12 +261,8 @@ impl Device {
     }
 
     /// Get active config descriptor of this device.
-    pub fn get_active_config_descriptor(&self) -> Result<ConfigDescriptorTree> {
-        let active_config = self.get_active_configuration()?;
-        match self
-            .device_descriptor_tree
-            .get_config_descriptor(active_config)
-        {
+    pub fn get_config_descriptor(&self, config: u8) -> Result<ConfigDescriptorTree> {
+        match self.device_descriptor_tree.get_config_descriptor(config) {
             Some(config_descriptor) => Ok(config_descriptor.clone()),
             None => Err(Error::NoSuchDescriptor),
         }
@@ -297,6 +293,11 @@ impl Device {
         Ok(active_config)
     }
 
+    /// Get the total number of configurations for this device.
+    pub fn get_num_configurations(&self) -> u8 {
+        self.device_descriptor_tree.bNumConfigurations
+    }
+
     /// Clear the halt/stall condition for an endpoint.
     pub fn clear_halt(&self, ep_addr: u8) -> Result<()> {
         let endpoint: c_uint = ep_addr.into();