[PATCH] mxser-workqueue-fixes
[safe/jmp/linux-2.6] / drivers / char / mxser.c
index 048d911..2dc49be 100644 (file)
@@ -389,7 +389,7 @@ static int mxser_init(void);
 /* static void   mxser_poll(unsigned long); */
 static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
 static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
-static void mxser_do_softint(void *);
+static void mxser_do_softint(struct work_struct *);
 static int mxser_open(struct tty_struct *, struct file *);
 static void mxser_close(struct tty_struct *, struct file *);
 static int mxser_write(struct tty_struct *, const unsigned char *, int);
@@ -515,6 +515,7 @@ static void __exit mxser_module_exit(void)
                        if (pdev != NULL) {     /* PCI */
                                release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
                                release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
+                               pci_dev_put(pdev);
                        } else {
                                release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports);
                                release_region(mxsercfg[i].vector, 1);
@@ -556,7 +557,7 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
        n = board * MXSER_PORTS_PER_BOARD;
        info = &mxvar_table[n];
        /*if (verbose) */  {
-               printk(KERN_DEBUG "        ttyM%d - ttyM%d ",
+               printk(KERN_DEBUG "        ttyMI%d - ttyMI%d ",
                        n, n + hwconf->ports - 1);
                printk(" max. baud rate = %d bps.\n",
                        hwconf->MaxCanSetBaudRate[0]);
@@ -590,7 +591,7 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
                info->custom_divisor = hwconf->baud_base[i] * 16;
                info->close_delay = 5 * HZ / 10;
                info->closing_wait = 30 * HZ;
-               INIT_WORK(&info->tqueue, mxser_do_softint, info);
+               INIT_WORK(&info->tqueue, mxser_do_softint);
                info->normal_termios = mxvar_sdriver->init_termios;
                init_waitqueue_head(&info->open_wait);
                init_waitqueue_head(&info->close_wait);
@@ -717,7 +718,7 @@ static int mxser_init(void)
        /* Initialize the tty_driver structure */
        memset(mxvar_sdriver, 0, sizeof(struct tty_driver));
        mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
-       mxvar_sdriver->name = "ttyM";
+       mxvar_sdriver->name = "ttyMI";
        mxvar_sdriver->major = ttymajor;
        mxvar_sdriver->minor_start = 0;
        mxvar_sdriver->num = MXSER_PORTS + 1;
@@ -839,9 +840,9 @@ static int mxser_init(void)
        index = 0;
        b = 0;
        while (b < n) {
-               pdev = pci_find_device(mxser_pcibrds[b].vendor,
+               pdev = pci_get_device(mxser_pcibrds[b].vendor,
                                mxser_pcibrds[b].device, pdev);
-                       if (pdev == NULL) {
+               if (pdev == NULL) {
                        b++;
                        continue;
                }
@@ -893,6 +894,9 @@ static int mxser_init(void)
                        if (mxser_initbrd(m, &hwconf) < 0)
                                continue;
                        m++;
+                       /* Keep an extra reference if we succeeded. It will
+                          be returned at unload time */
+                       pci_dev_get(pdev);
                }
        }
 #endif
@@ -917,9 +921,10 @@ static int mxser_init(void)
        return 0;
 }
 
-static void mxser_do_softint(void *private_)
+static void mxser_do_softint(struct work_struct *work)
 {
-       struct mxser_struct *info = private_;
+       struct mxser_struct *info =
+               container_of(work, struct mxser_struct, tqueue);
        struct tty_struct *tty;
 
        tty = info->tty;
@@ -993,7 +998,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
                mxser_change_speed(info, NULL);
        }
 
-       info->session = current->signal->session;
+       info->session = process_session(current);
        info->pgrp = process_group(current);
 
        /*