]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/staging/me4000/me4000.c
Staging: me4000: do not use C99 style comments.
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / me4000 / me4000.c
index 0394e2709278cae3c00ad94e3daa21ca5d21b309..be8ffefb9c3528ca5ca5f309a45280d455a5468e 100644 (file)
@@ -36,8 +36,8 @@
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
 #include <asm/pgtable.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
 #include <asm/system.h>
 
 /* Include-File for the Meilhaus ME-4000 I/O board */
@@ -246,17 +246,17 @@ static irqreturn_t me4000_ext_int_isr(int, void *);
   Inline functions
   ---------------------------------------------------------------------------*/
 
-static int inline me4000_buf_count(struct me4000_circ_buf buf, int size)
+static inline int me4000_buf_count(struct me4000_circ_buf buf, int size)
 {
-       return ((buf.head - buf.tail) & (size - 1));
+       return (buf.head - buf.tail) & (size - 1);
 }
 
-static int inline me4000_buf_space(struct me4000_circ_buf buf, int size)
+static inline int me4000_buf_space(struct me4000_circ_buf buf, int size)
 {
-       return ((buf.tail - (buf.head + 1)) & (size - 1));
+       return (buf.tail - (buf.head + 1)) & (size - 1);
 }
 
-static int inline me4000_values_to_end(struct me4000_circ_buf buf, int size)
+static inline int me4000_values_to_end(struct me4000_circ_buf buf, int size)
 {
        int end;
        int n;
@@ -265,7 +265,7 @@ static int inline me4000_values_to_end(struct me4000_circ_buf buf, int size)
        return (n < end) ? n : end;
 }
 
-static int inline me4000_space_to_end(struct me4000_circ_buf buf, int size)
+static inline int me4000_space_to_end(struct me4000_circ_buf buf, int size)
 {
        int end;
        int n;
@@ -275,19 +275,19 @@ static int inline me4000_space_to_end(struct me4000_circ_buf buf, int size)
        return (n <= end) ? n : (end + 1);
 }
 
-static void inline me4000_outb(unsigned char value, unsigned long port)
+static inline void me4000_outb(unsigned char value, unsigned long port)
 {
        PORT_PDEBUG("--> 0x%02X port 0x%04lX\n", value, port);
        outb(value, port);
 }
 
-static void inline me4000_outl(unsigned long value, unsigned long port)
+static inline void me4000_outl(unsigned long value, unsigned long port)
 {
        PORT_PDEBUG("--> 0x%08lX port 0x%04lX\n", value, port);
        outl(value, port);
 }
 
-static unsigned long inline me4000_inl(unsigned long port)
+static inline unsigned long me4000_inl(unsigned long port)
 {
        unsigned long value;
        value = inl(port);
@@ -295,7 +295,7 @@ static unsigned long inline me4000_inl(unsigned long port)
        return value;
 }
 
-static unsigned char inline me4000_inb(unsigned long port)
+static inline unsigned char me4000_inb(unsigned long port)
 {
        unsigned char value;
        value = inb(port);
@@ -402,17 +402,25 @@ static struct file_operations me4000_ext_int_fops = {
 };
 
 static struct file_operations *me4000_ao_fops_array[] = {
-       &me4000_ao_fops_sing,   // single operations
-       &me4000_ao_fops_wrap,   // wraparound operations
-       &me4000_ao_fops_cont,   // continous operations
+       /* single operations */
+       &me4000_ao_fops_sing,
+       /* wraparound operations */
+       &me4000_ao_fops_wrap,
+       /* continuous operations */
+       &me4000_ao_fops_cont,
 };
 
 static struct file_operations *me4000_ai_fops_array[] = {
-       &me4000_ai_fops_sing,   // single operations
-       &me4000_ai_fops_cont_sw,        // continuous operations with software start
-       &me4000_ai_fops_cont_et,        // continous operations with external trigger
-       &me4000_ai_fops_cont_et_value,  // sample values by external trigger
-       &me4000_ai_fops_cont_et_chanlist,       // work through one channel list by external trigger
+       /* single operations */
+       &me4000_ai_fops_sing,
+       /* continuous operations with software start */
+       &me4000_ai_fops_cont_sw,
+       /* continuous operations with external trigger */
+       &me4000_ai_fops_cont_et,
+       /* sample values by external trigger */
+       &me4000_ai_fops_cont_et_value,
+       /* work through one channel list by external trigger */
+       &me4000_ai_fops_cont_et_chanlist,
 };
 
 static int __init me4000_init_module(void)
@@ -536,31 +544,23 @@ module_init(me4000_init_module);
 
 static void clear_board_info_list(void)
 {
-       struct list_head *board_p;
-       struct list_head *dac_p;
-       struct me4000_info *board_info;
-       struct me4000_ao_context *ao_context;
+       struct me4000_info *board_info, *board_info_safe;
+       struct me4000_ao_context *ao_context, *ao_context_safe;
 
        /* Clear context lists */
-       for (board_p = me4000_board_info_list.next;
-            board_p != &me4000_board_info_list; board_p = board_p->next) {
-               board_info = list_entry(board_p, struct me4000_info, list);
+       list_for_each_entry(board_info, &me4000_board_info_list, list) {
                /* Clear analog output context list */
-               while (!list_empty(&board_info->ao_context_list)) {
-                       dac_p = board_info->ao_context_list.next;
-                       ao_context =
-                           list_entry(dac_p, struct me4000_ao_context, list);
+               list_for_each_entry_safe(ao_context, ao_context_safe,
+                               &board_info->ao_context_list, list) {
                        me4000_ao_reset(ao_context);
                        free_irq(ao_context->irq, ao_context);
-                       if (ao_context->circ_buf.buf)
-                               kfree(ao_context->circ_buf.buf);
-                       list_del(dac_p);
+                       kfree(ao_context->circ_buf.buf);
+                       list_del(&ao_context->list);
                        kfree(ao_context);
                }
 
                /* Clear analog input context */
-               if (board_info->ai_context->circ_buf.buf)
-                       kfree(board_info->ai_context->circ_buf.buf);
+               kfree(board_info->ai_context->circ_buf.buf);
                kfree(board_info->ai_context);
 
                /* Clear digital I/O context */
@@ -574,11 +574,10 @@ static void clear_board_info_list(void)
        }
 
        /* Clear the board info list */
-       while (!list_empty(&me4000_board_info_list)) {
-               board_p = me4000_board_info_list.next;
-               board_info = list_entry(board_p, struct me4000_info, list);
+       list_for_each_entry_safe(board_info, board_info_safe,
+                       &me4000_board_info_list, list) {
                pci_release_regions(board_info->pci_dev_p);
-               list_del(board_p);
+               list_del(&board_info->list);
                kfree(board_info);
        }
 }
@@ -663,16 +662,17 @@ static int init_board_info(struct pci_dev *pci_dev_p,
        }
 
        /* Get the index of the board in the global list */
-       for (board_p = me4000_board_info_list.next, i = 0;
-            board_p != &me4000_board_info_list; board_p = board_p->next, i++) {
+       i = 0;
+       list_for_each(board_p, &me4000_board_info_list) {
                if (board_p == &board_info->list) {
                        board_info->board_count = i;
                        break;
                }
+               i++;
        }
        if (board_p == &me4000_board_info_list) {
                printk(KERN_ERR
-                      "ME4000:init_board_info():Cannot get index of baord\n");
+                      "ME4000:init_board_info():Cannot get index of board\n");
                return -ENODEV;
        }
 
@@ -863,16 +863,14 @@ static int alloc_ao_contexts(struct me4000_info *info)
 
 static void release_ao_contexts(struct me4000_info *board_info)
 {
-       struct list_head *dac_p;
-       struct me4000_ao_context *ao_context;
+       struct me4000_ao_context *ao_context, *ao_context_safe;
 
        /* Clear analog output context list */
-       while (!list_empty(&board_info->ao_context_list)) {
-               dac_p = board_info->ao_context_list.next;
-               ao_context = list_entry(dac_p, struct me4000_ao_context, list);
+       list_for_each_entry_safe(ao_context, ao_context_safe,
+                       &board_info->ao_context_list, list) {
                free_irq(ao_context->irq, ao_context);
                kfree(ao_context->circ_buf.buf);
-               list_del(dac_p);
+               list_del(&ao_context->list);
                kfree(ao_context);
        }
 }
@@ -1180,7 +1178,7 @@ static int me4000_xilinx_download(struct me4000_info *info)
 
        /* Wait until /INIT pin is set */
        udelay(20);
-       if (!inl(info->plx_regbase + PLX_INTCSR) & 0x20) {
+       if (!(inl(info->plx_regbase + PLX_INTCSR) & 0x20)) {
                printk(KERN_ERR "%s:Can't init Xilinx\n", __func__);
                return -EIO;
        }
@@ -1271,9 +1269,8 @@ static int me4000_reset_board(struct me4000_info *info)
                    info->me4000_regbase + ME4000_AO_DEMUX_ADJUST_REG);
 
        /* Set digital I/O direction for port 0 to output on isolated versions */
-       if (!(me4000_inl(info->me4000_regbase + ME4000_DIO_DIR_REG) & 0x1)) {
+       if (!(me4000_inl(info->me4000_regbase + ME4000_DIO_DIR_REG) & 0x1))
                me4000_outl(0x1, info->me4000_regbase + ME4000_DIO_CTRL_REG);
-       }
 
        return 0;
 }
@@ -1303,12 +1300,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                       dev, mode);
 
                /* Search for the board context */
-               for (ptr = me4000_board_info_list.next, i = 0;
-                    ptr != &me4000_board_info_list; ptr = ptr->next, i++) {
-                       board_info = list_entry(ptr, struct me4000_info, list);
+               i = 0;
+               list_for_each(ptr, &me4000_board_info_list) {
                        if (i == board)
                                break;
+                       i++;
                }
+               board_info = list_entry(ptr, struct me4000_info, list);
 
                if (ptr == &me4000_board_info_list) {
                        printk(KERN_ERR
@@ -1318,14 +1316,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                }
 
                /* Search for the dac context */
-               for (ptr = board_info->ao_context_list.next, i = 0;
-                    ptr != &board_info->ao_context_list;
-                    ptr = ptr->next, i++) {
-                       ao_context = list_entry(ptr, struct me4000_ao_context,
-                                                                       list);
+               i = 0;
+               list_for_each(ptr, &board_info->ao_context_list) {
                        if (i == dev)
                                break;
+                       i++;
                }
+               ao_context = list_entry(ptr, struct me4000_ao_context, list);
 
                if (ptr == &board_info->ao_context_list) {
                        printk(KERN_ERR
@@ -1384,12 +1381,13 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                PDEBUG("me4000_open():ai board = %d mode = %d\n", board, mode);
 
                /* Search for the board context */
-               for (ptr = me4000_board_info_list.next, i = 0;
-                    ptr != &me4000_board_info_list; ptr = ptr->next, i++) {
-                       board_info = list_entry(ptr, struct me4000_info, list);
+               i = 0;
+               list_for_each(ptr, &me4000_board_info_list) {
                        if (i == board)
                                break;
+                       i++;
                }
+               board_info = list_entry(ptr, struct me4000_info, list);
 
                if (ptr == &me4000_board_info_list) {
                        printk(KERN_ERR
@@ -1438,14 +1436,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                PDEBUG("me4000_open():board = %d\n", board);
 
                /* Search for the board context */
-               for (ptr = me4000_board_info_list.next;
-                    ptr != &me4000_board_info_list; ptr = ptr->next) {
-                       board_info = list_entry(ptr, struct me4000_info, list);
+               list_for_each_entry(board_info, &me4000_board_info_list, list) {
                        if (board_info->board_count == board)
                                break;
                }
 
-               if (ptr == &me4000_board_info_list) {
+               if (&board_info->list == &me4000_board_info_list) {
                        printk(KERN_ERR
                               "ME4000:me4000_open():Board %d not in device list\n",
                               board);
@@ -1472,7 +1468,7 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                /* Set file operations pointer to single functions */
                file_p->f_op = &me4000_dio_fops;
 
-               //me4000_dio_reset(dio_context);
+               /* me4000_dio_reset(dio_context); */
        }
        /* Counters */
        else if (MAJOR(inode_p->i_rdev) == me4000_cnt_major_driver_no) {
@@ -1483,14 +1479,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                PDEBUG("me4000_open():board = %d\n", board);
 
                /* Search for the board context */
-               for (ptr = me4000_board_info_list.next;
-                    ptr != &me4000_board_info_list; ptr = ptr->next) {
-                       board_info = list_entry(ptr, struct me4000_info, list);
+               list_for_each_entry(board_info, &me4000_board_info_list, list) {
                        if (board_info->board_count == board)
                                break;
                }
 
-               if (ptr == &me4000_board_info_list) {
+               if (&board_info->list == &me4000_board_info_list) {
                        printk(KERN_ERR
                               "ME4000:me4000_open():Board %d not in device list\n",
                               board);
@@ -1526,14 +1520,12 @@ static int me4000_open(struct inode *inode_p, struct file *file_p)
                PDEBUG("me4000_open():board = %d\n", board);
 
                /* Search for the board context */
-               for (ptr = me4000_board_info_list.next;
-                    ptr != &me4000_board_info_list; ptr = ptr->next) {
-                       board_info = list_entry(ptr, struct me4000_info, list);
+               list_for_each_entry(board_info, &me4000_board_info_list, list) {
                        if (board_info->board_count == board)
                                break;
                }
 
-               if (ptr == &me4000_board_info_list) {
+               if (&board_info->list == &me4000_board_info_list) {
                        printk(KERN_ERR
                               "ME4000:me4000_open():Board %d not in device list\n",
                               board);
@@ -2071,7 +2063,7 @@ static ssize_t me4000_ao_write_cont(struct file *filep, const char *buff,
                                                ME4000_AO_BUFFER_COUNT);
 
                        if (c == 0)
-                               return (2 * ret);
+                               return 2 * ret;
 
                        /* Only able to write size of free buffer or size of count */
                        if (count < c)
@@ -2117,9 +2109,8 @@ static ssize_t me4000_ao_write_cont(struct file *filep, const char *buff,
                }
        }
 
-       if (filep->f_flags & O_NONBLOCK) {
+       if (filep->f_flags & O_NONBLOCK)
                return (ret == 0) ? -EAGAIN : 2 * ret;
-       }
 
        return 2 * ret;
 }
@@ -2374,7 +2365,9 @@ static int me4000_ao_start(unsigned long *arg,
                                               "ME4000:me4000_ao_start():Wait on start of state machine interrupted\n");
                                        return -EINTR;
                                }
-                               if (((jiffies - ref) > (timeout * HZ / USER_HZ))) {     // 2.6 has diffrent definitions for HZ in user and kernel space
+                               /* kernel 2.6 has different definitions for HZ
+                                * in user and kernel space */
+                               if ((jiffies - ref) > (timeout * HZ / USER_HZ)) {
                                        printk(KERN_ERR
                                               "ME4000:me4000_ao_start():Timeout reached\n");
                                        return -EIO;
@@ -2415,8 +2408,8 @@ static int me4000_ao_stop(struct me4000_ao_context *ao_context)
        }
 
        /* Clear the stop bit */
-       //tmp &= ~ME4000_AO_CTRL_BIT_STOP;
-       //me4000_outl(tmp, ao_context->ctrl_reg);
+       /* tmp &= ~ME4000_AO_CTRL_BIT_STOP; */
+       /* me4000_outl(tmp, ao_context->ctrl_reg); */
 
        return 0;
 }
@@ -2447,8 +2440,8 @@ static int me4000_ao_immediate_stop(struct me4000_ao_context *ao_context)
        }
 
        /* Clear the stop bits */
-       //tmp &= ~(ME4000_AO_CTRL_BIT_STOP | ME4000_AO_CTRL_BIT_IMMEDIATE_STOP);
-       //me4000_outl(tmp, ao_context->ctrl_reg);
+       /* tmp &= ~(ME4000_AO_CTRL_BIT_STOP | ME4000_AO_CTRL_BIT_IMMEDIATE_STOP); */
+       /* me4000_outl(tmp, ao_context->ctrl_reg); */
 
        return 0;
 }
@@ -2611,8 +2604,10 @@ static int me4000_ao_simultaneous_disable(struct me4000_ao_context *ao_context)
 
        spin_lock(&ao_context->board_info->preload_lock);
        tmp = me4000_inl(ao_context->preload_reg);
-       tmp &= ~(0x1 << ao_context->index);     // Disable preload bit
-       tmp &= ~(0x1 << (ao_context->index + 16));      // Disable hw simultaneous bit
+       /* Disable preload bit */
+       tmp &= ~(0x1 << ao_context->index);
+       /* Disable hw simultaneous bit */
+       tmp &= ~(0x1 << (ao_context->index + 16));
        me4000_outl(tmp, ao_context->preload_reg);
        spin_unlock(&ao_context->board_info->preload_lock);
 
@@ -2627,8 +2622,10 @@ static int me4000_ao_simultaneous_ex_trig(struct me4000_ao_context *ao_context)
 
        spin_lock(&ao_context->board_info->preload_lock);
        tmp = me4000_inl(ao_context->preload_reg);
-       tmp |= (0x1 << ao_context->index);      // Enable preload bit
-       tmp |= (0x1 << (ao_context->index + 16));       // Enable hw simultaneous bit
+       /* Enable preload bit */
+       tmp |= (0x1 << ao_context->index);
+       /* Enable hw simulatenous bit */
+       tmp |= (0x1 << (ao_context->index + 16));
        me4000_outl(tmp, ao_context->preload_reg);
        spin_unlock(&ao_context->board_info->preload_lock);
 
@@ -2643,8 +2640,10 @@ static int me4000_ao_simultaneous_sw(struct me4000_ao_context *ao_context)
 
        spin_lock(&ao_context->board_info->preload_lock);
        tmp = me4000_inl(ao_context->preload_reg);
-       tmp |= (0x1 << ao_context->index);      // Enable preload bit
-       tmp &= ~(0x1 << (ao_context->index + 16));      // Disable hw simultaneous bit
+       /* Enable preload bit */
+       tmp |= (0x1 << ao_context->index);
+       /* Enable hw simulatenous bit */
+       tmp &= ~(0x1 << (ao_context->index + 16));
        me4000_outl(tmp, ao_context->preload_reg);
        spin_unlock(&ao_context->board_info->preload_lock);
 
@@ -2745,8 +2744,10 @@ static int me4000_ao_simultaneous_update(struct me4000_ao_channel_list *arg,
                               "ME4000:me4000_ao_simultaneous_update():Invalid board number specified\n");
                        return -EFAULT;
                }
-               tmp &= ~(0x1 << channels.list[i]);      // Clear the preload bit
-               tmp &= ~(0x1 << (channels.list[i] + 16));       // Clear the hw simultaneous bit
+               /* Clear the preload bit */
+               tmp &= ~(0x1 << channels.list[i]);
+               /* Clear the hw simultaneous bit */
+               tmp &= ~(0x1 << (channels.list[i] + 16));
        }
        me4000_outl(tmp, ao_context->preload_reg);
        spin_unlock(&ao_context->board_info->preload_lock);
@@ -2772,8 +2773,10 @@ static int me4000_ao_synchronous_ex_trig(struct me4000_ao_context *ao_context)
 
        spin_lock(&ao_context->board_info->preload_lock);
        tmp = me4000_inl(ao_context->preload_reg);
-       tmp &= ~(0x1 << ao_context->index);     // Disable synchronous sw bit
-       tmp |= 0x1 << (ao_context->index + 16); // Enable synchronous hw bit
+       /* Disable synchronous sw bit */
+       tmp &= ~(0x1 << ao_context->index);
+       /* Enable synchronous hw bit */
+       tmp |= 0x1 << (ao_context->index + 16);
        me4000_outl(tmp, ao_context->preload_reg);
        spin_unlock(&ao_context->board_info->preload_lock);
 
@@ -2807,8 +2810,10 @@ static int me4000_ao_synchronous_sw(struct me4000_ao_context *ao_context)
 
        spin_lock(&ao_context->board_info->preload_lock);
        tmp = me4000_inl(ao_context->preload_reg);
-       tmp |= 0x1 << ao_context->index;        // Enable synchronous sw bit
-       tmp &= ~(0x1 << (ao_context->index + 16));      // Disable synchronous hw bit
+       /* Enable synchronous sw bit */
+       tmp |= 0x1 << ao_context->index;
+       /* Disable synchronous hw bit */
+       tmp &= ~(0x1 << (ao_context->index + 16));
        me4000_outl(tmp, ao_context->preload_reg);
        spin_unlock(&ao_context->board_info->preload_lock);
 
@@ -2880,7 +2885,9 @@ static int me4000_ao_ex_trig_timeout(unsigned long *arg,
                                               "ME4000:me4000_ao_ex_trig_timeout():Wait on start of state machine interrupted\n");
                                        return -EINTR;
                                }
-                               if (((jiffies - ref) > (timeout * HZ / USER_HZ))) {     // 2.6 has diffrent definitions for HZ in user and kernel space
+                               /* kernel 2.6 has different definitions for HZ
+                                * in user and kernel space */
+                               if ((jiffies - ref) > (timeout * HZ / USER_HZ)) {
                                        printk(KERN_ERR
                                               "ME4000:me4000_ao_ex_trig_timeout():Timeout reached\n");
                                        return -EIO;
@@ -3256,7 +3263,8 @@ static int me4000_ai_single(struct me4000_ai_single *arg,
                                       "ME4000:me4000_ai_single():Wait on start of state machine interrupted\n");
                                return -EINTR;
                        }
-                       if (((jiffies - jiffy) > (cmd.timeout * HZ / USER_HZ)) && cmd.timeout) {        // 2.6 has diffrent definitions for HZ in user and kernel space
+                       /* 2.6 has different definitions for HZ in user and kernel space */
+                       if (((jiffies - jiffy) > (cmd.timeout * HZ / USER_HZ)) && cmd.timeout) {
                                printk(KERN_ERR
                                       "ME4000:me4000_ai_single():Timeout reached\n");
                                return -EIO;
@@ -3635,9 +3643,8 @@ static int me4000_ai_config(struct me4000_ai_config *arg,
        me4000_outl(tmp, ai_context->ctrl_reg);
 
        /* Write the channel list */
-       for (i = 0; i < cmd.channel_list.count; i++) {
+       for (i = 0; i < cmd.channel_list.count; i++)
                me4000_outl(list[i], ai_context->channel_list_reg);
-       }
 
        /* Setup sample and hold */
        if (cmd.sh) {
@@ -3676,8 +3683,7 @@ AI_CONFIG_ERR:
        tmp &=
            ~(ME4000_AI_CTRL_BIT_CHANNEL_FIFO | ME4000_AI_CTRL_BIT_SAMPLE_HOLD);
 
-       if (list)
-               kfree(list);
+       kfree(list);
 
        return err;
 
@@ -3787,25 +3793,22 @@ static int me4000_ai_start_ex(unsigned long *arg,
 
        if (timeout) {
                ref = jiffies;
-               while (!
-                      (inl(ai_context->status_reg) & ME4000_AI_STATUS_BIT_FSM))
-               {
+               while (!(inl(ai_context->status_reg) & ME4000_AI_STATUS_BIT_FSM)) {
                        interruptible_sleep_on_timeout(&queue, 1);
                        if (signal_pending(current)) {
                                printk(KERN_ERR
                                       "ME4000:me4000_ai_start_ex():Wait on start of state machine interrupted\n");
                                return -EINTR;
                        }
-                       if (((jiffies - ref) > (timeout * HZ / USER_HZ))) {     // 2.6 has diffrent definitions for HZ in user and kernel space
+                       /* 2.6 has different definitions for HZ in user and kernel space */
+                       if ((jiffies - ref) > (timeout * HZ / USER_HZ)) {
                                printk(KERN_ERR
                                       "ME4000:me4000_ai_start_ex():Timeout reached\n");
                                return -EIO;
                        }
                }
        } else {
-               while (!
-                      (inl(ai_context->status_reg) & ME4000_AI_STATUS_BIT_FSM))
-               {
+               while (!(inl(ai_context->status_reg) & ME4000_AI_STATUS_BIT_FSM)) {
                        interruptible_sleep_on_timeout(&queue, 1);
                        if (signal_pending(current)) {
                                printk(KERN_ERR
@@ -4126,9 +4129,8 @@ static ssize_t me4000_ai_read(struct file *filep, char *buff, size_t cnt,
                return -EPIPE;
        }
 
-       if (filep->f_flags & O_NONBLOCK) {
+       if (filep->f_flags & O_NONBLOCK)
                return (k == 0) ? -EAGAIN : 2 * ret;
-       }
 
        CALL_PDEBUG("me4000_ai_read() is leaved\n");
        return ret * 2;
@@ -4267,11 +4269,10 @@ static int eeprom_write_cmd(struct me4000_ai_context *ai_context, unsigned long
        udelay(EEPROM_DELAY);
 
        for (i = 0; i < length; i++) {
-               if (cmd & ((0x1 << (length - 1)) >> i)) {
+               if (cmd & ((0x1 << (length - 1)) >> i))
                        value |= PLX_ICR_BIT_EEPROM_WRITE;
-               } else {
+               else
                        value &= ~PLX_ICR_BIT_EEPROM_WRITE;
-               }
 
                /* Write to EEPROM */
                me4000_outl(value,
@@ -4327,11 +4328,11 @@ static unsigned short eeprom_read_cmd(struct me4000_ai_context *ai_context,
 
        /* Write the read command to the eeprom */
        for (i = 0; i < length; i++) {
-               if (cmd & ((0x1 << (length - 1)) >> i)) {
+               if (cmd & ((0x1 << (length - 1)) >> i))
                        value |= PLX_ICR_BIT_EEPROM_WRITE;
-               } else {
+               else
                        value &= ~PLX_ICR_BIT_EEPROM_WRITE;
-               }
+
                me4000_outl(value,
                            ai_context->board_info->plx_regbase + PLX_ICR);
                udelay(EEPROM_DELAY);
@@ -5453,8 +5454,6 @@ static irqreturn_t me4000_ao_isr(int irq, void *dev_id)
        int i;
        int c = 0;
        int c1 = 0;
-       //unsigned long before;
-       //unsigned long after;
 
        ISR_PDEBUG("me4000_ao_isr() is executed\n");
 
@@ -5506,7 +5505,6 @@ static irqreturn_t me4000_ao_isr(int irq, void *dev_id)
                            ("me4000_ao_isr():Work done or buffer empty\n");
                        break;
                }
-               //rdtscl(before);
                if (((ao_context->fifo_reg & 0xFF) == ME4000_AO_01_FIFO_REG) ||
                    ((ao_context->fifo_reg & 0xFF) == ME4000_AO_03_FIFO_REG)) {
                        for (i = 0; i < c1; i++) {
@@ -5522,8 +5520,6 @@ static irqreturn_t me4000_ao_isr(int irq, void *dev_id)
                              ao_context->circ_buf.buf +
                              ao_context->circ_buf.tail, c1);
 
-               //rdtscl(after);
-               //printk(KERN_ERR"ME4000:me4000_ao_isr():Time lapse = %lu\n", after - before);
 
                ao_context->circ_buf.tail =
                    (ao_context->circ_buf.tail + c1) & (ME4000_AO_BUFFER_COUNT -
@@ -5555,8 +5551,10 @@ static irqreturn_t me4000_ao_isr(int irq, void *dev_id)
        /* If state machine is stopped, flow was interrupted */
        if (!(me4000_inl(ao_context->status_reg) & ME4000_AO_STATUS_BIT_FSM)) {
                printk(KERN_ERR "ME4000:me4000_ao_isr():Broken pipe\n");
-               ao_context->pipe_flag = 1;      // Set flag in order to inform write routine
-               tmp &= ~ME4000_AO_CTRL_BIT_ENABLE_IRQ;  // Disable interrupt
+               /* Set flag in order to inform write routine */
+               ao_context->pipe_flag = 1;
+               /* Disable interrupt */
+               tmp &= ~ME4000_AO_CTRL_BIT_ENABLE_IRQ;
        }
        me4000_outl(tmp, ao_context->ctrl_reg);
        spin_unlock(&ao_context->int_lock);
@@ -5955,7 +5953,6 @@ static irqreturn_t me4000_ext_int_isr(int irq, void *dev_id)
 
 static void __exit me4000_module_exit(void)
 {
-       struct list_head *board_p;
        struct me4000_info *board_info;
 
        CALL_PDEBUG("cleanup_module() is executed\n");
@@ -5975,9 +5972,7 @@ static void __exit me4000_module_exit(void)
        pci_unregister_driver(&me4000_driver);
 
        /* Reset the boards */
-       for (board_p = me4000_board_info_list.next;
-            board_p != &me4000_board_info_list; board_p = board_p->next) {
-               board_info = list_entry(board_p, struct me4000_info, list);
+       list_for_each_entry(board_info, &me4000_board_info_list, list) {
                me4000_reset_board(board_info);
        }
 
@@ -5992,7 +5987,6 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count,
        int len = 0;
        int limit = count - 1000;
        struct me4000_info *board_info;
-       struct list_head *ptr;
 
        len += sprintf(buf + len, "\nME4000 DRIVER VERSION %X.%X.%X\n\n",
                       (ME4000_DRIVER_VERSION & 0xFF0000) >> 16,
@@ -6000,11 +5994,7 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count,
                       (ME4000_DRIVER_VERSION & 0xFF));
 
        /* Search for the board context */
-       for (ptr = me4000_board_info_list.next;
-            (ptr != &me4000_board_info_list) && (len < limit);
-            ptr = ptr->next) {
-               board_info = list_entry(ptr, struct me4000_info, list);
-
+       list_for_each_entry(board_info, &me4000_board_info_list, list) {
                len +=
                    sprintf(buf + len, "Board number %d:\n",
                            board_info->board_count);
@@ -6110,6 +6100,8 @@ static int me4000_read_procmem(char *buf, char **start, off_t offset, int count,
                    sprintf(buf + len, "AO 3 status register = 0x%08X\n",
                            inl(board_info->me4000_regbase +
                                ME4000_AO_03_STATUS_REG));
+               if (len >= limit)
+                       break;
        }
 
        *eof = 1;