These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / dgnc / dgnc_driver.c
index 805dc61..fc6d298 100644 (file)
@@ -13,7 +13,6 @@
  * PURPOSE.  See the GNU General Public License for more details.
  */
 
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -39,7 +38,6 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 static int             dgnc_start(void);
 static int             dgnc_finalize_board_init(struct dgnc_board *brd);
-static void            dgnc_init_globals(void);
 static int             dgnc_found_board(struct pci_dev *pdev, int id);
 static void            dgnc_cleanup_board(struct dgnc_board *brd);
 static void            dgnc_poll_handler(ulong dummy);
@@ -57,13 +55,13 @@ static const struct file_operations dgnc_BoardFops = {
        .release        =       dgnc_mgmt_close
 };
 
-
 /*
  * Globals
  */
 uint                   dgnc_NumBoards;
 struct dgnc_board              *dgnc_Board[MAXBOARDS];
 DEFINE_SPINLOCK(dgnc_global_lock);
+DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
 uint                   dgnc_Major;
 int                    dgnc_poll_tick = 20;    /* Poll interval - 20 ms */
 
@@ -75,12 +73,10 @@ static struct class *dgnc_class;
 /*
  * Poller stuff
  */
-static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
 static ulong           dgnc_poll_time; /* Time of next poll */
 static uint            dgnc_poll_stop; /* Used to tell poller to stop */
 static struct timer_list dgnc_poll_timer;
 
-
 static const struct pci_device_id dgnc_pci_tbl[] = {
        {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_4_DID),     .driver_data = 0},
        {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID), .driver_data = 1},
@@ -171,7 +167,7 @@ static void dgnc_cleanup_module(void)
  */
 static int __init dgnc_init_module(void)
 {
-       int rc = 0;
+       int rc;
 
        /*
         * Initialize global stuff
@@ -216,8 +212,8 @@ static int dgnc_start(void)
        unsigned long flags;
        struct device *dev;
 
-       /* make sure that the globals are init'd before we do anything else */
-       dgnc_init_globals();
+       /* make sure timer is initialized before we do anything else */
+       init_timer(&dgnc_poll_timer);
 
        /*
         * Register our base character device into the kernel.
@@ -241,7 +237,7 @@ static int dgnc_start(void)
        }
 
        dev = device_create(dgnc_class, NULL,
-                       MKDEV(dgnc_Major, 0),
+                           MKDEV(dgnc_Major, 0),
                        NULL, "dgnc_mgmt");
        if (IS_ERR(dev)) {
                rc = PTR_ERR(dev);
@@ -355,14 +351,11 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
                }
        }
 
-       kfree(brd->flipbuf);
-
        dgnc_Board[brd->boardnum] = NULL;
 
        kfree(brd);
 }
 
-
 /*
  * dgnc_found_board()
  *
@@ -423,9 +416,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        pci_irq = pdev->irq;
        brd->irq = pci_irq;
 
-
        switch (brd->device) {
-
        case PCI_DEVICE_CLASSIC_4_DID:
        case PCI_DEVICE_CLASSIC_8_DID:
        case PCI_DEVICE_CLASSIC_4_422_DID:
@@ -443,7 +434,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
                 * 4    Memory Mapped UARTs and Status
                 */
 
-
                /* get the PCI Base Address Registers */
                brd->membase = pci_resource_start(pdev, 4);
 
@@ -462,7 +452,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
                brd->iobase     = pci_resource_start(pdev, 1);
                brd->iobase_end = pci_resource_end(pdev, 1);
-               brd->iobase     = ((unsigned int) (brd->iobase)) & 0xFFFE;
+               brd->iobase     = ((unsigned int)(brd->iobase)) & 0xFFFE;
 
                /* Assign the board_ops struct */
                brd->bd_ops = &dgnc_cls_ops;
@@ -484,7 +474,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
                break;
 
-
        case PCI_DEVICE_NEO_4_DID:
        case PCI_DEVICE_NEO_8_DID:
        case PCI_DEVICE_NEO_2DB9_DID:
@@ -526,7 +515,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
                dgnc_do_remap(brd);
 
                if (brd->re_map_membase) {
-
                        /* Read and store the dvid after remapping */
                        brd->dvid = readb(brd->re_map_membase + 0x8D);
 
@@ -539,7 +527,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
                dev_err(&brd->pdev->dev,
                        "Didn't find any compatible Neo/Classic PCI boards.\n");
                return -ENXIO;
-
        }
 
        /*
@@ -572,7 +559,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        /* init our poll helper tasklet */
        tasklet_init(&brd->helper_tasklet,
                     brd->bd_ops->tasklet,
-                    (unsigned long) brd);
+                    (unsigned long)brd);
 
        spin_lock_irqsave(&dgnc_global_lock, flags);
        brd->msgbuf = NULL;
@@ -581,14 +568,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        brd->msgbuf_head = NULL;
        spin_unlock_irqrestore(&dgnc_global_lock, flags);
 
-       /*
-        * allocate flip buffer for board.
-        *
-        * Okay to malloc with GFP_KERNEL, we are not at interrupt
-        * context, and there are no locks held.
-        */
-       brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
-
        wake_up_interruptible(&brd->state_wait);
 
        return 0;
@@ -599,10 +578,8 @@ failed:
        brd->dpastatus = BD_NOFEP;
 
        return -ENXIO;
-
 }
 
-
 static int dgnc_finalize_board_init(struct dgnc_board *brd)
 {
        int rc = 0;
@@ -630,14 +607,12 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)
  */
 static void dgnc_do_remap(struct dgnc_board *brd)
 {
-
        if (!brd || brd->magic != DGNC_BOARD_MAGIC)
                return;
 
        brd->re_map_membase = ioremap(brd->membase, 0x1000);
 }
 
-
 /*****************************************************************************
 *
 * Function:
@@ -697,7 +672,7 @@ static void dgnc_poll_handler(ulong dummy)
 
        new_time = dgnc_poll_time - jiffies;
 
-       if ((ulong) new_time >= 2 * dgnc_poll_tick)
+       if ((ulong)new_time >= 2 * dgnc_poll_tick)
                dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
 
        setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0);
@@ -707,23 +682,3 @@ static void dgnc_poll_handler(ulong dummy)
        if (!dgnc_poll_stop)
                add_timer(&dgnc_poll_timer);
 }
-
-/*
- * dgnc_init_globals()
- *
- * This is where we initialize the globals from the static insmod
- * configuration variables.  These are declared near the head of
- * this file.
- */
-static void dgnc_init_globals(void)
-{
-       int i = 0;
-
-       dgnc_NumBoards          = 0;
-
-       for (i = 0; i < MAXBOARDS; i++)
-               dgnc_Board[i] = NULL;
-
-       init_timer(&dgnc_poll_timer);
-}
-