fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / irda / via-ircc.c
index ec4cba2..c3ed9b3 100644 (file)
@@ -83,7 +83,7 @@ static struct via_ircc_cb *dev_self[] = { NULL, NULL, NULL, NULL };
 
 /* Some prototypes */
 static int via_ircc_open(int i, chipio_t * info, unsigned int id);
-static int __exit via_ircc_close(struct via_ircc_cb *self);
+static int via_ircc_close(struct via_ircc_cb *self);
 static int via_ircc_dma_receive(struct via_ircc_cb *self);
 static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
                                         int iobase);
@@ -93,8 +93,7 @@ static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
                                  struct net_device *dev);
 static void via_hw_init(struct via_ircc_cb *self);
 static void via_ircc_change_speed(struct via_ircc_cb *self, __u32 baud);
-static irqreturn_t via_ircc_interrupt(int irq, void *dev_id,
-                                     struct pt_regs *regs);
+static irqreturn_t via_ircc_interrupt(int irq, void *dev_id);
 static int via_ircc_is_receiving(struct via_ircc_cb *self);
 static int via_ircc_read_dongle_id(int iobase);
 
@@ -111,7 +110,7 @@ static void hwreset(struct via_ircc_cb *self);
 static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase);
 static int upload_rxdata(struct via_ircc_cb *self, int iobase);
 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id);
-static void __exit via_remove_one (struct pci_dev *pdev);
+static void __devexit via_remove_one (struct pci_dev *pdev);
 
 /* FIXME : Should use udelay() instead, even if we are x86 only - Jean II */
 static void iodelay(int udelay)
@@ -140,7 +139,7 @@ static struct pci_driver via_driver = {
        .name           = VIA_MODULE_NAME,
        .id_table       = via_pci_tbl,
        .probe          = via_init_one,
-       .remove         = via_remove_one,
+       .remove         = __devexit_p(via_remove_one),
 };
 
 
@@ -273,19 +272,19 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
  *    Close all configured chips
  *
  */
-static void __exit via_ircc_clean(void)
+static void via_ircc_clean(void)
 {
        int i;
 
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
-       for (i=0; i < 4; i++) {
+       for (i=0; i < ARRAY_SIZE(dev_self); i++) {
                if (dev_self[i])
                        via_ircc_close(dev_self[i]);
        }
 }
 
-static void __exit via_remove_one (struct pci_dev *pdev)
+static void __devexit via_remove_one (struct pci_dev *pdev)
 {
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
@@ -327,6 +326,9 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
 
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
+       if (i >= ARRAY_SIZE(dev_self))
+               return -ENOMEM;
+
        /* Allocate new instance of the driver */
        dev = alloc_irdadev(sizeof(struct via_ircc_cb));
        if (dev == NULL) 
@@ -441,7 +443,7 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
        if (err)
                goto err_out4;
 
-       MESSAGE("IrDA: Registered device %s (via-ircc)\n", dev->name);
+       IRDA_MESSAGE("IrDA: Registered device %s (via-ircc)\n", dev->name);
 
        /* Initialise the hardware..
        */
@@ -468,13 +470,13 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
  *    Close driver instance
  *
  */
-static int __exit via_ircc_close(struct via_ircc_cb *self)
+static int via_ircc_close(struct via_ircc_cb *self)
 {
        int iobase;
 
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
-       ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
 
        iobase = self->io.fir_base;
 
@@ -565,7 +567,7 @@ static int via_ircc_read_dongle_id(int iobase)
 {
        int dongle_id = 9;      /* Default to IBM */
 
-       ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
+       IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
        return dongle_id;
 }
 
@@ -707,8 +709,8 @@ static void via_ircc_change_dongle_speed(int iobase, int speed,
                break;
 
        default:
-               ERROR("%s: Error: dongle_id %d unsupported !\n",
-                     __FUNCTION__, dongle_id);
+               IRDA_ERROR("%s: Error: dongle_id %d unsupported !\n",
+                          __FUNCTION__, dongle_id);
        }
 }
 
@@ -826,7 +828,7 @@ static int via_ircc_hard_xmit_sir(struct sk_buff *skb,
        __u32 speed;
 
        self = (struct via_ircc_cb *) dev->priv;
-       ASSERT(self != NULL, return 0;);
+       IRDA_ASSERT(self != NULL, return 0;);
        iobase = self->io.fir_base;
 
        netif_stop_queue(dev);
@@ -1220,8 +1222,13 @@ static int upload_rxdata(struct via_ircc_cb *self, int iobase)
 
        IRDA_DEBUG(2, "%s(): len=%x\n", __FUNCTION__, len);
 
+       if ((len - 4) < 2) {
+               self->stats.rx_dropped++;
+               return FALSE;
+       }
+
        skb = dev_alloc_skb(len + 1);
-       if ((skb == NULL) || ((len - 4) < 2)) {
+       if (skb == NULL) {
                self->stats.rx_dropped++;
                return FALSE;
        }
@@ -1337,13 +1344,12 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
 
 
 /*
- * Function via_ircc_interrupt (irq, dev_id, regs)
+ * Function via_ircc_interrupt (irq, dev_id)
  *
  *    An interrupt from the chip has arrived. Time to do some work
  *
  */
-static irqreturn_t via_ircc_interrupt(int irq, void *dev_id,
-                                     struct pt_regs *regs)
+static irqreturn_t via_ircc_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
        struct via_ircc_cb *self;
@@ -1351,8 +1357,8 @@ static irqreturn_t via_ircc_interrupt(int irq, void *dev_id,
        u8 iHostIntType, iRxIntType, iTxIntType;
 
        if (!dev) {
-               WARNING("%s: irq %d for unknown device.\n", driver_name,
-                       irq);
+               IRDA_WARNING("%s: irq %d for unknown device.\n", driver_name,
+                            irq);
                return IRQ_NONE;
        }
        self = (struct via_ircc_cb *) dev->priv;
@@ -1498,7 +1504,7 @@ static int via_ircc_is_receiving(struct via_ircc_cb *self)
        int status = FALSE;
        int iobase;
 
-       ASSERT(self != NULL, return FALSE;);
+       IRDA_ASSERT(self != NULL, return FALSE;);
 
        iobase = self->io.fir_base;
        if (CkRxRecv(iobase, self))
@@ -1524,14 +1530,14 @@ static int via_ircc_net_open(struct net_device *dev)
 
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
-       ASSERT(dev != NULL, return -1;);
+       IRDA_ASSERT(dev != NULL, return -1;);
        self = (struct via_ircc_cb *) dev->priv;
        self->stats.rx_packets = 0;
-       ASSERT(self != NULL, return 0;);
+       IRDA_ASSERT(self != NULL, return 0;);
        iobase = self->io.fir_base;
        if (request_irq(self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) {
-               WARNING("%s, unable to allocate irq=%d\n", driver_name,
-                       self->io.irq);
+               IRDA_WARNING("%s, unable to allocate irq=%d\n", driver_name,
+                            self->io.irq);
                return -EAGAIN;
        }
        /*
@@ -1539,15 +1545,15 @@ static int via_ircc_net_open(struct net_device *dev)
         * failure.
         */
        if (request_dma(self->io.dma, dev->name)) {
-               WARNING("%s, unable to allocate dma=%d\n", driver_name,
-                       self->io.dma);
+               IRDA_WARNING("%s, unable to allocate dma=%d\n", driver_name,
+                            self->io.dma);
                free_irq(self->io.irq, self);
                return -EAGAIN;
        }
        if (self->io.dma2 != self->io.dma) {
                if (request_dma(self->io.dma2, dev->name)) {
-                       WARNING("%s, unable to allocate dma2=%d\n",
-                               driver_name, self->io.dma2);
+                       IRDA_WARNING("%s, unable to allocate dma2=%d\n",
+                                    driver_name, self->io.dma2);
                        free_irq(self->io.irq, self);
                        return -EAGAIN;
                }
@@ -1590,9 +1596,9 @@ static int via_ircc_net_close(struct net_device *dev)
 
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
-       ASSERT(dev != NULL, return -1;);
+       IRDA_ASSERT(dev != NULL, return -1;);
        self = (struct via_ircc_cb *) dev->priv;
-       ASSERT(self != NULL, return 0;);
+       IRDA_ASSERT(self != NULL, return 0;);
 
        /* Stop device */
        netif_stop_queue(dev);
@@ -1627,9 +1633,9 @@ static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
        unsigned long flags;
        int ret = 0;
 
-       ASSERT(dev != NULL, return -1;);
+       IRDA_ASSERT(dev != NULL, return -1;);
        self = dev->priv;
-       ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
        IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name,
                   cmd);
        /* Disable interrupts & save flags */