Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337233
b: refs/heads/master
c: c10aa03
h: refs/heads/master
i:
  337231: 9aa9343
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Oct 24, 2012
1 parent 9636d75 commit 07273ae
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 28 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: 2662a9b62668ed541014fa078d88fbe99fce2b1e
refs/heads/master: c10aa035512f9c5092d7044676d3f3d14739f8d8
72 changes: 45 additions & 27 deletions trunk/drivers/staging/comedi/drivers/amplc_dio200.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,24 @@ static inline bool is_isa_board(const struct dio200_board *board)
return DO_ISA && board->bustype == isa_bustype;
}

/*
* Read 8-bit register.
*/
static unsigned char dio200_read8(struct comedi_device *dev,
unsigned int offset)
{
return inb(dev->iobase + offset);
}

/*
* Write 8-bit register.
*/
static void dio200_write8(struct comedi_device *dev, unsigned int offset,
unsigned char val)
{
outb(val, dev->iobase + offset);
}

/*
* This function looks for a board matching the supplied PCI device.
*/
Expand Down Expand Up @@ -518,7 +536,7 @@ dio200_subdev_intr_insn_bits(struct comedi_device *dev,

if (layout->has_int_sce) {
/* Just read the interrupt status register. */
data[1] = inb(dev->iobase + subpriv->ofs) & subpriv->valid_isns;
data[1] = dio200_read8(dev, subpriv->ofs) & subpriv->valid_isns;
} else {
/* No interrupt status register. */
data[0] = 0;
Expand All @@ -539,7 +557,7 @@ static void dio200_stop_intr(struct comedi_device *dev,
subpriv->active = 0;
subpriv->enabled_isns = 0;
if (layout->has_int_sce)
outb(0, dev->iobase + subpriv->ofs);
dio200_write8(dev, subpriv->ofs, 0);
}

/*
Expand Down Expand Up @@ -571,7 +589,7 @@ static int dio200_start_intr(struct comedi_device *dev,
/* Enable interrupt sources. */
subpriv->enabled_isns = isn_bits;
if (layout->has_int_sce)
outb(isn_bits, dev->iobase + subpriv->ofs);
dio200_write8(dev, subpriv->ofs, isn_bits);
}

return retval;
Expand Down Expand Up @@ -637,11 +655,11 @@ static int dio200_handle_read_intr(struct comedi_device *dev,
* loop in case of misconfiguration.
*/
cur_enabled = subpriv->enabled_isns;
while ((intstat = (inb(dev->iobase + subpriv->ofs) &
while ((intstat = (dio200_read8(dev, subpriv->ofs) &
subpriv->valid_isns & ~triggered)) != 0) {
triggered |= intstat;
cur_enabled &= ~triggered;
outb(cur_enabled, dev->iobase + subpriv->ofs);
dio200_write8(dev, subpriv->ofs, cur_enabled);
}
} else {
/*
Expand All @@ -660,7 +678,7 @@ static int dio200_handle_read_intr(struct comedi_device *dev,
*/
cur_enabled = subpriv->enabled_isns;
if (layout->has_int_sce)
outb(cur_enabled, dev->iobase + subpriv->ofs);
dio200_write8(dev, subpriv->ofs, cur_enabled);

if (subpriv->active) {
/*
Expand Down Expand Up @@ -882,7 +900,7 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,

if (layout->has_int_sce)
/* Disable interrupt sources. */
outb(0, dev->iobase + subpriv->ofs);
dio200_write8(dev, subpriv->ofs, 0);

s->private = subpriv;
s->type = COMEDI_SUBD_DI;
Expand Down Expand Up @@ -951,10 +969,10 @@ dio200_subdev_8254_read_chan(struct comedi_device *dev,

/* latch counter */
val = chan << 6;
outb(val, dev->iobase + subpriv->ofs + i8254_control_reg);
dio200_write8(dev, subpriv->ofs + i8254_control_reg, val);
/* read lsb, msb */
val = inb(dev->iobase + subpriv->ofs + chan);
val += inb(dev->iobase + subpriv->ofs + chan) << 8;
val = dio200_read8(dev, subpriv->ofs + chan);
val += dio200_read8(dev, subpriv->ofs + chan) << 8;
return val;
}

Expand All @@ -969,8 +987,8 @@ dio200_subdev_8254_write_chan(struct comedi_device *dev,
struct dio200_subdev_8254 *subpriv = s->private;

/* write lsb, msb */
outb(count & 0xff, dev->iobase + subpriv->ofs + chan);
outb((count >> 8) & 0xff, dev->iobase + subpriv->ofs + chan);
dio200_write8(dev, subpriv->ofs + chan, count & 0xff);
dio200_write8(dev, subpriv->ofs + chan, (count >> 8) & 0xff);
}

/*
Expand All @@ -987,7 +1005,7 @@ dio200_subdev_8254_set_mode(struct comedi_device *dev,
byte = chan << 6;
byte |= 0x30; /* access order: lsb, msb */
byte |= (mode & 0xf); /* counter mode and BCD|binary */
outb(byte, dev->iobase + subpriv->ofs + i8254_control_reg);
dio200_write8(dev, subpriv->ofs + i8254_control_reg, byte);
}

/*
Expand All @@ -1000,10 +1018,10 @@ dio200_subdev_8254_status(struct comedi_device *dev,
struct dio200_subdev_8254 *subpriv = s->private;

/* latch status */
outb(0xe0 | (2 << chan),
dev->iobase + subpriv->ofs + i8254_control_reg);
dio200_write8(dev, subpriv->ofs + i8254_control_reg,
0xe0 | (2 << chan));
/* read status */
return inb(dev->iobase + subpriv->ofs + chan);
return dio200_read8(dev, subpriv->ofs + chan);
}

/*
Expand Down Expand Up @@ -1064,7 +1082,7 @@ dio200_subdev_8254_set_gate_src(struct comedi_device *dev,

subpriv->gate_src[counter_number] = gate_src;
byte = GAT_SCE(subpriv->which, counter_number, gate_src);
outb(byte, dev->iobase + subpriv->gat_sce_ofs);
dio200_write8(dev, subpriv->gat_sce_ofs, byte);

return 0;
}
Expand Down Expand Up @@ -1110,7 +1128,7 @@ dio200_subdev_8254_set_clock_src(struct comedi_device *dev,

subpriv->clock_src[counter_number] = clock_src;
byte = CLK_SCE(subpriv->which, counter_number, clock_src);
outb(byte, dev->iobase + subpriv->clk_sce_ofs);
dio200_write8(dev, subpriv->clk_sce_ofs, byte);

return 0;
}
Expand Down Expand Up @@ -1276,7 +1294,7 @@ static void dio200_subdev_8255_set_dir(struct comedi_device *dev,
config |= CR_C_LO_IO;
if (!(s->io_bits & 0xf00000))
config |= CR_C_HI_IO;
outb(config, dev->iobase + subpriv->ofs + 3);
dio200_write8(dev, subpriv->ofs + 3, config);
}

/*
Expand All @@ -1292,17 +1310,17 @@ static int dio200_subdev_8255_bits(struct comedi_device *dev,
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (data[0] & 0xff)
outb(s->state & 0xff, dev->iobase + subpriv->ofs);
dio200_write8(dev, subpriv->ofs, s->state & 0xff);
if (data[0] & 0xff00)
outb((s->state >> 8) & 0xff,
dev->iobase + subpriv->ofs + 1);
dio200_write8(dev, subpriv->ofs + 1,
(s->state >> 8) & 0xff);
if (data[0] & 0xff0000)
outb((s->state >> 16) & 0xff,
dev->iobase + subpriv->ofs + 2);
dio200_write8(dev, subpriv->ofs + 2,
(s->state >> 16) & 0xff);
}
data[1] = inb(dev->iobase + subpriv->ofs);
data[1] |= inb(dev->iobase + subpriv->ofs + 1) << 8;
data[1] |= inb(dev->iobase + subpriv->ofs + 2) << 16;
data[1] = dio200_read8(dev, subpriv->ofs);
data[1] |= dio200_read8(dev, subpriv->ofs + 1) << 8;
data[1] |= dio200_read8(dev, subpriv->ofs + 2) << 16;
return 2;
}

Expand Down

0 comments on commit 07273ae

Please sign in to comment.