Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 317662
b: refs/heads/master
c: fc2536f
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 6, 2012
1 parent a07679e commit 0c36d5a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 57 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b4dda059056a9be086fc95abe2a7410b87e6c33f
refs/heads/master: fc2536fd814ea1e4399ccbfc913b5742e467320a
106 changes: 50 additions & 56 deletions trunk/drivers/staging/comedi/drivers/adl_pci6208.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,54 +137,45 @@ static int pci6208_ao_rinsn(struct comedi_device *dev,
return i;
}

/* DIO devices are slightly special. Although it is possible to
* implement the insn_read/insn_write interface, it is much more
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
/* static int pci6208_dio_insn_bits(struct comedi_device *dev,
* struct comedi_subdevice *s, */
/* struct comedi_insn *insn,unsigned int *data) */
/* { */
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
/* if(data[0]){ */
/* s->state &= ~data[0]; */
/* s->state |= data[0]&data[1]; */
/* Write out the new digital output lines */
/* outw(s->state,dev->iobase + SKEL_DIO); */
/* } */

/* on return, data[1] contains the value of the digital
* input and output lines. */
/* data[1]=inw(dev->iobase + SKEL_DIO); */
/* or we could just return the software copy of the output values if
* it was a purely digital output subdevice */
/* data[1]=s->state; */

/* return insn->n; */
/* } */

/* static int pci6208_dio_insn_config(struct comedi_device *dev,
* struct comedi_subdevice *s, */
/* struct comedi_insn *insn,unsigned int *data) */
/* { */
/* int chan=CR_CHAN(insn->chanspec); */

/* The input or output configuration of each digital line is
* configured by a special insn_config instruction. chanspec
* contains the channel to be changed, and data[0] contains the
* value COMEDI_INPUT or COMEDI_OUTPUT. */

/* if(data[0]==COMEDI_OUTPUT){ */
/* s->io_bits |= 1<<chan; */
/* }else{ */
/* s->io_bits &= ~(1<<chan); */
/* } */
/* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */

/* return 1; */
/* } */
static int pci6208_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0] & PCI6208_DIO_DO_MASK;
unsigned int bits = data[1];

if (mask) {
s->state &= ~mask;
s->state |= bits & mask;

outw(s->state, dev->iobase + PCI6208_DIO);
}

s->state = inw(dev->iobase + PCI6208_DIO);
data[1] = s->state;

return insn->n;
}

static int pci6208_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
int chan = CR_CHAN(insn->chanspec);
unsigned int mask = 1 << chan;

switch (data[0]) {
case INSN_CONFIG_DIO_QUERY:
data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT;
break;
default:
return -EINVAL;
}

return insn->n;
}

static struct pci_dev *pci6208_find_device(struct comedi_device *dev,
struct comedi_devconfig *it)
Expand Down Expand Up @@ -268,15 +259,18 @@ static int pci6208_attach(struct comedi_device *dev,
s->insn_write = pci6208_ao_winsn;
s->insn_read = pci6208_ao_rinsn;

/* s=dev->subdevices+1; */
s = dev->subdevices + 1;
/* digital i/o subdevice */
/* s->type=COMEDI_SUBD_DIO; */
/* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */
/* s->n_chan=16; */
/* s->maxdata=1; */
/* s->range_table=&range_digital; */
/* s->insn_bits = pci6208_dio_insn_bits; */
/* s->insn_config = pci6208_dio_insn_config; */
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 8;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pci6208_dio_insn_bits;
s->insn_config = pci6208_dio_insn_config;

s->io_bits = 0x0f;
s->state = inw(dev->iobase + PCI6208_DIO);

dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n",
dev->driver->driver_name, dev->board_name, dev->iobase);
Expand Down

0 comments on commit 0c36d5a

Please sign in to comment.