readahead: combine file_ra_state.prev_index/prev_offset into prev_pos
[linux-2.6.git] / drivers / char / sx.c
index 1057cc4..85a2328 100644 (file)
@@ -2497,10 +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);
-               if (pdev)
+               if (pdev) {
+#ifdef CONFIG_PCI
                        pci_iounmap(pdev, board->base);
-               else
+                       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);
        }
@@ -2538,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);
@@ -2554,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;
@@ -2586,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.*
@@ -2617,10 +2635,12 @@ 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, reg;
        int retval = -EIO;
@@ -2645,12 +2665,17 @@ static int __devinit sx_pci_probe(struct pci_dev *pdev,
 
        /* CF boards use base address 3.... */
        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 = 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 ....  */
@@ -2674,10 +2699,15 @@ static int __devinit sx_pci_probe(struct pci_dev *pdev,
        return 0;
 err_unmap:
        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)
@@ -2691,9 +2721,9 @@ static void __devexit sx_pci_remove(struct pci_dev *pdev)
    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 }
 };
 
@@ -2736,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;
@@ -2747,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;
@@ -2764,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;
@@ -2780,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