X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fchar%2Fsx.c;h=a6e1c9ba12174d769e1389d5329b70676e5e3b16;hb=79472b6ea9e74ee4400ba57ba84cad86426e2d6d;hp=401ebab26018e17d34e8d27477488512386cb59d;hpb=15b611f63f0fb8709a5fae498c2d688b5d05edc9;p=linux-2.6-omap-h63xx.git diff --git a/drivers/char/sx.c b/drivers/char/sx.c index 401ebab2601..a6e1c9ba121 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -1353,10 +1353,7 @@ static void sx_pollfunc(unsigned long data) sx_interrupt(0, board); - init_timer(&board->timer); - - board->timer.expires = jiffies + sx_poll; - add_timer(&board->timer); + mod_timer(&board->timer, jiffies + sx_poll); func_exit(); } @@ -1470,7 +1467,7 @@ static int sx_open(struct tty_struct *tty, struct file *filp) line = tty->index; sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, " - "np=%d)\n", current->pid, line, tty, + "np=%d)\n", task_pid_nr(current), line, tty, current->signal->tty, sx_nports); if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports)) @@ -2134,14 +2131,10 @@ static int sx_init_board(struct sx_board *board) /* The timer should be initialized anyway: That way we can safely del_timer it when the module is unloaded. */ - init_timer(&board->timer); + setup_timer(&board->timer, sx_pollfunc, (unsigned long)board); - if (board->poll) { - board->timer.data = (unsigned long)board; - board->timer.function = sx_pollfunc; - board->timer.expires = jiffies + board->poll; - add_timer(&board->timer); - } + if (board->poll) + mod_timer(&board->timer, jiffies + board->poll); } else { board->irq = 0; } @@ -2492,7 +2485,8 @@ static void __exit sx_release_drivers(void) func_exit(); } -static void __devexit sx_remove_card(struct sx_board *board) +static void __devexit sx_remove_card(struct sx_board *board, + struct pci_dev *pdev) { if (board->flags & SX_BOARD_INITIALIZED) { /* The board should stop messing with us. (actually I mean the @@ -2503,7 +2497,15 @@ static void __devexit sx_remove_card(struct sx_board *board) /* It is safe/allowed to del_timer a non-active timer */ del_timer(&board->timer); - iounmap(board->base); + if (pdev) { +#ifdef CONFIG_PCI + pci_iounmap(pdev, board->base); + pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); +#endif + } else { + iounmap(board->base); + release_region(board->hw_base, board->hw_len); + } board->flags &= ~(SX_BOARD_INITIALIZED | SX_BOARD_PRESENT); } @@ -2541,8 +2543,17 @@ static int __devinit sx_eisa_probe(struct device *dev) board->hw_base = ((inb(eisa_slot + 0xc01) << 8) + inb(eisa_slot + 0xc00)) << 16; + board->hw_len = SI2_EISA_WINDOW_LEN; + if (!request_region(board->hw_base, board->hw_len, "sx")) { + dev_err(dev, "can't request region\n"); + goto err_flag; + } board->base2 = board->base = ioremap(board->hw_base, SI2_EISA_WINDOW_LEN); + if (!board->base) { + dev_err(dev, "can't remap memory\n"); + goto err_reg; + } sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base); sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base); @@ -2557,6 +2568,9 @@ static int __devinit sx_eisa_probe(struct device *dev) return 0; err_unmap: iounmap(board->base); +err_reg: + release_region(board->hw_base, board->hw_len); +err_flag: board->flags &= ~SX_BOARD_PRESENT; err: return retval; @@ -2566,7 +2580,7 @@ static int __devexit sx_eisa_remove(struct device *dev) { struct sx_board *board = dev_get_drvdata(dev); - sx_remove_card(board); + sx_remove_card(board, NULL); return 0; } @@ -2589,6 +2603,7 @@ static struct eisa_driver sx_eisadriver = { #endif +#ifdef CONFIG_PCI /******************************************************** * Setting bit 17 in the CNTRL register of the PLX 9050 * * chip forces a retry on writes while a read is pending.* @@ -2620,12 +2635,14 @@ static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board) } iounmap(rebase); } +#endif static int __devinit sx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { +#ifdef CONFIG_PCI struct sx_board *board; - unsigned int i; + unsigned int i, reg; int retval = -EIO; mutex_lock(&sx_boards_lock); @@ -2647,15 +2664,18 @@ static int __devinit sx_pci_probe(struct pci_dev *pdev, SX_CFPCI_BOARD; /* CF boards use base address 3.... */ - if (IS_CF_BOARD(board)) - board->hw_base = pci_resource_start(pdev, 3); - else - board->hw_base = pci_resource_start(pdev, 2); + reg = IS_CF_BOARD(board) ? 3 : 2; + retval = pci_request_region(pdev, reg, "sx"); + if (retval) { + dev_err(&pdev->dev, "can't request region\n"); + goto err_flag; + } + board->hw_base = pci_resource_start(pdev, reg); board->base2 = - board->base = ioremap(board->hw_base, WINDOW_LEN(board)); + board->base = pci_iomap(pdev, reg, WINDOW_LEN(board)); if (!board->base) { dev_err(&pdev->dev, "ioremap failed\n"); - goto err_flag; + goto err_reg; } /* Most of the stuff on the CF board is offset by 0x18000 .... */ @@ -2678,27 +2698,32 @@ static int __devinit sx_pci_probe(struct pci_dev *pdev, return 0; err_unmap: - iounmap(board->base2); + pci_iounmap(pdev, board->base); +err_reg: + pci_release_region(pdev, reg); err_flag: board->flags &= ~SX_BOARD_PRESENT; err: return retval; +#else + return -ENODEV; +#endif } static void __devexit sx_pci_remove(struct pci_dev *pdev) { struct sx_board *board = pci_get_drvdata(pdev); - sx_remove_card(board); + sx_remove_card(board, pdev); } /* Specialix has a whole bunch of cards with 0x2000 as the device ID. They say its because the standard requires it. So check for SUBVENDOR_ID. */ static struct pci_device_id sx_pci_tbl[] = { { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, - .subvendor = 0x0200,.subdevice = PCI_ANY_ID }, + .subvendor = PCI_ANY_ID, .subdevice = 0x0200 }, { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, - .subvendor = 0x0300,.subdevice = PCI_ANY_ID }, + .subvendor = PCI_ANY_ID, .subdevice = 0x0300 }, { 0 } }; @@ -2741,8 +2766,13 @@ static int __init sx_init(void) for (i = 0; i < NR_SX_ADDRS; i++) { board = &boards[found]; board->hw_base = sx_probe_addrs[i]; + board->hw_len = SX_WINDOW_LEN; + if (!request_region(board->hw_base, board->hw_len, "sx")) + continue; board->base2 = - board->base = ioremap(board->hw_base, SX_WINDOW_LEN); + board->base = ioremap(board->hw_base, board->hw_len); + if (!board->base) + goto err_sx_reg; board->flags &= ~SX_BOARD_TYPE; board->flags |= SX_ISA_BOARD; board->irq = sx_irqmask ? -1 : 0; @@ -2752,14 +2782,21 @@ static int __init sx_init(void) found++; } else { iounmap(board->base); +err_sx_reg: + release_region(board->hw_base, board->hw_len); } } for (i = 0; i < NR_SI_ADDRS; i++) { board = &boards[found]; board->hw_base = si_probe_addrs[i]; + board->hw_len = SI2_ISA_WINDOW_LEN; + if (!request_region(board->hw_base, board->hw_len, "sx")) + continue; board->base2 = - board->base = ioremap(board->hw_base, SI2_ISA_WINDOW_LEN); + board->base = ioremap(board->hw_base, board->hw_len); + if (!board->base) + goto err_si_reg; board->flags &= ~SX_BOARD_TYPE; board->flags |= SI_ISA_BOARD; board->irq = sx_irqmask ? -1 : 0; @@ -2769,13 +2806,20 @@ static int __init sx_init(void) found++; } else { iounmap(board->base); +err_si_reg: + release_region(board->hw_base, board->hw_len); } } for (i = 0; i < NR_SI1_ADDRS; i++) { board = &boards[found]; board->hw_base = si1_probe_addrs[i]; + board->hw_len = SI1_ISA_WINDOW_LEN; + if (!request_region(board->hw_base, board->hw_len, "sx")) + continue; board->base2 = - board->base = ioremap(board->hw_base, SI1_ISA_WINDOW_LEN); + board->base = ioremap(board->hw_base, board->hw_len); + if (!board->base) + goto err_si1_reg; board->flags &= ~SX_BOARD_TYPE; board->flags |= SI1_ISA_BOARD; board->irq = sx_irqmask ? -1 : 0; @@ -2785,6 +2829,8 @@ static int __init sx_init(void) found++; } else { iounmap(board->base); +err_si1_reg: + release_region(board->hw_base, board->hw_len); } } #endif @@ -2798,6 +2844,7 @@ static int __init sx_init(void) retval = 0; } else if (retval) { #ifdef CONFIG_EISA + retval = retval1; if (retval1) #endif misc_deregister(&sx_fw_device); @@ -2818,7 +2865,7 @@ static void __exit sx_exit(void) pci_unregister_driver(&sx_pcidriver); for (i = 0; i < SX_NBOARDS; i++) - sx_remove_card(&boards[i]); + sx_remove_card(&boards[i], NULL); if (misc_deregister(&sx_fw_device) < 0) { printk(KERN_INFO "sx: couldn't deregister firmware loader "