/* * Function irda_irnet_destroy(self) * * Destroy irnet instance * */ void irda_irnet_destroy(irnet_socket * self) { DENTER(IRDA_SOCK_TRACE, "(self=0x%X)\n", (unsigned int) self); if(self == NULL) return; /* Remove ourselves from hashbin (if we are queued in hashbin) * Note : `irnet_server.running' protect us from calls in hashbin_delete() */ if((irnet_server.running) && (self->q.q_next != NULL)) { struct irnet_socket * entry; unsigned long flags; DEBUG(IRDA_SOCK_INFO, "Removing from hash..\n"); spin_lock_irqsave(&irnet_server.spinlock, flags); entry = hashbin_remove_this(irnet_server.list, (irda_queue_t *) self); self->q.q_next = NULL; spin_unlock_irqrestore(&irnet_server.spinlock, flags); DASSERT(entry == self, , IRDA_SOCK_ERROR, "Can't remove from hash.\n"); } /* Unregister with IrLMP */ irlmp_unregister_client(self->ckey); /* Unregister with LM-IAS */ if(self->iriap) iriap_close(self->iriap); /* Prevent higher layer from accessing IrTTP */ self->ttp_open = 0; /* Close our IrTTP connection */ if(self->tsap) { DEBUG(IRDA_SOCK_INFO, "Closing our TTP connection.\n"); irttp_disconnect_request(self->tsap, NULL, P_NORMAL); irttp_close_tsap(self->tsap); self->tsap = NULL; /* Note : as the disconnect comes from ppp_generic, the unit number * doesn't exist anymore when we post the event, so we need to pass * NULL as the first arg... */ irnet_post_event(NULL, IRNET_DISCONNECT_TO, self->daddr, self->rname); } self->stsap_sel = 0; DEXIT(IRDA_SOCK_TRACE, "\n"); return; }
void irda_irnet_destroy(irnet_socket * self) { DENTER(IRDA_SOCK_TRACE, "(self=0x%p)\n", self); if(self == NULL) return; if((irnet_server.running) && (self->q.q_next != NULL)) { struct irnet_socket * entry; DEBUG(IRDA_SOCK_INFO, "Removing from hash..\n"); spin_lock_bh(&irnet_server.spinlock); entry = hashbin_remove_this(irnet_server.list, (irda_queue_t *) self); self->q.q_next = NULL; spin_unlock_bh(&irnet_server.spinlock); DASSERT(entry == self, , IRDA_SOCK_ERROR, "Can't remove from hash.\n"); } if(test_bit(0, &self->ttp_open)) { irnet_post_event(NULL, IRNET_DISCONNECT_TO, self->saddr, self->daddr, self->rname, 0); } clear_bit(0, &self->ttp_connect); clear_bit(0, &self->ttp_open); irlmp_unregister_client(self->ckey); if(self->iriap) { iriap_close(self->iriap); self->iriap = NULL; } if(self->discoveries != NULL) { kfree(self->discoveries); self->discoveries = NULL; } if(self->tsap) { DEBUG(IRDA_SOCK_INFO, "Closing our TTP connection.\n"); irttp_disconnect_request(self->tsap, NULL, P_NORMAL); irttp_close_tsap(self->tsap); self->tsap = NULL; } self->stsap_sel = 0; DEXIT(IRDA_SOCK_TRACE, "\n"); return; }