[PATCH] Char: isicom, remove unneeded memset
[safe/jmp/linux-2.6] / drivers / char / isicom.c
index c105b95..c5cb2a9 100644 (file)
@@ -193,7 +193,6 @@ struct      isi_board {
        unsigned short          shift_count;
        struct isi_port         * ports;
        signed char             count;
-       unsigned char           isa;
        spinlock_t              card_lock; /* Card wide lock 11/5/00 -sameer */
        unsigned long           flags;
 };
@@ -530,9 +529,9 @@ sched_again:
 /*     Interrupt handlers      */
 
 
-static void isicom_bottomhalf(void *data)
+static void isicom_bottomhalf(struct work_struct *work)
 {
-       struct isi_port *port = (struct isi_port *) data;
+       struct isi_port *port = container_of(work, struct isi_port, bh_tqueue);
        struct tty_struct *tty = port->tty;
 
        if (!tty)
@@ -546,7 +545,7 @@ static void isicom_bottomhalf(void *data)
  *     Main interrupt handler routine
  */
 
-static irqreturn_t isicom_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 {
        struct isi_board *card = dev_id;
        struct isi_port *port;
@@ -562,14 +561,12 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        base = card->base;
        spin_lock(&card->card_lock);
 
-       if (card->isa == NO) {
-               /*
-                * disable any interrupts from the PCI card and lower the
-                * interrupt line
-                */
-               outw(0x8000, base+0x04);
-               ClearInterrupt(base);
-       }
+       /*
+        * disable any interrupts from the PCI card and lower the
+        * interrupt line
+        */
+       outw(0x8000, base+0x04);
+       ClearInterrupt(base);
 
        inw(base);              /* get the dummy word out */
        header = inw(base);
@@ -579,19 +576,13 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        if (channel + 1 > card->port_count) {
                printk(KERN_WARNING "ISICOM: isicom_interrupt(0x%lx): "
                        "%d(channel) > port_count.\n", base, channel+1);
-               if (card->isa)
-                       ClearInterrupt(base);
-               else
-                       outw(0x0000, base+0x04); /* enable interrupts */
+               outw(0x0000, base+0x04); /* enable interrupts */
                spin_unlock(&card->card_lock);
                return IRQ_HANDLED;
        }
        port = card->ports + channel;
        if (!(port->flags & ASYNC_INITIALIZED)) {
-               if (card->isa)
-                       ClearInterrupt(base);
-               else
-                       outw(0x0000, base+0x04); /* enable interrupts */
+               outw(0x0000, base+0x04); /* enable interrupts */
                return IRQ_HANDLED;
        }
 
@@ -604,10 +595,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                }
                if (byte_count & 0x01)
                        inw(base);
-               if (card->isa == YES)
-                       ClearInterrupt(base);
-               else
-                       outw(0x0000, base+0x04); /* enable interrupts */
+               outw(0x0000, base+0x04); /* enable interrupts */
                spin_unlock(&card->card_lock);
                return IRQ_HANDLED;
        }
@@ -708,10 +696,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                }
                tty_flip_buffer_push(tty);
        }
-       if (card->isa == YES)
-               ClearInterrupt(base);
-       else
-               outw(0x0000, base+0x04); /* enable interrupts */
+       outw(0x0000, base+0x04); /* enable interrupts */
 
        return IRQ_HANDLED;
 }
@@ -1062,11 +1047,12 @@ static void isicom_shutdown_port(struct isi_port *port)
 static void isicom_close(struct tty_struct *tty, struct file *filp)
 {
        struct isi_port *port = tty->driver_data;
-       struct isi_board *card = port->card;
+       struct isi_board *card;
        unsigned long flags;
 
        if (!port)
                return;
+       card = port->card;
        if (isicom_paranoia_check(port, tty->name, "isicom_close"))
                return;
 
@@ -1398,7 +1384,7 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,
 
 /* set_termios et all */
 static void isicom_set_termios(struct tty_struct *tty,
-       struct termios *old_termios)
+       struct ktermios *old_termios)
 {
        struct isi_port *port = tty->driver_data;
 
@@ -1473,9 +1459,9 @@ static void isicom_start(struct tty_struct *tty)
 }
 
 /* hangup et all */
-static void do_isicom_hangup(void *data)
+static void do_isicom_hangup(struct work_struct *work)
 {
-       struct isi_port *port = data;
+       struct isi_port *port = container_of(work, struct isi_port, hangup_tq);
        struct tty_struct *tty;
 
        tty = port->tty;
@@ -1519,38 +1505,7 @@ static void isicom_flush_buffer(struct tty_struct *tty)
  * Driver init and deinit functions
  */
 
-static int __devinit isicom_register_ioregion(struct pci_dev *pdev,
-       const unsigned int index)
-{
-       struct isi_board *board = pci_get_drvdata(pdev);
-
-       if (!board->base)
-               return -EINVAL;
-
-       if (!request_region(board->base, 16, ISICOM_NAME)) {
-               dev_dbg(&pdev->dev, "I/O Region 0x%lx-0x%lx is busy. Card%d "
-                       "will be disabled.\n", board->base, board->base + 15,
-                       index + 1);
-               return -EBUSY;
-       }
-
-       return 0;
-}
-
-static void isicom_unregister_ioregion(struct pci_dev *pdev)
-{
-       struct isi_board *board = pci_get_drvdata(pdev);
-
-       if (!board->base)
-               return;
-
-       release_region(board->base, 16);
-       dev_dbg(&pdev->dev, "I/O Region 0x%lx-0x%lx released.\n",
-               board->base, board->base + 15);
-       board->base = 0;
-}
-
-static struct tty_operations isicom_ops = {
+static const struct tty_operations isicom_ops = {
        .open                   = isicom_open,
        .close                  = isicom_close,
        .write                  = isicom_write,
@@ -1570,70 +1525,6 @@ static struct tty_operations isicom_ops = {
        .tiocmset               = isicom_tiocmset,
 };
 
-static int __devinit isicom_register_tty_driver(void)
-{
-       int error = -ENOMEM;
-
-       /* tty driver structure initialization */
-       isicom_normal = alloc_tty_driver(PORT_COUNT);
-       if (!isicom_normal)
-               goto end;
-
-       isicom_normal->owner                    = THIS_MODULE;
-       isicom_normal->name                     = "ttyM";
-       isicom_normal->major                    = ISICOM_NMAJOR;
-       isicom_normal->minor_start              = 0;
-       isicom_normal->type                     = TTY_DRIVER_TYPE_SERIAL;
-       isicom_normal->subtype                  = SERIAL_TYPE_NORMAL;
-       isicom_normal->init_termios             = tty_std_termios;
-       isicom_normal->init_termios.c_cflag     = B9600 | CS8 | CREAD | HUPCL |
-               CLOCAL;
-       isicom_normal->flags                    = TTY_DRIVER_REAL_RAW;
-       tty_set_operations(isicom_normal, &isicom_ops);
-
-       if ((error = tty_register_driver(isicom_normal))) {
-               pr_dbg("Couldn't register the dialin driver, error=%d\n",
-                       error);
-               put_tty_driver(isicom_normal);
-       }
-end:
-       return error;
-}
-
-static void isicom_unregister_tty_driver(void)
-{
-       int error;
-
-       if ((error = tty_unregister_driver(isicom_normal)))
-               pr_dbg("couldn't unregister normal driver, error=%d.\n", error);
-
-       put_tty_driver(isicom_normal);
-}
-
-static int __devinit isicom_register_isr(struct pci_dev *pdev,
-       const unsigned int index)
-{
-       struct isi_board *board = pci_get_drvdata(pdev);
-       unsigned long irqflags = SA_INTERRUPT;
-       int retval = -EINVAL;
-
-       if (!board->base)
-               goto end;
-
-       if (board->isa == NO)
-               irqflags |= SA_SHIRQ;
-
-       retval = request_irq(board->irq, isicom_interrupt, irqflags,
-               ISICOM_NAME, board);
-       if (retval < 0)
-               dev_warn(&pdev->dev, "Could not install handler at Irq %d. "
-                       "Card%d will be disabled.\n", board->irq, index + 1);
-       else
-               retval = 0;
-end:
-       return retval;
-}
-
 static int __devinit reset_card(struct pci_dev *pdev,
        const unsigned int card, unsigned int *signature)
 {
@@ -1655,36 +1546,23 @@ static int __devinit reset_card(struct pci_dev *pdev,
 
        *signature = inw(base + 0x4) & 0xff;
 
-       if (board->isa == YES) {
-               if (!(inw(base + 0xe) & 0x1) || (inw(base + 0x2))) {
-                       dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
-                               inw(base + 0x2), inw(base + 0xe));
-                       dev_err(&pdev->dev, "ISILoad:ISA Card%d reset failure "
-                               "(Possible bad I/O Port Address 0x%lx).\n",
-                               card + 1, base);
-                       retval = -EIO;
-                       goto end;
-               }
-       } else {
-               portcount = inw(base + 0x2);
-               if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) &&
-                               (portcount != 4) && (portcount != 8))) {
-                       dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
-                               inw(base + 0x2), inw(base + 0xe));
-                       dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure "
-                               "(Possible bad I/O Port Address 0x%lx).\n",
-                               card + 1, base);
-                       retval = -EIO;
-                       goto end;
-               }
+       portcount = inw(base + 0x2);
+       if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) &&
+                       (portcount != 4) && (portcount != 8))) {
+               dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n",
+                       inw(base + 0x2), inw(base + 0xe));
+               dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure "
+                       "(Possible bad I/O Port Address 0x%lx).\n",
+                       card + 1, base);
+               retval = -EIO;
+               goto end;
        }
 
        switch (*signature) {
        case 0xa5:
        case 0xbb:
        case 0xdd:
-               board->port_count = (board->isa == NO && portcount == 4) ? 4 :
-                       8;
+               board->port_count = (portcount == 4) ? 4 : 8;
                board->shift_count = 12;
                break;
        case 0xcc:
@@ -1756,9 +1634,12 @@ static int __devinit load_firmware(struct pci_dev *pdev,
        if (retval)
                goto end;
 
+       retval = -EIO;
+
        for (frame = (struct stframe *)fw->data;
                        frame < (struct stframe *)(fw->data + fw->size);
-                       frame++) {
+                       frame = (struct stframe *)((u8 *)(frame + 1) +
+                               frame->count)) {
                if (WaitTillCardIsFree(base))
                        goto errrelfw;
 
@@ -1797,23 +1678,12 @@ static int __devinit load_firmware(struct pci_dev *pdev,
                }
        }
 
-       retval = -EIO;
-
-       if (WaitTillCardIsFree(base))
-               goto errrelfw;
-
-       outw(0xf2, base);
-       outw(0x800, base);
-       outw(0x0, base);
-       outw(0x0, base);
-       InterruptTheCard(base);
-       outw(0x0, base + 0x4); /* for ISI4608 cards */
-
 /* XXX: should we test it by reading it back and comparing with original like
  * in load firmware package? */
-       for (frame = (struct stframe*)fw->data;
-                       frame < (struct stframe*)(fw->data + fw->size);
-                       frame++) {
+       for (frame = (struct stframe *)fw->data;
+                       frame < (struct stframe *)(fw->data + fw->size);
+                       frame = (struct stframe *)((u8 *)(frame + 1) +
+                               frame->count)) {
                if (WaitTillCardIsFree(base))
                        goto errrelfw;
 
@@ -1863,6 +1733,17 @@ static int __devinit load_firmware(struct pci_dev *pdev,
                }
        }
 
+       /* xfer ctrl */
+       if (WaitTillCardIsFree(base))
+               goto errrelfw;
+
+       outw(0xf2, base);
+       outw(0x800, base);
+       outw(0x0, base);
+       outw(0x0, base);
+       InterruptTheCard(base);
+       outw(0x0, base + 0x4); /* for ISI4608 cards */
+
        board->status |= FIRMWARE_LOADED;
        retval = 0;
 
@@ -1875,8 +1756,6 @@ end:
 /*
  *     Insmod can set static symbols so keep these static
  */
-static int io[4];
-static int irq[4];
 static int card;
 
 static int __devinit isicom_probe(struct pci_dev *pdev,
@@ -1904,18 +1783,25 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
 
        board->base = ioaddr;
        board->irq = pciirq;
-       board->isa = NO;
        card++;
 
        pci_set_drvdata(pdev, board);
 
-       retval = isicom_register_ioregion(pdev, index);
-       if (retval < 0)
+       if (!request_region(board->base, 16, ISICOM_NAME)) {
+               dev_err(&pdev->dev, "I/O Region 0x%lx-0x%lx is busy. Card%d "
+                       "will be disabled.\n", board->base, board->base + 15,
+                       index + 1);
+               retval = -EBUSY;
                goto err;
+       }
 
-       retval = isicom_register_isr(pdev, index);
-       if (retval < 0)
+       retval = request_irq(board->irq, isicom_interrupt,
+                       IRQF_SHARED | IRQF_DISABLED, ISICOM_NAME, board);
+       if (retval < 0) {
+               dev_err(&pdev->dev, "Could not install handler at Irq %d. "
+                       "Card%d will be disabled.\n", board->irq, index + 1);
                goto errunrr;
+       }
 
        retval = reset_card(pdev, index, &signature);
        if (retval < 0)
@@ -1930,7 +1816,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
 errunri:
        free_irq(board->irq, board);
 errunrr:
-       isicom_unregister_ioregion(pdev);
+       release_region(board->base, 16);
 err:
        board->base = 0;
        return retval;
@@ -1941,16 +1827,15 @@ static void __devexit isicom_remove(struct pci_dev *pdev)
        struct isi_board *board = pci_get_drvdata(pdev);
 
        free_irq(board->irq, board);
-       isicom_unregister_ioregion(pdev);
+       release_region(board->base, 16);
 }
 
-static int __devinit isicom_setup(void)
+static int __init isicom_init(void)
 {
        int retval, idx, channel;
        struct isi_port *port;
 
        card = 0;
-       memset(isi_ports, 0, sizeof(isi_ports));
 
        for(idx = 0; idx < BOARD_COUNT; idx++) {
                port = &isi_ports[idx * 16];
@@ -1962,8 +1847,8 @@ static int __devinit isicom_setup(void)
                        port->channel = channel;
                        port->close_delay = 50 * HZ/100;
                        port->closing_wait = 3000 * HZ/100;
-                       INIT_WORK(&port->hangup_tq, do_isicom_hangup, port);
-                       INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port);
+                       INIT_WORK(&port->hangup_tq, do_isicom_hangup);
+                       INIT_WORK(&port->bh_tqueue, isicom_bottomhalf);
                        port->status = 0;
                        init_waitqueue_head(&port->open_wait);
                        init_waitqueue_head(&port->close_wait);
@@ -1971,30 +1856,37 @@ static int __devinit isicom_setup(void)
                }
                isi_card[idx].base = 0;
                isi_card[idx].irq = 0;
-
-               if (!io[idx])
-                       continue;
-
-               if (irq[idx] == 2 || irq[idx] == 3 || irq[idx] == 4     ||
-                               irq[idx] == 5   || irq[idx] == 7        ||
-                               irq[idx] == 10  || irq[idx] == 11       ||
-                               irq[idx] == 12  || irq[idx] == 15) {
-                       printk(KERN_ERR "ISICOM: ISA not supported yet.\n");
-                       retval = -EINVAL;
-                       goto error;
-               } else
-                       printk(KERN_ERR "ISICOM: Irq %d unsupported. "
-                               "Disabling Card%d...\n", irq[idx], idx + 1);
        }
 
-       retval = isicom_register_tty_driver();
-       if (retval < 0)
+       /* tty driver structure initialization */
+       isicom_normal = alloc_tty_driver(PORT_COUNT);
+       if (!isicom_normal) {
+               retval = -ENOMEM;
                goto error;
+       }
+
+       isicom_normal->owner                    = THIS_MODULE;
+       isicom_normal->name                     = "ttyM";
+       isicom_normal->major                    = ISICOM_NMAJOR;
+       isicom_normal->minor_start              = 0;
+       isicom_normal->type                     = TTY_DRIVER_TYPE_SERIAL;
+       isicom_normal->subtype                  = SERIAL_TYPE_NORMAL;
+       isicom_normal->init_termios             = tty_std_termios;
+       isicom_normal->init_termios.c_cflag     = B9600 | CS8 | CREAD | HUPCL |
+               CLOCAL;
+       isicom_normal->flags                    = TTY_DRIVER_REAL_RAW;
+       tty_set_operations(isicom_normal, &isicom_ops);
+
+       retval = tty_register_driver(isicom_normal);
+       if (retval) {
+               pr_dbg("Couldn't register the dialin driver\n");
+               goto err_puttty;
+       }
 
        retval = pci_register_driver(&isicom_driver);
        if (retval < 0) {
                printk(KERN_ERR "ISICOM: Unable to register pci driver.\n");
-               goto errtty;
+               goto err_unrtty;
        }
 
        init_timer(&tx);
@@ -2005,8 +1897,10 @@ static int __devinit isicom_setup(void)
        add_timer(&tx);
 
        return 0;
-errtty:
-       isicom_unregister_tty_driver();
+err_unrtty:
+       tty_unregister_driver(isicom_normal);
+err_puttty:
+       put_tty_driver(isicom_normal);
 error:
        return retval;
 }
@@ -2021,16 +1915,13 @@ static void __exit isicom_exit(void)
                msleep(10);
 
        pci_unregister_driver(&isicom_driver);
-       isicom_unregister_tty_driver();
+       tty_unregister_driver(isicom_normal);
+       put_tty_driver(isicom_normal);
 }
 
-module_init(isicom_setup);
+module_init(isicom_init);
 module_exit(isicom_exit);
 
 MODULE_AUTHOR("MultiTech");
 MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech");
 MODULE_LICENSE("GPL");
-module_param_array(io, int, NULL, 0);
-MODULE_PARM_DESC(io, "I/O ports for the cards");
-module_param_array(irq, int, NULL, 0);
-MODULE_PARM_DESC(irq, "Interrupts for the cards");