X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Firda%2Firda_device.c;h=7e7a31798d8d04855fead92b2ebdb444f85ea26a;hb=refs%2Fheads%2Fvserver;hp=80a6648a40438b9ec6ba8bc3ee369661ab3bc3dc;hpb=9bf4aaab3e101692164d49b7ca357651eb691cb6;p=linux-2.6.git diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c index 80a6648a4..7e7a31798 100644 --- a/net/irda/irda_device.c +++ b/net/irda/irda_device.c @@ -29,10 +29,10 @@ * ********************************************************************/ -#include #include #include #include +#include #include #include #include @@ -77,14 +77,14 @@ int __init irda_device_init( void) { dongles = hashbin_new(HB_NOLOCK); if (dongles == NULL) { - printk(KERN_WARNING "IrDA: Can't allocate dongles hashbin!\n"); + IRDA_WARNING("IrDA: Can't allocate dongles hashbin!\n"); return -ENOMEM; } spin_lock_init(&dongles->hb_spinlock); tasks = hashbin_new(HB_LOCK); if (tasks == NULL) { - printk(KERN_WARNING "IrDA: Can't allocate tasks hashbin!\n"); + IRDA_WARNING("IrDA: Can't allocate tasks hashbin!\n"); hashbin_delete(dongles, NULL); return -ENOMEM; } @@ -98,8 +98,8 @@ int __init irda_device_init( void) static void __exit leftover_dongle(void *arg) { struct dongle_reg *reg = arg; - printk(KERN_WARNING "IrDA: Dongle type %x not unregistered\n", - reg->type); + IRDA_WARNING("IrDA: Dongle type %x not unregistered\n", + reg->type); } void __exit irda_device_cleanup(void) @@ -125,8 +125,15 @@ void irda_device_set_media_busy(struct net_device *dev, int status) self = (struct irlap_cb *) dev->atalk_ptr; - ASSERT(self != NULL, return;); - ASSERT(self->magic == LAP_MAGIC, return;); + /* Some drivers may enable the receive interrupt before calling + * irlap_open(), or they may disable the receive interrupt + * after calling irlap_close(). + * The IrDA stack is protected from this in irlap_driver_rcv(). + * However, the driver calls directly the wrapper, that calls + * us directly. Make sure we protect ourselves. + * Jean II */ + if (!self || self->magic != LAP_MAGIC) + return; if (status) { self->media_busy = TRUE; @@ -143,47 +150,6 @@ void irda_device_set_media_busy(struct net_device *dev, int status) EXPORT_SYMBOL(irda_device_set_media_busy); -int irda_device_set_dtr_rts(struct net_device *dev, int dtr, int rts) -{ - struct if_irda_req req; - int ret; - - IRDA_DEBUG(2, "%s()\n", __FUNCTION__); - - if (!dev->do_ioctl) { - ERROR("%s: do_ioctl not impl. by device driver\n", - __FUNCTION__); - return -1; - } - - req.ifr_dtr = dtr; - req.ifr_rts = rts; - - ret = dev->do_ioctl(dev, (struct ifreq *) &req, SIOCSDTRRTS); - - return ret; -} - -int irda_device_change_speed(struct net_device *dev, __u32 speed) -{ - struct if_irda_req req; - int ret; - - IRDA_DEBUG(2, "%s()\n", __FUNCTION__); - - if (!dev->do_ioctl) { - ERROR("%s: do_ioctl not impl. by device driver\n", - __FUNCTION__); - return -1; - } - - req.ifr_baudrate = speed; - - ret = dev->do_ioctl(dev, (struct ifreq *) &req, SIOCSBANDWIDTH); - - return ret; -} - /* * Function irda_device_is_receiving (dev) * @@ -198,8 +164,8 @@ int irda_device_is_receiving(struct net_device *dev) IRDA_DEBUG(2, "%s()\n", __FUNCTION__); if (!dev->do_ioctl) { - ERROR("%s: do_ioctl not impl. by device driver\n", - __FUNCTION__); + IRDA_ERROR("%s: do_ioctl not impl. by device driver\n", + __FUNCTION__); return -1; } @@ -250,21 +216,22 @@ static int irda_task_kick(struct irda_task *task) IRDA_DEBUG(2, "%s()\n", __FUNCTION__); - ASSERT(task != NULL, return -1;); - ASSERT(task->magic == IRDA_TASK_MAGIC, return -1;); + IRDA_ASSERT(task != NULL, return -1;); + IRDA_ASSERT(task->magic == IRDA_TASK_MAGIC, return -1;); /* Execute task until it's finished, or askes for a timeout */ do { timeout = task->function(task); if (count++ > 100) { - ERROR("%s: error in task handler!\n", __FUNCTION__); + IRDA_ERROR("%s: error in task handler!\n", + __FUNCTION__); irda_task_delete(task); return TRUE; } } while ((timeout == 0) && (task->state != IRDA_TASK_DONE)); if (timeout < 0) { - ERROR("%s: Error executing task!\n", __FUNCTION__); + IRDA_ERROR("%s: Error executing task!\n", __FUNCTION__); irda_task_delete(task); return TRUE; } @@ -372,15 +339,15 @@ static void irda_task_timer_expired(void *data) * This function should be used by low level device drivers in a similar way * as ether_setup() is used by normal network device drivers */ -void irda_device_setup(struct net_device *dev) +static void irda_device_setup(struct net_device *dev) { dev->hard_header_len = 0; - dev->addr_len = 0; + dev->addr_len = LAP_ALEN; dev->type = ARPHRD_IRDA; dev->tx_queue_len = 8; /* Window size + 1 s-frame */ - memset(dev->broadcast, 0xff, 4); + memset(dev->broadcast, 0xff, LAP_ALEN); dev->mtu = 2048; dev->flags = IFF_NOARP; @@ -428,17 +395,16 @@ dongle_t *irda_device_dongle_init(struct net_device *dev, int type) #endif if (!reg || !try_module_get(reg->owner) ) { - ERROR("IrDA: Unable to find requested dongle type %x\n", type); + IRDA_ERROR("IrDA: Unable to find requested dongle type %x\n", + type); goto out; } /* Allocate dongle info for this instance */ - dongle = kmalloc(sizeof(dongle_t), GFP_KERNEL); + dongle = kzalloc(sizeof(dongle_t), GFP_KERNEL); if (!dongle) goto out; - memset(dongle, 0, sizeof(dongle_t)); - /* Bind the registration info to this particular instance */ dongle->issue = reg; dongle->dev = dev; @@ -454,7 +420,7 @@ EXPORT_SYMBOL(irda_device_dongle_init); */ int irda_device_dongle_cleanup(dongle_t *dongle) { - ASSERT(dongle != NULL, return -1;); + IRDA_ASSERT(dongle != NULL, return -1;); dongle->issue->close(dongle); module_put(dongle->issue->owner); @@ -472,8 +438,8 @@ 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)) { - MESSAGE("%s: Dongle type %x already registered\n", - __FUNCTION__, new->type); + 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); @@ -497,43 +463,16 @@ void irda_device_unregister_dongle(struct dongle_reg *dongle) spin_lock(&dongles->hb_spinlock); node = hashbin_remove(dongles, dongle->type, NULL); if (!node) - ERROR("%s: dongle not found!\n", __FUNCTION__); + IRDA_ERROR("%s: dongle not found!\n", __FUNCTION__); spin_unlock(&dongles->hb_spinlock); } EXPORT_SYMBOL(irda_device_unregister_dongle); -/* - * Function irda_device_set_mode (self, mode) - * - * Set the Infrared device driver into mode where it sends and receives - * data without using IrLAP framing. Check out the particular device - * driver to find out which modes it support. - */ -int irda_device_set_mode(struct net_device* dev, int mode) -{ - struct if_irda_req req; - int ret; - - IRDA_DEBUG(0, "%s()\n", __FUNCTION__); - - if (!dev->do_ioctl) { - ERROR("%s: set_raw_mode not impl. by device driver\n", - __FUNCTION__); - return -1; - } - - req.ifr_mode = mode; - - ret = dev->do_ioctl(dev, (struct ifreq *) &req, SIOCSMODE); - - return ret; -} - -#ifdef CONFIG_ISA +#ifdef CONFIG_ISA_DMA_API /* * Function setup_dma (idev, buffer, count, mode) * - * Setup the DMA channel. Commonly used by ISA FIR drivers + * Setup the DMA channel. Commonly used by LPC FIR drivers * */ void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode)