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
 
                /* It is safe/allowed to del_timer a non-active timer */
                del_timer(&board->timer);
-               iounmap(board->base);
+               if (pdev)
+                       pci_iounmap(pdev, board->base);
+               else
+                       iounmap(board->base);
 
                board->flags &= ~(SX_BOARD_INITIALIZED | SX_BOARD_PRESENT);
        }
 {
        struct sx_board *board = dev_get_drvdata(dev);
 
-       sx_remove_card(board);
+       sx_remove_card(board, NULL);
 
        return 0;
 }
                                  const struct pci_device_id *ent)
 {
        struct sx_board *board;
-       unsigned int i;
+       unsigned int i, reg;
        int retval = -EIO;
 
        mutex_lock(&sx_boards_lock);
                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;
+       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;
 
        return 0;
 err_unmap:
-       iounmap(board->base2);
+       pci_iounmap(pdev, board->base);
 err_flag:
        board->flags &= ~SX_BOARD_PRESENT;
 err:
 {
        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
        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 "