diff options
-rw-r--r-- | drivers/char/mxser_new.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index c87bda388892..7da717730ac7 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c | |||
@@ -2563,6 +2563,22 @@ static const struct tty_operations mxser_ops = { | |||
2563 | * The MOXA Smartio/Industio serial driver boot-time initialization code! | 2563 | * The MOXA Smartio/Industio serial driver boot-time initialization code! |
2564 | */ | 2564 | */ |
2565 | 2565 | ||
2566 | static void mxser_release_res(struct mxser_board *brd, unsigned int irq) | ||
2567 | { | ||
2568 | struct pci_dev *pdev = brd->pdev; | ||
2569 | |||
2570 | if (irq) | ||
2571 | free_irq(brd->irq, brd); | ||
2572 | if (pdev != NULL) { /* PCI */ | ||
2573 | pci_release_region(pdev, 2); | ||
2574 | pci_release_region(pdev, 3); | ||
2575 | pci_dev_put(pdev); | ||
2576 | } else { | ||
2577 | release_region(brd->ports[0].ioaddr, 8 * brd->nports); | ||
2578 | release_region(brd->vector, 1); | ||
2579 | } | ||
2580 | } | ||
2581 | |||
2566 | static int __devinit mxser_initbrd(struct mxser_board *brd) | 2582 | static int __devinit mxser_initbrd(struct mxser_board *brd) |
2567 | { | 2583 | { |
2568 | struct mxser_port *info; | 2584 | struct mxser_port *info; |
@@ -2613,6 +2629,8 @@ static int __devinit mxser_initbrd(struct mxser_board *brd) | |||
2613 | printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " | 2629 | printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " |
2614 | "conflict with another device.\n", | 2630 | "conflict with another device.\n", |
2615 | mxser_brdname[brd->board_type - 1], brd->irq); | 2631 | mxser_brdname[brd->board_type - 1], brd->irq); |
2632 | /* We hold resources, we need to release them. */ | ||
2633 | mxser_release_res(brd, 0); | ||
2616 | return retval; | 2634 | return retval; |
2617 | } | 2635 | } |
2618 | return 0; | 2636 | return 0; |
@@ -2963,14 +2981,9 @@ static int __init mxser_module_init(void) | |||
2963 | " driver !\n"); | 2981 | " driver !\n"); |
2964 | put_tty_driver(mxvar_sdriver); | 2982 | put_tty_driver(mxvar_sdriver); |
2965 | 2983 | ||
2966 | for (i = 0; i < MXSER_BOARDS; i++) { | 2984 | for (i = 0; i < MXSER_BOARDS; i++) |
2967 | if (mxser_boards[i].board_type == -1) | 2985 | if (mxser_boards[i].board_type != -1) |
2968 | continue; | 2986 | mxser_release_res(&mxser_boards[i], 1); |
2969 | else { | ||
2970 | free_irq(mxser_boards[i].irq, &mxser_boards[i]); | ||
2971 | /* todo: release io, vector */ | ||
2972 | } | ||
2973 | } | ||
2974 | return retval; | 2987 | return retval; |
2975 | } | 2988 | } |
2976 | 2989 | ||
@@ -2991,24 +3004,10 @@ static void __exit mxser_module_exit(void) | |||
2991 | else | 3004 | else |
2992 | printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); | 3005 | printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); |
2993 | 3006 | ||
2994 | for (i = 0; i < MXSER_BOARDS; i++) { | 3007 | for (i = 0; i < MXSER_BOARDS; i++) |
2995 | struct pci_dev *pdev; | 3008 | if (mxser_boards[i].board_type != -1) |
3009 | mxser_release_res(&mxser_boards[i], 1); | ||
2996 | 3010 | ||
2997 | if (mxser_boards[i].board_type == -1) | ||
2998 | continue; | ||
2999 | else { | ||
3000 | pdev = mxser_boards[i].pdev; | ||
3001 | free_irq(mxser_boards[i].irq, &mxser_boards[i]); | ||
3002 | if (pdev != NULL) { /* PCI */ | ||
3003 | pci_release_region(pdev, 2); | ||
3004 | pci_release_region(pdev, 3); | ||
3005 | pci_dev_put(pdev); | ||
3006 | } else { | ||
3007 | release_region(mxser_boards[i].ports[0].ioaddr, 8 * mxser_boards[i].nports); | ||
3008 | release_region(mxser_boards[i].vector, 1); | ||
3009 | } | ||
3010 | } | ||
3011 | } | ||
3012 | pr_debug("Done.\n"); | 3011 | pr_debug("Done.\n"); |
3013 | } | 3012 | } |
3014 | 3013 | ||