diff options
Diffstat (limited to 'net/irda/irqueue.c')
-rw-r--r-- | net/irda/irqueue.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c index 1d26cd3..9266233 100644 --- a/net/irda/irqueue.c +++ b/net/irda/irqueue.c @@ -1,5 +1,5 @@ /********************************************************************* - * + * * Filename: irqueue.c * Version: 0.3 * Description: General queue implementation @@ -10,28 +10,28 @@ * Modified by: Dag Brattli <dagb@cs.uit.no> * Modified at: Thu Jan 4 14:29:10 CET 2001 * Modified by: Marc Zyngier <mzyngier@freesurf.fr> - * + * * Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no> - * Copyright (C) 1998, Dag Brattli, + * Copyright (C) 1998, Dag Brattli, * All Rights Reserved. * * This code is taken from the Vortex Operating System written by Aage * Kvalnes. Aage has agreed that this code can use the GPL licence, * although he does not use that licence in his own code. - * + * * This copyright does however _not_ include the ELF hash() function * which I currently don't know which licence or copyright it * has. Please inform me if you know. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * Neither Dag Brattli nor University of Tromsų admit liability nor - * provide warranty for any of this software. This material is + * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge. - * + * ********************************************************************/ /* @@ -213,7 +213,7 @@ static __u32 hash( const char* name) { __u32 h = 0; __u32 g; - + while(*name) { h = (h<<4) + *name++; if ((g = (h & 0xf0000000))) @@ -231,7 +231,7 @@ static __u32 hash( const char* name) */ static void enqueue_first(irda_queue_t **queue, irda_queue_t* element) { - + IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); /* @@ -242,7 +242,7 @@ static void enqueue_first(irda_queue_t **queue, irda_queue_t* element) * Queue is empty. Insert one element into the queue. */ element->q_next = element->q_prev = *queue = element; - + } else { /* * Queue is not empty. Insert element into front of queue. @@ -267,20 +267,20 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue) irda_queue_t *ret; IRDA_DEBUG( 4, "dequeue_first()\n"); - + /* * Set return value */ ret = *queue; - + if ( *queue == NULL ) { /* * Queue was empty. */ } else if ( (*queue)->q_next == *queue ) { - /* + /* * Queue only contained a single element. It will now be - * empty. + * empty. */ *queue = NULL; } else { @@ -291,7 +291,7 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue) (*queue)->q_next->q_prev = (*queue)->q_prev; *queue = (*queue)->q_next; } - + /* * Return the removed entry (or NULL of queue was empty). */ @@ -306,25 +306,25 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue) static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element) { irda_queue_t *ret; - + IRDA_DEBUG( 4, "dequeue_general()\n"); - + /* * Set return value */ ret = *queue; - + if ( *queue == NULL ) { /* * Queue was empty. */ } else if ( (*queue)->q_next == *queue ) { - /* + /* * Queue only contained a single element. It will now be - * empty. + * empty. */ *queue = NULL; - + } else { /* * Remove specific element. @@ -334,7 +334,7 @@ static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element if ( (*queue) == element) (*queue) = element->q_next; } - + /* * Return the removed entry (or NULL of queue was empty). */ @@ -352,7 +352,7 @@ static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element hashbin_t *hashbin_new(int type) { hashbin_t* hashbin; - + /* * Allocate new hashbin */ @@ -380,8 +380,8 @@ EXPORT_SYMBOL(hashbin_new); /* * Function hashbin_delete (hashbin, free_func) * - * Destroy hashbin, the free_func can be a user supplied special routine - * for deallocating this structure if it's complex. If not the user can + * Destroy hashbin, the free_func can be a user supplied special routine + * for deallocating this structure if it's complex. If not the user can * just supply kfree, which should take care of the job. */ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func) @@ -392,7 +392,7 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func) IRDA_ASSERT(hashbin != NULL, return -1;); IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;); - + /* Synchronize */ if ( hashbin->hb_type & HB_LOCK ) { spin_lock_irqsave(&hashbin->hb_spinlock, flags); @@ -407,11 +407,11 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func) while (queue ) { if (free_func) (*free_func)(queue); - queue = dequeue_first( + queue = dequeue_first( (irda_queue_t**) &hashbin->hb_queue[i]); } } - + /* Cleanup local data */ hashbin->hb_current = NULL; hashbin->magic = ~HB_MAGIC; @@ -438,7 +438,7 @@ EXPORT_SYMBOL(hashbin_delete); * Insert an entry into the hashbin * */ -void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, +void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, const char* name) { unsigned long flags = 0; @@ -460,14 +460,14 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, if ( hashbin->hb_type & HB_LOCK ) { spin_lock_irqsave(&hashbin->hb_spinlock, flags); } /* Default is no-lock */ - + /* * Store name and key */ entry->q_hash = hashv; if ( name ) strlcpy( entry->q_name, name, sizeof(entry->q_name)); - + /* * Insert new entry first */ @@ -482,7 +482,7 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, } EXPORT_SYMBOL(hashbin_insert); -/* +/* * Function hashbin_remove_first (hashbin) * * Remove first entry of the hashbin @@ -537,7 +537,7 @@ void *hashbin_remove_first( hashbin_t *hashbin) } -/* +/* * Function hashbin_remove (hashbin, hashv, name) * * Remove entry with the given name @@ -561,7 +561,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name) IRDA_ASSERT( hashbin != NULL, return NULL;); IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); - + /* * Locate hashbin */ @@ -601,7 +601,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name) entry = entry->q_next; } while ( entry != hashbin->hb_queue[ bin ] ); } - + /* * If entry was found, dequeue it */ @@ -622,18 +622,18 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name) if ( hashbin->hb_type & HB_LOCK ) { spin_unlock_irqrestore(&hashbin->hb_spinlock, flags); } /* Default is no-lock */ - - + + /* Return */ - if ( found ) + if ( found ) return entry; else return NULL; - + } EXPORT_SYMBOL(hashbin_remove); -/* +/* * Function hashbin_remove_this (hashbin, entry) * * Remove entry with the given name @@ -655,7 +655,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry) IRDA_ASSERT( hashbin != NULL, return NULL;); IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); IRDA_ASSERT( entry != NULL, return NULL;); - + /* Synchronize */ if ( hashbin->hb_type & HB_LOCK ) { spin_lock_irqsave(&hashbin->hb_spinlock, flags); @@ -722,7 +722,7 @@ void* hashbin_find( hashbin_t* hashbin, long hashv, const char* name ) if ( name ) hashv = hash( name ); bin = GET_HASHBIN( hashv ); - + /* * Search for entry */ @@ -829,7 +829,7 @@ void* hashbin_find_next( hashbin_t* hashbin, long hashv, const char* name, * called before any calls to hashbin_get_next()! * */ -irda_queue_t *hashbin_get_first( hashbin_t* hashbin) +irda_queue_t *hashbin_get_first( hashbin_t* hashbin) { irda_queue_t *entry; int i; @@ -860,7 +860,7 @@ EXPORT_SYMBOL(hashbin_get_first); * Get next item in hashbin. A series of hashbin_get_next() calls must * be started by a call to hashbin_get_first(). The function returns * NULL when all items have been traversed - * + * * The context of the search is stored within the hashbin, so you must * protect yourself from concurrent enumerations. - Jean II */ @@ -876,13 +876,13 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin) if ( hashbin->hb_current == NULL) { IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;); return NULL; - } + } entry = hashbin->hb_current->q_next; bin = GET_HASHBIN( entry->q_hash); - /* + /* * Make sure that we are not back at the beginning of the queue - * again + * again */ if ( entry != hashbin->hb_queue[ bin ]) { hashbin->hb_current = entry; @@ -895,7 +895,7 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin) */ if ( bin >= HASHBIN_SIZE) return NULL; - + /* * Move to next queue in hashbin */ @@ -904,7 +904,7 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin) entry = hashbin->hb_queue[ i]; if ( entry) { hashbin->hb_current = entry; - + return entry; } } |