-/*
- * Function irda_device_init_dongle (self, type, qos)
- *
- * Initialize attached dongle.
- *
- * Important : request_module require us to call this function with
- * a process context and irq enabled. - Jean II
- */
-dongle_t *irda_device_dongle_init(struct net_device *dev, int type)
-{
- struct dongle_reg *reg;
- dongle_t *dongle = NULL;
-
- might_sleep();
-
- spin_lock(&dongles->hb_spinlock);
- reg = hashbin_find(dongles, type, NULL);
-
-#ifdef CONFIG_KMOD
- /* Try to load the module needed */
- if (!reg && capable(CAP_SYS_MODULE)) {
- spin_unlock(&dongles->hb_spinlock);
-
- request_module("irda-dongle-%d", type);
-
- spin_lock(&dongles->hb_spinlock);
- reg = hashbin_find(dongles, type, NULL);
- }
-#endif
-
- if (!reg || !try_module_get(reg->owner) ) {
- IRDA_ERROR("IrDA: Unable to find requested dongle type %x\n",
- type);
- goto out;
- }
-
- /* Allocate dongle info for this instance */
- dongle = kzalloc(sizeof(dongle_t), GFP_KERNEL);
- if (!dongle)
- goto out;
-
- /* Bind the registration info to this particular instance */
- dongle->issue = reg;
- dongle->dev = dev;
-
- out:
- spin_unlock(&dongles->hb_spinlock);
- return dongle;
-}
-EXPORT_SYMBOL(irda_device_dongle_init);
-
-/*
- * Function irda_device_dongle_cleanup (dongle)
- */
-int irda_device_dongle_cleanup(dongle_t *dongle)
-{
- IRDA_ASSERT(dongle != NULL, return -1;);
-
- dongle->issue->close(dongle);
- module_put(dongle->issue->owner);
- kfree(dongle);
-
- return 0;
-}
-EXPORT_SYMBOL(irda_device_dongle_cleanup);
-
-/*
- * Function irda_device_register_dongle (dongle)
- */
-int irda_device_register_dongle(struct dongle_reg *new)
-{
- spin_lock(&dongles->hb_spinlock);
- /* Check if this dongle has been registered before */
- if (hashbin_find(dongles, new->type, NULL)) {
- IRDA_MESSAGE("%s: Dongle type %x already registered\n",
- __FUNCTION__, new->type);
- } else {
- /* Insert IrDA dongle into hashbin */
- hashbin_insert(dongles, (irda_queue_t *) new, new->type, NULL);
- }
- spin_unlock(&dongles->hb_spinlock);
-
- return 0;
-}
-EXPORT_SYMBOL(irda_device_register_dongle);
-
-/*
- * Function irda_device_unregister_dongle (dongle)
- *
- * Unregister dongle, and remove dongle from list of registered dongles
- *
- */
-void irda_device_unregister_dongle(struct dongle_reg *dongle)
-{
- struct dongle *node;
-
- spin_lock(&dongles->hb_spinlock);
- node = hashbin_remove(dongles, dongle->type, NULL);
- if (!node)
- IRDA_ERROR("%s: dongle not found!\n", __FUNCTION__);
- spin_unlock(&dongles->hb_spinlock);
-}
-EXPORT_SYMBOL(irda_device_unregister_dongle);
-