Whitespace cleanup

This commit is contained in:
Pete Batard 2010-05-12 21:46:31 -03:00 committed by Daniel Drake
parent 23b5db8b3e
commit a636df4ca1
5 changed files with 55 additions and 55 deletions

View file

@ -169,7 +169,7 @@ static int set_mode_async(unsigned char data)
if (!buf)
return -ENOMEM;
transfer = libusb_alloc_transfer(0);
if (!transfer) {
free(buf);
@ -208,7 +208,7 @@ static int do_sync_intr(unsigned char *data)
}
static int sync_intr(unsigned char type)
{
{
int r;
unsigned char data[INTR_LENGTH];
@ -396,7 +396,7 @@ static int alloc_transfers(void)
img_transfer = libusb_alloc_transfer(0);
if (!img_transfer)
return -ENOMEM;
irq_transfer = libusb_alloc_transfer(0);
if (!irq_transfer)
return -ENOMEM;
@ -411,7 +411,7 @@ static int alloc_transfers(void)
static void sighandler(int signum)
{
do_exit = 1;
do_exit = 1;
}
int main(void)
@ -470,7 +470,7 @@ int main(void)
}
printf("shutting down...\n");
if (irq_transfer) {
r = libusb_cancel_transfer(irq_transfer);
if (r < 0)
@ -482,11 +482,11 @@ int main(void)
if (r < 0)
goto out_deinit;
}
while (irq_transfer || img_transfer)
if (libusb_handle_events(NULL) < 0)
break;
if (do_exit == 1)
r = 0;
else

View file

@ -120,7 +120,7 @@ if (r == 0 && actual_length == sizeof(data)) {
*
* For details on how to use the synchronous API, see the
* \ref syncio "synchronous I/O API documentation" pages.
*
*
* \section async The asynchronous interface
*
* Asynchronous I/O is the most significant new feature in libusb-1.0.
@ -241,7 +241,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* -# <b>Completion handling</b>: examine transfer results in the
* libusb_transfer structure
* -# <b>Deallocation</b>: clean up resources
*
*
*
* \subsection asyncalloc Allocation
*
@ -394,7 +394,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* request was not supported.
*
* \section asyncintr Considerations for interrupt transfers
*
*
* All interrupt transfers are performed using the polling interval presented
* by the bInterval value of the endpoint descriptor.
*
@ -512,12 +512,12 @@ if (r == 0 && actual_length == sizeof(data)) {
* -# Repeatedly call libusb_handle_events() in blocking mode from a dedicated
* thread.
*
* The first option is plainly not very nice, and will cause unnecessary
* The first option is plainly not very nice, and will cause unnecessary
* CPU wakeups leading to increased power usage and decreased battery life.
* The second option is not very nice either, but may be the nicest option
* available to you if the "proper" approach can not be applied to your
* application (read on...).
*
*
* The recommended option is to integrate libusb with your application main
* event loop. libusb exposes a set of file descriptors which allow you to do
* this. Your main loop is probably already calling poll() or select() or a
@ -757,7 +757,7 @@ void myfunc() {
* the loop, <em>up to 120 seconds later.</em> Clearly a two-minute delay is
* undesirable, and don't even think about using short timeouts to circumvent
* this issue!
*
*
* The solution here is to ensure that no two threads are ever polling the
* file descriptors at the same time. A naive implementation of this would
* impact the capabilities of the library, so libusb offers the scheme
@ -765,7 +765,7 @@ void myfunc() {
*
* Before we go any further, it is worth mentioning that all libusb-wrapped
* event handling procedures fully adhere to the scheme documented below.
* This includes libusb_handle_events() and all the synchronous I/O functions -
* This includes libusb_handle_events() and all the synchronous I/O functions -
* libusb hides this headache from you. You do not need to worry about any
* of these issues if you stick to that level.
*
@ -853,7 +853,7 @@ if (libusb_try_lock_events(ctx) == 0) {
libusb_unlock_event_waiters(ctx);
goto retry;
}
libusb_wait_for_event(ctx);
}
libusb_unlock_event_waiters(ctx);
@ -1461,7 +1461,7 @@ API_EXPORTED int libusb_try_lock_events(libusb_context *ctx)
if (r)
return 1;
ctx->event_handler_active = 1;
ctx->event_handler_active = 1;
return 0;
}
@ -1727,7 +1727,7 @@ static int handle_timeouts_locked(struct libusb_context *ctx)
(cur_tv->tv_sec == systime.tv_sec &&
cur_tv->tv_usec > systime.tv_usec))
return 0;
/* otherwise, we've got an expired timeout to handle */
handle_timeout(transfer);
}
@ -2058,7 +2058,7 @@ API_EXPORTED int libusb_pollfds_handle_timeouts(libusb_context *ctx)
* need to use this function if you are calling poll() or select() or similar
* on libusb's file descriptors yourself - you do not need to use it if you
* are calling libusb_handle_events() or a variant directly.
*
*
* You should call this function in your main loop in order to determine how
* long to wait for select() or poll() to return results. libusb needs to be
* called into at this timeout, so you should use it as an upper bound on
@ -2275,7 +2275,7 @@ void usbi_handle_disconnect(struct libusb_device_handle *handle)
/* terminate all pending transfers with the LIBUSB_TRANSFER_NO_DEVICE
* status code.
*
*
* this is a bit tricky because:
* 1. we can't do transfer completion while holding flying_transfers_lock
* 2. the transfers list can change underneath us - if we were to build a

View file

@ -39,10 +39,10 @@ struct list_head {
struct list_head *prev, *next;
};
/* Get an entry from the list
* ptr - the address of this list_head element in "type"
/* Get an entry from the list
* ptr - the address of this list_head element in "type"
* type - the data type that contains "member"
* member - the list_head element in "type"
* member - the list_head element in "type"
*/
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr) - (unsigned long)(&((type *)0L)->member)))
@ -160,7 +160,7 @@ struct libusb_context {
struct list_head open_devs;
usbi_mutex_t open_devs_lock;
/* this is a list of in-flight transfer handles, sorted by timeout
/* this is a list of in-flight transfer handles, sorted by timeout
* expiration. URBs to timeout the soonest are placed at the beginning of
* the list, URBs that will time out later are placed after, and urbs with
* infinite timeout are always placed at the very end. */
@ -663,7 +663,7 @@ struct usbi_os_backend {
*/
int (*kernel_driver_active)(struct libusb_device_handle *handle,
int interface);
/* Detach a kernel driver from an interface. Optional.
*
* After detaching a kernel driver, the interface should be available

View file

@ -140,7 +140,7 @@ static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, ui
/* No pipe found with the correct endpoint address */
usbi_warn (HANDLE_CTX(dev_handle), "no pipeRef found with endpoint address 0x%02x.", ep);
return -1;
}
@ -178,7 +178,7 @@ static usb_device_t **usb_get_next_device (io_iterator_t deviceIterator, UInt32
(*plugInInterface)->Stop(plugInInterface);
IODestroyPlugInInterface (plugInInterface);
(*(device))->GetLocationID(device, locationp);
return device;
@ -211,7 +211,7 @@ static kern_return_t darwin_get_device (uint32_t dev_location, usb_device_t ***d
static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
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;
struct darwin_device_priv *dpriv;
@ -279,7 +279,7 @@ static void *event_thread_main (void *arg0) {
IOServiceMatching(kIOUSBDeviceClassName),
(IOServiceMatchingCallback)darwin_devices_detached,
(void *)ctx, &libusb_rem_device_iterator);
if (kresult != kIOReturnSuccess) {
usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult));
@ -437,7 +437,7 @@ static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t confi
static int process_new_device (struct libusb_context *ctx, usb_device_t **device, UInt32 locationID, struct discovered_devs **_discdevs) {
struct darwin_device_priv *priv;
struct libusb_device *dev;
struct libusb_device *dev;
struct discovered_devs *discdevs;
UInt16 address, idVendor, idProduct;
UInt8 bDeviceClass, bDeviceSubClass;
@ -467,7 +467,7 @@ static int process_new_device (struct libusb_context *ctx, usb_device_t **device
req.wIndex = 0;
req.wLength = sizeof(IOUSBDeviceDescriptor);
req.pData = &(priv->dev_descriptor);
(*(device))->GetDeviceAddress (device, (USBDeviceAddress *)&address);
(*(device))->GetDeviceProduct (device, &idProduct);
(*(device))->GetDeviceVendor (device, &idVendor);
@ -511,7 +511,7 @@ static int process_new_device (struct libusb_context *ctx, usb_device_t **device
}
/**** end: retrieve device descriptors ****/
/* catch buggy hubs (which appear to be virtual). Apple's own USB prober has problems with these devices. */
if (libusb_le16_to_cpu (priv->dev_descriptor.idProduct) != idProduct) {
/* not a valid device */
@ -538,9 +538,9 @@ static int process_new_device (struct libusb_context *ctx, usb_device_t **device
ret = LIBUSB_ERROR_NO_MEM;
break;
}
*_discdevs = discdevs;
usbi_info (ctx, "found device with address %d at %s", dev->device_address, priv->sys_path);
} while (0);
@ -558,7 +558,7 @@ static int darwin_get_device_list(struct libusb_context *ctx, struct discovered_
if (!libusb_darwin_mp)
return LIBUSB_ERROR_INVALID_PARAM;
kresult = usb_setup_device_iterator (&deviceIterator);
if (kresult != kIOReturnSuccess)
return darwin_to_libusb (kresult);
@ -670,7 +670,7 @@ static void darwin_close (struct libusb_device_handle *dev_handle) {
usbi_err (HANDLE_CTX (dev_handle), "USBDeviceClose: %s", darwin_error_str(kresult));
}
}
kresult = (*(dpriv->device))->Release(dpriv->device);
if (kresult) {
/* Log the fact that we had a problem closing the file, however failing a
@ -733,7 +733,7 @@ static int darwin_get_interface (usb_device_t **darwin_device, uint8_t ifc, io_s
io_iterator_t interface_iterator;
*usbInterfacep = IO_OBJECT_NULL;
/* Setup the Interface Request */
request.bInterfaceClass = kIOUSBFindInterfaceDontCare;
request.bInterfaceSubClass = kIOUSBFindInterfaceDontCare;
@ -746,10 +746,10 @@ static int darwin_get_interface (usb_device_t **darwin_device, uint8_t ifc, io_s
for ( current_interface = 0 ; current_interface <= ifc ; current_interface++ )
*usbInterfacep = IOIteratorNext(interface_iterator);
/* done with the interface iterator */
IOObjectRelease(interface_iterator);
return 0;
}
@ -767,7 +767,7 @@ static int get_endpoints (struct libusb_device_handle *dev_handle, int iface) {
int i;
usbi_info (HANDLE_CTX (dev_handle), "building table of endpoints.");
/* retrieve the total number of endpoints on this interface */
kresult = (*(cInterface->interface))->GetNumEndpoints(cInterface->interface, &numep);
if (kresult) {
@ -792,7 +792,7 @@ static int get_endpoints (struct libusb_device_handle *dev_handle, int iface) {
}
cInterface->num_endpoints = numep;
return 0;
}
@ -827,7 +827,7 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
usbi_err (HANDLE_CTX (dev_handle), "GetNumberOfConfigurations: %s", darwin_error_str(kresult));
return darwin_to_libusb(kresult);
}
if (nConfig < 1) {
usbi_err (HANDLE_CTX (dev_handle), "GetNumberOfConfigurations: no configurations");
return LIBUSB_ERROR_OTHER;
@ -866,7 +866,7 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
usbi_err (HANDLE_CTX (dev_handle), "interface not found");
return LIBUSB_ERROR_NOT_FOUND;
}
/* get an interface to the device's interface */
kresult = IOCreatePlugInInterfaceForService (usbInterface, kIOUSBInterfaceUserClientTypeID,
kIOCFPlugInInterfaceID, &plugInInterface, &score);
@ -882,7 +882,7 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
/* ignore release error */
(void)IOObjectRelease (usbInterface);
/* Do the actual claim */
kresult = (*plugInInterface)->QueryInterface(plugInInterface,
CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID),
@ -891,7 +891,7 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
usbi_err (HANDLE_CTX (dev_handle), "QueryInterface: %s", darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
/* We no longer need the intermediate plug-in */
(*plugInInterface)->Release(plugInInterface);
@ -945,7 +945,7 @@ static int darwin_release_interface(struct libusb_device_handle *dev_handle, int
/* clean up endpoint data */
cInterface->num_endpoints = 0;
/* delete the interface's async event source */
if (cInterface->cfSource) {
CFRunLoopRemoveSource (libusb_darwin_acfl, cInterface->cfSource, kCFRunLoopDefaultMode);
@ -1043,7 +1043,7 @@ static int darwin_kernel_driver_active(struct libusb_device_handle *dev_handle,
return darwin_to_libusb (kresult);
}
driver = IORegistryEntryCreateCFProperty (usbInterface, kIOBundleIdentifierKey, kCFAllocatorDefault, 0);
IOObjectRelease (usbInterface);
@ -1084,7 +1084,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
/* are we reading or writing? */
is_read = transfer->endpoint & LIBUSB_ENDPOINT_IN;
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, &iface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
@ -1095,7 +1095,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
(*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
&transferType, &maxPacketSize, &interval);
/* submit the request */
/* timeouts are unavailable on interrupt endpoints */
if (transferType == kUSBInterrupt) {
@ -1139,7 +1139,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
/* are we reading or writing? */
is_read = transfer->endpoint & LIBUSB_ENDPOINT_IN;
/* construct an array of IOUSBIsocFrames */
tpriv->isoc_framelist = (IOUSBIsocFrame*) calloc (transfer->num_iso_packets, sizeof(IOUSBIsocFrame));
if (!tpriv->isoc_framelist)
@ -1170,7 +1170,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
/* schedule for a frame a little in the future */
frame += 2;
/* submit the request */
if (is_read)
kresult = (*(cInterface->interface))->ReadIsochPipeAsync(cInterface->interface, pipeRef, transfer->buffer, frame,
@ -1191,7 +1191,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
return darwin_to_libusb (kresult);
}
static int submit_control_transfer(struct usbi_transfer *itransfer) {
static int submit_control_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = __USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct libusb_control_setup *setup = (struct libusb_control_setup *) transfer->buffer;
struct darwin_device_priv *dpriv = (struct darwin_device_priv *)transfer->dev_handle->dev->os_priv;
@ -1218,7 +1218,7 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
if (kresult != kIOReturnSuccess)
usbi_err (TRANSFER_CTX (transfer), "control request failed: %s", darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
@ -1270,7 +1270,7 @@ static int darwin_abort_transfers (struct usbi_transfer *itransfer) {
/* abort transactions */
(*(cInterface->interface))->AbortPipe (cInterface->interface, pipeRef);
usbi_info (ITRANSFER_CTX (itransfer), "calling clear pipe stall to clear the data toggle bit");
/* clear the data toggle bit */
@ -1426,7 +1426,7 @@ static int op_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds
usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->fds[0]);
usbi_handle_disconnect(handle);
/* done with this device */
continue;
case MESSAGE_ASYNC_IO_COMPLETE:

View file

@ -80,7 +80,7 @@ API_EXPORTED int libusb_control_transfer(libusb_device_handle *dev_handle,
if (!transfer)
return LIBUSB_ERROR_NO_MEM;
buffer = malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength);
if (!buffer) {
libusb_free_transfer(transfer);