and compatibles
COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1998 David A. Schleef <ds@stm.lbl.gov>
+ Copyright (C) 1998 David A. Schleef <ds@schleef.org>
Janne Jalkanen <jalkanen@cs.hut.fi>
Eric Bunn <ebu@cs.hut.fi>
/*
Driver: pcl711.o
Description: Advantech PCL-711 and 711b, ADLink ACL-8112
-Authors: ds, Janne Jalkanen <jalkanen@cs.hut.fi>, Eric Bunn <ebu@cs.hut.fi>
+Author: ds, Janne Jalkanen <jalkanen@cs.hut.fi>, Eric Bunn <ebu@cs.hut.fi>
Status: mostly complete
Devices: [Advantech] PCL-711 (pcl711), PCL-711B (pcl711b),
[AdLink] ACL-8112HG (acl8112hg), ACL-8112DG (acl8112dg)
*/
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
+#include <linux/comedidev.h>
+
#include <linux/ioport.h>
#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/timer.h>
-#include <asm/io.h>
-#include <linux/comedidev.h>
+
#include "8253.h"
#define PCL711_DO_LO 13
#define PCL711_DO_HI 14
-static comedi_lrange range_pcl711b_ai = { 5, {
+static const comedi_lrange range_pcl711b_ai = { 5, {
BIP_RANGE( 5 ),
BIP_RANGE( 2.5 ),
BIP_RANGE( 1.25 ),
BIP_RANGE( 0.625 ),
BIP_RANGE( 0.3125 )
}};
-static comedi_lrange range_acl8112hg_ai = { 12, {
+static const comedi_lrange range_acl8112hg_ai = { 12, {
BIP_RANGE( 5 ),
BIP_RANGE( 0.5 ),
BIP_RANGE( 0.05 ),
BIP_RANGE( 0.1 ),
BIP_RANGE( 0.01 )
}};
-static comedi_lrange range_acl8112dg_ai = { 9, {
+static const comedi_lrange range_acl8112dg_ai = { 9, {
BIP_RANGE( 5 ),
BIP_RANGE( 2.5 ),
BIP_RANGE( 1.25 ),
BIP_RANGE( 10 )
}};
-typedef int bool;
-
/*
* flags
*/
#define PCL711_TIMEOUT 100
#define PCL711_DRDY 0x10
-static int i8253_osc_base = 500; /* 2 Mhz */
+static const int i8253_osc_base = 500; /* 2 Mhz */
typedef struct {
- char *name;
+ const char *name;
int is_pcl711b;
int is_8112;
int is_dg;
int n_aichan;
int n_aochan;
int maxirq;
- comedi_lrange * ai_range_type;
+ const comedi_lrange * ai_range_type;
} boardtype;
-static boardtype boardtypes[] =
+static const boardtype boardtypes[] =
{
{"pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5},
{"pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai},
{"acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
-#define this_board ((boardtype *)dev->board_ptr)
+#define this_board ((const boardtype *)dev->board_ptr)
static int pcl711_attach(comedi_device *dev,comedi_devconfig *it);
static int pcl711_detach(comedi_device *dev);
module: THIS_MODULE,
attach: pcl711_attach,
detach: pcl711_detach,
- board_name: boardtypes,
+ board_name: &boardtypes[0].name,
num_names: n_boardtypes,
offset: sizeof(boardtype),
};
#define devpriv ((pcl711_private *)dev->private)
-static void pcl711_interrupt(int irq, void *d, struct pt_regs *regs)
+static irqreturn_t pcl711_interrupt(int irq, void *d PT_REGS_ARG)
{
int lo, hi;
int data;
s->async->events |= COMEDI_CB_EOA;
}
comedi_event(dev, s, s->async->events);
+ return IRQ_HANDLED;
}
static void pcl711_set_changain(comedi_device * dev, int chan)
int chan_register;
outb(CR_RANGE(chan), dev->iobase + PCL711_GAIN);
-
+
chan_register=CR_CHAN(chan);
if (this_board->is_8112) {
pcl711_set_changain(dev,insn->chanspec);
- /*
- a sensible precaution to wait for the mux to
- settle here. is 10us enough?
- */
- udelay(10);
-
for(n=0;n<insn->n;n++){
/*
* Write the correct mode (software polling) and start polling by writing
hi = inb(dev->iobase + PCL711_AD_HI);
if (!(hi & PCL711_DRDY))
goto ok;
+ comedi_udelay(1);
}
rt_printk("comedi%d: pcl711: A/D timeout\n", dev->minor);
return -ETIME;
-
+
ok:
lo = inb(dev->iobase + PCL711_AD_LO);
static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
{
int ret;
- int iobase;
- int irq;
+ unsigned long iobase;
+ unsigned int irq;
comedi_subdevice *s;
/* claim our I/O space */
iobase = it->options[0];
- printk("comedi%d: pcl711: 0x%04x ", dev->minor, iobase);
- if (check_region(iobase, PCL711_SIZE) < 0) {
+ printk("comedi%d: pcl711: 0x%04lx ", dev->minor, iobase);
+ if (!request_region(iobase, PCL711_SIZE, "pcl711")) {
printk("I/O port conflict\n");
return -EIO;
}
- request_region(iobase, PCL711_SIZE, "pcl711");
dev->iobase = iobase;
/* there should be a sanity check here */
/* grab our IRQ */
irq = it->options[1];
- if (irq < 0 || irq > this_board->maxirq) {
+ if (irq > this_board->maxirq) {
printk("irq out of range\n");
return -EINVAL;
}
if (irq) {
if (comedi_request_irq(irq, pcl711_interrupt, 0, "pcl711", dev)) {
- printk("unable to allocate irq %d\n", irq);
+ printk("unable to allocate irq %u\n", irq);
return -EINVAL;
} else {
- printk("( irq = %d )\n", irq);
+ printk("( irq = %u )\n", irq);
}
}
dev->irq = irq;
- dev->n_subdevices = 4;
- if((ret=alloc_subdevices(dev))<0)
+ if((ret=alloc_subdevices(dev, 4))<0)
return ret;
if((ret=alloc_private(dev,sizeof(pcl711_private)))<0)
return ret;
s = dev->subdevices + 0;
/* AI subdevice */
s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = this_board->n_aichan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->range_table = this_board->ai_range_type;
s->insn_read = pcl711_ai_insn;
if(irq){
+ dev->read_subdev = s;
+ s->subdev_flags |= SDF_CMD_READ;
s->do_cmdtest = pcl711_ai_cmdtest;
s->do_cmd = pcl711_ai_cmd;
}
s++;
/* AO subdevice */
s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITEABLE;
+ s->subdev_flags = SDF_WRITABLE;
s->n_chan = this_board->n_aochan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s++;
/* 16-bit digital out */
s->type = COMEDI_SUBD_DO;
- s->subdev_flags = SDF_WRITEABLE;
+ s->subdev_flags = SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->len_chanlist = 16;