X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Firda%2Firqueue.c;h=1d26cd33ea13af07bbc22e53df6ce54c02f3e759;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=65a3eb94327c2a086fbc973f2ec72a2aa8eebfe4;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c index 65a3eb943..1d26cd33e 100644 --- a/net/irda/irqueue.c +++ b/net/irda/irqueue.c @@ -356,14 +356,13 @@ hashbin_t *hashbin_new(int type) /* * Allocate new hashbin */ - hashbin = kmalloc( sizeof(hashbin_t), GFP_ATOMIC); + hashbin = kzalloc(sizeof(*hashbin), GFP_ATOMIC); if (!hashbin) return NULL; /* * Initialize structure */ - memset(hashbin, 0, sizeof(hashbin_t)); hashbin->hb_type = type; hashbin->magic = HB_MAGIC; //hashbin->hb_current = NULL; @@ -391,8 +390,8 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func) unsigned long flags = 0; int i; - ASSERT(hashbin != NULL, return -1;); - ASSERT(hashbin->magic == HB_MAGIC, return -1;); + IRDA_ASSERT(hashbin != NULL, return -1;); + IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;); /* Synchronize */ if ( hashbin->hb_type & HB_LOCK ) { @@ -447,8 +446,8 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); - ASSERT( hashbin != NULL, return;); - ASSERT( hashbin->magic == HB_MAGIC, return;); + IRDA_ASSERT( hashbin != NULL, return;); + IRDA_ASSERT( hashbin->magic == HB_MAGIC, return;); /* * Locate hashbin @@ -560,8 +559,8 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name) IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); - ASSERT( hashbin != NULL, return NULL;); - ASSERT( hashbin->magic == HB_MAGIC, return NULL;); + IRDA_ASSERT( hashbin != NULL, return NULL;); + IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); /* * Locate hashbin @@ -653,9 +652,9 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry) IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); - ASSERT( hashbin != NULL, return NULL;); - ASSERT( hashbin->magic == HB_MAGIC, return NULL;); - ASSERT( entry != NULL, return NULL;); + 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 ) { @@ -663,8 +662,10 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry) } /* Default is no-lock */ /* Check if valid and not already removed... */ - if((entry->q_next == NULL) || (entry->q_prev == NULL)) - return NULL; + if((entry->q_next == NULL) || (entry->q_prev == NULL)) { + entry = NULL; + goto out; + } /* * Locate hashbin @@ -687,7 +688,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry) */ if ( entry == hashbin->hb_current) hashbin->hb_current = NULL; - +out: /* Release lock */ if ( hashbin->hb_type & HB_LOCK ) { spin_unlock_irqrestore(&hashbin->hb_spinlock, flags); @@ -712,8 +713,8 @@ void* hashbin_find( hashbin_t* hashbin, long hashv, const char* name ) IRDA_DEBUG( 4, "hashbin_find()\n"); - ASSERT( hashbin != NULL, return NULL;); - ASSERT( hashbin->magic == HB_MAGIC, return NULL;); + IRDA_ASSERT( hashbin != NULL, return NULL;); + IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); /* * Locate hashbin @@ -820,7 +821,6 @@ void* hashbin_find_next( hashbin_t* hashbin, long hashv, const char* name, return entry; } -EXPORT_SYMBOL(hashbin_find_next); /* * Function hashbin_get_first (hashbin) @@ -834,8 +834,8 @@ irda_queue_t *hashbin_get_first( hashbin_t* hashbin) irda_queue_t *entry; int i; - ASSERT( hashbin != NULL, return NULL;); - ASSERT( hashbin->magic == HB_MAGIC, return NULL;); + IRDA_ASSERT( hashbin != NULL, return NULL;); + IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); if ( hashbin == NULL) return NULL; @@ -870,11 +870,11 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin) int bin; int i; - ASSERT( hashbin != NULL, return NULL;); - ASSERT( hashbin->magic == HB_MAGIC, return NULL;); + IRDA_ASSERT( hashbin != NULL, return NULL;); + IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); if ( hashbin->hb_current == NULL) { - ASSERT( hashbin->hb_current != NULL, return NULL;); + IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;); return NULL; } entry = hashbin->hb_current->q_next;