Commit c4ad65e6 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: pcmuio: remove 'iobases' from subdevice private data

The 'asic' and 'port' associated with a given subdevice can easily be
found based on the subdevice 'index'. With that information we can
then calculate the correct iobase and register offset needed to read/
write the 8-bit ports.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 021314f8
...@@ -141,9 +141,6 @@ static const struct pcmuio_board pcmuio_boards[] = { ...@@ -141,9 +141,6 @@ static const struct pcmuio_board pcmuio_boards[] = {
}; };
struct pcmuio_subdev_private { struct pcmuio_subdev_private {
/* mapping of halfwords (bytes) in port/chanarray to iobase */
unsigned long iobases[PORTS_PER_SUBDEV];
/* The below is only used for intr subdevices */ /* The below is only used for intr subdevices */
struct { struct {
/* if non-negative, this subdev has an interrupt asic */ /* if non-negative, this subdev has an interrupt asic */
...@@ -190,7 +187,9 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev, ...@@ -190,7 +187,9 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pcmuio_subdev_private *subpriv = s->private; int asic = s->index / 2;
int port = (s->index % 2) ? 3 : 0;
unsigned long iobase = dev->iobase + (asic * ASIC_IOSIZE);
int byte_no; int byte_no;
/* NOTE: /* NOTE:
...@@ -207,10 +206,8 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev, ...@@ -207,10 +206,8 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
s->state = 0; s->state = 0;
for (byte_no = 0; byte_no < s->n_chan / CHANS_PER_PORT; ++byte_no) { for (byte_no = 0; byte_no < s->n_chan / CHANS_PER_PORT; ++byte_no) {
/* address of 8-bit port */ /* bit offset of port in 32-bit doubleword */
unsigned long ioaddr = subpriv->iobases[byte_no], unsigned long offset = byte_no * 8;
/* bit offset of port in 32-bit doubleword */
offset = byte_no * 8;
/* this 8-bit port's data */ /* this 8-bit port's data */
unsigned char byte = 0, unsigned char byte = 0,
/* The write mask for this port (if any) */ /* The write mask for this port (if any) */
...@@ -218,12 +215,12 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev, ...@@ -218,12 +215,12 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
/* The data byte for this port */ /* The data byte for this port */
data_byte = (data[1] >> offset) & 0xff; data_byte = (data[1] >> offset) & 0xff;
byte = inb(ioaddr); /* read all 8-bits for this port */ byte = inb(iobase + PCMUIO_PORT_REG(port + byte_no));
if (write_mask_byte) { if (write_mask_byte) {
byte &= ~write_mask_byte; byte &= ~write_mask_byte;
byte |= ~data_byte & write_mask_byte; byte |= ~data_byte & write_mask_byte;
outb(byte, ioaddr); outb(byte, iobase + PCMUIO_PORT_REG(port + byte_no));
} }
/* save the digital input lines for this byte.. */ /* save the digital input lines for this byte.. */
s->state |= ((unsigned int)byte) << offset; s->state |= ((unsigned int)byte) << offset;
...@@ -239,15 +236,14 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev, ...@@ -239,15 +236,14 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pcmuio_subdev_private *subpriv = s->private; int asic = s->index / 2;
int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no = int port = (s->index % 2) ? 3 : 0;
chan % 8; unsigned long iobase = dev->iobase + (asic * ASIC_IOSIZE);
unsigned long ioaddr; unsigned int chan = CR_CHAN(insn->chanspec);
int byte_no = chan / 8;
int bit_no = chan % 8;
unsigned char byte; unsigned char byte;
/* Compute ioaddr for this channel */
ioaddr = subpriv->iobases[byte_no];
/* NOTE: /* NOTE:
writing a 0 an IO channel's bit sets the channel to INPUT writing a 0 an IO channel's bit sets the channel to INPUT
and pulls the line high as well and pulls the line high as well
...@@ -269,7 +265,7 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev, ...@@ -269,7 +265,7 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev,
case INSN_CONFIG_DIO_INPUT: case INSN_CONFIG_DIO_INPUT:
/* write a 0 to the actual register representing the channel /* write a 0 to the actual register representing the channel
to set it to 'input'. 0 means "float high". */ to set it to 'input'. 0 means "float high". */
byte = inb(ioaddr); byte = inb(iobase + PCMUIO_PORT_REG(port + byte_no));
byte &= ~(1 << bit_no); byte &= ~(1 << bit_no);
/**< set input channel to '0' */ /**< set input channel to '0' */
...@@ -279,7 +275,7 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev, ...@@ -279,7 +275,7 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev,
* as all channels are implicitly output -- but input * as all channels are implicitly output -- but input
* channels are set to float-high. * channels are set to float-high.
*/ */
outb(byte, ioaddr); outb(byte, iobase + PCMUIO_PORT_REG(port + byte_no));
/* save to io_bits */ /* save to io_bits */
s->io_bits &= ~(1 << chan); s->io_bits &= ~(1 << chan);
...@@ -706,8 +702,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -706,8 +702,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
subpriv->intr.asic = -1; subpriv->intr.asic = -1;
s->len_chanlist = 1; s->len_chanlist = 1;
/* save the ioport address for each 'port' of 8 channels in the
subdevice */
for (byte_no = 0; byte_no < PORTS_PER_SUBDEV; for (byte_no = 0; byte_no < PORTS_PER_SUBDEV;
++byte_no, ++port) { ++byte_no, ++port) {
if (port >= PORTS_PER_ASIC) { if (port >= PORTS_PER_ASIC) {
...@@ -715,8 +709,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -715,8 +709,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
++asic; ++asic;
thisasic_chanct = 0; thisasic_chanct = 0;
} }
subpriv->iobases[byte_no] = dev->iobase +
(asic * ASIC_IOSIZE) + port;
if (thisasic_chanct < if (thisasic_chanct <
CHANS_PER_PORT * INTR_PORTS_PER_ASIC CHANS_PER_PORT * INTR_PORTS_PER_ASIC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment