All of lore.kernel.org
 help / color / mirror / Atom feed
* Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c
@ 2010-03-28 15:26 Olimpiu Pascariu
  2010-03-29  3:23 ` Simon Horman
  0 siblings, 1 reply; 17+ messages in thread
From: Olimpiu Pascariu @ 2010-03-28 15:26 UTC (permalink / raw)
  To: gregkh, horms, hsweeten, ss; +Cc: devel, linux-kernel

>From cebbf20baee8df57b879a2b6dd1b9a04afe3e5e8 Mon Sep 17 00:00:00 2001
From: Olimpiu Pascariu <olimpiu.pascariu@gmail.com>
Date: Sun, 28 Mar 2010 18:22:06 +0300
Subject: [PATCH 7/7] Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c
 This is a patch to the dt3155_drv.c file that fixes up errors and warnings found by the checkpatch.pl tool
 Signed-off-by: Olimpiu Pascariu <olimpiu.pascariu@gmail.com>

---
 drivers/staging/dt3155/dt3155_drv.c | 1220 +++++++++++++++++------------------
 1 files changed, 583 insertions(+), 637 deletions(-)

diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index a67c622..6adbeb2 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -1,59 +1,57 @@
 /*
-
-Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
-                         Jason Lapenta, Scott Smedley, Greg Sharp
-
-This file is part of the DT3155 Device Driver.
-
-The DT3155 Device Driver is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The DT3155 Device Driver is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the DT3155 Device Driver; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA
-
--- Changes --
-
-  Date     Programmer	Description of changes made
-  -------------------------------------------------------------------
-  03-Jul-2000 JML       n/a
-  10-Oct-2001 SS        port to 2.4 kernel
-  02-Apr-2002 SS        Mods to use allocator as a standalone module;
-                        Merged John Roll's changes (john@cfa.harvard.edu)
-                        to make work with multiple boards.
-  02-Jul-2002 SS        Merged James Rose's chages (rosejr@purdue.edu) to:
-                         * fix successive interrupt-driven captures
-                         * add select/poll support.
-  10-Jul-2002 GCS       Add error check when ndevices > MAXBOARDS.
-  02-Aug-2002 GCS       Fix field mode so that odd (lower) field is stored
-                        in lower half of buffer.
-  05-Aug-2005 SS        port to 2.6 kernel.
-  26-Oct-2009 SS	port to 2.6.30 kernel.
-
--- Notes --
-
-** appended "mem=124" in lilo.conf to allow for 4megs free on my 128meg system.
+ *
+ * Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
+ *                          Jason Lapenta, Scott Smedley, Greg Sharp
+ *
+ * This file is part of the DT3155 Device Driver.
+ *
+ * The DT3155 Device Driver is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The DT3155 Device Driver is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the DT3155 Device Driver; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * -- Changes --
+ *
+ * Date     Programmer	Description of changes made
+ * -------------------------------------------------------------------
+ * 03-Jul-2000 JML       n/a
+ * 10-Oct-2001 SS        port to 2.4 kernel
+ * 02-Apr-2002 SS        Mods to use allocator as a standalone module;
+ *                       Merged John Roll's changes (john@cfa.harvard.edu)
+ *                       to make work with multiple boards.
+ * 02-Jul-2002 SS        Merged James Rose's chages (rosejr@purdue.edu) to:
+ *                        * fix successive interrupt-driven captures
+ *                        * add select/poll support.
+ * 10-Jul-2002 GCS       Add error check when ndevices > MAXBOARDS.
+ * 02-Aug-2002 GCS       Fix field mode so that odd (lower) field is stored
+ *                       in lower half of buffer.
+ * 05-Aug-2005 SS        port to 2.6 kernel.
+ * 26-Oct-2009 SS	port to 2.6.30 kernel.
+ *
+ * -- Notes --
+ *
+ * appended "mem=124" in lilo.conf to allow for 4megs free on my 128meg system.
  * using allocator.c and allocator.h from o'reilly book (alessandro rubini)
-    ftp://ftp.systemy.it/pub/develop (see README.allocator)
-
- + might want to get rid of MAXboards for allocating initial buffer.
-    confusing and not necessary
-
- + in cleanup_module the MOD_IN_USE looks like it is check after it should
-
+ * ftp://ftp.systemy.it/pub/develop (see README.allocator)
+ *
+ * + might want to get rid of MAXboards for allocating initial buffer.
+ * confusing and not necessary
+ * + in cleanup_module the MOD_IN_USE looks like it is check after it should
+ *
  * GFP_DMA should not be set with a PCI system (pg 291)
-
- - NJC why are only two buffers allowed? (see isr, approx line 358)
-
-*/
+ *
+ * - NJC why are only two buffers allowed? (see isr, approx line 358)
+ */
 
 extern void printques(int);
 
@@ -75,8 +73,8 @@ MODULE_LICENSE("GPL");
 #include <linux/poll.h>
 #include <linux/sched.h>
 
-#include <asm/io.h>
-#include <asm/uaccess.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
 
 #include "dt3155.h"
 #include "dt3155_drv.h"
@@ -96,19 +94,20 @@ int dt3155_errno = 0;
 #define MAXPCI    16
 
 #ifdef DT_DEBUG
-#define DT_3155_DEBUG_MSG(x,y) printk(x,y)
+#define DT_3155_DEBUG_MSG(x, y) printk(x, y)
 #else
-#define DT_3155_DEBUG_MSG(x,y)
+#define DT_3155_DEBUG_MSG(x, y)
 #endif
 
 /* wait queue for interrupts */
-wait_queue_head_t dt3155_read_wait_queue[ MAXBOARDS ];
+wait_queue_head_t dt3155_read_wait_queue[MAXBOARDS];
 
 #define DT_3155_SUCCESS 0
 #define DT_3155_FAILURE -EIO
 
-/* set to dynamicaly allocate, but it is tunable: */
-/* insmod DT_3155 dt3155 dt3155_major=XX */
+/* set to dynamicaly allocate, but it is tunable:
+ * insmod DT_3155 dt3155 dt3155_major=XX
+ */
 int dt3155_major = 0;
 
 /* The minor numbers are 0 and 1 ... they are not tunable.
@@ -119,18 +118,21 @@ int dt3155_major = 0;
 /* Global structures and variables */
 
 /* Status of each device */
-struct dt3155_status_s dt3155_status[ MAXBOARDS ];
+struct dt3155_status_s dt3155_status[MAXBOARDS];
 
 /* kernel logical address of the board */
-u8 *dt3155_lbase[ MAXBOARDS ] = { NULL
+u8 *dt3155_lbase[MAXBOARDS] = { NULL
 #if MAXBOARDS == 2
 				      , NULL
 #endif
 };
-/* DT3155 registers              */
-u8 *dt3155_bbase = NULL;		  /* kernel logical address of the *
-					   * buffer region                 */
-u32  dt3155_dev_open[ MAXBOARDS ] = {0
+/* DT3155 registers
+ * kernel logical address of the
+ * buffer region
+ */
+u8 *dt3155_bbase = NULL;
+
+u32  dt3155_dev_open[MAXBOARDS] = {0
 #if MAXBOARDS == 2
 				       , 0
 #endif
@@ -145,21 +147,21 @@ u32 unique_tag = 0;;
  * to idle.  I don't know why this works and the other way doesn't.
  * (James Rose)
  */
-static void quick_stop (int minor)
+static void quick_stop(int minor)
 {
-  // TODO: scott was here
+  /* TODO: scott was here */
 #if 1
-  ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
+  ReadMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
   /* disable interrupts */
   int_csr_r.fld.FLD_END_EVE_EN = 0;
   int_csr_r.fld.FLD_END_ODD_EN = 0;
-  WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+  WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
 
-  dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff);
+  dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff);
   /* mark the system stopped: */
-  dt3155_status[ minor ].state |= DT3155_STATE_IDLE;
-  dt3155_fbuffer[ minor ]->stop_acquire = 0;
-  dt3155_fbuffer[ minor ]->even_stopped = 0;
+  dt3155_status[minor].state |= DT3155_STATE_IDLE;
+  dt3155_fbuffer[minor]->stop_acquire = 0;
+  dt3155_fbuffer[minor]->even_stopped = 0;
 #else
   dt3155_status[minor].state |= DT3155_STATE_STOP;
   dt3155_status[minor].fbuffer.stop_acquire = 1;
@@ -168,14 +170,14 @@ static void quick_stop (int minor)
 }
 
 
-/*****************************************************
- *  dt3155_isr() Interrupt service routien
+/*
+ * dt3155_isr() Interrupt service routien
  *
  * - looks like this isr supports IRQ sharing (or could) JML
  * - Assumes irq's are disabled, via SA_INTERRUPT flag
  * being set in request_irq() call from init_module()
- *****************************************************/
-static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs )
+ */
+static inline void dt3155_isr(int irq, void *dev_id, struct pt_regs *regs)
 {
   int    minor = -1;
   int    index;
@@ -183,298 +185,273 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs )
   u32 buffer_addr;
 
   /* find out who issued the interrupt */
-  for ( index = 0; index < ndevices; index++ ) {
-    if( dev_id == (void*) &dt3155_status[ index ])
-      {
-	minor = index;
-	break;
-      }
+  for (index = 0; index < ndevices; index++) {
+	if (dev_id == (void *) &dt3155_status[index]) {
+		minor = index;
+		break;
+	}
   }
 
   /* hopefully we should not get here */
-  if ( minor < 0 || minor >= MAXBOARDS ) {
-    printk(KERN_ERR "dt3155_isr called with invalid dev_id\n");
-    return;
+  if (minor < 0 || minor >= MAXBOARDS) {
+	printk(KERN_ERR "dt3155_isr called with invalid dev_id\n");
+	return;
   }
 
   /* Check for corruption and set a flag if so */
-  ReadMReg( (dt3155_lbase[ minor ] + CSR1), csr1_r.reg );
-
-  if ( (csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD) )
-    {
-      /* TODO: this should probably stop acquisition */
-      /* and set some flags so that dt3155_read      */
-      /* returns an error next time it is called     */
-      dt3155_errno = DT_ERR_CORRUPT;
-      printk("dt3155:  corrupt field\n");
-      return;
-    }
+  ReadMReg((dt3155_lbase[minor] + CSR1), csr1_r.reg);
+
+  if ((csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD)) {
+	/* TODO: this should probably stop acquisition
+	* and set some flags so that dt3155_read
+	* returns an error next time it is called
+	*/
+	dt3155_errno = DT_ERR_CORRUPT;
+	printk("dt3155:  corrupt field\n");
+	return;
+  }
 
-  ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
+  ReadMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
 
   /* Handle the even field ... */
-  if (int_csr_r.fld.FLD_END_EVE)
-    {
-      if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	   DT3155_STATE_FLD )
-	{
-	  dt3155_fbuffer[ minor ]->frame_count++;
+  if (int_csr_r.fld.FLD_END_EVE) {
+	if ((dt3155_status[minor].state & DT3155_STATE_MODE) ==
+	     DT3155_STATE_FLD)
+		dt3155_fbuffer[minor]->frame_count++;
+
+	ReadI2C(dt3155_lbase[minor], EVEN_CSR, &i2c_even_csr.reg);
+
+	/* Clear the interrupt? */
+	int_csr_r.fld.FLD_END_EVE = 1;
+
+	/* disable the interrupt if last field */
+	if (dt3155_fbuffer[minor]->stop_acquire) {
+		printk("dt3155:  even stopped.\n");
+		dt3155_fbuffer[minor]->even_stopped = 1;
+		if (i2c_even_csr.fld.SNGL_EVE)
+			int_csr_r.fld.FLD_END_EVE_EN = 0;
+		else
+			i2c_even_csr.fld.SNGL_EVE  = 1;
 	}
 
-      ReadI2C(dt3155_lbase[ minor ], EVEN_CSR, &i2c_even_csr.reg);
-
-      /* Clear the interrupt? */
-      int_csr_r.fld.FLD_END_EVE = 1;
-
-      /* disable the interrupt if last field */
-      if (dt3155_fbuffer[ minor ]->stop_acquire)
-	{
-	  printk("dt3155:  even stopped.\n");
-	  dt3155_fbuffer[ minor ]->even_stopped = 1;
-	  if (i2c_even_csr.fld.SNGL_EVE)
-	    {
-	      int_csr_r.fld.FLD_END_EVE_EN = 0;
-	    }
-	  else
-	    {
-	      i2c_even_csr.fld.SNGL_EVE  = 1;
-	    }
-	}
-
-      WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
-
-      /* Set up next DMA if we are doing FIELDS */
-      if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE ) ==
-	   DT3155_STATE_FLD)
-	{
-	  /* GCS (Aug 2, 2002) -- In field mode, dma the odd field
-	     into the lower half of the buffer */
-	  const u32 stride =  dt3155_status[ minor ].config.cols;
-	  buffer_addr = dt3155_fbuffer[ minor ]->
-	    frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr
-	    + (DT3155_MAX_ROWS / 2) * stride;
-	  local_save_flags(flags);
-	  local_irq_disable();
-	  wake_up_interruptible( &dt3155_read_wait_queue[ minor ] );
-
-	  /* Set up the DMA address for the next field */
-	  local_irq_restore(flags);
-	  WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr);
+	WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+	/* Set up next DMA if we are doing FIELDS */
+	if ((dt3155_status[minor].state & DT3155_STATE_MODE) ==
+	     DT3155_STATE_FLD) {
+		/* GCS (Aug 2, 2002) -- In field mode, dma the odd field
+		 * into the lower half of the buffer
+		 */
+		const u32 stride =  dt3155_status[minor].config.cols;
+		buffer_addr = dt3155_fbuffer[minor]->
+		  frame_info[dt3155_fbuffer[minor]->active_buf].addr
+		  + (DT3155_MAX_ROWS / 2) * stride;
+		local_save_flags(flags);
+		local_irq_disable();
+		wake_up_interruptible(&dt3155_read_wait_queue[minor]);
+
+		/* Set up the DMA address for the next field */
+		local_irq_restore(flags);
+		WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), buffer_addr);
 	}
 
-      /* Check for errors. */
-      i2c_even_csr.fld.DONE_EVE = 1;
-      if ( i2c_even_csr.fld.ERROR_EVE )
-	dt3155_errno = DT_ERR_OVERRUN;
-
-      WriteI2C( dt3155_lbase[ minor ], EVEN_CSR, i2c_even_csr.reg );
-
-      /* Note that we actually saw an even field meaning  */
-      /* that subsequent odd field complete the frame     */
-      dt3155_fbuffer[ minor ]->even_happened = 1;
-
-      /* recording the time that the even field finished, this should be */
-      /* about time in the middle of the frame */
-      do_gettimeofday( &(dt3155_fbuffer[ minor ]->
-			 frame_info[ dt3155_fbuffer[ minor ]->
-				     active_buf ].time) );
-      return;
-    }
+	/* Check for errors. */
+	i2c_even_csr.fld.DONE_EVE = 1;
+	if (i2c_even_csr.fld.ERROR_EVE)
+		dt3155_errno = DT_ERR_OVERRUN;
+
+	WriteI2C(dt3155_lbase[minor], EVEN_CSR, i2c_even_csr.reg);
+
+	/* Note that we actually saw an even field meaning
+	 * that subsequent odd field complete the frame
+	 */
+	dt3155_fbuffer[minor]->even_happened = 1;
+
+	/* recording the time that the even field finished, this should be
+	 * about time in the middle of the frame
+	 */
+	do_gettimeofday(&(dt3155_fbuffer[minor]->
+			  frame_info[dt3155_fbuffer[minor]->
+				     active_buf].time));
+	return;
+  }
 
   /* ... now handle the odd field */
-  if ( int_csr_r.fld.FLD_END_ODD )
-    {
-      ReadI2C( dt3155_lbase[ minor ], ODD_CSR, &i2c_odd_csr.reg );
-
-      /* Clear the interrupt? */
-      int_csr_r.fld.FLD_END_ODD = 1;
-
-      if (dt3155_fbuffer[ minor ]->even_happened ||
-	  (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	  DT3155_STATE_FLD)
-	{
-	  dt3155_fbuffer[ minor ]->frame_count++;
-	}
-
-      if ( dt3155_fbuffer[ minor ]->stop_acquire &&
-	   dt3155_fbuffer[ minor ]->even_stopped )
-	{
-	  printk(KERN_DEBUG "dt3155:  stopping odd..\n");
-	  if ( i2c_odd_csr.fld.SNGL_ODD )
-	    {
-	      /* disable interrupts */
-	      int_csr_r.fld.FLD_END_ODD_EN = 0;
-	      dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff);
-
-	      /* mark the system stopped: */
-	      dt3155_status[ minor ].state |= DT3155_STATE_IDLE;
-	      dt3155_fbuffer[ minor ]->stop_acquire = 0;
-	      dt3155_fbuffer[ minor ]->even_stopped = 0;
-
-	      printk(KERN_DEBUG "dt3155:  state is now %x\n",
-		     dt3155_status[minor].state);
-	    }
-	  else
-	    {
-	      i2c_odd_csr.fld.SNGL_ODD  = 1;
-	    }
+  if (int_csr_r.fld.FLD_END_ODD) {
+	ReadI2C(dt3155_lbase[minor], ODD_CSR, &i2c_odd_csr.reg);
+
+	/* Clear the interrupt? */
+	int_csr_r.fld.FLD_END_ODD = 1;
+
+	if (dt3155_fbuffer[minor]->even_happened ||
+	   (dt3155_status[minor].state & DT3155_STATE_MODE) ==
+	    DT3155_STATE_FLD)
+		dt3155_fbuffer[minor]->frame_count++;
+
+	if (dt3155_fbuffer[minor]->stop_acquire &&
+	    dt3155_fbuffer[minor]->even_stopped) {
+		printk(KERN_DEBUG "dt3155:  stopping odd..\n");
+		if (i2c_odd_csr.fld.SNGL_ODD) {
+			/* disable interrupts */
+			int_csr_r.fld.FLD_END_ODD_EN = 0;
+			dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff);
+
+			/* mark the system stopped: */
+			dt3155_status[minor].state |= DT3155_STATE_IDLE;
+			dt3155_fbuffer[minor]->stop_acquire = 0;
+			dt3155_fbuffer[minor]->even_stopped = 0;
+
+			printk(KERN_DEBUG "dt3155:  state is now %x\n",
+			dt3155_status[minor].state);
+		} else {
+			i2c_odd_csr.fld.SNGL_ODD  = 1;
+		}
 	}
 
-      WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+	WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
 
-      /* if the odd field has been acquired, then     */
-      /* change the next dma location for both fields */
-      /* and wake up the process if sleeping          */
-      if ( dt3155_fbuffer[ minor ]->even_happened ||
-	   (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	   DT3155_STATE_FLD )
-	{
+	/* if the odd field has been acquired, then
+	 * change the next dma location for both fields
+	 * and wake up the process if sleeping
+	 */
+	if (dt3155_fbuffer[minor]->even_happened ||
+	   (dt3155_status[minor].state & DT3155_STATE_MODE) ==
+	    DT3155_STATE_FLD) {
 
-	  local_save_flags(flags);
-	  local_irq_disable();
+		local_save_flags(flags);
+		local_irq_disable();
 
 #ifdef DEBUG_QUES_B
-	  printques( minor );
+		printques(minor);
 #endif
-	  if ( dt3155_fbuffer[ minor ]->nbuffers > 2 )
-	    {
-	      if ( !are_empty_buffers( minor ) )
-		{
-		  /* The number of active + locked buffers is
-		   * at most 2, and since there are none empty, there
-		   * must be at least nbuffers-2 ready buffers.
-		   * This is where we 'drop frames', oldest first. */
-		  push_empty( pop_ready( minor ),  minor );
-		}
-
-	      /* The ready_que can't be full, since we know
-	       * there is one active buffer right now, so it's safe
-	       * to push the active buf on the ready_que. */
-	      push_ready( minor, dt3155_fbuffer[ minor ]->active_buf );
-	      /* There's at least 1 empty -- make it active */
-	      dt3155_fbuffer[ minor ]->active_buf = pop_empty( minor );
-	      dt3155_fbuffer[ minor ]->
-		frame_info[ dt3155_fbuffer[ minor ]->
-			    active_buf ].tag = ++unique_tag;
-	    }
-	  else /* nbuffers == 2, special case */
-	    { /* There is 1 active buffer.
-	       * If there is a locked buffer, keep the active buffer
-	       * the same -- that means we drop a frame.
-	       */
-	      if ( dt3155_fbuffer[ minor ]->locked_buf < 0 )
-		{
-		  push_ready( minor,
-			      dt3155_fbuffer[ minor ]->active_buf );
-		  if (are_empty_buffers( minor ) )
-		    {
-		      dt3155_fbuffer[ minor ]->active_buf =
-			pop_empty( minor );
-		    }
-		  else
-		    { /* no empty or locked buffers, so use a readybuf */
-		      dt3155_fbuffer[ minor ]->active_buf =
-			pop_ready( minor );
-		    }
+		if (dt3155_fbuffer[minor]->nbuffers > 2) {
+			if (!are_empty_buffers(minor))
+				/* The number of active + locked buffers is
+				 * at most 2, and since there are none empty,
+				 * there must be at least nbuffers-2 ready
+				 * buffers. This is where we 'drop frames',
+				 * oldest first.
+				 */
+				push_empty(pop_ready(minor), minor);
+
+			/* The ready_que can't be full, since we know
+			 * there is one active buffer right now, so it's safe
+			 * to push the active buf on the ready_que.
+			 */
+			push_ready(minor, dt3155_fbuffer[minor]->active_buf);
+			/* There's at least 1 empty -- make it active */
+			dt3155_fbuffer[minor]->active_buf = pop_empty(minor);
+			dt3155_fbuffer[minor]->
+			  frame_info[dt3155_fbuffer[minor]->
+				     active_buf].tag = ++unique_tag;
+		} else {
+			/* nbuffers == 2, special case
+			 * There is 1 active buffer.
+			 * If there is a locked buffer, keep the active buffer
+			 * the same -- that means we drop a frame.
+			 */
+			if (dt3155_fbuffer[minor]->locked_buf < 0) {
+				push_ready(minor,
+					   dt3155_fbuffer[minor]->active_buf);
+			if (are_empty_buffers(minor))
+				dt3155_fbuffer[minor]->active_buf =
+				  pop_empty(minor);
+			else
+				/* no empty or locked buffers, so use a
+				 * readybuf
+				 */
+				dt3155_fbuffer[minor]->active_buf =
+				  pop_ready(minor);
+			}
 		}
-	    }
 
 #ifdef DEBUG_QUES_B
-	  printques( minor );
+		printques(minor);
 #endif
 
-	  dt3155_fbuffer[ minor ]->even_happened = 0;
+		dt3155_fbuffer[minor]->even_happened = 0;
 
-	  wake_up_interruptible( &dt3155_read_wait_queue[ minor ] );
+		wake_up_interruptible(&dt3155_read_wait_queue[minor]);
 
-	  local_irq_restore(flags);
+		local_irq_restore(flags);
 	}
 
-
-      /* Set up the DMA address for the next frame/field */
-      buffer_addr = dt3155_fbuffer[ minor ]->
-	frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr;
-      if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	   DT3155_STATE_FLD )
-	{
-	  WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr);
+	/* Set up the DMA address for the next frame/field */
+	buffer_addr = dt3155_fbuffer[minor]->
+	  frame_info[dt3155_fbuffer[minor]->active_buf].addr;
+	if ((dt3155_status[minor].state & DT3155_STATE_MODE) ==
+	     DT3155_STATE_FLD) {
+		WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), buffer_addr);
+	} else {
+		WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), buffer_addr);
+		WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), buffer_addr
+			  + dt3155_status[minor].config.cols);
 	}
-      else
-	{
-	  WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr);
 
-	  WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr
-		    + dt3155_status[ minor ].config.cols);
-	}
+	/* Do error checking */
+	i2c_odd_csr.fld.DONE_ODD = 1;
+	if (i2c_odd_csr.fld.ERROR_ODD)
+		dt3155_errno = DT_ERR_OVERRUN;
 
-      /* Do error checking */
-      i2c_odd_csr.fld.DONE_ODD = 1;
-      if ( i2c_odd_csr.fld.ERROR_ODD )
-	dt3155_errno = DT_ERR_OVERRUN;
+	WriteI2C(dt3155_lbase[minor], ODD_CSR, i2c_odd_csr.reg);
 
-      WriteI2C(dt3155_lbase[ minor ], ODD_CSR, i2c_odd_csr.reg );
-
-      return;
-    }
+	return;
+  }
   /* If we get here, the Odd Field wasn't it either... */
-  printk( "neither even nor odd.  shared perhaps?\n");
+  printk("neither even nor odd.  shared perhaps?\n");
 }
 
-/*****************************************************
+/*
  * init_isr(int minor)
  *   turns on interupt generation for the card
  *   designated by "minor".
  *   It is called *only* from inside ioctl().
- *****************************************************/
+ */
 static void dt3155_init_isr(int minor)
 {
-  const u32 stride =  dt3155_status[ minor ].config.cols;
-
-  switch (dt3155_status[ minor ].state & DT3155_STATE_MODE)
-    {
-    case DT3155_STATE_FLD:
-      {
-	even_dma_start_r  = dt3155_status[ minor ].
-	  fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr;
+  const u32 stride =  dt3155_status[minor].config.cols;
+
+  switch (dt3155_status[minor].state & DT3155_STATE_MODE) {
+  case DT3155_STATE_FLD:
+	even_dma_start_r  = dt3155_status[minor].
+	  fbuffer.frame_info[dt3155_status[minor].fbuffer.active_buf].addr;
 	even_dma_stride_r = 0;
 	odd_dma_stride_r  = 0;
 
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START),
+	WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START),
 		  even_dma_start_r);
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE),
+	WriteMReg((dt3155_lbase[minor] + EVEN_DMA_STRIDE),
 		  even_dma_stride_r);
-	WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE),
+	WriteMReg((dt3155_lbase[minor] + ODD_DMA_STRIDE),
 		  odd_dma_stride_r);
 	break;
-      }
 
-    case DT3155_STATE_FRAME:
-    default:
-      {
-	even_dma_start_r  = dt3155_status[ minor ].
-	  fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr;
+  case DT3155_STATE_FRAME:
+  default:
+	even_dma_start_r  = dt3155_status[minor].
+	  fbuffer.frame_info[dt3155_status[minor].fbuffer.active_buf].addr;
 	odd_dma_start_r   =  even_dma_start_r + stride;
 	even_dma_stride_r =  stride;
 	odd_dma_stride_r  =  stride;
 
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START),
+	WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START),
 		  even_dma_start_r);
-	WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START),
+	WriteMReg((dt3155_lbase[minor] + ODD_DMA_START),
 		  odd_dma_start_r);
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE),
+	WriteMReg((dt3155_lbase[minor] + EVEN_DMA_STRIDE),
 		  even_dma_stride_r);
-	WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE),
+	WriteMReg((dt3155_lbase[minor] + ODD_DMA_STRIDE),
 		  odd_dma_stride_r);
 	break;
-      }
-    }
+  }
 
-  /* 50/60 Hz should be set before this point but let's make sure it is */
-  /* right anyway */
+  /* 50/60 Hz should be set before this point but let's make sure it is
+   * right anyway
+   */
 
-  ReadI2C(dt3155_lbase[ minor ], CONFIG, &i2c_csr2.reg);
+  ReadI2C(dt3155_lbase[minor], CONFIG, &i2c_csr2.reg);
   i2c_csr2.fld.HZ50 = FORMAT50HZ;
-  WriteI2C(dt3155_lbase[ minor ], CONFIG, i2c_config.reg);
+  WriteI2C(dt3155_lbase[minor], CONFIG, i2c_config.reg);
 
   /* enable busmaster chip, clear flags */
 
@@ -494,7 +471,7 @@ static void dt3155_init_isr(int minor)
   csr1_r.fld.FLD_CRPT_EVE   = 1; /* writing a 1 clears flags */
   csr1_r.fld.FLD_CRPT_ODD   = 1;
 
-  WriteMReg((dt3155_lbase[ minor ] + CSR1),csr1_r.reg);
+  WriteMReg((dt3155_lbase[minor] + CSR1), csr1_r.reg);
 
   /* Enable interrupts at the end of each field */
 
@@ -503,14 +480,14 @@ static void dt3155_init_isr(int minor)
   int_csr_r.fld.FLD_END_ODD_EN = 1;
   int_csr_r.fld.FLD_START_EN = 0;
 
-  WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
+  WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
 
   /* start internal BUSY bits */
 
-  ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg);
+  ReadI2C(dt3155_lbase[minor], CSR2, &i2c_csr2.reg);
   i2c_csr2.fld.BUSY_ODD  = 1;
   i2c_csr2.fld.BUSY_EVE  = 1;
-  WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg);
+  WriteI2C(dt3155_lbase[minor], CSR2, i2c_csr2.reg);
 
   /* Now its up to the interrupt routine!! */
 
@@ -518,10 +495,10 @@ static void dt3155_init_isr(int minor)
 }
 
 
-/*****************************************************
+/*
  * ioctl()
  *
- *****************************************************/
+ */
 static int dt3155_ioctl(struct inode *inode,
 			struct file *file,
 			unsigned int cmd,
@@ -529,33 +506,30 @@ static int dt3155_ioctl(struct inode *inode,
 {
   int minor = MINOR(inode->i_rdev); /* What device are we ioctl()'ing? */
 
-  if ( minor >= MAXBOARDS || minor < 0 )
-    return -ENODEV;
+  if (minor >= MAXBOARDS || minor < 0)
+	return -ENODEV;
 
   /* make sure it is valid command */
-  if (_IOC_NR(cmd) > DT3155_IOC_MAXNR)
-    {
-      printk("DT3155: invalid IOCTL(0x%x)\n",cmd);
-      printk("DT3155: Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
-	     (unsigned int)DT3155_GET_CONFIG,
-	     (unsigned int)DT3155_SET_CONFIG,
-	     (unsigned int)DT3155_START,
-	     (unsigned int)DT3155_STOP,
-	     (unsigned int)DT3155_FLUSH);
-      return -EINVAL;
-    }
-
-  switch (cmd)
-    {
-    case DT3155_SET_CONFIG:
-      {
+  if (_IOC_NR(cmd) > DT3155_IOC_MAXNR) {
+	printk("DT3155: invalid IOCTL(0x%x)\n", cmd);
+	printk("DT3155: Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
+		(unsigned int)DT3155_GET_CONFIG,
+		(unsigned int)DT3155_SET_CONFIG,
+		(unsigned int)DT3155_START,
+		(unsigned int)DT3155_STOP,
+		(unsigned int)DT3155_FLUSH);
+	return -EINVAL;
+  }
+
+  switch (cmd) {
+  case DT3155_SET_CONFIG:
 	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
-	  return -EBUSY;
+		return -EBUSY;
 
 	{
 	  struct dt3155_config_s tmp;
 	  if (copy_from_user((void *)&tmp, (void *) arg, sizeof(tmp)))
-	      return -EFAULT;
+		return -EFAULT;
 	  /* check for valid settings */
 	  if (tmp.rows > DT3155_MAX_ROWS ||
 	      tmp.cols > DT3155_MAX_COLS ||
@@ -563,79 +537,62 @@ static int dt3155_ioctl(struct inode *inode,
 	       tmp.acq_mode != DT3155_MODE_FIELD) ||
 	      (tmp.continuous != DT3155_SNAP &&
 	       tmp.continuous != DT3155_ACQ))
-	    {
-	      return -EINVAL;
-	    }
+		return -EINVAL;
 	  dt3155_status[minor].config = tmp;
 	}
 	return 0;
-      }
-    case DT3155_GET_CONFIG:
-      {
+  case DT3155_GET_CONFIG:
 	if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
-		     sizeof(dt3155_status_t) ))
-	    return -EFAULT;
+		     sizeof(dt3155_status_t)))
+		return -EFAULT;
 	return 0;
-      }
-    case DT3155_FLUSH: /* Flushes the buffers -- ensures fresh data */
-      {
+  case DT3155_FLUSH: /* Flushes the buffers -- ensures fresh data */
 	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
-	  return -EBUSY;
+		return -EBUSY;
 	return dt3155_flush(minor);
-      }
-    case DT3155_STOP:
-      {
+  case DT3155_STOP:
 	if (dt3155_status[minor].state & DT3155_STATE_STOP ||
 	    dt3155_status[minor].fbuffer.stop_acquire)
-	  return -EBUSY;
+		return -EBUSY;
 
 	if (dt3155_status[minor].state == DT3155_STATE_IDLE)
-	  return 0;
+		return 0;
 
 	quick_stop(minor);
 	if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
 		     sizeof(dt3155_status_t)))
-	    return -EFAULT;
+		return -EFAULT;
 	return 0;
-      }
-    case DT3155_START:
-      {
+  case DT3155_START:
 	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
-	  return -EBUSY;
+		return -EBUSY;
 
 	dt3155_status[minor].fbuffer.stop_acquire = 0;
 	dt3155_status[minor].fbuffer.frame_count = 0;
 
 	/* Set the MODE in the status -- we default to FRAME */
 	if (dt3155_status[minor].config.acq_mode == DT3155_MODE_FIELD)
-	  {
-	    dt3155_status[minor].state = DT3155_STATE_FLD;
-	  }
+		dt3155_status[minor].state = DT3155_STATE_FLD;
 	else
-	  {
-	    dt3155_status[minor].state = DT3155_STATE_FRAME;
-	  }
+		dt3155_status[minor].state = DT3155_STATE_FRAME;
 
 	dt3155_init_isr(minor);
-	if (copy_to_user( (void *) arg, (void *) &dt3155_status[minor],
+	if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
 		      sizeof(dt3155_status_t)))
-	    return -EFAULT;
+		return -EFAULT;
 	return 0;
-      }
-    default:
-      {
-	printk("DT3155: invalid IOCTL(0x%x)\n",cmd);
-      printk("DT3155: Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
-	     (unsigned int)DT3155_GET_CONFIG,
-	     (unsigned int)DT3155_SET_CONFIG,
-	     DT3155_START, DT3155_STOP, DT3155_FLUSH);
+  default:
+	printk("DT3155: invalid IOCTL(0x%x)\n", cmd);
+	printk("DT3155: Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
+	       (unsigned int)DT3155_GET_CONFIG,
+	       (unsigned int)DT3155_SET_CONFIG,
+	       DT3155_START, DT3155_STOP, DT3155_FLUSH);
 	return -ENOSYS;
-      }
-    }
+  }
   return -ENOSYS;
 }
 
-/*****************************************************
+/*
  * mmap()
  *
  * only allow the user to mmap the registers and buffer
@@ -643,8 +600,8 @@ static int dt3155_ioctl(struct inode *inode,
  * addition of of the capacity for two cards!!!!!!!!
  * It *looks* like it should work but since I'm not
  * sure how to use it, I'm not actually sure. (NJC? ditto by SS)
- *****************************************************/
-static int dt3155_mmap (struct file * file, struct vm_area_struct * vma)
+ */
+static int dt3155_mmap(struct file *file, struct vm_area_struct *vma)
 {
   /* which device are we mmapping? */
   int				minor = MINOR(file->f_dentry->d_inode->i_rdev);
@@ -652,7 +609,7 @@ static int dt3155_mmap (struct file * file, struct vm_area_struct * vma)
   offset = vma->vm_pgoff << PAGE_SHIFT;
 
   if (offset >= __pa(high_memory) || (file->f_flags & O_SYNC))
-    vma->vm_flags |= VM_IO;
+	vma->vm_flags |= VM_IO;
 
   /* Don't try to swap out physical pages.. */
   vma->vm_flags |= VM_RESERVED;
@@ -661,64 +618,60 @@ static int dt3155_mmap (struct file * file, struct vm_area_struct * vma)
   if ((offset == dt3155_status[minor].reg_addr &&
        vma->vm_end - vma->vm_start == PCI_PAGE_SIZE) ||
       (offset == dt3155_status[minor].mem_addr &&
-       vma->vm_end - vma->vm_start == dt3155_status[minor].mem_size))
-    {
-      if (remap_pfn_range(vma,
-			vma->vm_start,
-			offset >> PAGE_SHIFT,
-			vma->vm_end - vma->vm_start,
-			vma->vm_page_prot)) {
-	  printk("DT3155: remap_page_range() failed.\n");
-	  return -EAGAIN;
+       vma->vm_end - vma->vm_start == dt3155_status[minor].mem_size)) {
+	if (remap_pfn_range(vma,
+			    vma->vm_start,
+			    offset >> PAGE_SHIFT,
+			    vma->vm_end - vma->vm_start,
+			    vma->vm_page_prot)) {
+		printk("DT3155: remap_page_range() failed.\n");
+		return -EAGAIN;
 	}
-    }
-  else
-    {
-      printk("DT3155: dt3155_mmap() bad call.\n");
-      return -ENXIO;
-    }
+  } else {
+	printk("DT3155: dt3155_mmap() bad call.\n");
+	return -ENXIO;
+  }
 
   return 0;
 }
 
 
-/*****************************************************
+/*
  * open()
  *
  * Our special open code.
  * MOD_INC_USE_COUNT make sure that the driver memory is not freed
  * while the device is in use.
- *****************************************************/
-static int dt3155_open( struct inode* inode, struct file* filep)
+ */
+static int dt3155_open(struct inode *inode, struct file *filep)
 {
   int minor = MINOR(inode->i_rdev); /* what device are we opening? */
-  if (dt3155_dev_open[ minor ]) {
-    printk ("DT3155:  Already opened by another process.\n");
-    return -EBUSY;
+  if (dt3155_dev_open[minor]) {
+	printk("DT3155:  Already opened by another process.\n");
+	return -EBUSY;
   }
 
-  if (dt3155_status[ minor ].device_installed==0)
-    {
-      printk("DT3155 Open Error: No such device dt3155 minor number %d\n",
-	     minor);
-      return -EIO;
-    }
-
-  if (dt3155_status[ minor ].state != DT3155_STATE_IDLE) {
-    printk ("DT3155:  Not in idle state (state = %x)\n",
-	    dt3155_status[ minor ].state);
-    return -EBUSY;
+  if (dt3155_status[minor].device_installed == 0) {
+	printk("DT3155 Open Error: No such device dt3155 minor number %d\n",
+		minor);
+	return -EIO;
+  }
+
+  if (dt3155_status[minor].state != DT3155_STATE_IDLE) {
+	printk("DT3155:  Not in idle state (state = %x)\n",
+		dt3155_status[minor].state);
+	return -EBUSY;
   }
 
   printk("DT3155: Device opened.\n");
 
-  dt3155_dev_open[ minor ] = 1 ;
+  dt3155_dev_open[minor] = 1 ;
 
-  dt3155_flush( minor );
+  dt3155_flush(minor);
 
   /* Disable ALL interrupts */
   int_csr_r.reg = 0;
-  WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
+  WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg);
 
   init_waitqueue_head(&(dt3155_read_wait_queue[minor]));
 
@@ -726,37 +679,32 @@ static int dt3155_open( struct inode* inode, struct file* filep)
 }
 
 
-/*****************************************************
+/*
  * close()
  *
  * Now decrement the use count.
  *
- *****************************************************/
-static int dt3155_close( struct inode *inode, struct file *filep)
+ */
+static int dt3155_close(struct inode *inode, struct file *filep)
 {
   int minor;
 
   minor = MINOR(inode->i_rdev); /* which device are we closing */
-  if (!dt3155_dev_open[ minor ])
-    {
-      printk("DT3155: attempt to CLOSE a not OPEN device\n");
-    }
-  else
-    {
-      dt3155_dev_open[ minor ] = 0;
-
-      if (dt3155_status[ minor ].state != DT3155_STATE_IDLE)
-	{
-	  quick_stop(minor);
-	}
-    }
+  if (!dt3155_dev_open[minor]) {
+	printk("DT3155: attempt to CLOSE a not OPEN device\n");
+  } else {
+	dt3155_dev_open[minor] = 0;
+
+	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
+		quick_stop(minor);
+  }
   return 0;
 }
 
-/*****************************************************
+/*
  * read()
  *
- *****************************************************/
+ */
 static ssize_t dt3155_read(struct file *filep, char __user *buf,
 			   size_t count, loff_t *ppos)
 {
@@ -768,11 +716,10 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf,
 
   /* TODO: this should check the error flag and */
   /*   return an error on hardware failures */
-  if (count != sizeof(dt3155_read_t))
-    {
-      printk("DT3155 ERROR (NJC): count is not right\n");
-      return -EINVAL;
-    }
+  if (count != sizeof(dt3155_read_t)) {
+	printk("DT3155 ERROR (NJC): count is not right\n");
+	return -EINVAL;
+  }
 
 
   /* Hack here -- I'm going to allow reading even when idle.
@@ -780,39 +727,39 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf,
    * been called.  Leaving it here, commented out, as a reminder
    * for a short while to make sure there are no problems.
    * Note that if the driver is not opened in non_blocking mode,
-   * and the device is idle, then it could sit here forever! */
+   * and the device is idle, then it could sit here forever!
+   */
 
-  /*  if (dt3155_status[minor].state == DT3155_STATE_IDLE)*/
-  /*    return -EBUSY;*/
+  /*  if (dt3155_status[minor].state == DT3155_STATE_IDLE)
+   *	return -EBUSY;
+   */
 
   /* non-blocking reads should return if no data */
-  if (filep->f_flags & O_NDELAY)
-    {
-      if ((frame_index = dt3155_get_ready_buffer(minor)) < 0) {
-	/*printk( "dt3155:  no buffers available (?)\n");*/
-	/* 		printques(minor); */
-	return -EAGAIN;
-      }
-    }
-  else
-    {
-      /*
-       * sleep till data arrives , or we get interrupted.
-       * Note that wait_event_interruptible() does not actually
-       * sleep/wait if it's condition evaluates to true upon entry.
-       */
-      wait_event_interruptible(dt3155_read_wait_queue[minor],
-			       (frame_index = dt3155_get_ready_buffer(minor))
-			       >= 0);
-
-      if (frame_index < 0)
-	{
-	  printk ("DT3155: read: interrupted\n");
-	  quick_stop (minor);
-	  printques(minor);
-	  return -EINTR;
+  if (filep->f_flags & O_NDELAY) {
+	frame_index = dt3155_get_ready_buffer(minor);
+	if (frame_index < 0) {
+		/* printk( "dt3155:  no buffers available (?)\n");
+		 * printques(minor);
+		 */
+		return -EAGAIN;
 	}
-    }
+  } else {
+	/*
+	 * sleep till data arrives , or we get interrupted.
+	 * Note that wait_event_interruptible() does not actually
+	 * sleep/wait if it's condition evaluates to true upon entry.
+	 */
+	wait_event_interruptible(dt3155_read_wait_queue[minor],
+				 (frame_index = dt3155_get_ready_buffer(minor))
+				 >= 0);
+
+	if (frame_index < 0) {
+		printk("DT3155: read: interrupted\n");
+		quick_stop(minor);
+		printques(minor);
+		return -EINTR;
+	}
+  }
 
   frame_info_p = &dt3155_status[minor].fbuffer.frame_info[frame_index];
 
@@ -821,50 +768,50 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf,
 
   put_user(offset, (unsigned int *) buf);
   buf += sizeof(u32);
-  put_user( dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf);
+  put_user(dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf);
   buf += sizeof(u32);
   put_user(dt3155_status[minor].state, (unsigned int *) buf);
   buf += sizeof(u32);
   if (copy_to_user(buf, frame_info_p, sizeof(frame_info_t)))
-      return -EFAULT;
+	return -EFAULT;
 
   return sizeof(dt3155_read_t);
 }
 
-static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
+static unsigned int dt3155_poll(struct file *filp, poll_table *wait)
 {
   int minor = MINOR(filp->f_dentry->d_inode->i_rdev);
 
   if (!is_ready_buf_empty(minor))
-    return POLLIN | POLLRDNORM;
+	return POLLIN | POLLRDNORM;
 
-  poll_wait (filp, &dt3155_read_wait_queue[minor], wait);
+  poll_wait(filp, &dt3155_read_wait_queue[minor], wait);
 
   return 0;
 }
 
 
-/*****************************************************
+/*
  * file operations supported by DT3155 driver
  *  needed by init_module
  *  register_chrdev
- *****************************************************/
-static struct file_operations dt3155_fops = {
-  read:		dt3155_read,
-  ioctl:		dt3155_ioctl,
-  mmap:		dt3155_mmap,
-  poll:           dt3155_poll,
-  open:		dt3155_open,
-  release:	dt3155_close
+ */
+static const struct file_operations dt3155_fops = {
+  .read	= dt3155_read,
+  .ioctl = dt3155_ioctl,
+  .mmap = dt3155_mmap,
+  .poll = dt3155_poll,
+  .open = dt3155_open,
+  .release = dt3155_close
 };
 
 
-/*****************************************************
+/*
  * find_PCI();
  *
  * PCI has been totally reworked in 2.1..
- *****************************************************/
-static int find_PCI (void)
+ */
+static int find_PCI(void)
 {
   struct pci_dev *pci_dev = NULL;
   int error, pci_index = 0;
@@ -873,68 +820,70 @@ static int find_PCI (void)
   unsigned char irq;
 
   while ((pci_dev = pci_get_device
-	  (DT3155_VENDORID, DT3155_DEVICEID, pci_dev)) != NULL)
-    {
-      pci_index ++;
-
-      /* Is it really there? */
-      if ((error =
-	   pci_read_config_word(pci_dev, PCI_CLASS_DEVICE, &rev_device)))
-	continue;
-
-      /* Found a board */
-      DT_3155_DEBUG_MSG("DT3155: Device number %d \n", pci_index);
-
-      /* Make sure the driver was compiled with enough buffers to handle
-	 this many boards */
-      if (pci_index > MAXBOARDS) {
-	printk("DT3155: ERROR - found %d devices, but driver only configured "
-	       "for %d devices\n"
-	       "DT3155: Please change MAXBOARDS in dt3155.h\n",
-	       pci_index, MAXBOARDS);
-	goto err;
-      }
-
-      /* Now, just go out and make sure that this/these device(s) is/are
-	 actually mapped into the kernel address space */
-      if ((error = pci_read_config_dword( pci_dev, PCI_BASE_ADDRESS_0,
-					  (u32 *) &base)))
-	{
-	  printk("DT3155: Was not able to find device \n");
-	  goto err;
+	  (DT3155_VENDORID, DT3155_DEVICEID, pci_dev)) != NULL) {
+	pci_index++;
+
+	/* Is it really there? */
+	error = pci_read_config_word(pci_dev, PCI_CLASS_DEVICE, &rev_device);
+	if (error)
+		continue;
+
+	/* Found a board */
+	DT_3155_DEBUG_MSG("DT3155: Device number %d\n", pci_index);
+
+	/* Make sure the driver was compiled with enough buffers to handle
+	 * this many boards
+	 */
+	if (pci_index > MAXBOARDS) {
+		printk(KERN_DEBUG
+		  "DT3155: ERROR - found %d devices, but driver only configured"
+		  " for %d devices\n"
+		  "DT3155: Please change MAXBOARDS in dt3155.h\n",
+		  pci_index, MAXBOARDS);
+		goto err;
 	}
 
-      DT_3155_DEBUG_MSG("DT3155: Base address 0 for device is %lx \n", base);
-      dt3155_status[pci_index-1].reg_addr = base;
+	/* Now, just go out and make sure that this/these device(s) is/are
+	 * actually mapped into the kernel address space
+	 */
+	error = pci_read_config_dword(pci_dev, PCI_BASE_ADDRESS_0,
+				      (u32 *) &base);
+	if (error) {
+		printk("DT3155: Was not able to find device\n");
+		goto err;
+	}
 
-      /* Remap the base address to a logical address through which we
-       * can access it. */
-      dt3155_lbase[ pci_index - 1 ] = ioremap(base,PCI_PAGE_SIZE);
-      dt3155_status[ pci_index - 1 ].reg_addr = base;
-      DT_3155_DEBUG_MSG("DT3155: New logical address is %p \n",
-			dt3155_lbase[pci_index-1]);
-      if ( !dt3155_lbase[pci_index-1] )
-	{
-	  printk("DT3155: Unable to remap control registers\n");
-	  goto err;
+	DT_3155_DEBUG_MSG("DT3155: Base address 0 for device is %lx\n", base);
+	dt3155_status[pci_index-1].reg_addr = base;
+
+	/* Remap the base address to a logical address through which we
+	 * can access it.
+	 */
+	dt3155_lbase[pci_index - 1] = ioremap(base, PCI_PAGE_SIZE);
+	dt3155_status[pci_index - 1].reg_addr = base;
+	DT_3155_DEBUG_MSG("DT3155: New logical address is %p\n",
+			   dt3155_lbase[pci_index-1]);
+	if (!dt3155_lbase[pci_index-1]) {
+		printk("DT3155: Unable to remap control registers\n");
+		goto err;
 	}
 
-      if ( (error = pci_read_config_byte( pci_dev, PCI_INTERRUPT_LINE, &irq)) )
-	{
-	  printk("DT3155: Was not able to find device \n");
-	  goto err;
+	error = pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &irq);
+	if (error) {
+		printk("DT3155: Was not able to find device\n");
+		goto err;
 	}
 
-      DT_3155_DEBUG_MSG("DT3155: IRQ is %d \n",irq);
-      dt3155_status[ pci_index-1 ].irq = irq;
-      /* Set flag: kth device found! */
-      dt3155_status[ pci_index-1 ].device_installed = 1;
-      printk("DT3155: Installing device %d w/irq %d and address %p\n",
-	     pci_index,
-	     dt3155_status[pci_index-1].irq,
-	     dt3155_lbase[pci_index-1]);
+	DT_3155_DEBUG_MSG("DT3155: IRQ is %d\n", irq);
+	dt3155_status[pci_index-1].irq = irq;
+	/* Set flag: kth device found! */
+	dt3155_status[pci_index-1].device_installed = 1;
+	printk("DT3155: Installing device %d w/irq %d and address %p\n",
+		pci_index,
+		dt3155_status[pci_index-1].irq,
+		dt3155_lbase[pci_index-1]);
 
-    }
+  }
   ndevices = pci_index;
 
   return DT_3155_SUCCESS;
@@ -946,126 +895,125 @@ err:
 
 u32 allocatorAddr = 0;
 
-/*****************************************************
+/*
  * init_module()
- *****************************************************/
+ */
 int init_module(void)
 {
   int index;
   int rcode = 0;
-  char *devname[ MAXBOARDS ];
+  char *devname[MAXBOARDS];
 
-  devname[ 0 ] = "dt3155a";
+  devname[0] = "dt3155a";
 #if MAXBOARDS == 2
-  devname[ 1 ] = "dt3155b";
+  devname[1] = "dt3155b";
 #endif
 
   printk("DT3155: Loading module...\n");
 
   /* Register the device driver */
-  rcode = register_chrdev( dt3155_major, "dt3155", &dt3155_fops );
-  if( rcode < 0 )
-    {
-      printk( KERN_INFO "DT3155: register_chrdev failed \n");
-      return rcode;
-    }
-
-  if( dt3155_major == 0 )
-    dt3155_major = rcode; /* dynamic */
-
-
-  /* init the status variables.                     */
-  /* DMA memory is taken care of in setup_buffers() */
-  for ( index = 0; index < MAXBOARDS; index++ )
-    {
-      dt3155_status[ index ].config.acq_mode   = DT3155_MODE_FRAME;
-      dt3155_status[ index ].config.continuous = DT3155_ACQ;
-      dt3155_status[ index ].config.cols       = DT3155_MAX_COLS;
-      dt3155_status[ index ].config.rows       = DT3155_MAX_ROWS;
-      dt3155_status[ index ].state = DT3155_STATE_IDLE;
-
-      /* find_PCI() will check if devices are installed; */
-      /* first assume they're not:                       */
-      dt3155_status[ index ].mem_addr          = 0;
-      dt3155_status[ index ].mem_size          = 0;
-      dt3155_status[ index ].state             = DT3155_STATE_IDLE;
-      dt3155_status[ index ].device_installed  = 0;
-    }
+  rcode = register_chrdev(dt3155_major, "dt3155", &dt3155_fops);
+  if (rcode < 0) {
+	printk(KERN_INFO "DT3155: register_chrdev failed\n");
+	return rcode;
+  }
+
+  if (dt3155_major == 0)
+	dt3155_major = rcode; /* dynamic */
+
+
+  /* init the status variables.
+   * DMA memory is taken care of in setup_buffers()
+   */
+  for (index = 0; index < MAXBOARDS; index++) {
+	dt3155_status[index].config.acq_mode   = DT3155_MODE_FRAME;
+	dt3155_status[index].config.continuous = DT3155_ACQ;
+	dt3155_status[index].config.cols       = DT3155_MAX_COLS;
+	dt3155_status[index].config.rows       = DT3155_MAX_ROWS;
+	dt3155_status[index].state = DT3155_STATE_IDLE;
+
+	/* find_PCI() will check if devices are installed;
+	 * first assume they're not:
+	 */
+	dt3155_status[index].mem_addr          = 0;
+	dt3155_status[index].mem_size          = 0;
+	dt3155_status[index].state             = DT3155_STATE_IDLE;
+	dt3155_status[index].device_installed  = 0;
+  }
 
   /* Now let's find the hardware.  find_PCI() will set ndevices to the
-   * number of cards found in this machine. */
-    {
-      if ( (rcode = find_PCI()) !=  DT_3155_SUCCESS )
-	{
-	  printk("DT3155 error: find_PCI() failed to find dt3155 board(s)\n");
-	  unregister_chrdev( dt3155_major, "dt3155" );
-	  return rcode;
-	}
-    }
+   * number of cards found in this machine.
+   */
+      rcode = find_PCI();
+  if (rcode !=  DT_3155_SUCCESS) {
+	printk("DT3155 error: find_PCI() failed to find dt3155 board(s)\n");
+	unregister_chrdev(dt3155_major, "dt3155");
+	return rcode;
+  }
 
   /* Ok, time to setup the frame buffers */
-  if( (rcode = dt3155_setup_buffers(&allocatorAddr)) < 0 )
-    {
-      printk("DT3155: Error: setting up buffer not large enough.");
-      unregister_chrdev( dt3155_major, "dt3155" );
-      return rcode;
-    }
-
-  /* If we are this far, then there is enough RAM */
-  /* for the buffers: Print the configuration.    */
-  for(  index = 0;  index < ndevices;  index++ )
-    {
-      printk("DT3155: Device = %d; acq_mode = %d; "
-	     "continuous = %d; cols = %d; rows = %d;\n",
-	     index ,
-	     dt3155_status[ index ].config.acq_mode,
-	     dt3155_status[ index ].config.continuous,
-	     dt3155_status[ index ].config.cols,
-	     dt3155_status[ index ].config.rows);
-      printk("DT3155: m_addr = 0x%x; m_size = %ld; "
-	     "state = %d; device_installed = %d\n",
-	     dt3155_status[ index ].mem_addr,
-	     (long int)dt3155_status[ index ].mem_size,
-	     dt3155_status[ index ].state,
-	     dt3155_status[ index ].device_installed);
-    }
+  rcode = dt3155_setup_buffers(&allocatorAddr);
+  if (rcode < 0) {
+	printk("DT3155: Error: setting up buffer not large enough.");
+	unregister_chrdev(dt3155_major, "dt3155");
+	return rcode;
+ }
+
+  /* If we are this far, then there is enough RAM
+   * for the buffers: Print the configuration.
+   */
+  for (index = 0; index < ndevices; index++) {
+	printk("DT3155: Device = %d; acq_mode = %d; "
+	       "continuous = %d; cols = %d; rows = %d;\n",
+	       index ,
+	       dt3155_status[index].config.acq_mode,
+	       dt3155_status[index].config.continuous,
+	       dt3155_status[index].config.cols,
+	       dt3155_status[index].config.rows);
+	printk("DT3155: m_addr = 0x%x; m_size = %ld; "
+	       "state = %d; device_installed = %d\n",
+	       dt3155_status[index].mem_addr,
+	       (long int)dt3155_status[index].mem_size,
+	       dt3155_status[index].state,
+	       dt3155_status[index].device_installed);
+  }
 
   /* Disable ALL interrupts */
   int_csr_r.reg = 0;
-  for(  index = 0;  index < ndevices;  index++ )
-    {
-      WriteMReg( (dt3155_lbase[ index ] + INT_CSR), int_csr_r.reg );
-      if( dt3155_status[ index ].device_installed )
-	{
-	  /*
-	   * This driver *looks* like it can handle sharing interrupts,
-	   * but I can't actually test myself. I've had reports that it
-	   * DOES work so I'll enable it for now. This comment will remain
-	   * as a reminder in case any problems arise. (SS)
-	   */
-	  /* in older kernels flags are: SA_SHIRQ | SA_INTERRUPT */
-	  rcode = request_irq( dt3155_status[ index ].irq, (void *)dt3155_isr,
-			       IRQF_SHARED | IRQF_DISABLED, devname[ index ],
-			       (void*) &dt3155_status[index]);
-	  if( rcode < 0 )
-	    {
-	      printk("DT3155: minor %d request_irq failed for IRQ %d\n",
-		     index, dt3155_status[index].irq);
-	      unregister_chrdev( dt3155_major, "dt3155" );
-	      return rcode;
-	    }
+  for (index = 0; index < ndevices; index++) {
+	WriteMReg((dt3155_lbase[index] + INT_CSR), int_csr_r.reg);
+	if (dt3155_status[index].device_installed) {
+		/*
+		 * This driver *looks* like it can handle sharing interrupts,
+		 * but I can't actually test myself. I've had reports that it
+		 * DOES work so I'll enable it for now. This comment will remain
+		 * as a reminder in case any problems arise. (SS)
+		 *
+		 * in older kernels flags are: SA_SHIRQ | SA_INTERRUPT
+		 */
+		rcode = request_irq(dt3155_status[index].irq,
+				    (void *)dt3155_isr,
+				    IRQF_SHARED | IRQF_DISABLED, devname[index],
+				    (void *) &dt3155_status[index]);
+		if (rcode < 0) {
+			printk(
+			    "DT3155: minor %d request_irq failed for IRQ %d\n",
+			    index, dt3155_status[index].irq);
+			unregister_chrdev(dt3155_major, "dt3155");
+			return rcode;
+		}
 	}
-    }
+  }
 
   printk("DT3155: finished loading\n");
 
   return 0;
 }
 
-/*****************************************************
+/*
  * cleanup_module(void)
  *
- *****************************************************/
+ */
 void cleanup_module(void)
 {
   int index;
@@ -1075,21 +1023,19 @@ void cleanup_module(void)
   /* removed DMA allocated with the allocator */
 #ifdef STANDALONE_ALLOCATOR
   if (allocatorAddr != 0)
-    allocator_free_dma(allocatorAddr);
+	allocator_free_dma(allocatorAddr);
 #else
   allocator_cleanup();
 #endif
 
-  unregister_chrdev( dt3155_major, "dt3155" );
+  unregister_chrdev(dt3155_major, "dt3155");
 
-  for( index = 0; index < ndevices; index++ )
-    {
-      if( dt3155_status[ index ].device_installed == 1 )
-	{
-	  printk( "DT3155: Freeing irq %d for device %d\n",
-		  dt3155_status[ index ].irq, index );
-	  free_irq( dt3155_status[ index ].irq, (void*)&dt3155_status[index] );
+  for (index = 0; index < ndevices; index++) {
+	if (dt3155_status[index].device_installed == 1) {
+		printk("DT3155: Freeing irq %d for device %d\n",
+			dt3155_status[index].irq, index);
+		free_irq(dt3155_status[index].irq,
+			 (void *)&dt3155_status[index]);
 	}
-    }
+  }
 }
-
-- 
1.7.0




^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c
  2010-03-28 15:26 Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c Olimpiu Pascariu
@ 2010-03-29  3:23 ` Simon Horman
  2010-03-29  7:34   ` [PATCH 0/3] drivers/staging/dt3155: Large cleanups Joe Perches
  2010-03-29 17:35   ` Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c Olimpiu Pascariu
  0 siblings, 2 replies; 17+ messages in thread
From: Simon Horman @ 2010-03-29  3:23 UTC (permalink / raw)
  To: Olimpiu Pascariu; +Cc: gregkh, hsweeten, ss, devel, linux-kernel, Jason Baldus

Hi,

this patch seems to duplicate work being done by Jason Baldus.
Could you co-ordinate with him?

http://marc.info/?l=linux-kernel&m=126973249428849&w=2

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 0/3] drivers/staging/dt3155: Large cleanups
  2010-03-29  3:23 ` Simon Horman
@ 2010-03-29  7:34   ` Joe Perches
  2010-03-29  7:34     ` [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file Joe Perches
                       ` (2 more replies)
  2010-03-29 17:35   ` Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c Olimpiu Pascariu
  1 sibling, 3 replies; 17+ messages in thread
From: Joe Perches @ 2010-03-29  7:34 UTC (permalink / raw)
  To: devel
  Cc: Simon Horman, Jason Baldus, Greg KH, Scott Smedley,
	Harley Sweeten, linux-kernel

A large set of cleanups to dt3155.
Integrated separate files into a single file
Made most functions and variables static
Checkpatch cleanups

Compile tested only

Joe Perches (3):
  drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  drivers/staging/dt3155/allocator: sparse cleanups
  drivers/staging/dt3155: Remove old files

 drivers/staging/dt3155/Makefile      |    5 +-
 drivers/staging/dt3155/allocator.c   |   15 +-
 drivers/staging/dt3155/allocator.h   |    4 +-
 drivers/staging/dt3155/dt3155_drv.c  | 1095 ------------------------
 drivers/staging/dt3155/dt3155_drv.h  |   45 -
 drivers/staging/dt3155/dt3155_io.c   |  175 ----
 drivers/staging/dt3155/dt3155_io.h   |   51 --
 drivers/staging/dt3155/dt3155_isr.c  |  516 ------------
 drivers/staging/dt3155/dt3155_isr.h  |   77 --
 drivers/staging/dt3155/dt3155_main.c | 1524 ++++++++++++++++++++++++++++++++++
 10 files changed, 1535 insertions(+), 1972 deletions(-)
 delete mode 100644 drivers/staging/dt3155/dt3155_drv.c
 delete mode 100644 drivers/staging/dt3155/dt3155_drv.h
 delete mode 100644 drivers/staging/dt3155/dt3155_io.c
 delete mode 100644 drivers/staging/dt3155/dt3155_isr.c
 delete mode 100644 drivers/staging/dt3155/dt3155_isr.h
 create mode 100644 drivers/staging/dt3155/dt3155_main.c


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-03-29  7:34   ` [PATCH 0/3] drivers/staging/dt3155: Large cleanups Joe Perches
@ 2010-03-29  7:34     ` Joe Perches
  2010-04-27 23:02       ` Greg KH
  2010-03-29  7:34     ` [PATCH 2/3] drivers/staging/dt3155/allocator: sparse cleanups Joe Perches
  2010-03-29  7:34     ` [PATCH 3/3] drivers/staging/dt3155: Remove old files Joe Perches
  2 siblings, 1 reply; 17+ messages in thread
From: Joe Perches @ 2010-03-29  7:34 UTC (permalink / raw)
  To: devel
  Cc: Simon Horman, Jason Baldus, Greg KH, Scott Smedley,
	Harley Sweeten, linux-kernel

Make variables static where appropriate
Rename dt3155_<foo_with_long_names> variables to dt_<foo_tla>
to reduce code length and make more lines fit well in 80 chars
Remove now unnecessary .h files
Change indent to use tabs
Remove unused functions
Used bool more often
Checkpatch clean

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/staging/dt3155/Makefile      |    5 +-
 drivers/staging/dt3155/dt3155_io.h   |   51 --
 drivers/staging/dt3155/dt3155_main.c | 1524 ++++++++++++++++++++++++++++++++++
 3 files changed, 1525 insertions(+), 55 deletions(-)
 create mode 100644 drivers/staging/dt3155/dt3155_main.c

diff --git a/drivers/staging/dt3155/Makefile b/drivers/staging/dt3155/Makefile
index 136f21f..ae2fc08 100644
--- a/drivers/staging/dt3155/Makefile
+++ b/drivers/staging/dt3155/Makefile
@@ -1,6 +1,3 @@
 obj-$(CONFIG_DT3155)	+= dt3155.o
-dt3155-objs :=	\
-		dt3155_drv.o	\
-		dt3155_isr.o	\
-		dt3155_io.o	\
+dt3155-objs :=	dt3155_main.o	\
 		allocator.o
diff --git a/drivers/staging/dt3155/dt3155_io.h b/drivers/staging/dt3155/dt3155_io.h
index d1a2510..74dcac0 100644
--- a/drivers/staging/dt3155/dt3155_io.h
+++ b/drivers/staging/dt3155/dt3155_io.h
@@ -214,31 +214,6 @@ typedef union dma_upper_lmt_tag   {
 /*
  * Global declarations of local copies of boards' 32 bit registers
  */
-extern u32 even_dma_start_r;		/*  bit 0 should always be 0 */
-extern u32 odd_dma_start_r;		/*               ..          */
-extern u32 even_dma_stride_r;	/*  bits 0&1 should always be 0 */
-extern u32 odd_dma_stride_r;		/*               ..             */
-extern u32 even_pixel_fmt_r;
-extern u32 odd_pixel_fmt_r;
-
-extern FIFO_TRIGGER_R		fifo_trigger_r;
-extern XFER_MODE_R		xfer_mode_r;
-extern CSR1_R			csr1_r;
-extern RETRY_WAIT_CNT_R		retry_wait_cnt_r;
-extern INT_CSR_R		int_csr_r;
-
-extern u32 even_fld_mask_r;
-extern u32 odd_fld_mask_r;
-
-extern MASK_LENGTH_R		mask_length_r;
-extern FIFO_FLAG_CNT_R		fifo_flag_cnt_r;
-extern IIC_CLK_DUR_R		iic_clk_dur_r;
-extern IIC_CSR1_R		iic_csr1_r;
-extern IIC_CSR2_R		iic_csr2_r;
-extern DMA_UPPER_LMT_R		even_dma_upper_lmt_r;
-extern DMA_UPPER_LMT_R		odd_dma_upper_lmt_r;
-
-
 
 /***************** 8 bit I2C register globals  ***********/
 #define CSR2		0x010	/* indices of 8-bit I2C mapped reg's*/
@@ -329,30 +304,4 @@ typedef union i2c_ad_cmd_tag {
 	} bt252_iout1;
 } I2C_AD_CMD;
 
-
-/***** Global declarations of local copies of boards' 8 bit I2C registers ***/
-
-extern I2C_CSR2			i2c_csr2;
-extern I2C_EVEN_CSR		i2c_even_csr;
-extern I2C_ODD_CSR		i2c_odd_csr;
-extern I2C_CONFIG		i2c_config;
-extern u8			i2c_dt_id;
-extern u8			i2c_x_clip_start;
-extern u8			i2c_y_clip_start;
-extern u8			i2c_x_clip_end;
-extern u8			i2c_y_clip_end;
-extern u8			i2c_ad_addr;
-extern u8			i2c_ad_lut;
-extern I2C_AD_CMD		i2c_ad_cmd;
-extern u8			i2c_dig_out;
-extern u8			i2c_pm_lut_addr;
-extern u8			i2c_pm_lut_data;
-
-/* Functions for Global use */
-
-/* access 8-bit IIC registers */
-
-extern int ReadI2C(u8 *lpReg, u_short wIregIndex, u8 *byVal);
-extern int WriteI2C(u8 *lpReg, u_short wIregIndex, u8 byVal);
-
 #endif
diff --git a/drivers/staging/dt3155/dt3155_main.c b/drivers/staging/dt3155/dt3155_main.c
new file mode 100644
index 0000000..adfd3a7
--- /dev/null
+++ b/drivers/staging/dt3155/dt3155_main.c
@@ -0,0 +1,1524 @@
+/*
+ * This is the DT3155 Device Driver.
+ *
+ * The DT3155 Device Driver is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+
+ * The DT3155 Device Driver is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the DT3155 Device Driver; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
+ *                          Jason Lapenta, Scott Smedley, Greg Sharp
+ *
+ * to do:
+ * + might want to get rid of MAXboards for allocating initial buffer.
+ *   confusing and not necessary
+ *
+ * + in cleanup_module the MOD_IN_USE looks like it is check after it should
+ *
+ * + GFP_DMA should not be set with a PCI system (pg 291)
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#ifndef CONFIG_PCI
+#error  "DT3155: Kernel PCI support not enabled (DT3155 drive requires PCI)"
+#endif
+
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
+#include <linux/delay.h>
+#include <linux/wait.h>
+
+#ifdef MODULE
+#include <linux/module.h>
+
+MODULE_LICENSE("GPL");
+
+#endif
+
+#include <asm/system.h>
+
+#include "dt3155.h"
+#include "dt3155_io.h"
+#include "allocator.h"
+
+/* Error variable.  Zero means no error. */
+static int dt_errno;
+
+#ifndef PCI_DEVICE_ID_INTEL_7116
+#define PCI_DEVICE_ID_INTEL_7116 0x1223
+#endif
+
+#define DT3155_VENDORID    PCI_VENDOR_ID_INTEL
+#define DT3155_DEVICEID    PCI_DEVICE_ID_INTEL_7116
+#define MAXPCI    16
+
+#ifdef DT_DEBUG
+#define DPRINTK(fmt, args...)					\
+	printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, ##args)
+#else
+#define DPRINTK(fmt, args...)						\
+do {									\
+	if (0)								\
+		printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, ##args);	\
+} while (0)
+#endif
+
+/* wait queue for interrupts */
+static wait_queue_head_t dt_rwq[MAXBOARDS];
+
+#define DT_3155_SUCCESS 0
+#define DT_3155_FAILURE (-EIO)
+
+static int dt_major;
+
+/* The minor numbers are 0 and 1 ... they are not tunable.
+ * They are used as the indices for the structure vectors,
+ * and register address vectors
+ */
+
+/* Global structures and variables */
+
+/* Status of each device */
+static struct dt3155_status_s dt_status[MAXBOARDS];
+
+/* kernel logical address of the board */
+static u8 *dt_lbase[MAXBOARDS];
+
+/* DT3155 registers */
+static u32 dt_dev_open[MAXBOARDS];
+
+/* Pointer into structure for handling buffers */
+static struct dt3155_fbuffer_s *dt_fb[MAXBOARDS];
+
+static u32 unique_tag;
+static int ndevices;
+static u32 allocatorAddr;
+
+/*
+ * This section provides some basic register io routines.
+ * It is modified from demo code provided by Data Translations.
+ */
+
+/****** local copies of board's 32 bit registers ******/
+static u32 even_dma_start_r;		/*  bit 0 should always be 0 */
+static u32 odd_dma_start_r;		/*               .. */
+static u32 even_dma_stride_r;		/*  bits 0&1 should always be 0 */
+static u32 odd_dma_stride_r;		/*               .. */
+
+static CSR1_R csr1_r;
+static INT_CSR_R int_csr_r;
+
+static IIC_CSR1_R iic_csr1_r;
+static IIC_CSR2_R iic_csr2_r;
+
+/******** local copies of board's 8 bit I2C registers ******/
+static I2C_CSR2 i2c_csr2;
+static I2C_EVEN_CSR i2c_even_csr;
+static I2C_ODD_CSR i2c_odd_csr;
+static I2C_CONFIG i2c_config;
+
+/*****************************************************
+ * get_tail()
+ * m is minor # of device
+ *
+ * Simply comptutes the tail given the head and the length.
+ *****************************************************/
+static int get_tail(int m)
+{
+	return (dt_fb[m]->ready_head -
+		dt_fb[m]->ready_len +
+		dt_fb[m]->nbuffers) % dt_fb[m]->nbuffers;
+}
+
+/*****************************************************
+ * printques
+ * m is minor # of device
+ *****************************************************/
+static void printques(int m)
+{
+	int head = dt_fb[m]->ready_head;
+	int tail;
+	int num = dt_fb[m]->nbuffers;
+	int frame_index;
+	int index;
+
+	tail = get_tail(m);
+
+	pr_info("R:");
+	for (index = tail; index != head; index++, index = index % (num)) {
+		frame_index = dt_fb[m]->ready_que[index];
+		pr_cont(" %d ", frame_index);
+	}
+
+	pr_cont("\n");
+	pr_info("E:");
+	for (index = 0; index < dt_fb[m]->empty_len; index++) {
+		frame_index = dt_fb[m]->empty_buffers[index];
+		pr_cont(" %d ", frame_index);
+	}
+	pr_cont("\n");
+
+	frame_index = dt_fb[m]->active_buf;
+	pr_info("A: %d\n", frame_index);
+
+	frame_index = dt_fb[m]->locked_buf;
+	pr_info("L: %d\n", frame_index);
+}
+
+/*
+ * wait_ibsyclr()
+ *
+ * This function handles read/write timing and r/w timeout error
+ *
+ * Returns TRUE  if NEW_CYCLE clears
+ * Returns FALSE if NEW_CYCLE doesn't clear in roughly 3 msecs, otherwise
+ * returns 0
+ */
+static bool wait_ibsyclr(u8 *lpReg)
+{
+	/* wait 100 microseconds */
+	udelay(100L);
+	/* __delay(loops_per_sec/10000); */
+	if (iic_csr2_r.fld.NEW_CYCLE) {
+		/* if NEW_CYCLE didn't clear */
+		/* TIMEOUT ERROR */
+		dt_errno = DT_ERR_I2C_TIMEOUT;
+		return false;
+	}
+
+	return true;	/* no error */
+}
+
+/*
+ * WriteI2C()
+ *
+ * This function handles writing to 8-bit DT3155 registers
+ *
+ * 1st parameter is pointer to 32-bit register base address
+ * 2nd parameter is reg. index;
+ * 3rd is value to be written
+ *
+ * Returns true   -  Successful completion
+ *         false  -  Timeout error - cycle did not complete!
+ */
+bool WriteI2C(u8 *lpReg, u_short wIregIndex, u8 byVal)
+{
+	/* read 32 bit IIC_CSR2 register data into union */
+	ReadMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
+
+	/* for write operation */
+	iic_csr2_r.fld.DIR_RD = 0;
+	/* I2C address of I2C register: */
+	iic_csr2_r.fld.DIR_ADDR = wIregIndex;
+	/* 8 bit data to be written to I2C reg */
+	iic_csr2_r.fld.DIR_WR_DATA = byVal;
+	/* will start a direct I2C cycle: */
+	iic_csr2_r.fld.NEW_CYCLE = 1;
+
+	/* xfer union data into 32 bit IIC_CSR2 register */
+	WriteMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
+
+	/* wait for IIC cycle to finish */
+	return wait_ibsyclr(lpReg);
+}
+
+/*
+ * ReadI2C()
+ *
+ * This function handles reading from 8-bit DT3155 registers
+ *
+ * 1st parameter is pointer to 32-bit register base address
+ * 2nd parameter is reg. index;
+ * 3rd is adrs of value to be read
+ *
+ * Returns TRUE   -  Successful completion
+ *         FALSE  -  Timeout error - cycle did not complete!
+ */
+int ReadI2C(u8 *lpReg, u_short wIregIndex, u8 *byVal)
+{
+	bool writestat;		/* status for return */
+
+	/*  read 32 bit IIC_CSR2 register data into union */
+	ReadMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
+
+	/*  for read operation */
+	iic_csr2_r.fld.DIR_RD = 1;
+
+	/*  I2C address of I2C register: */
+	iic_csr2_r.fld.DIR_ADDR = wIregIndex;
+
+	/*  will start a direct I2C cycle: */
+	iic_csr2_r.fld.NEW_CYCLE = 1;
+
+	/*  xfer union's data into 32 bit IIC_CSR2 register */
+	WriteMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
+
+	/* wait for IIC cycle to finish */
+	writestat = wait_ibsyclr(lpReg);
+
+	/* Next 2 commands read 32 bit IIC_CSR1 register's data into union */
+	/* first read data is in IIC_CSR1 */
+	ReadMReg((lpReg + IIC_CSR1), iic_csr1_r.reg);
+
+	/* now get data u8 out of register */
+	*byVal = (u8) iic_csr1_r.fld.RD_DATA;
+
+	return writestat;
+}
+
+/******************************************************************************
+ * Purpose: Buffer management routines, and other routines for the ISR
+ *****************************************************************************/
+
+#define FOUR_MB         (0x0400000)	/* Can't DMA accross a 4MB boundary! */
+#define UPPER_10_BITS   (0x3FF<<22)	/* Can't DMA accross a 4MB boundary! */
+
+/******************************************************************************
+ * Simple array based queue struct
+ *
+ * Some handy functions using the buffering structure.
+ *****************************************************************************/
+
+/***************************
+ * are_empty_buffers
+ * m is minor # of device
+ ***************************/
+static int are_empty_buffers(int m)
+{
+	return dt_fb[m]->empty_len;
+}
+
+/**************************
+ * push_empty
+ * m is minor # of device
+ *
+ * This is slightly confusing.  The number empty_len is the literal #
+ * of empty buffers.  After calling, empty_len-1 is the index into the
+ * empty buffer stack.  So, if empty_len == 1, there is one empty buffer,
+ * given by dt_fb[m]->empty_buffers[0].
+ * empty_buffers should never fill up, though this is not checked.
+ **************************/
+static void push_empty(int index, int m)
+{
+	dt_fb[m]->empty_buffers[dt_fb[m]->empty_len] = index;
+	dt_fb[m]->empty_len++;
+}
+
+/**************************
+ * pop_empty( m )
+ * m is minor # of device
+ **************************/
+static int pop_empty(int m)
+{
+	dt_fb[m]->empty_len--;
+	return dt_fb[m]->empty_buffers[dt_fb[m]->empty_len];
+}
+
+/*************************
+ * is_ready_buf_empty( m )
+ * m is minor # of device
+ *************************/
+static bool is_ready_buf_empty(int m)
+{
+	return (dt_fb[m]->ready_len) == 0;
+}
+
+/*****************************************************
+ * push_ready( m, buffer )
+ * m is minor # of device
+ *
+ *****************************************************/
+static void push_ready(int m, int index)
+{
+	int head = dt_fb[m]->ready_head;
+
+	dt_fb[m]->ready_que[head] = index;
+	dt_fb[m]->ready_head = (head + 1) % dt_fb[m]->nbuffers;
+	dt_fb[m]->ready_len++;
+}
+
+/*****************************************************
+ * pop_ready()
+ * m is minor # of device
+ *
+ * This assumes that there is a ready buffer ready... should
+ * be checked (e.g. with is_ready_buf_empty()  prior to call.
+ *****************************************************/
+static int pop_ready(int m)
+{
+	int tail = get_tail(m);
+
+	dt_fb[m]->ready_len--;
+	return dt_fb[m]->ready_que[tail];
+}
+
+/*****************************************************
+ * adjust_4MB
+ *
+ *  If a buffer intersects the 4MB boundary, push
+ *  the start address up to the beginning of the
+ *  next 4MB chunk (assuming bufsize < 4MB).
+ *****************************************************/
+static u32 adjust_4MB(u32 buf_addr, u32 bufsize)
+{
+	if (((buf_addr + bufsize) & UPPER_10_BITS) !=
+	    (buf_addr & UPPER_10_BITS))
+		return (buf_addr + bufsize) & UPPER_10_BITS;
+	return buf_addr;
+}
+
+/*****************************************************
+ * allocate_buffers
+ *
+ *  Try to allocate enough memory for all requested
+ *  buffers.  If there is not enough free space
+ *  try for less memory.
+ *****************************************************/
+void allocate_buffers(u32 *buf_addr, u32 *total_size_kbs, u32 bufsize)
+{
+	/* Compute the minimum amount of memory guaranteed to hold all
+	   MAXBUFFERS such that no buffer crosses the 4MB boundary.
+	   Store this value in the variable "full_size" */
+
+	u32 allocator_max;
+	u32 bufs_per_chunk = FOUR_MB / bufsize;
+	u32 filled_chunks = (MAXBUFFERS - 1) / bufs_per_chunk;
+	u32 leftover_bufs = MAXBUFFERS - filled_chunks * bufs_per_chunk;
+
+	u32 full_size = bufsize	/* possibly unusable part of 1st chunk */
+		+ filled_chunks * FOUR_MB
+				/* max # of completely filled 4mb chunks */
+		+ leftover_bufs * bufsize;
+				/* these buffs will be in a partly filled
+				 * chunk at beginning or end */
+
+	u32 full_size_kbs = 1 + (full_size - 1) / 1024;
+	u32 min_size_kbs = 2 * ndevices * bufsize / 1024;
+	u32 size_kbs;
+
+	/* Now, try to allocate full_size.  If this fails, keep trying for
+	   less & less memory until it succeeds. */
+#ifndef STANDALONE_ALLOCATOR
+	/* initialize the allocator */
+	allocator_init(&allocator_max);
+#endif
+	size_kbs = full_size_kbs;
+	*buf_addr = 0;
+	pr_info("We would like to get: %d KB\n", full_size_kbs);
+	pr_info("...but need at least: %d KB\n", min_size_kbs);
+	pr_info("...the allocator has: %d KB\n", allocator_max);
+	size_kbs = min(full_size_kbs, allocator_max);
+	if (size_kbs > min_size_kbs) {
+		*buf_addr = allocator_allocate_dma(size_kbs, GFP_KERNEL);
+		if (*buf_addr != 0) {
+			pr_info("Managed to allocate: %d KB\n", size_kbs);
+			*total_size_kbs = size_kbs;
+			return;
+		}
+	}
+	/* If we got here, the allocation failed */
+	pr_err("Allocator failed!\n");
+	*buf_addr = 0;
+	*total_size_kbs = 0;
+}
+
+/*****************************************************
+ * dt3155_setup_buffers
+ *
+ *  setup_buffers just puts the buffering system into
+ *  a consistent state before the start of interrupts
+ *
+ * JML : it looks like all the buffers need to be
+ * continuous. So I'm going to try and allocate one
+ * continuous buffer.
+ *
+ * GCS : Fix DMA problems when buffer spans
+ * 4MB boundary.  Also, add error checking.  This
+ * function will return -ENOMEM when not enough memory.
+ *****************************************************/
+static u32 dt3155_setup_buffers(u32 *allocatorAddr)
+{
+	u32 index;
+	u32 rambuff_addr;	/* start of allocation */
+	u32 rambuff_size;	/* total size allocated to driver */
+	u32 rambuff_acm;	/* accumlator, keep track of how much
+				   is left after being split up */
+	u32 rambuff_end;	/* end of rambuff */
+	u32 numbufs;		/* number of useful buffers allocated
+				   (per device) */
+	u32 bufsize = DT3155_MAX_ROWS * DT3155_MAX_COLS;
+	int m;			/* minor # of device, looped for all devs */
+
+	/* zero the fbuffer status and address structure */
+	for (m = 0; m < ndevices; m++) {
+		u8 *ptr;
+
+		dt_fb[m] = &(dt_status[m].fbuffer);
+		/* Make sure the buffering variables are consistent */
+		ptr = (u8 *)dt_fb[m];
+		for (index = 0; index < sizeof(struct dt3155_fbuffer_s);
+		     index++)
+			*(ptr++) = 0;
+	}
+
+	/* allocate a large contiguous chunk of RAM */
+	allocate_buffers(&rambuff_addr, &rambuff_size, bufsize);
+	pr_info("mem info\n");
+	pr_info("  - rambuf_addr = 0x%x\n", rambuff_addr);
+	pr_info("  - length (kb) = %u\n", rambuff_size);
+	if (rambuff_addr == 0) {
+		pr_err("Error setup_buffers() allocator dma failed\n");
+		return -ENOMEM;
+	}
+	*allocatorAddr = rambuff_addr;
+	rambuff_end = rambuff_addr + 1024 * rambuff_size;
+
+	/* after allocation, we need to count how many useful buffers there
+	   are so we can give an equal number to each device */
+	rambuff_acm = rambuff_addr;
+	for (index = 0; index < MAXBUFFERS; index++) {
+		rambuff_acm = adjust_4MB(rambuff_acm, bufsize);
+					/*avoid spanning 4MB bdry */
+		if (rambuff_acm + bufsize > rambuff_end)
+			break;
+		rambuff_acm += bufsize;
+	}
+	/* Following line is OK, will waste buffers if index
+	 * not evenly divisible by ndevices -NJC*/
+	numbufs = index / ndevices;
+	pr_info("  - numbufs = %u\n", numbufs);
+	if (numbufs < 2) {
+		pr_err("Error setup_buffers() couldn't allocate 2 bufs/board\n");
+		return -ENOMEM;
+	}
+
+	/* now that we have board memory we spit it up */
+	/* between the boards and the buffers          */
+	rambuff_acm = rambuff_addr;
+	for (m = 0; m < ndevices; m++) {
+		rambuff_acm = adjust_4MB(rambuff_acm, bufsize);
+
+		/* Save the start of this boards buffer space (for mmap). */
+		dt_status[m].mem_addr = rambuff_acm;
+
+		for (index = 0; index < numbufs; index++) {
+			rambuff_acm = adjust_4MB(rambuff_acm, bufsize);
+			if (rambuff_acm + bufsize > rambuff_end) {
+				/* Should never happen */
+				pr_info("DT3155 PROGRAM ERROR (GCS)\n"
+					"Error distributing allocated buffers\n");
+				return -ENOMEM;
+			}
+
+			dt_fb[m]->frame_info[index].addr = rambuff_acm;
+			push_empty(index, m);
+			/* pr_info("  - Buffer : %lx\n",
+			 * dt_fb[ m ]->frame_info[ index ].addr );
+			 */
+			dt_fb[m]->nbuffers += 1;
+			rambuff_acm += bufsize;
+		}
+
+		/* Make sure there is an active buffer there. */
+		dt_fb[m]->active_buf = pop_empty(m);
+		dt_fb[m]->even_happened = 0;
+		dt_fb[m]->even_stopped = 0;
+
+		/* make sure there is no locked_buf JML 2/28/00 */
+		dt_fb[m]->locked_buf = -1;
+
+		dt_status[m].mem_size = rambuff_acm - dt_status[m].mem_addr;
+
+		/* setup the ready queue */
+		dt_fb[m]->ready_head = 0;
+		dt_fb[m]->ready_len = 0;
+		pr_info("Available buffers for device %d: %d\n",
+			m, dt_fb[m]->nbuffers);
+	}
+
+	return 1;
+}
+
+/*****************************************************
+ * internal_release_locked_buffer
+ *
+ * The internal function for releasing a locked buffer.
+ * It assumes interrupts are turned off.
+ *
+ * m is minor number of device
+ *****************************************************/
+static void internal_release_locked_buffer(int m)
+{
+	/* Pointer into global structure for handling buffers */
+	if (dt_fb[m]->locked_buf >= 0) {
+		push_empty(dt_fb[m]->locked_buf, m);
+		dt_fb[m]->locked_buf = -1;
+	}
+}
+
+/*****************************************************
+ * dt3155_flush()
+ * m is minor # of device
+ *
+ *****************************************************/
+static int dt3155_flush(int m)
+{
+	int index;
+	unsigned long int flags;
+	local_save_flags(flags);
+	local_irq_disable();
+
+	internal_release_locked_buffer(m);
+	dt_fb[m]->empty_len = 0;
+
+	for (index = 0; index < dt_fb[m]->nbuffers; index++)
+		push_empty(index, m);
+
+	/* Make sure there is an active buffer there. */
+	dt_fb[m]->active_buf = pop_empty(m);
+
+	dt_fb[m]->even_happened = 0;
+	dt_fb[m]->even_stopped = 0;
+
+	/* setup the ready queue  */
+	dt_fb[m]->ready_head = 0;
+	dt_fb[m]->ready_len = 0;
+
+	local_irq_restore(flags);
+
+	return 0;
+}
+
+/*****************************************************
+ * dt3155_get_ready_buffer()
+ * m is minor # of device
+ *
+ * get_ready_buffer will grab the next chunk of data
+ * if it is already there, otherwise it returns 0.
+ * If the user has a buffer locked it will unlock
+ * that buffer before returning the new one.
+ *****************************************************/
+static int dt3155_get_ready_buffer(int m)
+{
+	int frame_index;
+	unsigned long int flags;
+
+	local_save_flags(flags);
+	local_irq_disable();
+
+#ifdef DEBUG_QUES_A
+	printques(m);
+#endif
+
+	internal_release_locked_buffer(m);
+
+	if (is_ready_buf_empty(m))
+		frame_index = -1;
+	else {
+		frame_index = pop_ready(m);
+		dt_fb[m]->locked_buf = frame_index;
+	}
+
+#ifdef DEBUG_QUES_B
+	printques(m);
+#endif
+
+	local_irq_restore(flags);
+
+	return frame_index;
+}
+
+/*
+ * Stops interrupt generation right away and resets the status
+ * to idle.  I don't know why this works and the other way doesn't.
+ * (James Rose)
+ */
+static void quick_stop(int minor)
+{
+	/* TODO: scott was here */
+#if 1
+	ReadMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+	/* disable interrupts */
+	int_csr_r.fld.FLD_END_EVE_EN = 0;
+	int_csr_r.fld.FLD_END_ODD_EN = 0;
+	WriteMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+	dt_status[minor].state &= ~(DT3155_STATE_STOP | 0xff);
+	/* mark the system stopped: */
+	dt_status[minor].state |= DT3155_STATE_IDLE;
+	dt_fb[minor]->stop_acquire = 0;
+	dt_fb[minor]->even_stopped = 0;
+#else
+	dt_status[minor].state |= DT3155_STATE_STOP;
+	dt_status[minor].fbuffer.stop_acquire = 1;
+#endif
+}
+
+/*****************************************************
+ *  dt3155_isr() Interrupt service routine
+ *
+ * - looks like this isr supports IRQ sharing (or could) JML
+ * - Assumes irq's are disabled, via SA_INTERRUPT flag
+ * being set in request_irq() call from init_module()
+ *****************************************************/
+static inline void dt3155_isr(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int minor = -1;
+	int index;
+	unsigned long flags;
+	u32 buffer_addr;
+
+	/* find out who issued the interrupt */
+	for (index = 0; index < ndevices; index++) {
+		if (dev_id == (void *)&dt_status[index]) {
+			minor = index;
+			break;
+		}
+	}
+
+	/* hopefully we should not get here */
+	if (minor < 0 || minor >= MAXBOARDS) {
+		pr_err("dt3155_isr called with invalid dev_id\n");
+		return;
+	}
+
+	/* Check for corruption and set a flag if so */
+	ReadMReg((dt_lbase[minor] + CSR1), csr1_r.reg);
+
+	if ((csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD)) {
+		/* TODO: this should probably stop acquisition */
+		/* and set some flags so that dt3155_read      */
+		/* returns an error next time it is called     */
+		dt_errno = DT_ERR_CORRUPT;
+		pr_err("corrupt field\n");
+		return;
+	}
+
+	ReadMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+	/* Handle the even field ... */
+	if (int_csr_r.fld.FLD_END_EVE) {
+		if ((dt_status[minor].state & DT3155_STATE_MODE) ==
+		    DT3155_STATE_FLD)
+			dt_fb[minor]->frame_count++;
+
+		ReadI2C(dt_lbase[minor], EVEN_CSR, &i2c_even_csr.reg);
+
+		/* Clear the interrupt? */
+		int_csr_r.fld.FLD_END_EVE = 1;
+
+		/* disable the interrupt if last field */
+		if (dt_fb[minor]->stop_acquire) {
+			pr_info("even stopped\n");
+			dt_fb[minor]->even_stopped = 1;
+			if (i2c_even_csr.fld.SNGL_EVE)
+				int_csr_r.fld.FLD_END_EVE_EN = 0;
+			else
+				i2c_even_csr.fld.SNGL_EVE = 1;
+		}
+
+		WriteMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+		/* Set up next DMA if we are doing FIELDS */
+		if ((dt_status[minor].state & DT3155_STATE_MODE) ==
+		    DT3155_STATE_FLD) {
+			/* GCS (Aug 2, 2002) -- In field mode, dma the odd field
+			   into the lower half of the buffer */
+			const u32 stride = dt_status[minor].config.cols;
+			buffer_addr = dt_fb[minor]->frame_info[dt_fb
+						     [minor]->active_buf].addr +
+			    (DT3155_MAX_ROWS / 2) * stride;
+			local_save_flags(flags);
+			local_irq_disable();
+			wake_up_interruptible(&dt_rwq[minor]);
+
+			/* Set up the DMA address for the next field */
+			local_irq_restore(flags);
+			WriteMReg((dt_lbase[minor] + ODD_DMA_START),
+				  buffer_addr);
+		}
+
+		/* Check for errors. */
+		i2c_even_csr.fld.DONE_EVE = 1;
+		if (i2c_even_csr.fld.ERROR_EVE)
+			dt_errno = DT_ERR_OVERRUN;
+
+		WriteI2C(dt_lbase[minor], EVEN_CSR, i2c_even_csr.reg);
+
+		/* Note that we actually saw an even field meaning  */
+		/* that subsequent odd field complete the frame     */
+		dt_fb[minor]->even_happened = 1;
+
+		/* recording the time that the even field finished,
+		 * this should be about time in the middle of the frame */
+		do_gettimeofday(&(dt_fb[minor]->frame_info
+				  [dt_fb[minor]->active_buf].time));
+		return;
+	}
+
+	/* ... now handle the odd field */
+	if (int_csr_r.fld.FLD_END_ODD) {
+		ReadI2C(dt_lbase[minor], ODD_CSR, &i2c_odd_csr.reg);
+
+		/* Clear the interrupt? */
+		int_csr_r.fld.FLD_END_ODD = 1;
+
+		if (dt_fb[minor]->even_happened ||
+		    (dt_status[minor].state & DT3155_STATE_MODE) ==
+		    DT3155_STATE_FLD)
+			dt_fb[minor]->frame_count++;
+
+		if (dt_fb[minor]->stop_acquire && dt_fb[minor]->even_stopped) {
+			printk(KERN_DEBUG KBUILD_MODNAME ": " "stopping odd\n");
+			if (i2c_odd_csr.fld.SNGL_ODD) {
+				/* disable interrupts */
+				int_csr_r.fld.FLD_END_ODD_EN = 0;
+				dt_status[minor].state &=
+				    ~(DT3155_STATE_STOP | 0xff);
+
+				/* mark the system stopped: */
+				dt_status[minor].state |= DT3155_STATE_IDLE;
+				dt_fb[minor]->stop_acquire = 0;
+				dt_fb[minor]->even_stopped = 0;
+
+				printk(KERN_DEBUG KBUILD_MODNAME ": " "state is now %x\n",
+				       dt_status[minor].state);
+			} else
+				i2c_odd_csr.fld.SNGL_ODD = 1;
+		}
+
+		WriteMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+		/* if the odd field has been acquired, then     */
+		/* change the next dma location for both fields */
+		/* and wake up the process if sleeping          */
+		if (dt_fb[minor]->even_happened ||
+		    (dt_status[minor].state & DT3155_STATE_MODE) ==
+		    DT3155_STATE_FLD) {
+
+			local_save_flags(flags);
+			local_irq_disable();
+
+#ifdef DEBUG_QUES_B
+			printques(minor);
+#endif
+			/* The number of active + locked buffers is
+			 * at most 2, and since there are none empty, there
+			 * must be at least nbuffers-2 ready buffers.
+			 * This is where we 'drop frames', oldest first. */
+
+			if (dt_fb[minor]->nbuffers > 2) {
+				if (!are_empty_buffers(minor))
+					push_empty(pop_ready(minor), minor);
+
+				/* The ready_que can't be full, since we know
+				 * there is one active buffer right now,
+				 * so it's safe to push the active buf on
+				 * the ready_que. */
+				push_ready(minor, dt_fb[minor]->active_buf);
+				/* There's at least 1 empty -- make it active */
+				dt_fb[minor]->active_buf = pop_empty(minor);
+				dt_fb[minor]->frame_info[dt_fb
+							 [minor]->
+							 active_buf].tag =
+				    ++unique_tag;
+			} else {	/* nbuffers == 2, special case */
+				/* There is 1 active buffer.
+				 * If there is a locked buffer,
+				 * keep the active buffer the same --
+				 * that means we drop a frame.
+				 */
+				if (dt_fb[minor]->locked_buf < 0) {
+					push_ready(minor,
+						   dt_fb[minor]->active_buf);
+					if (are_empty_buffers(minor))
+						dt_fb[minor]->active_buf =
+						    pop_empty(minor);
+					else	/* no empty or locked buffers,
+						 * so use a readybuf */
+						dt_fb[minor]->active_buf =
+						    pop_ready(minor);
+				}
+			}
+
+#ifdef DEBUG_QUES_B
+			printques(minor);
+#endif
+
+			dt_fb[minor]->even_happened = 0;
+
+			wake_up_interruptible(&dt_rwq[minor]);
+
+			local_irq_restore(flags);
+		}
+
+		/* Set up the DMA address for the next frame/field */
+		buffer_addr =
+		    dt_fb[minor]->frame_info[dt_fb[minor]->active_buf].addr;
+		if ((dt_status[minor].state & DT3155_STATE_MODE) ==
+		    DT3155_STATE_FLD) {
+			WriteMReg((dt_lbase[minor] + EVEN_DMA_START),
+				  buffer_addr);
+		} else {
+			WriteMReg((dt_lbase[minor] + EVEN_DMA_START),
+				  buffer_addr);
+
+			WriteMReg((dt_lbase[minor] + ODD_DMA_START),
+				  buffer_addr +
+				  dt_status[minor].config.cols);
+		}
+
+		/* Do error checking */
+		i2c_odd_csr.fld.DONE_ODD = 1;
+		if (i2c_odd_csr.fld.ERROR_ODD)
+			dt_errno = DT_ERR_OVERRUN;
+
+		WriteI2C(dt_lbase[minor], ODD_CSR, i2c_odd_csr.reg);
+
+		return;
+	}
+	/* If we get here, the Odd Field wasn't it either... */
+	pr_info("neither even nor odd.  shared perhaps?\n");
+}
+
+/*****************************************************
+ * init_isr(int minor)
+ *   turns on interupt generation for the card
+ *   designated by "minor".
+ *   It is called *only* from inside ioctl().
+ *****************************************************/
+static void dt3155_init_isr(int minor)
+{
+	const u32 stride = dt_status[minor].config.cols;
+
+	switch (dt_status[minor].state & DT3155_STATE_MODE) {
+	case DT3155_STATE_FLD:
+		even_dma_start_r = dt_status[minor].
+			fbuffer.frame_info[dt_status[minor].fbuffer.
+					       active_buf].addr;
+		even_dma_stride_r = 0;
+		odd_dma_stride_r = 0;
+
+		WriteMReg((dt_lbase[minor] + EVEN_DMA_START),
+			  even_dma_start_r);
+		WriteMReg((dt_lbase[minor] + EVEN_DMA_STRIDE),
+			  even_dma_stride_r);
+		WriteMReg((dt_lbase[minor] + ODD_DMA_STRIDE),
+			  odd_dma_stride_r);
+		break;
+
+	case DT3155_STATE_FRAME:
+	default:
+		even_dma_start_r =
+			dt_status[minor].
+			fbuffer.frame_info[dt_status[minor].fbuffer.
+					   active_buf].addr;
+		odd_dma_start_r = even_dma_start_r + stride;
+		even_dma_stride_r = stride;
+		odd_dma_stride_r = stride;
+
+		WriteMReg((dt_lbase[minor] + EVEN_DMA_START),
+			  even_dma_start_r);
+		WriteMReg((dt_lbase[minor] + ODD_DMA_START),
+			  odd_dma_start_r);
+		WriteMReg((dt_lbase[minor] + EVEN_DMA_STRIDE),
+			  even_dma_stride_r);
+		WriteMReg((dt_lbase[minor] + ODD_DMA_STRIDE),
+			  odd_dma_stride_r);
+		break;
+	}
+
+	/* 50/60 Hz should be set before this point but let's make sure it is */
+	/* right anyway */
+
+	ReadI2C(dt_lbase[minor], CONFIG, &i2c_csr2.reg);
+	i2c_csr2.fld.HZ50 = FORMAT50HZ;
+	WriteI2C(dt_lbase[minor], CONFIG, i2c_config.reg);
+
+	/* enable busmaster chip, clear flags */
+
+	/*
+	 * TODO:
+	 * shouldn't we be concerned with continuous values of
+	 * DT3155_SNAP & DT3155_ACQ here? (SS)
+	 */
+
+	csr1_r.reg = 0;
+	csr1_r.fld.CAP_CONT_EVE = 1;	/* use continuous capture bits to */
+	csr1_r.fld.CAP_CONT_ODD = 1;	/* enable */
+	csr1_r.fld.FLD_DN_EVE = 1;	/* writing a 1 clears flags */
+	csr1_r.fld.FLD_DN_ODD = 1;
+	csr1_r.fld.SRST = 1;		/* reset        - must be 1 */
+	csr1_r.fld.FIFO_EN = 1;		/* fifo control - must be 1 */
+	csr1_r.fld.FLD_CRPT_EVE = 1;	/* writing a 1 clears flags */
+	csr1_r.fld.FLD_CRPT_ODD = 1;
+
+	WriteMReg((dt_lbase[minor] + CSR1), csr1_r.reg);
+
+	/* Enable interrupts at the end of each field */
+
+	int_csr_r.reg = 0;
+	int_csr_r.fld.FLD_END_EVE_EN = 1;
+	int_csr_r.fld.FLD_END_ODD_EN = 1;
+	int_csr_r.fld.FLD_START_EN = 0;
+
+	WriteMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+	/* start internal BUSY bits */
+
+	ReadI2C(dt_lbase[minor], CSR2, &i2c_csr2.reg);
+	i2c_csr2.fld.BUSY_ODD = 1;
+	i2c_csr2.fld.BUSY_EVE = 1;
+	WriteI2C(dt_lbase[minor], CSR2, i2c_csr2.reg);
+
+	/* Now its up to the interrupt routine!! */
+
+	return;
+}
+
+/*****************************************************
+ * ioctl()
+ *
+ *****************************************************/
+static int dt3155_ioctl(struct inode *inode, struct file *file,
+			unsigned int cmd, unsigned long arg)
+{
+	int minor = MINOR(inode->i_rdev);	/* device are we ioctl()'ing */
+
+	if (minor >= MAXBOARDS || minor < 0)
+		return -ENODEV;
+
+	/* make sure it is valid command */
+	if (_IOC_NR(cmd) > DT3155_IOC_MAXNR) {
+		pr_info("invalid IOCTL(0x%x)\n", cmd);
+		pr_info("Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
+			(unsigned int)DT3155_GET_CONFIG,
+			(unsigned int)DT3155_SET_CONFIG,
+			(unsigned int)DT3155_START,
+			(unsigned int)DT3155_STOP,
+			(unsigned int)DT3155_FLUSH);
+		return -EINVAL;
+	}
+
+	switch (cmd) {
+	case DT3155_SET_CONFIG: {
+		struct dt3155_config_s tmp;
+		if (dt_status[minor].state != DT3155_STATE_IDLE)
+			return -EBUSY;
+
+		if (copy_from_user
+		    ((void *)&tmp, (void *)arg, sizeof(tmp)))
+			return -EFAULT;
+			/* check for valid settings */
+		if (tmp.rows > DT3155_MAX_ROWS ||
+		    tmp.cols > DT3155_MAX_COLS ||
+		    (tmp.acq_mode != DT3155_MODE_FRAME &&
+		     tmp.acq_mode != DT3155_MODE_FIELD) ||
+		    (tmp.continuous != DT3155_SNAP &&
+		     tmp.continuous != DT3155_ACQ))
+			return -EINVAL;
+		dt_status[minor].config = tmp;
+		return 0;
+	}
+
+	case DT3155_GET_CONFIG:
+		if (copy_to_user((void *)arg, (void *)&dt_status[minor],
+				 sizeof(dt3155_status_t)))
+			return -EFAULT;
+		return 0;
+
+	case DT3155_FLUSH:	/* Flushes the buffers -- ensures fresh data */
+		if (dt_status[minor].state != DT3155_STATE_IDLE)
+			return -EBUSY;
+		return dt3155_flush(minor);
+
+	case DT3155_STOP:
+		if (dt_status[minor].state & DT3155_STATE_STOP ||
+		    dt_status[minor].fbuffer.stop_acquire)
+			return -EBUSY;
+
+		if (dt_status[minor].state == DT3155_STATE_IDLE)
+			return 0;
+
+		quick_stop(minor);
+		if (copy_to_user((void *)arg, (void *)&dt_status[minor],
+				 sizeof(dt3155_status_t)))
+			return -EFAULT;
+		return 0;
+
+	case DT3155_START:
+		if (dt_status[minor].state != DT3155_STATE_IDLE)
+			return -EBUSY;
+
+		dt_status[minor].fbuffer.stop_acquire = 0;
+		dt_status[minor].fbuffer.frame_count = 0;
+
+		/* Set the MODE in the status -- we default to FRAME */
+		if (dt_status[minor].config.acq_mode == DT3155_MODE_FIELD)
+			dt_status[minor].state = DT3155_STATE_FLD;
+		else
+			dt_status[minor].state = DT3155_STATE_FRAME;
+
+		dt3155_init_isr(minor);
+		if (copy_to_user((void *)arg, (void *)&dt_status[minor],
+				 sizeof(dt3155_status_t)))
+			return -EFAULT;
+		return 0;
+
+	default:
+		pr_info("invalid IOCTL(0x%x)\n", cmd);
+		pr_info("Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
+			(unsigned int)DT3155_GET_CONFIG,
+			(unsigned int)DT3155_SET_CONFIG,
+			DT3155_START, DT3155_STOP, DT3155_FLUSH);
+		return -ENOSYS;
+	}
+	return -ENOSYS;
+}
+
+/*****************************************************
+ * mmap()
+ *
+ * only allow the user to mmap the registers and buffer
+ * It is quite possible that this is broken, since the
+ * addition of of the capacity for two cards!!!!!!!!
+ * It *looks* like it should work but since I'm not
+ * sure how to use it, I'm not actually sure. (NJC? ditto by SS)
+ *****************************************************/
+static int dt3155_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	/* which device are we mmapping? */
+	int minor = MINOR(file->f_dentry->d_inode->i_rdev);
+	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
+
+	if (offset >= __pa(high_memory) || (file->f_flags & O_SYNC))
+		vma->vm_flags |= VM_IO;
+
+	/* Don't try to swap out physical pages.. */
+	vma->vm_flags |= VM_RESERVED;
+
+	/* they are mapping the registers or the buffer */
+	if ((offset == dt_status[minor].reg_addr &&
+	     vma->vm_end - vma->vm_start == PCI_PAGE_SIZE) ||
+	    (offset == dt_status[minor].mem_addr &&
+	     vma->vm_end - vma->vm_start == dt_status[minor].mem_size)) {
+		if (remap_pfn_range(vma,
+				    vma->vm_start,
+				    offset >> PAGE_SHIFT,
+				    vma->vm_end - vma->vm_start,
+				    vma->vm_page_prot)) {
+			pr_err("remap_page_range() failed\n");
+			return -EAGAIN;
+		}
+	} else {
+		pr_err("dt3155_mmap() bad call\n");
+		return -ENXIO;
+	}
+
+	return 0;
+}
+
+/*****************************************************
+ * open()
+ *
+ * Our special open code.
+ * MOD_INC_USE_COUNT make sure that the driver memory is not freed
+ * while the device is in use.
+ *****************************************************/
+static int dt3155_open(struct inode *inode, struct file *filep)
+{
+	int minor = MINOR(inode->i_rdev);	/* device are we opening */
+	if (dt_dev_open[minor]) {
+		pr_err("Already opened by another process\n");
+		return -EBUSY;
+	}
+
+	if (dt_status[minor].device_installed == 0) {
+		pr_err("Open Error: No such device dt3155 minor number %d\n",
+		       minor);
+		return -EIO;
+	}
+
+	if (dt_status[minor].state != DT3155_STATE_IDLE) {
+		pr_err("Not in idle state (state = %x)\n",
+		       dt_status[minor].state);
+		return -EBUSY;
+	}
+
+	pr_info("Device opened\n");
+
+	dt_dev_open[minor] = 1;
+
+	dt3155_flush(minor);
+
+	/* Disable ALL interrupts */
+	int_csr_r.reg = 0;
+	WriteMReg((dt_lbase[minor] + INT_CSR), int_csr_r.reg);
+
+	init_waitqueue_head(&(dt_rwq[minor]));
+
+	return 0;
+}
+
+/*****************************************************
+ * close()
+ *
+ * Now decrement the use count.
+ *
+ *****************************************************/
+static int dt3155_close(struct inode *inode, struct file *filep)
+{
+	int minor;
+
+	minor = MINOR(inode->i_rdev);	/* device are we closing */
+	if (!dt_dev_open[minor]) {
+		pr_err("attempt to CLOSE a not OPEN device\n");
+	} else {
+		dt_dev_open[minor] = 0;
+
+		if (dt_status[minor].state != DT3155_STATE_IDLE)
+			quick_stop(minor);
+	}
+	return 0;
+}
+
+/*****************************************************
+ * read()
+ *
+ *****************************************************/
+static ssize_t dt3155_read(struct file *filep, char __user *buf,
+			   size_t count, loff_t *ppos)
+{
+	/* which device are we reading from? */
+	int minor = MINOR(filep->f_dentry->d_inode->i_rdev);
+	u32 offset;
+	int frame_index;
+	frame_info_t *frame_info_p;
+
+	/* TODO: this should check the error flag and */
+	/*   return an error on hardware failures */
+	if (count != sizeof(dt3155_read_t)) {
+		pr_err("DT3155 ERROR (NJC): count is not right\n");
+		return -EINVAL;
+	}
+
+	/* Hack here -- I'm going to allow reading even when idle.
+	 * this is so that the frames can be read after STOP has
+	 * been called.  Leaving it here, commented out, as a reminder
+	 * for a short while to make sure there are no problems.
+	 * Note that if the driver is not opened in non_blocking mode,
+	 * and the device is idle, then it could sit here forever! */
+
+	/*  if (dt_status[minor].state == DT3155_STATE_IDLE) */
+	/*    return -EBUSY; */
+
+	/* non-blocking reads should return if no data */
+	if (filep->f_flags & O_NDELAY) {
+		frame_index = dt3155_get_ready_buffer(minor);
+		if (frame_index < 0) {
+			/*pr_info("no buffers available (?)\n"); */
+			/*              printques(minor); */
+			return -EAGAIN;
+		}
+	} else {
+		/*
+		 * sleep till data arrives , or we get interrupted.
+		 * Note that wait_event_interruptible() does not actually
+		 * sleep/wait if it's condition evaluates to true upon entry.
+		 */
+		wait_event_interruptible(dt_rwq[minor],
+					 (frame_index =
+					  dt3155_get_ready_buffer(minor))
+					 >= 0);
+
+		if (frame_index < 0) {
+			pr_err("read: interrupted\n");
+			quick_stop(minor);
+			printques(minor);
+			return -EINTR;
+		}
+	}
+
+	frame_info_p = &dt_status[minor].fbuffer.frame_info[frame_index];
+
+	/* make this an offset */
+	offset = frame_info_p->addr - dt_status[minor].mem_addr;
+
+	put_user(offset, (unsigned int *)buf);
+	buf += sizeof(u32);
+	put_user(dt_status[minor].fbuffer.frame_count, (unsigned int *)buf);
+	buf += sizeof(u32);
+	put_user(dt_status[minor].state, (unsigned int *)buf);
+	buf += sizeof(u32);
+	if (copy_to_user(buf, frame_info_p, sizeof(frame_info_t)))
+		return -EFAULT;
+
+	return sizeof(dt3155_read_t);
+}
+
+static unsigned int dt3155_poll(struct file *filp, poll_table *wait)
+{
+	int minor = MINOR(filp->f_dentry->d_inode->i_rdev);
+
+	if (!is_ready_buf_empty(minor))
+		return POLLIN | POLLRDNORM;
+
+	poll_wait(filp, &dt_rwq[minor], wait);
+
+	return 0;
+}
+
+/*****************************************************
+ * file operations supported by DT3155 driver
+ *  needed by init_module
+ *  register_chrdev
+ *****************************************************/
+static const struct file_operations dt3155_fops = {
+	.read		= dt3155_read,
+	.ioctl		= dt3155_ioctl,
+	.mmap		= dt3155_mmap,
+	.poll		= dt3155_poll,
+	.open		= dt3155_open,
+	.release	= dt3155_close
+};
+
+/*****************************************************
+ * find_PCI();
+ *
+ * PCI has been totally reworked in 2.1..
+ *****************************************************/
+static int find_PCI(void)
+{
+	struct pci_dev *pci_dev = NULL;
+	int error, pci_index = 0;
+	unsigned short rev_device;
+	unsigned long base;
+	unsigned char irq;
+
+	while ((pci_dev = pci_get_device
+		(DT3155_VENDORID, DT3155_DEVICEID, pci_dev)) != NULL) {
+		pci_index++;
+
+		/* Is it really there? */
+		error = pci_read_config_word(pci_dev, PCI_CLASS_DEVICE,
+					  &rev_device);
+		if (error)
+			continue;
+
+		/* Found a board */
+		DPRINTK("Device number %d\n", pci_index);
+
+		/* Make sure the driver was compiled with enough buffers
+		 * to handle this many boards */
+		if (pci_index > MAXBOARDS) {
+			pr_err("ERROR - found %d devices, but driver only configured for %d devices\n"
+			       "Please change MAXBOARDS in dt3155.h\n",
+			       pci_index, MAXBOARDS);
+			goto err;
+		}
+
+		/* Now, just go out and make sure that this/these device(s)
+		   is/are actually mapped into the kernel address space */
+		error = pci_read_config_dword(pci_dev, PCI_BASE_ADDRESS_0,
+					      (u32 *)&base);
+		if (error) {
+			pr_err("Was not able to find device\n");
+			goto err;
+		}
+
+		DPRINTK("Base address 0 for device is %lx\n", base);
+		dt_status[pci_index - 1].reg_addr = base;
+
+		/* Remap the base address to a logical address through which we
+		 * can access it. */
+		dt_lbase[pci_index - 1] = ioremap(base, PCI_PAGE_SIZE);
+		dt_status[pci_index - 1].reg_addr = base;
+		DPRINTK("New logical address is %p\n", dt_lbase[pci_index - 1]);
+		if (!dt_lbase[pci_index - 1]) {
+			pr_err("Unable to remap control registers\n");
+			goto err;
+		}
+
+		error = pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &irq);
+		if (error) {
+			pr_err("Was not able to find device\n");
+			goto err;
+		}
+
+		DPRINTK("IRQ is %d\n", irq);
+		dt_status[pci_index - 1].irq = irq;
+		/* Set flag: kth device found! */
+		dt_status[pci_index - 1].device_installed = 1;
+		pr_info("Installing device %d w/irq %d and address %p\n",
+			pci_index,
+			dt_status[pci_index - 1].irq,
+			dt_lbase[pci_index - 1]);
+
+	}
+	ndevices = pci_index;
+
+	return DT_3155_SUCCESS;
+
+err:
+	pci_dev_put(pci_dev);
+	return DT_3155_FAILURE;
+}
+
+/*****************************************************
+ * init_module()
+ *****************************************************/
+int init_module(void)
+{
+	int index;
+	int rcode = 0;
+	char *devname[MAXBOARDS];
+
+	devname[0] = "dt3155a";
+#if MAXBOARDS == 2
+	devname[1] = "dt3155b";
+#endif
+
+	pr_info("Loading module...\n");
+
+	/* Register the device driver */
+	rcode = register_chrdev(dt_major, "dt3155", &dt3155_fops);
+	if (rcode < 0) {
+		pr_err("register_chrdev failed\n");
+		return rcode;
+	}
+
+	if (dt_major == 0)
+		dt_major = rcode;	/* dynamic */
+
+	/* init the status variables.                     */
+	/* DMA memory is taken care of in setup_buffers() */
+	for (index = 0; index < MAXBOARDS; index++) {
+		dt_status[index].config.acq_mode = DT3155_MODE_FRAME;
+		dt_status[index].config.continuous = DT3155_ACQ;
+		dt_status[index].config.cols = DT3155_MAX_COLS;
+		dt_status[index].config.rows = DT3155_MAX_ROWS;
+		dt_status[index].state = DT3155_STATE_IDLE;
+
+		/* find_PCI() will check if devices are installed; */
+		/* first assume they're not:                       */
+		dt_status[index].mem_addr = 0;
+		dt_status[index].mem_size = 0;
+		dt_status[index].state = DT3155_STATE_IDLE;
+		dt_status[index].device_installed = 0;
+	}
+
+	/* Now let's find the hardware.  find_PCI() will set ndevices to the
+	 * number of cards found in this machine. */
+	{
+		rcode = find_PCI();
+		if (rcode != DT_3155_SUCCESS) {
+			pr_err("find_PCI() failed to find dt3155 board(s)\n");
+			unregister_chrdev(dt_major, "dt3155");
+			return rcode;
+		}
+	}
+
+	/* Ok, time to setup the frame buffers */
+	rcode = dt3155_setup_buffers(&allocatorAddr);
+	if (rcode < 0) {
+		pr_err("setting up buffer not large enough\n");
+		unregister_chrdev(dt_major, "dt3155");
+		return rcode;
+	}
+
+	/* If we are this far, then there is enough RAM */
+	/* for the buffers: Print the configuration.    */
+	for (index = 0; index < ndevices; index++) {
+		pr_info("Device = %d; acq_mode = %d; continuous = %d; cols = %d; rows = %d\n",
+			index,
+			dt_status[index].config.acq_mode,
+			dt_status[index].config.continuous,
+			dt_status[index].config.cols,
+			dt_status[index].config.rows);
+		pr_info("m_addr = 0x%x; m_size = %ld; state = %d; device_installed = %d\n",
+			dt_status[index].mem_addr,
+			(long int)dt_status[index].mem_size,
+			dt_status[index].state,
+			dt_status[index].device_installed);
+	}
+
+	/* Disable ALL interrupts */
+	int_csr_r.reg = 0;
+	for (index = 0; index < ndevices; index++) {
+		WriteMReg((dt_lbase[index] + INT_CSR), int_csr_r.reg);
+		if (dt_status[index].device_installed) {
+			/*
+			 * This driver *looks* like it can handle sharing
+			 * interrupts, but I can't actually test myself.
+			 * I've had reports that it DOES work so I'll enable
+			 * it for now. This comment will remain as a reminder
+			 * in case any problems arise. (SS)
+			 */
+			/* in older kernels flags are:
+			 *   SA_SHIRQ | SA_INTERRUPT */
+			rcode = request_irq(dt_status[index].irq,
+					    (void *)dt3155_isr,
+					    IRQF_SHARED | IRQF_DISABLED,
+					    devname[index],
+					    (void *)&dt_status[index]);
+			if (rcode < 0) {
+				pr_err("minor %d request_irq failed for IRQ %d\n",
+				       index, dt_status[index].irq);
+				unregister_chrdev(dt_major, "dt3155");
+				return rcode;
+			}
+		}
+	}
+
+	pr_info("finished loading\n");
+
+	return 0;
+}
+
+/*****************************************************
+ * cleanup_module(void)
+ *
+ *****************************************************/
+void cleanup_module(void)
+{
+	int index;
+
+	pr_info("cleanup_module called\n");
+
+	/* removed DMA allocated with the allocator */
+#ifdef STANDALONE_ALLOCATOR
+	if (allocatorAddr != 0)
+		allocator_free_dma(allocatorAddr);
+#else
+	allocator_cleanup();
+#endif
+
+	unregister_chrdev(dt_major, "dt3155");
+
+	for (index = 0; index < ndevices; index++) {
+		if (dt_status[index].device_installed == 1) {
+			pr_info("Freeing irq %d for device %d\n",
+				dt_status[index].irq, index);
+			free_irq(dt_status[index].irq,
+				 (void *)&dt_status[index]);
+		}
+	}
+}
-- 
1.7.0.14.g7e948


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/3] drivers/staging/dt3155/allocator: sparse cleanups
  2010-03-29  7:34   ` [PATCH 0/3] drivers/staging/dt3155: Large cleanups Joe Perches
  2010-03-29  7:34     ` [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file Joe Perches
@ 2010-03-29  7:34     ` Joe Perches
  2010-03-29  7:34     ` [PATCH 3/3] drivers/staging/dt3155: Remove old files Joe Perches
  2 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2010-03-29  7:34 UTC (permalink / raw)
  To: devel
  Cc: Simon Horman, Jason Baldus, Greg KH, Scott Smedley,
	Harley Sweeten, linux-kernel

Make prototypes match implementation
Use gfp_t flags not int prio

Still a couple of sparse warnings left

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/staging/dt3155/allocator.c |   15 ++++++++-------
 drivers/staging/dt3155/allocator.h |    4 ++--
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dt3155/allocator.c b/drivers/staging/dt3155/allocator.c
index c74234c..217ddaa 100644
--- a/drivers/staging/dt3155/allocator.c
+++ b/drivers/staging/dt3155/allocator.c
@@ -58,6 +58,8 @@
 
 #include <asm/page.h>
 
+#include "allocator.h"
+
 /*#define ALL_DEBUG*/
 #define ALL_MSG "allocator: "
 
@@ -83,9 +85,9 @@
 /*#define PDEBUGG(fmt, args...) printk( KERN_DEBUG ALL_MSG fmt, ## args)*/
 
 
-int allocator_himem = 1; /* 0 = probe, pos. = megs, neg. = disable   */
-int allocator_step = 1;  /* This is the step size in MB              */
-int allocator_probe = 1; /* This is a flag -- 1=probe, 0=don't probe */
+static int allocator_himem = 1; /* 0 = probe, pos. = megs, neg. = disable   */
+static int allocator_step = 1;  /* This is the step size in MB              */
+static int allocator_probe = 1; /* This is a flag -- 1=probe, 0=don't probe */
 
 static unsigned long allocator_buffer;		/* physical address */
 static unsigned long allocator_buffer_size;	/* kilobytes */
@@ -101,8 +103,7 @@ struct allocator_struct {
 	struct allocator_struct *next;
 };
 
-struct allocator_struct *allocator_list;
-
+static struct allocator_struct *allocator_list;
 
 #ifdef ALL_DEBUG
 static int dump_list(void)
@@ -124,7 +125,7 @@ static int dump_list(void)
  * be used straight ahead for DMA, but needs remapping for program use).
  */
 
-unsigned long allocator_allocate_dma(unsigned long kilobytes, int prio)
+unsigned long allocator_allocate_dma(unsigned long kilobytes, gfp_t flags)
 {
 	struct allocator_struct *ptr = allocator_list, *newptr;
 	unsigned long bytes = kilobytes << 10;
@@ -147,7 +148,7 @@ unsigned long allocator_allocate_dma(unsigned long kilobytes, int prio)
 		PDEBUG("alloc failed\n");
 		return 0; /* end of list */
 	}
-	newptr = kmalloc(sizeof(struct allocator_struct), prio);
+	newptr = kmalloc(sizeof(struct allocator_struct), flags);
 	if (!newptr)
 		return 0;
 
diff --git a/drivers/staging/dt3155/allocator.h b/drivers/staging/dt3155/allocator.h
index bdf3268..425b70f 100644
--- a/drivers/staging/dt3155/allocator.h
+++ b/drivers/staging/dt3155/allocator.h
@@ -22,7 +22,7 @@
  *
  */
 
-void allocator_free_dma(unsigned long address);
-unsigned long allocator_allocate_dma(unsigned long kilobytes, int priority);
+int allocator_free_dma(unsigned long address);
+unsigned long allocator_allocate_dma(unsigned long kilobytes, gfp_t flags);
 int allocator_init(u32 *);
 void allocator_cleanup(void);
-- 
1.7.0.14.g7e948


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/3] drivers/staging/dt3155: Remove old files
  2010-03-29  7:34   ` [PATCH 0/3] drivers/staging/dt3155: Large cleanups Joe Perches
  2010-03-29  7:34     ` [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file Joe Perches
  2010-03-29  7:34     ` [PATCH 2/3] drivers/staging/dt3155/allocator: sparse cleanups Joe Perches
@ 2010-03-29  7:34     ` Joe Perches
  2 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2010-03-29  7:34 UTC (permalink / raw)
  To: devel
  Cc: Simon Horman, Jason Baldus, Greg KH, Scott Smedley,
	Harley Sweeten, linux-kernel

That have been integrated into dt3155_main.c

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/staging/dt3155/dt3155_drv.c | 1095 -----------------------------------
 drivers/staging/dt3155/dt3155_drv.h |   45 --
 drivers/staging/dt3155/dt3155_io.c  |  175 ------
 drivers/staging/dt3155/dt3155_isr.c |  516 -----------------
 drivers/staging/dt3155/dt3155_isr.h |   77 ---
 5 files changed, 0 insertions(+), 1908 deletions(-)
 delete mode 100644 drivers/staging/dt3155/dt3155_drv.c
 delete mode 100644 drivers/staging/dt3155/dt3155_drv.h
 delete mode 100644 drivers/staging/dt3155/dt3155_io.c
 delete mode 100644 drivers/staging/dt3155/dt3155_isr.c
 delete mode 100644 drivers/staging/dt3155/dt3155_isr.h

diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
deleted file mode 100644
index a67c622..0000000
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ /dev/null
@@ -1,1095 +0,0 @@
-/*
-
-Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
-                         Jason Lapenta, Scott Smedley, Greg Sharp
-
-This file is part of the DT3155 Device Driver.
-
-The DT3155 Device Driver is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The DT3155 Device Driver is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the DT3155 Device Driver; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA
-
--- Changes --
-
-  Date     Programmer	Description of changes made
-  -------------------------------------------------------------------
-  03-Jul-2000 JML       n/a
-  10-Oct-2001 SS        port to 2.4 kernel
-  02-Apr-2002 SS        Mods to use allocator as a standalone module;
-                        Merged John Roll's changes (john@cfa.harvard.edu)
-                        to make work with multiple boards.
-  02-Jul-2002 SS        Merged James Rose's chages (rosejr@purdue.edu) to:
-                         * fix successive interrupt-driven captures
-                         * add select/poll support.
-  10-Jul-2002 GCS       Add error check when ndevices > MAXBOARDS.
-  02-Aug-2002 GCS       Fix field mode so that odd (lower) field is stored
-                        in lower half of buffer.
-  05-Aug-2005 SS        port to 2.6 kernel.
-  26-Oct-2009 SS	port to 2.6.30 kernel.
-
--- Notes --
-
-** appended "mem=124" in lilo.conf to allow for 4megs free on my 128meg system.
- * using allocator.c and allocator.h from o'reilly book (alessandro rubini)
-    ftp://ftp.systemy.it/pub/develop (see README.allocator)
-
- + might want to get rid of MAXboards for allocating initial buffer.
-    confusing and not necessary
-
- + in cleanup_module the MOD_IN_USE looks like it is check after it should
-
- * GFP_DMA should not be set with a PCI system (pg 291)
-
- - NJC why are only two buffers allowed? (see isr, approx line 358)
-
-*/
-
-extern void printques(int);
-
-#ifdef MODULE
-#include <linux/module.h>
-#include <linux/interrupt.h>
-
-
-MODULE_LICENSE("GPL");
-
-#endif
-
-#ifndef CONFIG_PCI
-#error  "DT3155 :  Kernel PCI support not enabled (DT3155 drive requires PCI)"
-#endif
-
-#include <linux/pci.h>
-#include <linux/types.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#include "dt3155.h"
-#include "dt3155_drv.h"
-#include "dt3155_isr.h"
-#include "dt3155_io.h"
-#include "allocator.h"
-
-/* Error variable.  Zero means no error. */
-int dt3155_errno = 0;
-
-#ifndef PCI_DEVICE_ID_INTEL_7116
-#define PCI_DEVICE_ID_INTEL_7116 0x1223
-#endif
-
-#define DT3155_VENDORID    PCI_VENDOR_ID_INTEL
-#define DT3155_DEVICEID    PCI_DEVICE_ID_INTEL_7116
-#define MAXPCI    16
-
-#ifdef DT_DEBUG
-#define DT_3155_DEBUG_MSG(x,y) printk(x,y)
-#else
-#define DT_3155_DEBUG_MSG(x,y)
-#endif
-
-/* wait queue for interrupts */
-wait_queue_head_t dt3155_read_wait_queue[ MAXBOARDS ];
-
-#define DT_3155_SUCCESS 0
-#define DT_3155_FAILURE -EIO
-
-/* set to dynamicaly allocate, but it is tunable: */
-/* insmod DT_3155 dt3155 dt3155_major=XX */
-int dt3155_major = 0;
-
-/* The minor numbers are 0 and 1 ... they are not tunable.
- * They are used as the indices for the structure vectors,
- * and register address vectors
- */
-
-/* Global structures and variables */
-
-/* Status of each device */
-struct dt3155_status_s dt3155_status[ MAXBOARDS ];
-
-/* kernel logical address of the board */
-u8 *dt3155_lbase[ MAXBOARDS ] = { NULL
-#if MAXBOARDS == 2
-				      , NULL
-#endif
-};
-/* DT3155 registers              */
-u8 *dt3155_bbase = NULL;		  /* kernel logical address of the *
-					   * buffer region                 */
-u32  dt3155_dev_open[ MAXBOARDS ] = {0
-#if MAXBOARDS == 2
-				       , 0
-#endif
-};
-
-u32  ndevices = 0;
-u32 unique_tag = 0;;
-
-
-/*
- * Stops interrupt generation right away and resets the status
- * to idle.  I don't know why this works and the other way doesn't.
- * (James Rose)
- */
-static void quick_stop (int minor)
-{
-  // TODO: scott was here
-#if 1
-  ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
-  /* disable interrupts */
-  int_csr_r.fld.FLD_END_EVE_EN = 0;
-  int_csr_r.fld.FLD_END_ODD_EN = 0;
-  WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
-
-  dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff);
-  /* mark the system stopped: */
-  dt3155_status[ minor ].state |= DT3155_STATE_IDLE;
-  dt3155_fbuffer[ minor ]->stop_acquire = 0;
-  dt3155_fbuffer[ minor ]->even_stopped = 0;
-#else
-  dt3155_status[minor].state |= DT3155_STATE_STOP;
-  dt3155_status[minor].fbuffer.stop_acquire = 1;
-#endif
-
-}
-
-
-/*****************************************************
- *  dt3155_isr() Interrupt service routien
- *
- * - looks like this isr supports IRQ sharing (or could) JML
- * - Assumes irq's are disabled, via SA_INTERRUPT flag
- * being set in request_irq() call from init_module()
- *****************************************************/
-static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs )
-{
-  int    minor = -1;
-  int    index;
-  unsigned long flags;
-  u32 buffer_addr;
-
-  /* find out who issued the interrupt */
-  for ( index = 0; index < ndevices; index++ ) {
-    if( dev_id == (void*) &dt3155_status[ index ])
-      {
-	minor = index;
-	break;
-      }
-  }
-
-  /* hopefully we should not get here */
-  if ( minor < 0 || minor >= MAXBOARDS ) {
-    printk(KERN_ERR "dt3155_isr called with invalid dev_id\n");
-    return;
-  }
-
-  /* Check for corruption and set a flag if so */
-  ReadMReg( (dt3155_lbase[ minor ] + CSR1), csr1_r.reg );
-
-  if ( (csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD) )
-    {
-      /* TODO: this should probably stop acquisition */
-      /* and set some flags so that dt3155_read      */
-      /* returns an error next time it is called     */
-      dt3155_errno = DT_ERR_CORRUPT;
-      printk("dt3155:  corrupt field\n");
-      return;
-    }
-
-  ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
-
-  /* Handle the even field ... */
-  if (int_csr_r.fld.FLD_END_EVE)
-    {
-      if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	   DT3155_STATE_FLD )
-	{
-	  dt3155_fbuffer[ minor ]->frame_count++;
-	}
-
-      ReadI2C(dt3155_lbase[ minor ], EVEN_CSR, &i2c_even_csr.reg);
-
-      /* Clear the interrupt? */
-      int_csr_r.fld.FLD_END_EVE = 1;
-
-      /* disable the interrupt if last field */
-      if (dt3155_fbuffer[ minor ]->stop_acquire)
-	{
-	  printk("dt3155:  even stopped.\n");
-	  dt3155_fbuffer[ minor ]->even_stopped = 1;
-	  if (i2c_even_csr.fld.SNGL_EVE)
-	    {
-	      int_csr_r.fld.FLD_END_EVE_EN = 0;
-	    }
-	  else
-	    {
-	      i2c_even_csr.fld.SNGL_EVE  = 1;
-	    }
-	}
-
-      WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
-
-      /* Set up next DMA if we are doing FIELDS */
-      if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE ) ==
-	   DT3155_STATE_FLD)
-	{
-	  /* GCS (Aug 2, 2002) -- In field mode, dma the odd field
-	     into the lower half of the buffer */
-	  const u32 stride =  dt3155_status[ minor ].config.cols;
-	  buffer_addr = dt3155_fbuffer[ minor ]->
-	    frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr
-	    + (DT3155_MAX_ROWS / 2) * stride;
-	  local_save_flags(flags);
-	  local_irq_disable();
-	  wake_up_interruptible( &dt3155_read_wait_queue[ minor ] );
-
-	  /* Set up the DMA address for the next field */
-	  local_irq_restore(flags);
-	  WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr);
-	}
-
-      /* Check for errors. */
-      i2c_even_csr.fld.DONE_EVE = 1;
-      if ( i2c_even_csr.fld.ERROR_EVE )
-	dt3155_errno = DT_ERR_OVERRUN;
-
-      WriteI2C( dt3155_lbase[ minor ], EVEN_CSR, i2c_even_csr.reg );
-
-      /* Note that we actually saw an even field meaning  */
-      /* that subsequent odd field complete the frame     */
-      dt3155_fbuffer[ minor ]->even_happened = 1;
-
-      /* recording the time that the even field finished, this should be */
-      /* about time in the middle of the frame */
-      do_gettimeofday( &(dt3155_fbuffer[ minor ]->
-			 frame_info[ dt3155_fbuffer[ minor ]->
-				     active_buf ].time) );
-      return;
-    }
-
-  /* ... now handle the odd field */
-  if ( int_csr_r.fld.FLD_END_ODD )
-    {
-      ReadI2C( dt3155_lbase[ minor ], ODD_CSR, &i2c_odd_csr.reg );
-
-      /* Clear the interrupt? */
-      int_csr_r.fld.FLD_END_ODD = 1;
-
-      if (dt3155_fbuffer[ minor ]->even_happened ||
-	  (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	  DT3155_STATE_FLD)
-	{
-	  dt3155_fbuffer[ minor ]->frame_count++;
-	}
-
-      if ( dt3155_fbuffer[ minor ]->stop_acquire &&
-	   dt3155_fbuffer[ minor ]->even_stopped )
-	{
-	  printk(KERN_DEBUG "dt3155:  stopping odd..\n");
-	  if ( i2c_odd_csr.fld.SNGL_ODD )
-	    {
-	      /* disable interrupts */
-	      int_csr_r.fld.FLD_END_ODD_EN = 0;
-	      dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff);
-
-	      /* mark the system stopped: */
-	      dt3155_status[ minor ].state |= DT3155_STATE_IDLE;
-	      dt3155_fbuffer[ minor ]->stop_acquire = 0;
-	      dt3155_fbuffer[ minor ]->even_stopped = 0;
-
-	      printk(KERN_DEBUG "dt3155:  state is now %x\n",
-		     dt3155_status[minor].state);
-	    }
-	  else
-	    {
-	      i2c_odd_csr.fld.SNGL_ODD  = 1;
-	    }
-	}
-
-      WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
-
-      /* if the odd field has been acquired, then     */
-      /* change the next dma location for both fields */
-      /* and wake up the process if sleeping          */
-      if ( dt3155_fbuffer[ minor ]->even_happened ||
-	   (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	   DT3155_STATE_FLD )
-	{
-
-	  local_save_flags(flags);
-	  local_irq_disable();
-
-#ifdef DEBUG_QUES_B
-	  printques( minor );
-#endif
-	  if ( dt3155_fbuffer[ minor ]->nbuffers > 2 )
-	    {
-	      if ( !are_empty_buffers( minor ) )
-		{
-		  /* The number of active + locked buffers is
-		   * at most 2, and since there are none empty, there
-		   * must be at least nbuffers-2 ready buffers.
-		   * This is where we 'drop frames', oldest first. */
-		  push_empty( pop_ready( minor ),  minor );
-		}
-
-	      /* The ready_que can't be full, since we know
-	       * there is one active buffer right now, so it's safe
-	       * to push the active buf on the ready_que. */
-	      push_ready( minor, dt3155_fbuffer[ minor ]->active_buf );
-	      /* There's at least 1 empty -- make it active */
-	      dt3155_fbuffer[ minor ]->active_buf = pop_empty( minor );
-	      dt3155_fbuffer[ minor ]->
-		frame_info[ dt3155_fbuffer[ minor ]->
-			    active_buf ].tag = ++unique_tag;
-	    }
-	  else /* nbuffers == 2, special case */
-	    { /* There is 1 active buffer.
-	       * If there is a locked buffer, keep the active buffer
-	       * the same -- that means we drop a frame.
-	       */
-	      if ( dt3155_fbuffer[ minor ]->locked_buf < 0 )
-		{
-		  push_ready( minor,
-			      dt3155_fbuffer[ minor ]->active_buf );
-		  if (are_empty_buffers( minor ) )
-		    {
-		      dt3155_fbuffer[ minor ]->active_buf =
-			pop_empty( minor );
-		    }
-		  else
-		    { /* no empty or locked buffers, so use a readybuf */
-		      dt3155_fbuffer[ minor ]->active_buf =
-			pop_ready( minor );
-		    }
-		}
-	    }
-
-#ifdef DEBUG_QUES_B
-	  printques( minor );
-#endif
-
-	  dt3155_fbuffer[ minor ]->even_happened = 0;
-
-	  wake_up_interruptible( &dt3155_read_wait_queue[ minor ] );
-
-	  local_irq_restore(flags);
-	}
-
-
-      /* Set up the DMA address for the next frame/field */
-      buffer_addr = dt3155_fbuffer[ minor ]->
-	frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr;
-      if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) ==
-	   DT3155_STATE_FLD )
-	{
-	  WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr);
-	}
-      else
-	{
-	  WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr);
-
-	  WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr
-		    + dt3155_status[ minor ].config.cols);
-	}
-
-      /* Do error checking */
-      i2c_odd_csr.fld.DONE_ODD = 1;
-      if ( i2c_odd_csr.fld.ERROR_ODD )
-	dt3155_errno = DT_ERR_OVERRUN;
-
-      WriteI2C(dt3155_lbase[ minor ], ODD_CSR, i2c_odd_csr.reg );
-
-      return;
-    }
-  /* If we get here, the Odd Field wasn't it either... */
-  printk( "neither even nor odd.  shared perhaps?\n");
-}
-
-/*****************************************************
- * init_isr(int minor)
- *   turns on interupt generation for the card
- *   designated by "minor".
- *   It is called *only* from inside ioctl().
- *****************************************************/
-static void dt3155_init_isr(int minor)
-{
-  const u32 stride =  dt3155_status[ minor ].config.cols;
-
-  switch (dt3155_status[ minor ].state & DT3155_STATE_MODE)
-    {
-    case DT3155_STATE_FLD:
-      {
-	even_dma_start_r  = dt3155_status[ minor ].
-	  fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr;
-	even_dma_stride_r = 0;
-	odd_dma_stride_r  = 0;
-
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START),
-		  even_dma_start_r);
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE),
-		  even_dma_stride_r);
-	WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE),
-		  odd_dma_stride_r);
-	break;
-      }
-
-    case DT3155_STATE_FRAME:
-    default:
-      {
-	even_dma_start_r  = dt3155_status[ minor ].
-	  fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr;
-	odd_dma_start_r   =  even_dma_start_r + stride;
-	even_dma_stride_r =  stride;
-	odd_dma_stride_r  =  stride;
-
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START),
-		  even_dma_start_r);
-	WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START),
-		  odd_dma_start_r);
-	WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE),
-		  even_dma_stride_r);
-	WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE),
-		  odd_dma_stride_r);
-	break;
-      }
-    }
-
-  /* 50/60 Hz should be set before this point but let's make sure it is */
-  /* right anyway */
-
-  ReadI2C(dt3155_lbase[ minor ], CONFIG, &i2c_csr2.reg);
-  i2c_csr2.fld.HZ50 = FORMAT50HZ;
-  WriteI2C(dt3155_lbase[ minor ], CONFIG, i2c_config.reg);
-
-  /* enable busmaster chip, clear flags */
-
-  /*
-   * TODO:
-   * shouldn't we be concered with continuous values of
-   * DT3155_SNAP & DT3155_ACQ here? (SS)
-   */
-
-  csr1_r.reg                = 0;
-  csr1_r.fld.CAP_CONT_EVE   = 1; /* use continuous capture bits to */
-  csr1_r.fld.CAP_CONT_ODD   = 1; /* enable */
-  csr1_r.fld.FLD_DN_EVE     = 1; /* writing a 1 clears flags */
-  csr1_r.fld.FLD_DN_ODD     = 1;
-  csr1_r.fld.SRST           = 1; /* reset        - must be 1 */
-  csr1_r.fld.FIFO_EN        = 1; /* fifo control - must be 1 */
-  csr1_r.fld.FLD_CRPT_EVE   = 1; /* writing a 1 clears flags */
-  csr1_r.fld.FLD_CRPT_ODD   = 1;
-
-  WriteMReg((dt3155_lbase[ minor ] + CSR1),csr1_r.reg);
-
-  /* Enable interrupts at the end of each field */
-
-  int_csr_r.reg = 0;
-  int_csr_r.fld.FLD_END_EVE_EN = 1;
-  int_csr_r.fld.FLD_END_ODD_EN = 1;
-  int_csr_r.fld.FLD_START_EN = 0;
-
-  WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg);
-
-  /* start internal BUSY bits */
-
-  ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg);
-  i2c_csr2.fld.BUSY_ODD  = 1;
-  i2c_csr2.fld.BUSY_EVE  = 1;
-  WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg);
-
-  /* Now its up to the interrupt routine!! */
-
-  return;
-}
-
-
-/*****************************************************
- * ioctl()
- *
- *****************************************************/
-static int dt3155_ioctl(struct inode *inode,
-			struct file *file,
-			unsigned int cmd,
-			unsigned long arg)
-{
-  int minor = MINOR(inode->i_rdev); /* What device are we ioctl()'ing? */
-
-  if ( minor >= MAXBOARDS || minor < 0 )
-    return -ENODEV;
-
-  /* make sure it is valid command */
-  if (_IOC_NR(cmd) > DT3155_IOC_MAXNR)
-    {
-      printk("DT3155: invalid IOCTL(0x%x)\n",cmd);
-      printk("DT3155: Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
-	     (unsigned int)DT3155_GET_CONFIG,
-	     (unsigned int)DT3155_SET_CONFIG,
-	     (unsigned int)DT3155_START,
-	     (unsigned int)DT3155_STOP,
-	     (unsigned int)DT3155_FLUSH);
-      return -EINVAL;
-    }
-
-  switch (cmd)
-    {
-    case DT3155_SET_CONFIG:
-      {
-	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
-	  return -EBUSY;
-
-	{
-	  struct dt3155_config_s tmp;
-	  if (copy_from_user((void *)&tmp, (void *) arg, sizeof(tmp)))
-	      return -EFAULT;
-	  /* check for valid settings */
-	  if (tmp.rows > DT3155_MAX_ROWS ||
-	      tmp.cols > DT3155_MAX_COLS ||
-	      (tmp.acq_mode != DT3155_MODE_FRAME &&
-	       tmp.acq_mode != DT3155_MODE_FIELD) ||
-	      (tmp.continuous != DT3155_SNAP &&
-	       tmp.continuous != DT3155_ACQ))
-	    {
-	      return -EINVAL;
-	    }
-	  dt3155_status[minor].config = tmp;
-	}
-	return 0;
-      }
-    case DT3155_GET_CONFIG:
-      {
-	if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
-		     sizeof(dt3155_status_t) ))
-	    return -EFAULT;
-	return 0;
-      }
-    case DT3155_FLUSH: /* Flushes the buffers -- ensures fresh data */
-      {
-	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
-	  return -EBUSY;
-	return dt3155_flush(minor);
-      }
-    case DT3155_STOP:
-      {
-	if (dt3155_status[minor].state & DT3155_STATE_STOP ||
-	    dt3155_status[minor].fbuffer.stop_acquire)
-	  return -EBUSY;
-
-	if (dt3155_status[minor].state == DT3155_STATE_IDLE)
-	  return 0;
-
-	quick_stop(minor);
-	if (copy_to_user((void *) arg, (void *) &dt3155_status[minor],
-		     sizeof(dt3155_status_t)))
-	    return -EFAULT;
-	return 0;
-      }
-    case DT3155_START:
-      {
-	if (dt3155_status[minor].state != DT3155_STATE_IDLE)
-	  return -EBUSY;
-
-	dt3155_status[minor].fbuffer.stop_acquire = 0;
-	dt3155_status[minor].fbuffer.frame_count = 0;
-
-	/* Set the MODE in the status -- we default to FRAME */
-	if (dt3155_status[minor].config.acq_mode == DT3155_MODE_FIELD)
-	  {
-	    dt3155_status[minor].state = DT3155_STATE_FLD;
-	  }
-	else
-	  {
-	    dt3155_status[minor].state = DT3155_STATE_FRAME;
-	  }
-
-	dt3155_init_isr(minor);
-	if (copy_to_user( (void *) arg, (void *) &dt3155_status[minor],
-		      sizeof(dt3155_status_t)))
-	    return -EFAULT;
-	return 0;
-      }
-    default:
-      {
-	printk("DT3155: invalid IOCTL(0x%x)\n",cmd);
-      printk("DT3155: Valid commands (0x%x), (0x%x), (0x%x), (0x%x), (0x%x)\n",
-	     (unsigned int)DT3155_GET_CONFIG,
-	     (unsigned int)DT3155_SET_CONFIG,
-	     DT3155_START, DT3155_STOP, DT3155_FLUSH);
-	return -ENOSYS;
-      }
-    }
-  return -ENOSYS;
-}
-
-/*****************************************************
- * mmap()
- *
- * only allow the user to mmap the registers and buffer
- * It is quite possible that this is broken, since the
- * addition of of the capacity for two cards!!!!!!!!
- * It *looks* like it should work but since I'm not
- * sure how to use it, I'm not actually sure. (NJC? ditto by SS)
- *****************************************************/
-static int dt3155_mmap (struct file * file, struct vm_area_struct * vma)
-{
-  /* which device are we mmapping? */
-  int				minor = MINOR(file->f_dentry->d_inode->i_rdev);
-  unsigned long	offset;
-  offset = vma->vm_pgoff << PAGE_SHIFT;
-
-  if (offset >= __pa(high_memory) || (file->f_flags & O_SYNC))
-    vma->vm_flags |= VM_IO;
-
-  /* Don't try to swap out physical pages.. */
-  vma->vm_flags |= VM_RESERVED;
-
-  /* they are mapping the registers or the buffer */
-  if ((offset == dt3155_status[minor].reg_addr &&
-       vma->vm_end - vma->vm_start == PCI_PAGE_SIZE) ||
-      (offset == dt3155_status[minor].mem_addr &&
-       vma->vm_end - vma->vm_start == dt3155_status[minor].mem_size))
-    {
-      if (remap_pfn_range(vma,
-			vma->vm_start,
-			offset >> PAGE_SHIFT,
-			vma->vm_end - vma->vm_start,
-			vma->vm_page_prot)) {
-	  printk("DT3155: remap_page_range() failed.\n");
-	  return -EAGAIN;
-	}
-    }
-  else
-    {
-      printk("DT3155: dt3155_mmap() bad call.\n");
-      return -ENXIO;
-    }
-
-  return 0;
-}
-
-
-/*****************************************************
- * open()
- *
- * Our special open code.
- * MOD_INC_USE_COUNT make sure that the driver memory is not freed
- * while the device is in use.
- *****************************************************/
-static int dt3155_open( struct inode* inode, struct file* filep)
-{
-  int minor = MINOR(inode->i_rdev); /* what device are we opening? */
-  if (dt3155_dev_open[ minor ]) {
-    printk ("DT3155:  Already opened by another process.\n");
-    return -EBUSY;
-  }
-
-  if (dt3155_status[ minor ].device_installed==0)
-    {
-      printk("DT3155 Open Error: No such device dt3155 minor number %d\n",
-	     minor);
-      return -EIO;
-    }
-
-  if (dt3155_status[ minor ].state != DT3155_STATE_IDLE) {
-    printk ("DT3155:  Not in idle state (state = %x)\n",
-	    dt3155_status[ minor ].state);
-    return -EBUSY;
-  }
-
-  printk("DT3155: Device opened.\n");
-
-  dt3155_dev_open[ minor ] = 1 ;
-
-  dt3155_flush( minor );
-
-  /* Disable ALL interrupts */
-  int_csr_r.reg = 0;
-  WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg );
-
-  init_waitqueue_head(&(dt3155_read_wait_queue[minor]));
-
-  return 0;
-}
-
-
-/*****************************************************
- * close()
- *
- * Now decrement the use count.
- *
- *****************************************************/
-static int dt3155_close( struct inode *inode, struct file *filep)
-{
-  int minor;
-
-  minor = MINOR(inode->i_rdev); /* which device are we closing */
-  if (!dt3155_dev_open[ minor ])
-    {
-      printk("DT3155: attempt to CLOSE a not OPEN device\n");
-    }
-  else
-    {
-      dt3155_dev_open[ minor ] = 0;
-
-      if (dt3155_status[ minor ].state != DT3155_STATE_IDLE)
-	{
-	  quick_stop(minor);
-	}
-    }
-  return 0;
-}
-
-/*****************************************************
- * read()
- *
- *****************************************************/
-static ssize_t dt3155_read(struct file *filep, char __user *buf,
-			   size_t count, loff_t *ppos)
-{
-  /* which device are we reading from? */
-  int		minor = MINOR(filep->f_dentry->d_inode->i_rdev);
-  u32		offset;
-  int		frame_index;
-  frame_info_t	*frame_info_p;
-
-  /* TODO: this should check the error flag and */
-  /*   return an error on hardware failures */
-  if (count != sizeof(dt3155_read_t))
-    {
-      printk("DT3155 ERROR (NJC): count is not right\n");
-      return -EINVAL;
-    }
-
-
-  /* Hack here -- I'm going to allow reading even when idle.
-   * this is so that the frames can be read after STOP has
-   * been called.  Leaving it here, commented out, as a reminder
-   * for a short while to make sure there are no problems.
-   * Note that if the driver is not opened in non_blocking mode,
-   * and the device is idle, then it could sit here forever! */
-
-  /*  if (dt3155_status[minor].state == DT3155_STATE_IDLE)*/
-  /*    return -EBUSY;*/
-
-  /* non-blocking reads should return if no data */
-  if (filep->f_flags & O_NDELAY)
-    {
-      if ((frame_index = dt3155_get_ready_buffer(minor)) < 0) {
-	/*printk( "dt3155:  no buffers available (?)\n");*/
-	/* 		printques(minor); */
-	return -EAGAIN;
-      }
-    }
-  else
-    {
-      /*
-       * sleep till data arrives , or we get interrupted.
-       * Note that wait_event_interruptible() does not actually
-       * sleep/wait if it's condition evaluates to true upon entry.
-       */
-      wait_event_interruptible(dt3155_read_wait_queue[minor],
-			       (frame_index = dt3155_get_ready_buffer(minor))
-			       >= 0);
-
-      if (frame_index < 0)
-	{
-	  printk ("DT3155: read: interrupted\n");
-	  quick_stop (minor);
-	  printques(minor);
-	  return -EINTR;
-	}
-    }
-
-  frame_info_p = &dt3155_status[minor].fbuffer.frame_info[frame_index];
-
-  /* make this an offset */
-  offset = frame_info_p->addr - dt3155_status[minor].mem_addr;
-
-  put_user(offset, (unsigned int *) buf);
-  buf += sizeof(u32);
-  put_user( dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf);
-  buf += sizeof(u32);
-  put_user(dt3155_status[minor].state, (unsigned int *) buf);
-  buf += sizeof(u32);
-  if (copy_to_user(buf, frame_info_p, sizeof(frame_info_t)))
-      return -EFAULT;
-
-  return sizeof(dt3155_read_t);
-}
-
-static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
-{
-  int minor = MINOR(filp->f_dentry->d_inode->i_rdev);
-
-  if (!is_ready_buf_empty(minor))
-    return POLLIN | POLLRDNORM;
-
-  poll_wait (filp, &dt3155_read_wait_queue[minor], wait);
-
-  return 0;
-}
-
-
-/*****************************************************
- * file operations supported by DT3155 driver
- *  needed by init_module
- *  register_chrdev
- *****************************************************/
-static struct file_operations dt3155_fops = {
-  read:		dt3155_read,
-  ioctl:		dt3155_ioctl,
-  mmap:		dt3155_mmap,
-  poll:           dt3155_poll,
-  open:		dt3155_open,
-  release:	dt3155_close
-};
-
-
-/*****************************************************
- * find_PCI();
- *
- * PCI has been totally reworked in 2.1..
- *****************************************************/
-static int find_PCI (void)
-{
-  struct pci_dev *pci_dev = NULL;
-  int error, pci_index = 0;
-  unsigned short rev_device;
-  unsigned long base;
-  unsigned char irq;
-
-  while ((pci_dev = pci_get_device
-	  (DT3155_VENDORID, DT3155_DEVICEID, pci_dev)) != NULL)
-    {
-      pci_index ++;
-
-      /* Is it really there? */
-      if ((error =
-	   pci_read_config_word(pci_dev, PCI_CLASS_DEVICE, &rev_device)))
-	continue;
-
-      /* Found a board */
-      DT_3155_DEBUG_MSG("DT3155: Device number %d \n", pci_index);
-
-      /* Make sure the driver was compiled with enough buffers to handle
-	 this many boards */
-      if (pci_index > MAXBOARDS) {
-	printk("DT3155: ERROR - found %d devices, but driver only configured "
-	       "for %d devices\n"
-	       "DT3155: Please change MAXBOARDS in dt3155.h\n",
-	       pci_index, MAXBOARDS);
-	goto err;
-      }
-
-      /* Now, just go out and make sure that this/these device(s) is/are
-	 actually mapped into the kernel address space */
-      if ((error = pci_read_config_dword( pci_dev, PCI_BASE_ADDRESS_0,
-					  (u32 *) &base)))
-	{
-	  printk("DT3155: Was not able to find device \n");
-	  goto err;
-	}
-
-      DT_3155_DEBUG_MSG("DT3155: Base address 0 for device is %lx \n", base);
-      dt3155_status[pci_index-1].reg_addr = base;
-
-      /* Remap the base address to a logical address through which we
-       * can access it. */
-      dt3155_lbase[ pci_index - 1 ] = ioremap(base,PCI_PAGE_SIZE);
-      dt3155_status[ pci_index - 1 ].reg_addr = base;
-      DT_3155_DEBUG_MSG("DT3155: New logical address is %p \n",
-			dt3155_lbase[pci_index-1]);
-      if ( !dt3155_lbase[pci_index-1] )
-	{
-	  printk("DT3155: Unable to remap control registers\n");
-	  goto err;
-	}
-
-      if ( (error = pci_read_config_byte( pci_dev, PCI_INTERRUPT_LINE, &irq)) )
-	{
-	  printk("DT3155: Was not able to find device \n");
-	  goto err;
-	}
-
-      DT_3155_DEBUG_MSG("DT3155: IRQ is %d \n",irq);
-      dt3155_status[ pci_index-1 ].irq = irq;
-      /* Set flag: kth device found! */
-      dt3155_status[ pci_index-1 ].device_installed = 1;
-      printk("DT3155: Installing device %d w/irq %d and address %p\n",
-	     pci_index,
-	     dt3155_status[pci_index-1].irq,
-	     dt3155_lbase[pci_index-1]);
-
-    }
-  ndevices = pci_index;
-
-  return DT_3155_SUCCESS;
-
-err:
-  pci_dev_put(pci_dev);
-  return DT_3155_FAILURE;
-}
-
-u32 allocatorAddr = 0;
-
-/*****************************************************
- * init_module()
- *****************************************************/
-int init_module(void)
-{
-  int index;
-  int rcode = 0;
-  char *devname[ MAXBOARDS ];
-
-  devname[ 0 ] = "dt3155a";
-#if MAXBOARDS == 2
-  devname[ 1 ] = "dt3155b";
-#endif
-
-  printk("DT3155: Loading module...\n");
-
-  /* Register the device driver */
-  rcode = register_chrdev( dt3155_major, "dt3155", &dt3155_fops );
-  if( rcode < 0 )
-    {
-      printk( KERN_INFO "DT3155: register_chrdev failed \n");
-      return rcode;
-    }
-
-  if( dt3155_major == 0 )
-    dt3155_major = rcode; /* dynamic */
-
-
-  /* init the status variables.                     */
-  /* DMA memory is taken care of in setup_buffers() */
-  for ( index = 0; index < MAXBOARDS; index++ )
-    {
-      dt3155_status[ index ].config.acq_mode   = DT3155_MODE_FRAME;
-      dt3155_status[ index ].config.continuous = DT3155_ACQ;
-      dt3155_status[ index ].config.cols       = DT3155_MAX_COLS;
-      dt3155_status[ index ].config.rows       = DT3155_MAX_ROWS;
-      dt3155_status[ index ].state = DT3155_STATE_IDLE;
-
-      /* find_PCI() will check if devices are installed; */
-      /* first assume they're not:                       */
-      dt3155_status[ index ].mem_addr          = 0;
-      dt3155_status[ index ].mem_size          = 0;
-      dt3155_status[ index ].state             = DT3155_STATE_IDLE;
-      dt3155_status[ index ].device_installed  = 0;
-    }
-
-  /* Now let's find the hardware.  find_PCI() will set ndevices to the
-   * number of cards found in this machine. */
-    {
-      if ( (rcode = find_PCI()) !=  DT_3155_SUCCESS )
-	{
-	  printk("DT3155 error: find_PCI() failed to find dt3155 board(s)\n");
-	  unregister_chrdev( dt3155_major, "dt3155" );
-	  return rcode;
-	}
-    }
-
-  /* Ok, time to setup the frame buffers */
-  if( (rcode = dt3155_setup_buffers(&allocatorAddr)) < 0 )
-    {
-      printk("DT3155: Error: setting up buffer not large enough.");
-      unregister_chrdev( dt3155_major, "dt3155" );
-      return rcode;
-    }
-
-  /* If we are this far, then there is enough RAM */
-  /* for the buffers: Print the configuration.    */
-  for(  index = 0;  index < ndevices;  index++ )
-    {
-      printk("DT3155: Device = %d; acq_mode = %d; "
-	     "continuous = %d; cols = %d; rows = %d;\n",
-	     index ,
-	     dt3155_status[ index ].config.acq_mode,
-	     dt3155_status[ index ].config.continuous,
-	     dt3155_status[ index ].config.cols,
-	     dt3155_status[ index ].config.rows);
-      printk("DT3155: m_addr = 0x%x; m_size = %ld; "
-	     "state = %d; device_installed = %d\n",
-	     dt3155_status[ index ].mem_addr,
-	     (long int)dt3155_status[ index ].mem_size,
-	     dt3155_status[ index ].state,
-	     dt3155_status[ index ].device_installed);
-    }
-
-  /* Disable ALL interrupts */
-  int_csr_r.reg = 0;
-  for(  index = 0;  index < ndevices;  index++ )
-    {
-      WriteMReg( (dt3155_lbase[ index ] + INT_CSR), int_csr_r.reg );
-      if( dt3155_status[ index ].device_installed )
-	{
-	  /*
-	   * This driver *looks* like it can handle sharing interrupts,
-	   * but I can't actually test myself. I've had reports that it
-	   * DOES work so I'll enable it for now. This comment will remain
-	   * as a reminder in case any problems arise. (SS)
-	   */
-	  /* in older kernels flags are: SA_SHIRQ | SA_INTERRUPT */
-	  rcode = request_irq( dt3155_status[ index ].irq, (void *)dt3155_isr,
-			       IRQF_SHARED | IRQF_DISABLED, devname[ index ],
-			       (void*) &dt3155_status[index]);
-	  if( rcode < 0 )
-	    {
-	      printk("DT3155: minor %d request_irq failed for IRQ %d\n",
-		     index, dt3155_status[index].irq);
-	      unregister_chrdev( dt3155_major, "dt3155" );
-	      return rcode;
-	    }
-	}
-    }
-
-  printk("DT3155: finished loading\n");
-
-  return 0;
-}
-
-/*****************************************************
- * cleanup_module(void)
- *
- *****************************************************/
-void cleanup_module(void)
-{
-  int index;
-
-  printk("DT3155:  cleanup_module called\n");
-
-  /* removed DMA allocated with the allocator */
-#ifdef STANDALONE_ALLOCATOR
-  if (allocatorAddr != 0)
-    allocator_free_dma(allocatorAddr);
-#else
-  allocator_cleanup();
-#endif
-
-  unregister_chrdev( dt3155_major, "dt3155" );
-
-  for( index = 0; index < ndevices; index++ )
-    {
-      if( dt3155_status[ index ].device_installed == 1 )
-	{
-	  printk( "DT3155: Freeing irq %d for device %d\n",
-		  dt3155_status[ index ].irq, index );
-	  free_irq( dt3155_status[ index ].irq, (void*)&dt3155_status[index] );
-	}
-    }
-}
-
diff --git a/drivers/staging/dt3155/dt3155_drv.h b/drivers/staging/dt3155/dt3155_drv.h
deleted file mode 100644
index 95e68c3..0000000
--- a/drivers/staging/dt3155/dt3155_drv.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-
-Copyright 1996,2002 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
-		    Scott Smedley
-
-This file is part of the DT3155 Device Driver.
-
-The DT3155 Device Driver is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The DT3155 Device Driver is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the DT3155 Device Driver; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA
-*/
-
-#ifndef DT3155_DRV_INC
-#define DT3155_DRV_INC
-
-/* kernel logical address of the frame grabbers */
-extern u8 *dt3155_lbase[MAXBOARDS];
-
-/* kernel logical address of ram buffer */
-extern u8 *dt3155_bbase;
-
-#ifdef __KERNEL__
-#include <linux/wait.h>
-
-/* wait queue for reads */
-extern wait_queue_head_t dt3155_read_wait_queue[MAXBOARDS];
-#endif
-
-/* number of devices */
-extern u32 ndevices;
-
-extern int dt3155_errno;
-
-#endif
diff --git a/drivers/staging/dt3155/dt3155_io.c b/drivers/staging/dt3155/dt3155_io.c
deleted file mode 100644
index 6b9c685..0000000
--- a/drivers/staging/dt3155/dt3155_io.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
- *			    Jason Lapenta, Scott Smedley
- *
- * This file is part of the DT3155 Device Driver.
- *
- * The DT3155 Device Driver is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * The DT3155 Device Driver is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
- * Public License for more details.
- */
-
-/*
- * This file provides some basic register io routines.  It is modified from
- * demo code provided by Data Translations.
- */
-
-#include <linux/delay.h>
-#include "dt3155.h"
-#include "dt3155_io.h"
-#include "dt3155_drv.h"
-
-
-/****** local copies of board's 32 bit registers ******/
-u32 even_dma_start_r;	/*  bit 0 should always be 0 */
-u32 odd_dma_start_r;	/*               .. */
-u32 even_dma_stride_r;	/*  bits 0&1 should always be 0 */
-u32 odd_dma_stride_r;	/*               .. */
-u32 even_pixel_fmt_r;
-u32 odd_pixel_fmt_r;
-
-FIFO_TRIGGER_R		fifo_trigger_r;
-XFER_MODE_R		xfer_mode_r;
-CSR1_R			csr1_r;
-RETRY_WAIT_CNT_R	retry_wait_cnt_r;
-INT_CSR_R		int_csr_r;
-
-u32 even_fld_mask_r;
-u32 odd_fld_mask_r;
-
-MASK_LENGTH_R		mask_length_r;
-FIFO_FLAG_CNT_R		fifo_flag_cnt_r;
-IIC_CLK_DUR_R		iic_clk_dur_r;
-IIC_CSR1_R		iic_csr1_r;
-IIC_CSR2_R		iic_csr2_r;
-DMA_UPPER_LMT_R		even_dma_upper_lmt_r;
-DMA_UPPER_LMT_R		odd_dma_upper_lmt_r;
-
-
-
-/******** local copies of board's 8 bit I2C registers ******/
-I2C_CSR2 i2c_csr2;
-I2C_EVEN_CSR i2c_even_csr;
-I2C_ODD_CSR i2c_odd_csr;
-I2C_CONFIG i2c_config;
-u8 i2c_dt_id;
-u8 i2c_x_clip_start;
-u8 i2c_y_clip_start;
-u8 i2c_x_clip_end;
-u8 i2c_y_clip_end;
-u8 i2c_ad_addr;
-u8 i2c_ad_lut;
-I2C_AD_CMD i2c_ad_cmd;
-u8 i2c_dig_out;
-u8 i2c_pm_lut_addr;
-u8 i2c_pm_lut_data;
-
-/*
- * wait_ibsyclr()
- *
- * This function handles read/write timing and r/w timeout error
- *
- * Returns TRUE  if NEW_CYCLE clears
- * Returns FALSE if NEW_CYCLE doesn't clear in roughly 3 msecs, otherwise
- * returns 0
- */
-static int wait_ibsyclr(u8 *lpReg)
-{
-	/* wait 100 microseconds */
-	udelay(100L);
-	/* __delay(loops_per_sec/10000); */
-	if (iic_csr2_r.fld.NEW_CYCLE) {
-		/* if NEW_CYCLE didn't clear */
-		/* TIMEOUT ERROR */
-		dt3155_errno = DT_ERR_I2C_TIMEOUT;
-		return FALSE;
-	} else
-		return TRUE;	/* no error */
-}
-
-/*
- * WriteI2C()
- *
- * This function handles writing to 8-bit DT3155 registers
- *
- * 1st parameter is pointer to 32-bit register base address
- * 2nd parameter is reg. index;
- * 3rd is value to be written
- *
- * Returns TRUE   -  Successful completion
- *         FALSE  -  Timeout error - cycle did not complete!
- */
-int WriteI2C(u8 *lpReg, u_short wIregIndex, u8 byVal)
-{
-	int writestat;	/* status for return */
-
-	/* read 32 bit IIC_CSR2 register data into union */
-
-	ReadMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
-
-	/* for write operation */
-	iic_csr2_r.fld.DIR_RD      = 0;
-	/* I2C address of I2C register: */
-	iic_csr2_r.fld.DIR_ADDR    = wIregIndex;
-	/* 8 bit data to be written to I2C reg */
-	iic_csr2_r.fld.DIR_WR_DATA = byVal;
-	/* will start a direct I2C cycle: */
-	iic_csr2_r.fld.NEW_CYCLE   = 1;
-
-	/* xfer union data into 32 bit IIC_CSR2 register */
-	WriteMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
-
-	/* wait for IIC cycle to finish */
-	writestat = wait_ibsyclr(lpReg);
-	return writestat;
-}
-
-/*
- * ReadI2C()
- *
- * This function handles reading from 8-bit DT3155 registers
- *
- * 1st parameter is pointer to 32-bit register base address
- * 2nd parameter is reg. index;
- * 3rd is adrs of value to be read
- *
- * Returns TRUE   -  Successful completion
- *         FALSE  -  Timeout error - cycle did not complete!
- */
-int ReadI2C(u8 *lpReg, u_short wIregIndex, u8 *byVal)
-{
-	int writestat;	/* status for return */
-
-	/*  read 32 bit IIC_CSR2 register data into union */
-	ReadMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
-
-	/*  for read operation */
-	iic_csr2_r.fld.DIR_RD     = 1;
-
-	/*  I2C address of I2C register: */
-	iic_csr2_r.fld.DIR_ADDR   = wIregIndex;
-
-	/*  will start a direct I2C cycle: */
-	iic_csr2_r.fld.NEW_CYCLE  = 1;
-
-	/*  xfer union's data into 32 bit IIC_CSR2 register */
-	WriteMReg((lpReg + IIC_CSR2), iic_csr2_r.reg);
-
-	/* wait for IIC cycle to finish */
-	writestat = wait_ibsyclr(lpReg);
-
-	/* Next 2 commands read 32 bit IIC_CSR1 register's data into union */
-	/* first read data is in IIC_CSR1 */
-	ReadMReg((lpReg + IIC_CSR1), iic_csr1_r.reg);
-
-	/* now get data u8 out of register */
-	*byVal = (u8) iic_csr1_r.fld.RD_DATA;
-
-	return writestat;
-}
diff --git a/drivers/staging/dt3155/dt3155_isr.c b/drivers/staging/dt3155/dt3155_isr.c
deleted file mode 100644
index fd7f93d..0000000
--- a/drivers/staging/dt3155/dt3155_isr.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
-
-Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
-                         Jason Lapenta, Scott Smedley, Greg Sharp
-
-This file is part of the DT3155 Device Driver.
-
-The DT3155 Device Driver is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The DT3155 Device Driver is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the DT3155 Device Driver; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA
-
-   File: dt3155_isr.c
-Purpose: Buffer management routines, and other routines for the ISR
-         (the actual isr is in dt3155_drv.c)
-
--- Changes --
-
-  Date       Programmer  Description of changes made
-  -------------------------------------------------------------------
-  03-Jul-2000 JML       n/a
-  02-Apr-2002 SS        Mods to make work with separate allocator
-                        module; Merged John Roll's mods to make work with
-                        multiple boards.
-  10-Jul-2002 GCS       Complete rewrite of setup_buffers to disallow
-                        buffers which span a 4MB boundary.
-  24-Jul-2002 SS        GPL licence.
-  30-Jul-2002 NJC       Added support for buffer loop.
-  31-Jul-2002 NJC       Complete rewrite of buffer management
-  02-Aug-2002 NJC       Including slab.h instead of malloc.h (no warning).
-                        Also, allocator_init() now returns allocator_max
-                        so cleaned up allocate_buffers() accordingly.
-  08-Aug-2005 SS        port to 2.6 kernel.
-
-*/
-
-#include <asm/system.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-
-#include "dt3155.h"
-#include "dt3155_drv.h"
-#include "dt3155_io.h"
-#include "dt3155_isr.h"
-#include "allocator.h"
-
-#define FOUR_MB         (0x0400000)  /* Can't DMA accross a 4MB boundary!*/
-#define UPPER_10_BITS   (0x3FF<<22)  /* Can't DMA accross a 4MB boundary!*/
-
-
-/* Pointer into global structure for handling buffers */
-struct dt3155_fbuffer_s *dt3155_fbuffer[MAXBOARDS] = {NULL
-#if MAXBOARDS == 2
-						      , NULL
-#endif
-};
-
-/******************************************************************************
- * Simple array based que struct
- *
- * Some handy functions using the buffering structure.
- *****************************************************************************/
-
-
-/***************************
- * are_empty_buffers
- * m is minor # of device
- ***************************/
-inline bool are_empty_buffers( int m )
-{
-  return ( dt3155_fbuffer[ m ]->empty_len );
-}
-
-/**************************
- * push_empty
- * m is minor # of device
- *
- * This is slightly confusing.  The number empty_len is the literal #
- * of empty buffers.  After calling, empty_len-1 is the index into the
- * empty buffer stack.  So, if empty_len == 1, there is one empty buffer,
- * given by dt3155_fbuffer[m]->empty_buffers[0].
- * empty_buffers should never fill up, though this is not checked.
- **************************/
-inline void push_empty( int index, int m )
-{
-  dt3155_fbuffer[m]->empty_buffers[ dt3155_fbuffer[m]->empty_len ] = index;
-  dt3155_fbuffer[m]->empty_len++;
-}
-
-/**************************
- * pop_empty( m )
- * m is minor # of device
- **************************/
-inline int pop_empty( int m )
-{
-  dt3155_fbuffer[m]->empty_len--;
-  return dt3155_fbuffer[m]->empty_buffers[ dt3155_fbuffer[m]->empty_len ];
-}
-
-/*************************
- * is_ready_buf_empty( m )
- * m is minor # of device
- *************************/
-inline bool is_ready_buf_empty( int m )
-{
-  return ((dt3155_fbuffer[ m ]->ready_len) == 0);
-}
-
-/*************************
- * is_ready_buf_full( m )
- * m is minor # of device
- * this should *never* be true if there are any active, locked or empty
- * buffers, since it corresponds to nbuffers ready buffers!!
- * 7/31/02: total rewrite. --NJC
- *************************/
-inline bool is_ready_buf_full( int m )
-{
-  return ( dt3155_fbuffer[ m ]->ready_len == dt3155_fbuffer[ m ]->nbuffers );
-}
-
-/*****************************************************
- * push_ready( m, buffer )
- * m is minor # of device
- *
- *****************************************************/
-inline void push_ready( int m, int index )
-{
-  int head = dt3155_fbuffer[m]->ready_head;
-
-  dt3155_fbuffer[ m ]->ready_que[ head ] = index;
-  dt3155_fbuffer[ m ]->ready_head = ( (head + 1) %
-				      (dt3155_fbuffer[ m ]->nbuffers) );
-  dt3155_fbuffer[ m ]->ready_len++;
-
-}
-
-/*****************************************************
- * get_tail()
- * m is minor # of device
- *
- * Simply comptutes the tail given the head and the length.
- *****************************************************/
-static inline int get_tail( int m )
-{
-  return ((dt3155_fbuffer[ m ]->ready_head -
-	   dt3155_fbuffer[ m ]->ready_len +
-	   dt3155_fbuffer[ m ]->nbuffers)%
-	  (dt3155_fbuffer[ m ]->nbuffers));
-}
-
-
-
-/*****************************************************
- * pop_ready()
- * m is minor # of device
- *
- * This assumes that there is a ready buffer ready... should
- * be checked (e.g. with is_ready_buf_empty()  prior to call.
- *****************************************************/
-inline int pop_ready( int m )
-{
-  int tail;
-  tail = get_tail(m);
-  dt3155_fbuffer[ m ]->ready_len--;
-  return dt3155_fbuffer[ m ]->ready_que[ tail ];
-}
-
-
-/*****************************************************
- * printques
- * m is minor # of device
- *****************************************************/
-inline void printques( int m )
-{
-  int head = dt3155_fbuffer[ m ]->ready_head;
-  int tail;
-  int num = dt3155_fbuffer[ m ]->nbuffers;
-  int frame_index;
-  int index;
-
-  tail = get_tail(m);
-
-  printk("\n R:");
-  for ( index = tail; index != head; index++, index = index % (num) )
-    {
-      frame_index = dt3155_fbuffer[ m ]->ready_que[ index ];
-      printk(" %d ", frame_index );
-    }
-
-  printk("\n E:");
-  for ( index = 0; index < dt3155_fbuffer[ m ]->empty_len; index++ )
-    {
-      frame_index = dt3155_fbuffer[ m ]->empty_buffers[ index ];
-      printk(" %d ", frame_index );
-    }
-
-  frame_index = dt3155_fbuffer[ m ]->active_buf;
-  printk("\n A: %d", frame_index);
-
-  frame_index = dt3155_fbuffer[ m ]->locked_buf;
-  printk("\n L: %d \n", frame_index );
-
-}
-
-/*****************************************************
- * adjust_4MB
- *
- *  If a buffer intersects the 4MB boundary, push
- *  the start address up to the beginning of the
- *  next 4MB chunk (assuming bufsize < 4MB).
- *****************************************************/
-u32 adjust_4MB (u32 buf_addr, u32 bufsize) {
-  if (((buf_addr+bufsize) & UPPER_10_BITS) != (buf_addr & UPPER_10_BITS))
-    return (buf_addr+bufsize) & UPPER_10_BITS;
-  else
-    return buf_addr;
-}
-
-
-/*****************************************************
- * allocate_buffers
- *
- *  Try to allocate enough memory for all requested
- *  buffers.  If there is not enough free space
- *  try for less memory.
- *****************************************************/
-void allocate_buffers (u32 *buf_addr, u32* total_size_kbs,
-		       u32 bufsize)
-{
-  /* Compute the minimum amount of memory guaranteed to hold all
-     MAXBUFFERS such that no buffer crosses the 4MB boundary.
-     Store this value in the variable "full_size" */
-
-  u32 allocator_max;
-  u32 bufs_per_chunk = (FOUR_MB / bufsize);
-  u32 filled_chunks = (MAXBUFFERS-1) / bufs_per_chunk;
-  u32 leftover_bufs = MAXBUFFERS - filled_chunks * bufs_per_chunk;
-
-  u32 full_size = bufsize      /* possibly unusable part of 1st chunk */
-    + filled_chunks * FOUR_MB   /* max # of completely filled 4mb chunks */
-    + leftover_bufs * bufsize;  /* these buffs will be in a partly filled
-				   chunk at beginning or end */
-
-  u32 full_size_kbs = 1 + (full_size-1) / 1024;
-  u32 min_size_kbs = 2*ndevices*bufsize / 1024;
-  u32 size_kbs;
-
-  /* Now, try to allocate full_size.  If this fails, keep trying for
-     less & less memory until it succeeds. */
-#ifndef STANDALONE_ALLOCATOR
-  /* initialize the allocator            */
-  allocator_init(&allocator_max);
-#endif
-  size_kbs = full_size_kbs;
-  *buf_addr = 0;
-  printk("DT3155: We would like to get: %d KB\n", full_size_kbs);
-  printk("DT3155: ...but need at least: %d KB\n", min_size_kbs);
-  printk("DT3155: ...the allocator has: %d KB\n", allocator_max);
-  size_kbs = (full_size_kbs <= allocator_max ? full_size_kbs : allocator_max);
-  if (size_kbs > min_size_kbs) {
-    if ((*buf_addr = allocator_allocate_dma (size_kbs, GFP_KERNEL)) != 0) {
-      printk("DT3155:  Managed to allocate: %d KB\n", size_kbs);
-      *total_size_kbs = size_kbs;
-      return;
-    }
-  }
-  /* If we got here, the allocation failed */
-  printk ("DT3155: Allocator failed!\n");
-  *buf_addr = 0;
-  *total_size_kbs = 0;
-  return;
-
-}
-
-
-/*****************************************************
- * dt3155_setup_buffers
- *
- *  setup_buffers just puts the buffering system into
- *  a consistent state before the start of interrupts
- *
- * JML : it looks like all the buffers need to be
- * continuous. So I'm going to try and allocate one
- * continuous buffer.
- *
- * GCS : Fix DMA problems when buffer spans
- * 4MB boundary.  Also, add error checking.  This
- * function will return -ENOMEM when not enough memory.
- *****************************************************/
-u32 dt3155_setup_buffers(u32 *allocatorAddr)
-
-{
-  u32 index;
-  u32 rambuff_addr; /* start of allocation */
-  u32 rambuff_size; /* total size allocated to driver */
-  u32 rambuff_acm;  /* accumlator, keep track of how much
-			  is left after being split up*/
-  u32 rambuff_end;  /* end of rambuff */
-  u32 numbufs;      /* number of useful buffers allocated (per device) */
-  u32 bufsize      = DT3155_MAX_ROWS * DT3155_MAX_COLS;
-  int m;               /* minor # of device, looped for all devs */
-
-  /* zero the fbuffer status and address structure */
-  for ( m = 0; m < ndevices; m++)
-    {
-      dt3155_fbuffer[ m ] = &(dt3155_status[ m ].fbuffer);
-
-      /* Make sure the buffering variables are consistent */
-      {
-	u8 *ptr = (u8 *) dt3155_fbuffer[ m ];
-	for( index = 0; index < sizeof(struct dt3155_fbuffer_s); index++)
-	  *(ptr++)=0;
-      }
-    }
-
-  /* allocate a large contiguous chunk of RAM */
-  allocate_buffers (&rambuff_addr, &rambuff_size, bufsize);
-  printk("DT3155: mem info\n");
-  printk("  - rambuf_addr = 0x%x \n", rambuff_addr);
-  printk("  - length (kb) = %u \n", rambuff_size);
-  if( rambuff_addr == 0 )
-    {
-      printk( KERN_INFO
-	      "DT3155: Error setup_buffers() allocator dma failed \n" );
-      return -ENOMEM;
-    }
-  *allocatorAddr = rambuff_addr;
-  rambuff_end = rambuff_addr + 1024 * rambuff_size;
-
-  /* after allocation, we need to count how many useful buffers there
-     are so we can give an equal number to each device */
-  rambuff_acm = rambuff_addr;
-  for ( index = 0; index < MAXBUFFERS; index++) {
-    rambuff_acm = adjust_4MB (rambuff_acm, bufsize);/*avoid spanning 4MB bdry*/
-    if (rambuff_acm + bufsize > rambuff_end)
-      break;
-    rambuff_acm += bufsize;
-  }
-  /* Following line is OK, will waste buffers if index
-   * not evenly divisible by ndevices -NJC*/
-  numbufs = index / ndevices;
-  printk("  - numbufs = %u\n", numbufs);
-  if (numbufs < 2) {
-    printk( KERN_INFO
-	    "DT3155: Error setup_buffers() couldn't allocate 2 bufs/board\n" );
-    return -ENOMEM;
-  }
-
-  /* now that we have board memory we spit it up */
-  /* between the boards and the buffers          */
-  rambuff_acm = rambuff_addr;
-  for ( m = 0; m < ndevices; m ++)
-    {
-      rambuff_acm = adjust_4MB (rambuff_acm, bufsize);
-
-      /* Save the start of this boards buffer space (for mmap).  */
-      dt3155_status[ m ].mem_addr = rambuff_acm;
-
-      for (index = 0; index < numbufs; index++)
-	{
-	  rambuff_acm = adjust_4MB (rambuff_acm, bufsize);
-	  if (rambuff_acm + bufsize > rambuff_end) {
-	    /* Should never happen */
-	    printk ("DT3155 PROGRAM ERROR (GCS)\n"
-		    "Error distributing allocated buffers\n");
-	    return -ENOMEM;
-	  }
-
-	  dt3155_fbuffer[ m ]->frame_info[ index ].addr = rambuff_acm;
-	  push_empty( index, m );
-	  /* printk("  - Buffer : %lx\n",
-	   * dt3155_fbuffer[ m ]->frame_info[ index ].addr );
-	   */
-	  dt3155_fbuffer[ m ]->nbuffers += 1;
-	  rambuff_acm += bufsize;
-	}
-
-      /* Make sure there is an active buffer there. */
-      dt3155_fbuffer[ m ]->active_buf    = pop_empty( m );
-      dt3155_fbuffer[ m ]->even_happened = 0;
-      dt3155_fbuffer[ m ]->even_stopped  = 0;
-
-      /* make sure there is no locked_buf JML 2/28/00 */
-      dt3155_fbuffer[ m ]->locked_buf = -1;
-
-      dt3155_status[ m ].mem_size =
-	rambuff_acm - dt3155_status[ m ].mem_addr;
-
-      /* setup the ready queue */
-      dt3155_fbuffer[ m ]->ready_head = 0;
-      dt3155_fbuffer[ m ]->ready_len = 0;
-      printk("Available buffers for device %d: %d\n",
-	     m, dt3155_fbuffer[ m ]->nbuffers);
-    }
-
-  return 1;
-}
-
-/*****************************************************
- * internal_release_locked_buffer
- *
- * The internal function for releasing a locked buffer.
- * It assumes interrupts are turned off.
- *
- * m is minor number of device
- *****************************************************/
-static inline void internal_release_locked_buffer( int m )
-{
-  /* Pointer into global structure for handling buffers */
-  if ( dt3155_fbuffer[ m ]->locked_buf >= 0 )
-    {
-      push_empty( dt3155_fbuffer[ m ]->locked_buf, m );
-      dt3155_fbuffer[ m ]->locked_buf = -1;
-    }
-}
-
-
-/*****************************************************
- * dt3155_release_locked_buffer()
- * m is minor # of device
- *
- * The user function of the above.
- *
- *****************************************************/
-inline void dt3155_release_locked_buffer( int m )
-{
-	unsigned long int flags;
-	local_save_flags(flags);
-	local_irq_disable();
-	internal_release_locked_buffer(m);
-	local_irq_restore(flags);
-}
-
-
-/*****************************************************
- * dt3155_flush()
- * m is minor # of device
- *
- *****************************************************/
-inline int dt3155_flush( int m )
-{
-  int index;
-  unsigned long int flags;
-  local_save_flags(flags);
-  local_irq_disable();
-
-  internal_release_locked_buffer( m );
-  dt3155_fbuffer[ m ]->empty_len = 0;
-
-  for ( index = 0; index < dt3155_fbuffer[ m ]->nbuffers; index++ )
-    push_empty( index,  m );
-
-  /* Make sure there is an active buffer there. */
-  dt3155_fbuffer[ m ]->active_buf = pop_empty( m );
-
-  dt3155_fbuffer[ m ]->even_happened = 0;
-  dt3155_fbuffer[ m ]->even_stopped  = 0;
-
-  /* setup the ready queue  */
-  dt3155_fbuffer[ m ]->ready_head = 0;
-  dt3155_fbuffer[ m ]->ready_len = 0;
-
-  local_irq_restore(flags);
-
-  return 0;
-}
-
-/*****************************************************
- * dt3155_get_ready_buffer()
- * m is minor # of device
- *
- * get_ready_buffer will grab the next chunk of data
- * if it is already there, otherwise it returns 0.
- * If the user has a buffer locked it will unlock
- * that buffer before returning the new one.
- *****************************************************/
-inline int dt3155_get_ready_buffer( int m )
-{
-  int frame_index;
-  unsigned long int flags;
-  local_save_flags(flags);
-  local_irq_disable();
-
-#ifdef DEBUG_QUES_A
-  printques( m );
-#endif
-
-  internal_release_locked_buffer( m );
-
-  if (is_ready_buf_empty( m ))
-    frame_index = -1;
-  else
-    {
-      frame_index = pop_ready( m );
-      dt3155_fbuffer[ m ]->locked_buf = frame_index;
-    }
-
-#ifdef DEBUG_QUES_B
-  printques( m );
-#endif
-
-  local_irq_restore(flags);
-
-  return frame_index;
-}
diff --git a/drivers/staging/dt3155/dt3155_isr.h b/drivers/staging/dt3155/dt3155_isr.h
deleted file mode 100644
index 7595cb1..0000000
--- a/drivers/staging/dt3155/dt3155_isr.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-
-Copyright 1996,2002 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan,
-		    Jason Lapenta, Scott Smedley
-
-This file is part of the DT3155 Device Driver.
-
-The DT3155 Device Driver is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The DT3155 Device Driver is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with the DT3155 Device Driver; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA
-
-
--- Changes --
-
-  Date     Programmer   Description of changes made
-  -------------------------------------------------------------------
-  03-Jul-2000 JML       n/a
-  24-Jul-2002 SS        GPL licence.
-  26-Oct-2009 SS	Porting to 2.6.30 kernel.
-
--- notes --
-
-*/
-
-#ifndef DT3155_ISR_H
-#define DT3155_ISR_H
-
-extern struct dt3155_fbuffer_s *dt3155_fbuffer[MAXBOARDS];
-
-/* User functions for buffering */
-/* Initialize the buffering system.  This should */
-/* be called prior to enabling interrupts */
-
-u32 dt3155_setup_buffers(u32 *allocatorAddr);
-
-/* Get the next frame of data if it is ready.  Returns */
-/* zero if no data is ready.  If there is data but */
-/* the user has a locked buffer, it will unlock that */
-/* buffer and return it to the free list. */
-
-int dt3155_get_ready_buffer(int minor);
-
-/* Return a locked buffer to the free list */
-
-void dt3155_release_locked_buffer(int minor);
-
-/* Flush the buffer system */
-int dt3155_flush(int minor);
-
-/**********************************
- * Simple array based que struct
- **********************************/
-
-bool are_empty_buffers(int minor);
-void push_empty(int index, int minor);
-
-int  pop_empty(int minor);
-
-bool is_ready_buf_empty(int minor);
-bool is_ready_buf_full(int minor);
-
-void push_ready(int minor, int index);
-int  pop_ready(int minor);
-
-
-#endif
-- 
1.7.0.14.g7e948


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c
  2010-03-29  3:23 ` Simon Horman
  2010-03-29  7:34   ` [PATCH 0/3] drivers/staging/dt3155: Large cleanups Joe Perches
@ 2010-03-29 17:35   ` Olimpiu Pascariu
  1 sibling, 0 replies; 17+ messages in thread
From: Olimpiu Pascariu @ 2010-03-29 17:35 UTC (permalink / raw)
  To: Simon Horman; +Cc: gregkh, hsweeten, ss, devel, linux-kernel, Jason Baldus

On Mon, 2010-03-29 at 14:23 +1100, Simon Horman wrote:
> Hi,
> 
> this patch seems to duplicate work being done by Jason Baldus.
> Could you co-ordinate with him?
> 
> http://marc.info/?l=linux-kernel&m=126973249428849&w=2
Hi,

Since he sent the patch first and both patches do the same thing, please
ignore the patch I wrote.

Regards,



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-03-29  7:34     ` [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file Joe Perches
@ 2010-04-27 23:02       ` Greg KH
  2010-04-28  5:30         ` Joe Perches
  2010-04-28 12:18         ` Dan Carpenter
  0 siblings, 2 replies; 17+ messages in thread
From: Greg KH @ 2010-04-27 23:02 UTC (permalink / raw)
  To: Joe Perches
  Cc: devel, Scott Smedley, Greg KH, Jason Baldus, linux-kernel,
	Harley Sweeten, Simon Horman

On Mon, Mar 29, 2010 at 12:34:28AM -0700, Joe Perches wrote:
> Make variables static where appropriate
> Rename dt3155_<foo_with_long_names> variables to dt_<foo_tla>
> to reduce code length and make more lines fit well in 80 chars
> Remove now unnecessary .h files
> Change indent to use tabs
> Remove unused functions
> Used bool more often
> Checkpatch clean

This is too much in one patch, sorry.  It also doesn't apply due to
other changes in these files (that you then remove in patch 3) from
other developers.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-27 23:02       ` Greg KH
@ 2010-04-28  5:30         ` Joe Perches
  2010-04-28  5:34           ` Greg KH
  2010-04-28 12:18         ` Dan Carpenter
  1 sibling, 1 reply; 17+ messages in thread
From: Joe Perches @ 2010-04-28  5:30 UTC (permalink / raw)
  To: Greg KH
  Cc: devel, Scott Smedley, Greg KH, Jason Baldus, linux-kernel,
	Harley Sweeten, Simon Horman

On Tue, 2010-04-27 at 16:02 -0700, Greg KH wrote:
> On Mon, Mar 29, 2010 at 12:34:28AM -0700, Joe Perches wrote:
> > Make variables static where appropriate
> > Rename dt3155_<foo_with_long_names> variables to dt_<foo_tla>
> > to reduce code length and make more lines fit well in 80 chars
> > Remove now unnecessary .h files
> > Change indent to use tabs
> > Remove unused functions
> > Used bool more often
> > Checkpatch clean
> 
> This is too much in one patch, sorry.

You should be more consistent.

http://www.tuxradar.com/content/newbies-guide-hacking-linux-kernel
Greg even said, "submit one big patch if you want"


> It also doesn't apply due to
> other changes in these files (that you then remove in patch 3) from
> other developers.

No, it doesn't apply because you chose to apply other patches
before this one.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28  5:30         ` Joe Perches
@ 2010-04-28  5:34           ` Greg KH
  2010-04-28  5:44             ` Joe Perches
  0 siblings, 1 reply; 17+ messages in thread
From: Greg KH @ 2010-04-28  5:34 UTC (permalink / raw)
  To: Joe Perches
  Cc: devel, Scott Smedley, Greg KH, Jason Baldus, linux-kernel,
	Harley Sweeten, Simon Horman

On Tue, Apr 27, 2010 at 10:30:03PM -0700, Joe Perches wrote:
> On Tue, 2010-04-27 at 16:02 -0700, Greg KH wrote:
> > On Mon, Mar 29, 2010 at 12:34:28AM -0700, Joe Perches wrote:
> > > Make variables static where appropriate
> > > Rename dt3155_<foo_with_long_names> variables to dt_<foo_tla>
> > > to reduce code length and make more lines fit well in 80 chars
> > > Remove now unnecessary .h files
> > > Change indent to use tabs
> > > Remove unused functions
> > > Used bool more often
> > > Checkpatch clean
> > 
> > This is too much in one patch, sorry.
> 
> You should be more consistent.

I am human.

> http://www.tuxradar.com/content/newbies-guide-hacking-linux-kernel
> Greg even said, "submit one big patch if you want"

Yes, but I will then help to guide them to make it a more reasonable,
and reviewable, patch :)

> > It also doesn't apply due to
> > other changes in these files (that you then remove in patch 3) from
> > other developers.
> 
> No, it doesn't apply because you chose to apply other patches
> before this one.

Those patches were sent to me before yours, sorry.

thanks,

greg "slowly catching up" k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28  5:34           ` Greg KH
@ 2010-04-28  5:44             ` Joe Perches
  2010-04-28  5:52               ` Greg KH
  0 siblings, 1 reply; 17+ messages in thread
From: Joe Perches @ 2010-04-28  5:44 UTC (permalink / raw)
  To: Greg KH
  Cc: devel, Scott Smedley, Greg KH, Jason Baldus, linux-kernel,
	Harley Sweeten, Simon Horman

On Tue, 2010-04-27 at 22:34 -0700, Greg KH wrote:
> > No, it doesn't apply because you chose to apply other patches
> > before this one.
> Those patches were sent to me before yours, sorry.

By like an hour.  They were ugly so I cleaned them.
And besides, you didn't act on them for over a month.
I seem to be learning that you little taste.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28  5:44             ` Joe Perches
@ 2010-04-28  5:52               ` Greg KH
  2010-04-28  6:00                 ` Joe Perches
  0 siblings, 1 reply; 17+ messages in thread
From: Greg KH @ 2010-04-28  5:52 UTC (permalink / raw)
  To: Joe Perches
  Cc: Greg KH, devel, Scott Smedley, Jason Baldus, linux-kernel,
	Harley Sweeten, Simon Horman

On Tue, Apr 27, 2010 at 10:44:34PM -0700, Joe Perches wrote:
> On Tue, 2010-04-27 at 22:34 -0700, Greg KH wrote:
> > > No, it doesn't apply because you chose to apply other patches
> > > before this one.
> > Those patches were sent to me before yours, sorry.
> 
> By like an hour.  They were ugly so I cleaned them.

No, one was 14 days before yours, the other, 2 1/2 hours.

> And besides, you didn't act on them for over a month.

That has already been discussed.

> I seem to be learning that you little taste.

-ENOPARSE

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28  5:52               ` Greg KH
@ 2010-04-28  6:00                 ` Joe Perches
  2010-04-28 16:12                   ` Valdis.Kletnieks
  0 siblings, 1 reply; 17+ messages in thread
From: Joe Perches @ 2010-04-28  6:00 UTC (permalink / raw)
  To: Greg KH
  Cc: Greg KH, devel, Scott Smedley, Jason Baldus, linux-kernel,
	Harley Sweeten, Simon Horman

On Tue, 2010-04-27 at 22:52 -0700, Greg KH wrote:
> > I seem to be learning that you little taste.
> -ENOPARSE

Choosing competing patches based on date received
order not quality is poor taste.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-27 23:02       ` Greg KH
  2010-04-28  5:30         ` Joe Perches
@ 2010-04-28 12:18         ` Dan Carpenter
  1 sibling, 0 replies; 17+ messages in thread
From: Dan Carpenter @ 2010-04-28 12:18 UTC (permalink / raw)
  To: Greg KH
  Cc: Joe Perches, devel, Scott Smedley, Greg KH, Jason Baldus,
	linux-kernel, Harley Sweeten, Simon Horman

On Tue, Apr 27, 2010 at 04:02:28PM -0700, Greg KH wrote:
> On Mon, Mar 29, 2010 at 12:34:28AM -0700, Joe Perches wrote:
> > Make variables static where appropriate
> > Rename dt3155_<foo_with_long_names> variables to dt_<foo_tla>
> > to reduce code length and make more lines fit well in 80 chars
> > Remove now unnecessary .h files
> > Change indent to use tabs
> > Remove unused functions
> > Used bool more often
> > Checkpatch clean
> 
> This is too much in one patch, sorry.  It also doesn't apply due to
> other changes in these files (that you then remove in patch 3) from
> other developers.
> 

What I like is when people send in a patch that addresses all the white
space issues at once.  So from the above list it would probably fix these:

> > to reduce code length and make more lines fit well in 80 chars
> > Change indent to use tabs
> > Checkpatch clean

I have a script to check that a patch only changes whitespace and I can
check that directly from mutt.  It's in the my smatch repo:  
git://repo.or.cz/smatch.git under smatch_scripts/whitespace_only.sh

If that passes and the source still compiles then I'm pretty sure it 
doesn't break anything.  At that point I can look through it focusing on
the whitespace instead of worrying that the patch introduces bugs.

Once the whitespace is fixed the rest of the changes can be sent in 
separately and they're much smaller and easier to audit.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28  6:00                 ` Joe Perches
@ 2010-04-28 16:12                   ` Valdis.Kletnieks
  2010-04-28 16:33                     ` Joe Perches
  0 siblings, 1 reply; 17+ messages in thread
From: Valdis.Kletnieks @ 2010-04-28 16:12 UTC (permalink / raw)
  To: Joe Perches
  Cc: Greg KH, Greg KH, devel, Scott Smedley, Jason Baldus,
	linux-kernel, Harley Sweeten, Simon Horman

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

On Tue, 27 Apr 2010 23:00:30 PDT, Joe Perches said:
> On Tue, 2010-04-27 at 22:52 -0700, Greg KH wrote:
> > > I seem to be learning that you little taste.
> > -ENOPARSE
> 
> Choosing competing patches based on date received
> order not quality is poor taste.

So you're saying when Greg gets a somewhat ugly but passable patch 2 weeks ago,
he's supposed to *just know* that you'll be submitting a possibly better one 2
weeks later and wait for it to show up?

How is that supposed to work in reality?




[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28 16:12                   ` Valdis.Kletnieks
@ 2010-04-28 16:33                     ` Joe Perches
  2010-04-28 17:22                       ` Greg KH
  0 siblings, 1 reply; 17+ messages in thread
From: Joe Perches @ 2010-04-28 16:33 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Greg KH, Greg KH, devel, Scott Smedley, Jason Baldus,
	linux-kernel, Harley Sweeten, Simon Horman

On Wed, 2010-04-28 at 12:12 -0400, Valdis.Kletnieks@vt.edu wrote:
> On Tue, 27 Apr 2010 23:00:30 PDT, Joe Perches said:
> > On Tue, 2010-04-27 at 22:52 -0700, Greg KH wrote:
> > > > I seem to be learning that you little taste.
> > > -ENOPARSE
> > 
> > Choosing competing patches based on date received
> > order not quality is poor taste.
> 
> So you're saying when Greg gets a somewhat ugly but passable patch 2 weeks ago,
> he's supposed to *just know* that you'll be submitting a possibly better one 2
> weeks later and wait for it to show up?

No, I'm saying that when Greg gets multiple
patches for the same module and doesn't act on
any of them for several weeks, (in this case
one 6 weeks ago, and two others 4 weeks ago)
he should select the better patches, not just
apply the first one in chronological order.

> How is that supposed to work in reality?

Apparently slowly and fitfully.

If the cycle time was shorter and the feedback
better, it would be less of an issue.

Greg has explained he was unavailable to look at
patches for an extended period.  Unfortunately
that extended period was immediately after a talk
Greg gave and an article Greg authored designed
to generate new contributor patches for staging.

The talk and articled worked.

Many new individuals followed his template format
producing cleanup patches, some good, some less
good.  Few if any of those patches received feedback
from Greg or had notice of patch status for that
extended period.

It would be better if the backlog of patches were
order sifted by quality than chronology.

cheers, Joe


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file
  2010-04-28 16:33                     ` Joe Perches
@ 2010-04-28 17:22                       ` Greg KH
  0 siblings, 0 replies; 17+ messages in thread
From: Greg KH @ 2010-04-28 17:22 UTC (permalink / raw)
  To: Joe Perches
  Cc: Valdis.Kletnieks, Greg KH, devel, Scott Smedley, Jason Baldus,
	linux-kernel, Harley Sweeten, Simon Horman

On Wed, Apr 28, 2010 at 09:33:25AM -0700, Joe Perches wrote:
> On Wed, 2010-04-28 at 12:12 -0400, Valdis.Kletnieks@vt.edu wrote:
> > On Tue, 27 Apr 2010 23:00:30 PDT, Joe Perches said:
> > > On Tue, 2010-04-27 at 22:52 -0700, Greg KH wrote:
> > > > > I seem to be learning that you little taste.
> > > > -ENOPARSE
> > > 
> > > Choosing competing patches based on date received
> > > order not quality is poor taste.
> > 
> > So you're saying when Greg gets a somewhat ugly but passable patch 2 weeks ago,
> > he's supposed to *just know* that you'll be submitting a possibly better one 2
> > weeks later and wait for it to show up?
> 
> No, I'm saying that when Greg gets multiple
> patches for the same module and doesn't act on
> any of them for several weeks, (in this case
> one 6 weeks ago, and two others 4 weeks ago)
> he should select the better patches, not just
> apply the first one in chronological order.

In this case, I _did_ select the best patches.  Your "do it all in one
patch" was not acceptable, especially as others sent small,
do-one-thing, type patches.

I'm sorry you don't agree with this decision, but that was my call.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-04-28 17:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-28 15:26 Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c Olimpiu Pascariu
2010-03-29  3:23 ` Simon Horman
2010-03-29  7:34   ` [PATCH 0/3] drivers/staging/dt3155: Large cleanups Joe Perches
2010-03-29  7:34     ` [PATCH 1/3] drivers/staging/dt3155: Integrate 3 badly styled files into 1 clean file Joe Perches
2010-04-27 23:02       ` Greg KH
2010-04-28  5:30         ` Joe Perches
2010-04-28  5:34           ` Greg KH
2010-04-28  5:44             ` Joe Perches
2010-04-28  5:52               ` Greg KH
2010-04-28  6:00                 ` Joe Perches
2010-04-28 16:12                   ` Valdis.Kletnieks
2010-04-28 16:33                     ` Joe Perches
2010-04-28 17:22                       ` Greg KH
2010-04-28 12:18         ` Dan Carpenter
2010-03-29  7:34     ` [PATCH 2/3] drivers/staging/dt3155/allocator: sparse cleanups Joe Perches
2010-03-29  7:34     ` [PATCH 3/3] drivers/staging/dt3155: Remove old files Joe Perches
2010-03-29 17:35   ` Staging: dt3155: fixed some checkpatch.pl warnings and errors in dt3155_drv.c Olimpiu Pascariu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.