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

staging: comedi: 8255: add a comedi_device param to the (*io) callback

The 8255 driver uses an (*io) callback to read/write the registers
of the 8255 device. The default callback provided by the driver uses
inb()/outb() calls to access to registers based on an 'iobase' that
was initialized during the subdev_8255_init() and a 'port' value.

The users of this module can optionally provide a custom (*io) callback
to handle the read/write in another manner.

Make the (*io) callback a bit more flexible by also passing the
comedi_device pointer as a parameter.
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 4f9c63fe
......@@ -94,10 +94,11 @@ I/O port base address can be found in the output of 'lspci -v'.
struct subdev_8255_private {
unsigned long iobase;
int (*io)(int, int, int, unsigned long);
int (*io)(struct comedi_device *, int, int, int, unsigned long);
};
static int subdev_8255_io(int dir, int port, int data, unsigned long iobase)
static int subdev_8255_io(struct comedi_device *dev,
int dir, int port, int data, unsigned long iobase)
{
if (dir) {
outb(data, iobase + port);
......@@ -113,8 +114,8 @@ void subdev_8255_interrupt(struct comedi_device *dev,
unsigned long iobase = spriv->iobase;
unsigned short d;
d = spriv->io(0, _8255_DATA, 0, iobase);
d |= (spriv->io(0, _8255_DATA + 1, 0, iobase) << 8);
d = spriv->io(dev, 0, _8255_DATA, 0, iobase);
d |= (spriv->io(dev, 0, _8255_DATA + 1, 0, iobase) << 8);
comedi_buf_put(s, d);
s->async->events |= COMEDI_CB_EOS;
......@@ -136,18 +137,18 @@ static int subdev_8255_insn(struct comedi_device *dev,
mask = comedi_dio_update_state(s, data);
if (mask) {
if (mask & 0xff)
spriv->io(1, _8255_DATA, s->state & 0xff, iobase);
spriv->io(dev, 1, _8255_DATA, s->state & 0xff, iobase);
if (mask & 0xff00)
spriv->io(1, _8255_DATA + 1, (s->state >> 8) & 0xff,
iobase);
spriv->io(dev, 1, _8255_DATA + 1,
(s->state >> 8) & 0xff, iobase);
if (mask & 0xff0000)
spriv->io(1, _8255_DATA + 2, (s->state >> 16) & 0xff,
iobase);
spriv->io(dev, 1, _8255_DATA + 2,
(s->state >> 16) & 0xff, iobase);
}
v = spriv->io(0, _8255_DATA, 0, iobase);
v |= (spriv->io(0, _8255_DATA + 1, 0, iobase) << 8);
v |= (spriv->io(0, _8255_DATA + 2, 0, iobase) << 16);
v = spriv->io(dev, 0, _8255_DATA, 0, iobase);
v |= (spriv->io(dev, 0, _8255_DATA + 1, 0, iobase) << 8);
v |= (spriv->io(dev, 0, _8255_DATA + 2, 0, iobase) << 16);
data[1] = v;
......@@ -172,7 +173,7 @@ static void subdev_8255_do_config(struct comedi_device *dev,
if (!(s->io_bits & 0xf00000))
config |= CR_C_HI_IO;
spriv->io(1, _8255_CR, config, iobase);
spriv->io(dev, 1, _8255_CR, config, iobase);
}
static int subdev_8255_insn_config(struct comedi_device *dev,
......@@ -261,7 +262,8 @@ static int subdev_8255_cancel(struct comedi_device *dev,
}
int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
int (*io)(int, int, int, unsigned long),
int (*io)(struct comedi_device *,
int, int, int, unsigned long),
unsigned long iobase)
{
struct subdev_8255_private *spriv;
......@@ -288,7 +290,8 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
EXPORT_SYMBOL_GPL(subdev_8255_init);
int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
int (*io)(int, int, int, unsigned long),
int (*io)(struct comedi_device *,
int, int, int, unsigned long),
unsigned long iobase)
{
int ret;
......
......@@ -22,10 +22,12 @@
#include "../comedidev.h"
int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
int (*io)(int, int, int, unsigned long),
int (*io)(struct comedi_device *,
int, int, int, unsigned long),
unsigned long iobase);
int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
int (*io)(int, int, int, unsigned long),
int (*io)(struct comedi_device *,
int, int, int, unsigned long),
unsigned long iobase);
void subdev_8255_interrupt(struct comedi_device *dev,
struct comedi_subdevice *s);
......
......@@ -190,7 +190,8 @@ static int pci_8255_mite_init(struct pci_dev *pcidev)
return 0;
}
static int pci_8255_mmio(int dir, int port, int data, unsigned long iobase)
static int pci_8255_mmio(struct comedi_device *dev,
int dir, int port, int data, unsigned long iobase)
{
void __iomem *mmio_base = (void __iomem *)iobase;
......
......@@ -3369,7 +3369,8 @@ static int ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
static int dio_callback(int dir, int port, int data, unsigned long arg)
static int dio_callback(struct comedi_device *dev,
int dir, int port, int data, unsigned long arg)
{
void __iomem *iobase = (void __iomem *)arg;
......@@ -3380,7 +3381,8 @@ static int dio_callback(int dir, int port, int data, unsigned long arg)
return readb(iobase + port);
}
static int dio_callback_4020(int dir, int port, int data, unsigned long arg)
static int dio_callback_4020(struct comedi_device *dev,
int dir, int port, int data, unsigned long arg)
{
void __iomem *iobase = (void __iomem *)arg;
......
......@@ -651,7 +651,8 @@ static void daqboard2000_initializeDac(struct comedi_device *dev)
daqboard2000_dacDisarm(dev);
}
static int daqboard2000_8255_cb(int dir, int port, int data,
static int daqboard2000_8255_cb(struct comedi_device *dev,
int dir, int port, int data,
unsigned long ioaddr)
{
void __iomem *mmio_base = (void __iomem *)ioaddr;
......
......@@ -1035,7 +1035,8 @@ static int labpc_ao_insn_read(struct comedi_device *dev,
return 1;
}
static int labpc_8255_mmio(int dir, int port, int data, unsigned long arg)
static int labpc_8255_mmio(struct comedi_device *cdev,
int dir, int port, int data, unsigned long arg)
{
struct comedi_device *dev = (struct comedi_device *)arg;
......
......@@ -4176,7 +4176,8 @@ static int ni_freq_out_insn_config(struct comedi_device *dev,
return insn->n;
}
static int ni_8255_callback(int dir, int port, int data, unsigned long arg)
static int ni_8255_callback(struct comedi_device *cdev,
int dir, int port, int data, unsigned long arg)
{
struct comedi_device *dev = (struct comedi_device *)arg;
......
......@@ -81,7 +81,8 @@ static const struct pcl724_board boardtypes[] = {
},
};
static int pcl724_8255mapped_io(int dir, int port, int data,
static int pcl724_8255mapped_io(struct comedi_device *dev,
int dir, int port, int data,
unsigned long iobase)
{
int movport = SIZE_8255 * (iobase >> 12);
......
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