[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libusb-devel
Subject:    [Libusb-devel] [PATCH v2 2/2] Remove darwin_get_device
From:       vlovich () gmail ! com
Date:       2011-12-17 19:22:16
Message-ID: 1324149736-10289-3-git-send-email-vlovich () gmail ! com
[Download RAW message or body]

From: Vitali Lovich <vlovich@gmail.com>

It is no longer necessary
---
 libusb/os/darwin_usb.c |   49 +-----------------------------------------------
 1 files changed, 1 insertions(+), 48 deletions(-)

diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 511f2a9..80e3853 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -204,33 +204,6 @@ static usb_device_t **usb_get_next_device (io_iterator_t deviceIterator, UInt32
   return device;
 }
 
-static kern_return_t darwin_get_device (uint32_t dev_location, usb_device_t ***darwin_device) {
-  kern_return_t kresult;
-  UInt32        location;
-  io_iterator_t deviceIterator;
-
-  kresult = usb_setup_device_iterator (&deviceIterator);
-  if (kresult)
-    return kresult;
-
-  /* This port of libusb uses locations to keep track of devices. */
-  while ((*darwin_device = usb_get_next_device (deviceIterator, &location)) != NULL) {
-    if (location == dev_location)
-      break;
-
-    (**darwin_device)->Release(*darwin_device);
-  }
-
-  IOObjectRelease (deviceIterator);
-
-  if (!(*darwin_device))
-    return kIOReturnNoDevice;
-
-  return kIOReturnSuccess;
-}
-
-
-
 static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
   struct libusb_context *ctx = (struct libusb_context *)ptr;
   struct libusb_device_handle *handle;
@@ -530,17 +503,7 @@ static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t confi
   if (!priv)
     return LIBUSB_ERROR_OTHER;
 
-  if (!priv->device) {
-    kresult = darwin_get_device (priv->location, &device);
-    if (kresult || !device) {
-      usbi_err (DEVICE_CTX (dev), "could not find device: %s", darwin_error_str (kresult));
-
-      return darwin_to_libusb (kresult);
-    }
-
-    /* don't have to open the device to get a config descriptor */
-  } else
-    device = priv->device;
+  device = priv->device;
 
   kresult = (*device)->GetConfigurationDescriptorPtr (device, config_index, &desc);
   if (kresult == kIOReturnSuccess) {
@@ -785,16 +748,6 @@ static int darwin_open (struct libusb_device_handle *dev_handle) {
   IOReturn kresult;
 
   if (0 == dpriv->open_count) {
-    if (!dpriv->device) {
-      kresult = darwin_get_device (dpriv->location, &darwin_device);
-      if (kresult) {
-        usbi_err (HANDLE_CTX (dev_handle), "could not find device: %s", darwin_error_str (kresult));
-        return darwin_to_libusb (kresult);
-      }
-
-      dpriv->device = darwin_device;
-    }
-
     /* try to open the device */
     kresult = (*(dpriv->device))->USBDeviceOpenSeize (dpriv->device);
 
-- 
1.7.6


------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Libusb-devel mailing list
Libusb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic