Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -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;
+4 −2
Original line number Diff line number Diff line
@@ -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);
+2 −1
Original line number Diff line number Diff line
@@ -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;

+4 −2
Original line number Diff line number Diff line
@@ -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;

+2 −1
Original line number Diff line number Diff line
@@ -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;
Loading