riport LADAR driver
PATCH 1/1 riport LADAR driver
The following patch is a driver for a laser scanning device that scans terrain and communicates with the system over the parallel port. This deice is used on both the Red Team Racing DAPA Grand Challenge robot entrees.
This driver is a port from the 2.4 kernel version that was used recently to the 2.6.17.1 kernel. I am posting it for community review and input.
Thanks
--mgross
linux-2.6.17.1/drivers/char/Kconfig renamed from drivers/char/Kconfig +13 -0
@@ -1034,5 +1034,18 @@ sysfs directory, /sys/devices/platform/telco_clock, with a number of files for controlling the behavior of this hardware. + +config RIPORT + tristate "Riport driver to Riegl systems LADAR terrain scanner" + depends on EXPERIMENTAL + default n + help + The riport driver talks through the parallel port to a Riegl systems + LADAR terrain scanner http://www.riegl.com/. This is the scanner + that was used by http://www.redteamracing.org/ H1ghlander and + Sandstorm robots. Its the device in the big round thing on top of + the hummers. This driver is a 2.6 port of the driver used in those + robots. + endmenu
linux-2.6.17.1/drivers/char/Makefile renamed from drivers/char/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o +obj-$(CONFIG_RIPORT) += riport.o obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_MWAVE) += mwave/
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +678 -0
678 lines not on this page · raw message
Quoted 50 lines · On Thu, 22 Jun 2006 07:41:20 -0700 mark gross wrote:
The following patch is a driver for a laser scanning device that scans terrain and communicates with the system over the parallel port. This deice is used on both the Red Team Racing DAPA Grand Challenge robot entrees.
This driver is a port from the 2.4 kernel version that was used recently to the 2.6.17.1 kernel. I am posting it for community review and input.
Thanks
--mgross
Signed-off-by Mark Gross <[email protected]>diff -urN -X linux-2.6.17.1/Documentation/dontdiff linux-2.6.17.1/drivers/char/Kconfig riport_current/linux-2.6.17.1/drivers/char/Kconfig
linux-2.6.17.1/drivers/char/Kconfig renamed from drivers/char/Kconfig +13
-0@@ -1034,5 +1034,18 @@ sysfs directory, /sys/devices/platform/telco_clock, with a number of files for controlling the behavior of this hardware. + +config RIPORT + tristate "Riport driver to Riegl systems LADAR terrain scanner" + depends on EXPERIMENTAL + default n + help + The riport driver talks through the parallel port to a Riegl systems + LADAR terrain scanner http://www.riegl.com/. This is the scanner + that was used by http://www.redteamracing.org/ H1ghlander and + Sandstorm robots. Its the device in the big round thing on top of + the hummers. This driver is a 2.6 port of the driver used in those + robots. + endmenudiff -urN -X linux-2.6.17.1/Documentation/dontdiff
linux-2.6.17.1/drivers/char/riport.criport_current/linux-2.6.17.1/drivers/char/riport.clinux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +9
-0@@ -0,0 +1,678 @@ +/* +* riport.o +* Linux device driver to access Riegl LMS scanner units via the parallel port +* +* Copyright (C) 2000 Roland Schwarz +* +* The author can be reached by email: [email protected] +*/ +
linux-2.6.17.1/drivers/char/riport.c line 19
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+/* +* 10.07.2000 Tested for use with Kernel >= 2.2 +* 14.03.2000 First working version +* 10.02.2000 Start of work +* 21.06.2006 port to 2.6 kernel [email protected]. +*/ + +#define MAX_RIPORT_DEVICES 2 + +// default settings
Use /*...*/ style comments, not //. (multiple places)
Quoted 12 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +12
-0+#define RIPORT_IO 0x378 +#define RIPORT_IRQ 7 +#define RIPORT_SIZE 4000 + +// standard and ECP port offsets +#define ECP_OFFSET 0x400 +#define ECR_EXT 2 +#define DCR_BASE 2 +#define FIFO_EXT 0 + +// bit definitions for registers +#define ECR_SPP_MODE 0x00
linux-2.6.17.1/drivers/char/riport.c line 55
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+#define ECR_ERRINT_DISABLED 0x10 +#define ECR_SERVICE_INTERRUPT 0x04 +#define ECR_BYTE_MODE 0x20 +#define ECR_ECP_MODE 0x60 +#define DCR_NOT_REVERSE_REQUEST 0x04 +#define DCR_NOT_1284_ACTIVE 0x08 +#define DCR_DIRECTION 0x20 +#define DCR_SELECT_IN 0x08 +#define ECR_FIFO_EMPTY 0x01 +
Lots of trailing whitespace (multiple places).
Quoted 25 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +25
-0+#include <linux/module.h> +#include <linux/init.h> +#include <linux/fs.h> +#include <linux/ioport.h> +#include <linux/errno.h> +#include <linux/slab.h> +#include <linux/poll.h> +#include <linux/wait.h> +#include <linux/time.h> + +#include <linux/spinlock.h> +#include <linux/interrupt.h> +#include <linux/device.h> + +#include <asm/uaccess.h> +#include <asm/io.h> + +#define RIPORT_DEBUG + +#undef PDEBUG +#ifdef RIPORT_DEBUG +# define PDEBUG(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define PDEBUG(fmt, args...) +#endif /* */
linux-2.6.17.1/drivers/char/riport.c line 90
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ +/*----------------------------------------------------------------------------*/ + +#define RPINIT 0 +#define RPREAD_HEADER 1 +#define RPSYNC 2 +#define RPREAD 3 +#define RPDUMP_TIMESTAMP 4 +struct devriport { +int io;
May need to use unsigned long or some new resource_t (in -mm) for IO addresses.
Quoted 11 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +11
-0+int io_ext; +int irq; +int dma; +int size;/* buffer size */ +unsigned char *pbuf;/* pointer to the start of the memory that +stores scans from the riegl */ +unsigned char *pbuf_top;/* pointer to the end of pbuf (see above) */ +unsigned char *pin;/* pointer to the end of new data */ +unsigned char *pout;/* pointer to the start of new data (end of +old/read data) */ +wait_queue_head_t qwait;
linux-2.6.17.1/drivers/char/riport.c line 111
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+struct inode *pinode; +struct file *pfile; +int usage; +int irqinuse; +int readState; +short syncWord; +int numBytesThisState; +int bytesToRead; +char buf[4 ]; +struct timeval timeStamp;
Don't use studlyCaps names.
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+spinlock_t lock; +}; + +struct devriport *devriport_init (int major,int minor,int io,int irq, +int dma,int size,int *presult); +void devriport_cleanup (struct devriport *this); +int devriport_open (struct devriport *this); +int devriport_release (struct devriport *this); +int devriport_read (struct devriport *this,char *pbuf,int length); +unsigned int devriport_poll(struct devriport *this,
linux-2.6.17.1/drivers/char/riport.c line 132
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ struct poll_table_struct *ptable); +void devriport_irq (struct devriport *this,int irq,struct pt_regs *regs); + +irqreturn_t devriport_irq_wrap (int irq,void *pv,struct pt_regs *pr) +{ +devriport_irq (pv, irq, pr); +return IRQ_HANDLED ; +} + +void devriport_rx (struct devriport *this);
Lots of functions need to be made 'static'.
This function (below) can be __init, can't it?
Quoted 4 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +4
-0+struct devriport *devriport_init (int major,int minor,int io,int irq, +int dma,int size,int *presult) +{ +struct devriport *this;
linux-2.6.17.1/drivers/char/riport.c line 147
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ + *presult =0 ; + this =kmalloc (sizeof (struct devriport ),GFP_KERNEL ); +if (!this) { + *presult = -ENOMEM ; + goto fail_memory; + } + +if (!request_region (io,3 ,"riport" )) { +PDEBUG ("request_region 0x%X of 3 bytes fails \n" , io);
Drop space before newline.
linux-2.6.17.1/drivers/char/riport.c line 154
Quoted 7 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +7
-0+ *presult = -EBUSY ; + goto fail_io; + } +if (!request_region (io +ECP_OFFSET ,3 ,"riport" )) { +release_region (io,3 ); + +PDEBUG ("request_region 0x%X of 3 bytes fails \n" , io +ECP_OFFSET );
Drop space before newline.
linux-2.6.17.1/drivers/char/riport.c line 150
Quoted 3 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +3
-0+ *presult = -EBUSY ; + goto fail_io; + }
Could use kzalloc() above and skip clearing individual fields here.
Quoted 11 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +11
-0+ this->io = io; + this->io_ext = io +ECP_OFFSET ; + this->irq = irq; + this->dma = dma; + this->size = size; + this->pinode =NULL ; + this->pfile =NULL ; + this->usage =0 ; + this->readState =RPINIT ; + this->syncWord =0 ; + this->bytesToRead =0 ;
linux-2.6.17.1/drivers/char/riport.c line 178
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ this->numBytesThisState =0 ; +init_waitqueue_head (&this->qwait); + + this->irqinuse =0 ; + +spin_lock_init (&this->lock); + +/* test if ECP port (required) */ +outb (0x34 , this->io_ext +ECR_EXT ); +if (0x35 !=inb (this->io_ext +ECR_EXT )) {
May not be documented, but kernel style is (mostly)
if (x != constant) as opposed to if (constant != x)
linux-2.6.17.1/drivers/char/riport.c line 188
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ *presult = -ENXIO ; + goto fail_dev; + } +printk (KERN_NOTICE +"ecp: found at io=0x%x irq=%d major=%d minor=%d size=%d\n" , + io, irq, major, minor, size); +return this; + +fail_dev: +PDEBUG ("fail_dev \n" );
Drop space before newline.
linux-2.6.17.1/drivers/char/riport.c line 192
Quoted 4 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +4
-0+release_region (io +ECP_OFFSET ,3 ); +release_region (io,3 ); +fail_io: +PDEBUG ("fail_io \n" );
Ditto.
Quoted 8 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +8
-0+kfree (this); + +fail_memory: +return NULL ; + +} + +
linux-2.6.17.1/drivers/char/riport.c line 217
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+int devriport_open (struct devriport *this) +{ +int result; + +if (this->usage) +return -EBUSY ; + + result = +request_irq (this->irq, devriport_irq_wrap,SA_INTERRUPT ,"riport" , + this);
indentation problem.
linux-2.6.17.1/drivers/char/riport.c line 219
Quoted 2 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +2
-0+if (result) { +PDEBUG ("request_irq returns %d \n" , result);
no space before newline.
linux-2.6.17.1/drivers/char/riport.c line 229
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ goto fail_irq; + } + + this->irqinuse =1 ; + + this->pbuf =kmalloc (this->size,GFP_KERNEL ); +if (!this->pbuf) + result = -ENOMEM ; +if (result) + goto fail_memory;
Combine those 3 lines.
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+ + this->pbuf_top = this->pbuf + this->size -1 ; + + this->pin = this->pbuf; + this->pout = this->pbuf; +
linux-2.6.17.1/drivers/char/riport.c line 245
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+/* make the driver search for a sync byte. Needs a valid header to find +* the sync */ + this->readState =RPINIT ; + this->syncWord =0 ; + this->bytesToRead =0 ; + this->numBytesThisState =0 ; + +/* set up ECP port */ + +/* switch to compatibility mode */
If we had a parport maintainer and a well-documented parport client interface, I would expect this driver to use the parport sharing functions that are found in drivers/parport/share.c. Well, the driver should probably use them anyway.
Quoted 36 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +36
-0+outb (ECR_SPP_MODE |ECR_ERRINT_DISABLED |ECR_SERVICE_INTERRUPT , + this->io_ext +ECR_EXT ); +outb (DCR_NOT_REVERSE_REQUEST |DCR_NOT_1284_ACTIVE , + this->io +DCR_BASE ); + +/* switch to reverse direction & disable IRQ'S */ +outb (ECR_BYTE_MODE |ECR_ERRINT_DISABLED |ECR_SERVICE_INTERRUPT , + this->io_ext +ECR_EXT ); +outb (DCR_DIRECTION |DCR_NOT_REVERSE_REQUEST , this->io +DCR_BASE ); +outb (ECR_ECP_MODE |ECR_ERRINT_DISABLED |ECR_SERVICE_INTERRUPT , + this->io_ext +ECR_EXT ); +outb (DCR_DIRECTION , this->io +DCR_BASE ); + + this->usage++; +WARN_ON (this->usage >1 ); +PDEBUG ("open\n" ); + +/* do an initial read from the riegl -- reads the header */ +devriport_rx (this); +return 0 ; +fail_memory: + this->irqinuse =0 ; +free_irq (this->irq, this); +fail_irq: +return result; +} + + +int devriport_read (struct devriport *this,char *pbuf,int length) +{ +DECLARE_WAITQUEUE (wait, current); +int retval; +int length0, length1; +int count; + +add_wait_queue (&this->qwait, &wait);
linux-2.6.17.1/drivers/char/riport.c line 309
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ + retval =0 ; + current->state =TASK_INTERRUPTIBLE ; + +while (this->pin == this->pout) { + +/* if nonblocking, return with EAGAIN (to tell the caller to +* try again) */ +if (this->pfile->f_flags &O_NONBLOCK ) { +printk ("EAGAIN Error\n" );
Why the printk? at least use PDEBUG() for it.
Quoted 8 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +8
-0+ retval = -EAGAIN ; +break ; + } + +schedule (); + +if (signal_pending (current)) { + retval = -ERESTARTSYS ;
linux-2.6.17.1/drivers/char/riport.c line 327
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+break ; + } + } + + current->state =TASK_RUNNING ; +remove_wait_queue (&this->qwait, &wait); + +if (retval) { +return retval; + }
Drop the braces on one-line "blocks."
linux-2.6.17.1/drivers/char/riport.c line 331
Quoted 4 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +4
-0+ length0 = this->pin - this->pout; + +/* the buffer is circular, so pin can be less than pout, if this is the +* case read from pout and wrap around */
I thought that we had some circular buffer helpers in include/linux/, but I can't find them.
linux-2.6.17.1/drivers/char/riport.c line 341
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+if (length0 <0 ) { + length0 += this->size; + length = (length0 < length) ? length0 : length; + +/* length1 is the number of bytes from the current read +* position in the circular buffer to the end of the buffer */ + length1 = this->pbuf + this->size - this->pout; +if (length < length1) { + count =copy_to_user (pbuf, this->pout, length); +WARN_ON (count != length);
Does this work? copy_to_user() returns the number of bytes that could *not* be copied, returns 0 on success.
(same for below)
Quoted 76 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +76
-0+ } + +else { +/* we know that the buffer has wrapped, so read length +* bytes from the end of the buffer and the rest of the +* bytes from the start */ + count =copy_to_user (pbuf, this->pout, length1); +WARN_ON (count != length1); + count =copy_to_user (pbuf + length1, this->pbuf, + length - length1); +WARN_ON (count != length - length1); + } + } +else { +/* since the buffer hasn't wrapped yet, just dump bytes from +* the current read position (this->pout) to the user */ + length = (length0 < length) ? length0 : length; + count =copy_to_user (pbuf, this->pout, length); +WARN_ON (count != length); + } + +spin_lock_irq (&this->lock); + + this->pout += length; +if (this->pout > this->pbuf_top) + this->pout -= this->size; + +devriport_rx (this); + +spin_unlock_irq (&this->lock); + +return length; +} + +unsigned int devriport_poll (struct devriport *this, +struct poll_table_struct *ptable) +{ +unsigned int mask =0 ; +poll_wait (this->pfile, &this->qwait, ptable); +if (this->pin != this->pout) + mask |=POLLIN |POLLRDNORM ; +return mask; +} + +void devriport_irq (struct devriport *this,int irq,struct pt_regs *regs) +{ +if (this->irqinuse) { +spin_lock_irq (&this->lock); +devriport_rx (this); +spin_unlock_irq (&this->lock); +wake_up_interruptible (&this->qwait); + } +} + +void devriport_rx (struct devriport *this) +{ +int free; + + free = this->pin - this->pout; + +/* absolute value of free... using twos complement*/ +if (free <0 ) + free = -(free +1 ); +else + free = this->size - (free +1 ); + +while (free && !(ECR_FIFO_EMPTY &inb (this->io_ext +ECR_EXT ))) { + +if (this->readState !=RPDUMP_TIMESTAMP ) + *(this->pin++) =inb (this->io_ext +FIFO_EXT ); +else + *(this->pin++) = + ((char *)&this->timeStamp)[this->numBytesThisState]; + +if (this->pin > this->pbuf_top) + this->pin -= this->size;
linux-2.6.17.1/drivers/char/riport.c line 427
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ + free--; +switch (this->readState) { +/* due to the magic of the ECP port, it seems that we are +guaranteed to be fed a header from the riegl whenever we call +riport_open. this code assumes that is true */ +case RPINIT : +/* header length is the first 4 bytes in the header*/ + this->buf[(this->numBytesThisState)++] = + *(this->pin -1 );
Funky indentation above.
linux-2.6.17.1/drivers/char/riport.c line 435
Quoted 8 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +8
-0+ +/* after 4 bytes, we know the size of the header +the next two bytes are the size of the header */ +if (this->numBytesThisState ==4 ) { + this->bytesToRead = + this->buf[0 ] + (this->buf[1 ] <<8 ) + + (this->buf[2 ] <<16 ) + + (this->buf[3 ] <<24 ) -4 ;
Odd indentation.
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+ +/* reset variables for RPREAD_HEADER */ + this->numBytesThisState =0 ; + this->readState =RPREAD_HEADER ; + } +break ;
...
Quoted 20 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +20
-0+ } + } + +/* if we there isn't any more space in the buffer, enable interrupts +* otherwise disable service interrupts in both cases, leave parallel +* port in ECP mode and disable error interrupt*/ +if (free) +/* enable IRQ's */ +outb (ECR_ECP_MODE |ECR_ERRINT_DISABLED , + this->io_ext +ECR_EXT ); +else +/* disable IRQ's */ +outb (ECR_ECP_MODE |ECR_ERRINT_DISABLED | +ECR_SERVICE_INTERRUPT , this->io_ext +ECR_EXT ); +} + + +/*----------------------------------------------------------------------------*/ +static struct drvriport { + int major;
linux-2.6.17.1/drivers/char/riport.c line 548
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+int numdevs; +struct devriport *rgpdev[MAX_RIPORT_DEVICES ]; +} riport; + +int drvriport_open (struct inode *pinode,struct file *pfile) +{ +int result; +struct devriport *pdev; + +PDEBUG ("drvriport_open \n" );
Drop space before newline.
Quoted 16 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +16
-0+if (!(MINOR (pinode->i_rdev) < riport.numdevs)) +return -ENODEV ; + pdev = riport.rgpdev[MINOR (pinode->i_rdev)]; + pdev->pinode = pinode; + pdev->pfile = pfile; + pfile->private_data = pdev; + result =devriport_open (pdev); + +return result; +} + +int drvriport_release (struct inode *pinode,struct file *pfile) +{ +devriport_release (riport.rgpdev[MINOR (pinode->i_rdev)]); +return 0 ; +}
linux-2.6.17.1/drivers/char/riport.c line 574
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ +ssize_t drvriport_read (struct file * pfile,char *pbuf,size_t length, +loff_t * ppos) +{ +return devriport_read ((struct devriport *)pfile->private_data, pbuf, + length); +} + +unsigned int drvriport_poll (struct file *pfile, +struct poll_table_struct *ptable)
Is this function used? where?
linux-2.6.17.1/drivers/char/riport.c line 584
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+{ +return devriport_poll ((struct devriport *)pfile->private_data, ptable); +} + +static struct file_operations drvriport_fops = { + owner:THIS_MODULE , + read : drvriport_read, + open : drvriport_open, + release : drvriport_release, +};
Use C99-style initializers.
Quoted 13 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +13
-0+ + +static int io; +static int irq; +static int dma =1 ; +static int size; + +/*declarations to enable udev device node creation*/ +static struct class *riport_class; + +static int __init riport_init (void ) +{ +int major =0 ;
linux-2.6.17.1/drivers/char/riport.c line 607
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+int result; +struct devriport *pdev; +int n; +struct class_device *class_err; + +if (0 == io) + io =RIPORT_IO ; +if (0 == irq) + irq =RIPORT_IRQ ; +if (0 == size)
Reverse order inside parens.
Quoted 8 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +8
-0+ size =RIPORT_SIZE ; +if ((result =register_chrdev (major,"riport" , &drvriport_fops)) <0 ) + goto fail_register_chrdev; + +/* TODO: here is the place to add more riport devices */ + riport.major = result; + riport.numdevs =0 ; +
linux-2.6.17.1/drivers/char/riport.c line 625
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+ pdev = +devriport_init (riport.major, riport.numdevs, io, irq, dma, size, + &result); +if (!pdev) + goto init_fail_dev; + + riport.rgpdev[riport.numdevs++] = pdev; + + riport_class =class_create (THIS_MODULE ,"riport" ); +if (IS_ERR (riport_class)) {
space between if and '('.
Quoted 26 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +26
-0+ result =PTR_ERR (riport_class); + goto init_fail_dev; + } + + class_err =class_device_create (riport_class,NULL , +MKDEV (riport.major,0 ),NULL ,"riport0" ); + +if (IS_ERR (class_err)) { + result =PTR_ERR (class_err); +class_destroy (riport_class); + goto init_fail_dev; + } + +return 0 ; + +init_fail_dev: +PDEBUG ("init_fail_dev\n" ); +for (n =0 ; n < riport.numdevs; n++) +devriport_cleanup (riport.rgpdev[n]); +unregister_chrdev (riport.major,"riport" ); + +fail_register_chrdev: +PDEBUG ("fail_register_chrdev\n" ); +return result; +} +
linux-2.6.17.1/drivers/char/riport.c line 661
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+static void __exit riport_exit(void) +{ +int n; + +class_device_destroy (riport_class,MKDEV (riport.major,0 )); +class_destroy (riport_class); +for (n =0 ; n < riport.numdevs; n++) +devriport_cleanup (riport.rgpdev[n]); +unregister_chrdev (riport.major,"riport" ); +}
---
~Randy
linux-2.6.17.1/drivers/char/riport.c line 80
Quoted 7 lines · mark gross
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +7
-0+ +#undef PDEBUG +#ifdef RIPORT_DEBUG +# define PDEBUG(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define PDEBUG(fmt, args...) +#endif /* */
what's wrong with prdebug ?
linux-2.6.17.1/drivers/char/riport.c line 124
Quoted 11 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +11
-0+ + +struct devriport *devriport_init (int major,int minor,int io,int irq, +int dma,int size,int *presult); +void devriport_cleanup (struct devriport *this); +int devriport_open (struct devriport *this); +int devriport_release (struct devriport *this); +int devriport_read (struct devriport *this,char *pbuf,int length); +unsigned int devriport_poll (struct devriport *this, +struct poll_table_struct *ptable); +void devriport_irq (struct devriport *this,int irq,struct pt_regs *regs);
if you reorder the functions a bit you can get rid of these prototypes entirely... (and make a bunch static)
linux-2.6.17.1/drivers/char/riport.c line 130
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+ +irqreturn_t devriport_irq_wrap (int irq,void *pv,struct pt_regs *pr) +{ +devriport_irq (pv, irq, pr); +return IRQ_HANDLED ; +}
that looks odd; even if it's not your IRQ you always call it handled....
linux-2.6.17.1/drivers/char/riport.c line 217
Quoted 10 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +10
-0+int devriport_open (struct devriport *this) +{ +int result; + +if (this->usage) +return -EBUSY ; + + result = +request_irq (this->irq, devriport_irq_wrap,SA_INTERRUPT ,"riport" , + this);
are you sure you can handle an interrupt at this time already? Usually the request_irq() is done *after* initialization of all other data structures to make sure that if an irq hits all data structures are initialized...
linux-2.6.17.1/drivers/char/riport.c line 304
Quoted 13 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +13
-0+int devriport_read (struct devriport *this,char *pbuf,int length) +{ +DECLARE_WAITQUEUE (wait, current); +int retval; +int length0, length1; +int count; + +add_wait_queue (&this->qwait, &wait); + + retval =0 ; + current->state =TASK_INTERRUPTIBLE ; + +while (this->pin == this->pout) {
this looks buggy, at least you want to set the state inside the while loop somewhere (and use set_task_state() and friends API)
linux-2.6.17.1/drivers/char/riport.c line 322
Quoted 1 line
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +1
-0+ current->state =TASK_RUNNING ;
set_current_state()
linux-2.6.17.1/drivers/char/riport.c line 341
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+/* length1 is the number of bytes from the current read +* position in the circular buffer to the end of the buffer */ + length1 = this->pbuf + this->size - this->pout; +if (length < length1) { + count =copy_to_user (pbuf, this->pout, length); +WARN_ON (count != length);
WARN_ON isn't really handling the error......
linux-2.6.17.1/drivers/char/riport.c line 391
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+void devriport_irq (struct devriport *this,int irq,struct pt_regs *regs) +{ +if (this->irqinuse) { +spin_lock_irq (&this->lock); +devriport_rx (this); +spin_unlock_irq (&this->lock);
this unconditionally enables interrupts... that's generally bad. Please consider using irqsave/irqrestore
linux-2.6.17.1/drivers/char/riport.c line 571
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+ssize_t drvriport_read (struct file * pfile,char *pbuf,size_t length, +loff_t * ppos) +{ +return devriport_read ((struct devriport *)pfile->private_data, pbuf, + length); +}
this looks odd; you don't pass pfile to the _read function below... yet inside it you do use the file argument. Would make a lot more sense to pass it in....
linux-2.6.17.1/drivers/char/riport.c line 584
Quoted 6 lines
linux-2.6.17.1/drivers/char/riport.c renamed from drivers/char/riport.c +6
-0+static struct file_operations drvriport_fops = { + owner:THIS_MODULE , + read : drvriport_read, + open : drvriport_open, + release : drvriport_release, +};
can be "const"
Ok, I've addressed all of Randy's and your comments in the patch at appended to this email. Its includes the re-shuffling of the functions to loose the declarations at the top of the file. For the items I didn't address I have comments below.
Thanks for both of your inputs!
Quoted 11 lines · Arjan van de Ven
Review
Quoted 7 lines · mark gross
(quoted diff) +7
-0+ +#undef PDEBUG +#ifdef RIPORT_DEBUG +# define PDEBUG(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define PDEBUG(fmt, args...) +#endif /* */what's wrong with prdebug ?
Quoted 1 line
+
what is prdebug?
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ +irqreturn_t devriport_irq_wrap(int irq, void *pv, struct pt_regs *pr) +{ + devriport_irq(pv, irq, pr); + return IRQ_HANDLED; +}that looks odd; even if it's not your IRQ you always call it handled....
yeah, it cant share interrupts well like this. All I can say is that its no worse than parport_pc.c :( This should be fixed.
Quoted 9 lines
Review
Quoted 7 lines
(quoted diff) +4
-0+ length1 = this->pbuf + this->size - this->pout; + if (length < length1) { + count = copy_to_user(pbuf, this->pout, length); + WARN_ON(count != length);
WARN_ONisn't really handling the error......
Its not trying to handle the error. For this driver I can't think of what you would do other than drop the frame. As I don't have specs on the device (I'm just doing a port.) I'll leave it as a todo to get proper frame dropping logic for when the copy to user fails to copy all the data.
drivers/char/Kconfig renamed from linux-2.6.17.1/drivers/char/Kconfig +13 -0
@@ -1034,5 +1034,18 @@ sysfs directory, /sys/devices/platform/telco_clock, with a number of files for controlling the behavior of this hardware. + +config RIPORT + tristate "Riport driver to Riegl systems LADAR terrain scanner" + depends on EXPERIMENTAL + default n + help + The riport driver talks through the parallel port to a Riegl systems + LADAR terrain scanner http://www.riegl.com/. This is the scanner + that was used by http://www.redteamracing.org/ H1ghlander and + Sandstorm robots. Its the device in the big round thing on top of + the hummers. This driver is a 2.6 port of the driver used in those + robots. + endmenu
drivers/char/Makefile renamed from linux-2.6.17.1/drivers/char/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o +obj-$(CONFIG_RIPORT) += riport.o obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_MWAVE) += mwave/
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +649 -0
649 lines not on this page · raw message
Quoted 19 lines · On Thu, 22 Jun 2006 16:16:04 -0700 mark gross wrote:
Ok, I've addressed all of Randy's and your comments in the patch at appended to this email. Its includes the re-shuffling of the functions to loose the declarations at the top of the file. For the items I didn't address I have comments below.
Thanks for both of your inputs!
Quoted 10 lines · Arjan van de Ven
drivers/char/riport.c line 80
Quoted 7 lines · mark gross
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +7
-0+ +#undef PDEBUG +#ifdef RIPORT_DEBUG +# define PDEBUG(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define PDEBUG(fmt, args...) +#endif /* */ what's wrong with prdebug ?
Quoted 3 lines
Quoted 1 line
Quoted 1 line
+
what is prdebug?
pr_debug() in linux/kernel.h
I'll look at the updated version later.
---
~Randy
On Thu, 22 Jun 2006 16:16:04 -0700 mark gross wrote:
a. still has 6 lines of trailing whitespace.
Quoted 26 lines
diff -urN -X linux-2.6.17.1/Documentation/dontdiff
../linux-2.6.17.1/drivers/char/riport.clinux-2.6.17.1/drivers/char/riport.cdrivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +22
-0+static struct devriport __init *devriport_init (int major,int minor,unsigned int io,int irq, +int dma,int size,int *presult) +{ +struct devriport *this; + + *presult =0 ; + this =kzalloc (sizeof (struct devriport ),GFP_KERNEL ); +if (!this) { + *presult = -ENOMEM ; + goto fail_memory; + } + +if (!request_region (io,3 ,"riport" )) { +PDEBUG ("request_region 0x%X of 3 bytes fails\n" , io); + *presult = -EBUSY ; + goto fail_io; + } +if (!request_region (io +ECP_OFFSET ,3 ,"riport" )) { +release_region (io,3 ); + +PDEBUG ("request_region 0x%X of 3 bytes fails\n" , io +ECP_OFFSET ); + *presult = -EBUSY ;
drivers/char/riport.c line 155
Quoted 10 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +9
-0+ goto fail_io; + } + this->pinode =NULL ; + this->pfile =NULL ; + this->usage =0 ; + this->syncWord =0 ; + this->bytestoread =0 ; + this->numbytesthisstate =0 ; + this->irqinuse =0 ;
Since kzalloc() is now being used, above lines aren't needed.
drivers/char/riport.c line 238
Quoted 4 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +4
-0+switch (this->readstate) { +/* due to the magic of the ECP port, it seems that we are +guaranteed to be fed a header from the riegl whenever we call +riport_open. this code assumes that is true */
For multi-line comments (multiple places), regular kernel coding style is:
/* * due to blah blah ... * end */
drivers/char/riport.c line 485
Quoted 6 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +5
-0+static int devriport_open (struct devriport *this) +{ + result = +request_irq (this->irq, devriport_irq_wrap,SA_INTERRUPT , +"riport" , this);
Put that on 2 lines.
drivers/char/riport.c line 589
Quoted 6 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +5
-0+static int __init riport_init (void ) +{ + pdev = +devriport_init (riport.major, riport.numdevs, io, irq, dma, size, + &result);
Put on 2 lines.
drivers/char/riport.c line 644
Quoted 8 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +7
-0+} + +module_param (io, int,0444 ); +MODULE_PARM_DESC (io,"if non-zero then overrides IO port address" ); + +module_param (irq, int,0444 ); +MODULE_PARM_DESC (io,"if non-zero then overrides IRQ number" );
irq
drivers/char/riport.c line 647
Quoted 3 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +3
-0+ +module_param (size, int,0444 ); +MODULE_PARM_DESC (io,"if non-zero then overrides buffer size" );
size
---
~Randy
Quoted 35 lines · Randy.Dunlap
On Thu, 22 Jun 2006 16:16:04 -0700 mark gross wrote:
a. still has 6 lines of trailing whitespace.
Review
Quoted 4 lines
(quoted diff) +4
-0+ this->syncWord = 0; + this->bytestoread = 0; + this->numbytesthisstate = 0; + this->irqinuse = 0;Since
kzalloc()is now being used, above lines aren't needed.Review
Quoted 4 lines
(quoted diff) +4
-0+ switch (this->readstate) { + /* due to the magic of the ECP port, it seems that we are + guaranteed to be fed a header from the riegl whenever we call + riport_open. this code assumes that is true */For multi-line comments (multiple places), regular kernel coding style is:
/* * due to blah blah ... * end */Review
Quoted 6 lines
(quoted diff) +5
-0+static int devriport_open(struct devriport *this) +{ + result = + request_irq(this->irq, devriport_irq_wrap, SA_INTERRUPT, + "riport", this);Put that on 2 lines.
Quoted 2 lines
(quoted diff) +2
-0+static int __init riport_init(void) +{
Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ pdev = + devriport_init(riport.major, riport.numdevs, io, irq, dma, size, + &result);Put on 2 lines.
Review
Quoted 2 lines
(quoted diff) +2
-0+} +
Ok I think I got them all this time, see below.
Thanks so much for looking at this.
I don't actually want to get this driver into the kernel. I needed another example for a driver porting tutorial I'm working on, and this driver is something I had worked with a couple of years ago.
I think its as far as I want to take this code, CMU may what to take it father, but for now I'm happy with it for my use as an example.
thanks,
--mgross
drivers/char/Kconfig renamed from linux-2.6.17.1/drivers/char/Kconfig +13 -0
@@ -1034,5 +1034,18 @@ sysfs directory, /sys/devices/platform/telco_clock, with a number of files for controlling the behavior of this hardware. + +config RIPORT + tristate "Riport driver to Riegl systems LADAR terrain scanner" + depends on EXPERIMENTAL + default n + help + The riport driver talks through the parallel port to a Riegl systems + LADAR terrain scanner http://www.riegl.com/. This is the scanner + that was used by http://www.redteamracing.org/ H1ghlander and + Sandstorm robots. Its the device in the big round thing on top of + the hummers. This driver is a 2.6 port of the driver used in those + robots. + endmenu
drivers/char/Makefile renamed from linux-2.6.17.1/drivers/char/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o +obj-$(CONFIG_RIPORT) += riport.o obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_MWAVE) += mwave/
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +663 -0
663 lines not on this page · raw message
since this is for a tutorial... double nitpick mode ;-) (since examples should be squeeky clean or people will turn the right thing into the not quite right thing later in their own code)
drivers/char/riport.c line 80
Quoted 6 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +6
-0+#undef PDEBUG +#ifdef RIPORT_DEBUG +# define PDEBUG(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define PDEBUG(fmt, args...) +#endif /* */
this is still there while it really shouldn't be; either use pr_debug() or dev_printk().
Quoted 16 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +16
-0+struct devriport { +unsigned int io; +unsigned int io_ext; +int irq; +int dma; +int size;/* buffer size */ +unsigned char *pbuf;/* pointer to the start of the memory that +stores scans from the riegl */ +unsigned char *pbuf_top;/* pointer to the end of pbuf (see above) */ +unsigned char *pin;/* pointer to the end of new data */ +unsigned char *pout;/* pointer to the start of new data (end of +old/read data) */ +wait_queue_head_t qwait; +struct inode *pinode; +struct file *pfile; +int usage;
drivers/char/riport.c line 114
Quoted 10 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +10
-0+int irqinuse; +int readstate; +short syncWord; +int numbytesthisstate; +int bytestoread; +char buf[4 ]; +struct timeval timestamp; + +spinlock_t lock; +};
if this is for a tutorial.. might as well sort these fields in order of decreasing size so that you get minimal alignment packing by the compiler
drivers/char/riport.c line 140
Quoted 7 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +7
-0+if (!request_region (io +ECP_OFFSET ,3 ,"riport" )) { +release_region (io,3 ); + +PDEBUG ("request_region 0x%X of 3 bytes fails\n" , io +ECP_OFFSET ); + *presult = -EBUSY ; + goto fail_io; + }
might as well make another goto target and have that do the release_region...
Quoted 20 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +20
-0+ +static int devriport_release (struct devriport *this) +{ + this->irqinuse =0 ; + +/* switch to compatibility mode */ +outb (ECR_SPP_MODE |ECR_ERRINT_DISABLED |ECR_SERVICE_INTERRUPT , + this->io_ext +ECR_EXT ); +outb (DCR_NOT_REVERSE_REQUEST |DCR_SELECT_IN , this->io +DCR_BASE ); + +free_irq (this->irq, this); +kfree (this->pbuf); + + this->usage--; +WARN_ON (this->usage <0 ); +PDEBUG ("release\n" ); +return 0 ; +} + +
...
drivers/char/riport.c line 463
Quoted 8 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +8
-0+ + +static int devriport_open (struct devriport *this) +{ +int result; + +if (this->usage) +return -EBUSY ;
this "usage count" thing is probably buggy and racy; what is it for?
drivers/char/riport.c line 658
Quoted 5 lines · On Fri, 23 Jun 2006 15:46:54 -0700 mark gross wrote:
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +5
-0+module_param (io, int,0444 ); +MODULE_PARM_DESC (io,"if non-zero then overrides IO port address" ); + +module_param (irq, int,0444 ); +MODULE_PARM_DESC (io,"if non-zero then overrides IRQ number" );
irq
drivers/char/riport.c line 661
Quoted 2 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +2
-0+module_param (size, int,0444 ); +MODULE_PARM_DESC (io,"if non-zero then overrides buffer size" );
size
Did you ever update these? I mentioned them in a previous email.
---
~Randy
Quoted 5 lines · Arjan van de Ven
since this is for a tutorial... double nitpick mode ;-) (since examples should be squeeky clean or people will turn the right thing into the not quite right thing later in their own code)
Quoted 10 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+#undef PDEBUG +#ifdef RIPORT_DEBUG +# define PDEBUG(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define PDEBUG(fmt, args...) +#endif /* */this is still there while it really shouldn't be; either use
pr_debug()ordev_printk().
done
Quoted 23 lines
Quoted 23 lines
(quoted diff) +22
-0+struct devriport { + unsigned int io; + unsigned int io_ext; + int irq; + int dma; + int size; /* buffer size */ + unsigned char *pbuf; /* pointer to the start of the memory that + stores scans from the riegl */ + unsigned char *pbuf_top;/* pointer to the end of pbuf (see above) */ + unsigned char *pin; /* pointer to the end of new data */ + unsigned char *pout; /* pointer to the start of new data (end of + old/read data) */ + wait_queue_head_t qwait; + struct inode *pinode; + struct file *pfile; + int usage; + int irqinuse; + int readstate; + short syncWord; + int numbytesthisstate; + int bytestoread; + char buf[4];
Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ struct timeval timestamp; + + spinlock_t lock; +};if this is for a tutorial.. might as well sort these fields in order of decreasing size so that you get minimal alignment packing by the compiler
done
Quoted 11 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (!request_region(io + ECP_OFFSET, 3, "riport")) { + release_region(io,3); + + PDEBUG("request_region 0x%X of 3 bytes fails\n", io + ECP_OFFSET ); + *presult = -EBUSY; + goto fail_io; + }might as well make another goto target and have that do the
release_region...
yes
Quoted 22 lines
Quoted 20 lines
(quoted diff) +20
-0+ +static int devriport_release(struct devriport *this) +{ + this->irqinuse = 0; + + /* switch to compatibility mode */ + outb(ECR_SPP_MODE | ECR_ERRINT_DISABLED | ECR_SERVICE_INTERRUPT, + this->io_ext + ECR_EXT); + outb(DCR_NOT_REVERSE_REQUEST | DCR_SELECT_IN, this->io + DCR_BASE); + + free_irq(this->irq, this); + kfree(this->pbuf); + + this->usage--; + WARN_ON(this->usage < 0); + PDEBUG("release\n"); + return 0; +} + +...
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ + +static int devriport_open(struct devriport *this) +{ + int result; + + if (this->usage) + return -EBUSY;this "usage count" thing is probably buggy and racy; what is it for?
its just to keep the device a one user-at-a-time. It is racy.
In addition to these updates I ran space on the driver to find some missing __user declarations that are now fixed up.
drivers/char/Kconfig renamed from linux-2.6.17.1/drivers/char/Kconfig +13 -0
@@ -1034,5 +1034,18 @@ sysfs directory, /sys/devices/platform/telco_clock, with a number of files for controlling the behavior of this hardware. + +config RIPORT + tristate "Riport driver to Riegl systems LADAR terrain scanner" + depends on EXPERIMENTAL + default n + help + The riport driver talks through the parallel port to a Riegl systems + LADAR terrain scanner http://www.riegl.com/. This is the scanner + that was used by http://www.redteamracing.org/ H1ghlander and + Sandstorm robots. Its the device in the big round thing on top of + the hummers. This driver is a 2.6 port of the driver used in those + robots. + endmenu
drivers/char/Makefile renamed from linux-2.6.17.1/drivers/char/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o +obj-$(CONFIG_RIPORT) += riport.o obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_MWAVE) += mwave/
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +661 -0
661 lines not on this page · raw message
drivers/char/riport.c line 80
Quoted 9 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +8
-0+#define RIPORT_DEBUG + +#undef pr_debug +#ifdef RIPORT_DEBUG +# define pr_debug(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define pr_debug(fmt, args...) +#endif /* */
ehhhhh that's not what I meant... if you would just remove these 6 lines.. then sure..
drivers/char/riport.c line 138
Quoted 6 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +6
-0+if (!request_region (io +ECP_OFFSET ,3 ,"riport" )) { +release_region (io,3 ); + +pr_debug ("request_region 0x%X of 3 bytes fails\n" , io +ECP_OFFSET ); + *presult = -EBUSY ; + goto fail_io2;
this is a double release..
drivers/char/riport.c line 166
Quoted 5 lines
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +5
-0+ +fail_dev: +release_region (io +ECP_OFFSET ,3 ); +fail_io2: +release_region (io,3 );
with this.
drivers/char/riport.c line 378
Quoted 1 line
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +1
-0+ current->state =TASK_RUNNING ;
please use set_current_state() API for this
Quoted 14 lines · Arjan van de Ven
Review
Quoted 9 lines
(quoted diff) +8
-0+#define RIPORT_DEBUG + +#undef pr_debug +#ifdef RIPORT_DEBUG +# define pr_debug(fmt, args...) printk( KERN_DEBUG "riport: " fmt, ## args) +#else /* */ +# define pr_debug(fmt, args...) +#endif /* */ehhhhh that's not what I meant... if you would just remove these 6 lines.. then sure..a
It was a long weekend. I'm not as with it as I should be today.
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ if (!request_region(io + ECP_OFFSET, 3, "riport")) { + release_region(io,3); + + pr_debug("request_region 0x%X of 3 bytes fails\n", io + ECP_OFFSET ); + *presult = -EBUSY; + goto fail_io2;this is a double release..
see above.
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +fail_dev: + release_region(io + ECP_OFFSET,3); +fail_io2: + release_region(io,3);with this.
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ current->state = TASK_RUNNING;please use
set_current_state()API for this
yes.
drivers/char/Kconfig renamed from linux-2.6.17.1/drivers/char/Kconfig +13 -0
@@ -1034,5 +1034,18 @@ sysfs directory, /sys/devices/platform/telco_clock, with a number of files for controlling the behavior of this hardware. + +config RIPORT + tristate "Riport driver to Riegl systems LADAR terrain scanner" + depends on EXPERIMENTAL + default n + help + The riport driver talks through the parallel port to a Riegl systems + LADAR terrain scanner http://www.riegl.com/. This is the scanner + that was used by http://www.redteamracing.org/ H1ghlander and + Sandstorm robots. Its the device in the big round thing on top of + the hummers. This driver is a 2.6 port of the driver used in those + robots. + endmenu
drivers/char/Makefile renamed from linux-2.6.17.1/drivers/char/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o obj-$(CONFIG_TANBAC_TB0219) += tb0219.o obj-$(CONFIG_TELCLOCK) += tlclk.o +obj-$(CONFIG_RIPORT) += riport.o obj-$(CONFIG_WATCHDOG) += watchdog/ obj-$(CONFIG_MWAVE) += mwave/
drivers/char/riport.c renamed from linux-2.6.17.1/drivers/char/riport.c +649 -0
649 lines not on this page · raw message