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

staging: comedi: ii_pci20kc: remove forward declarations 2

Move the pci20xxx_dio_*() functions to remove the need for some of
the forward declarations.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0f8409dc
...@@ -361,95 +361,37 @@ static int pci20341_insn_read(struct comedi_device *dev, ...@@ -361,95 +361,37 @@ static int pci20341_insn_read(struct comedi_device *dev,
return i; return i;
} }
/* native DIO */ #if 0
static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s)
static void pci20xxx_dio_config(struct comedi_device *dev,
struct comedi_subdevice *s);
static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
static int pci20xxx_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
/* initialize struct pci20xxx_private */
static int pci20xxx_dio_init(struct comedi_device *dev,
struct comedi_subdevice *s)
{
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 32;
s->insn_bits = pci20xxx_dio_insn_bits;
s->insn_config = pci20xxx_dio_insn_config;
s->maxdata = 1;
s->len_chanlist = 32;
s->range_table = &range_digital;
s->io_bits = 0;
/* digital I/O lines default to input on board reset. */
pci20xxx_dio_config(dev, s);
return 0;
}
static int pci20xxx_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{ {
int mask, bits; struct pci20xxx_private *devpriv = dev->private;
mask = 1 << CR_CHAN(insn->chanspec);
if (mask & 0x000000ff)
bits = 0x000000ff;
else if (mask & 0x0000ff00)
bits = 0x0000ff00;
else if (mask & 0x00ff0000)
bits = 0x00ff0000;
else
bits = 0xff000000;
if (data[0])
s->io_bits |= bits;
else
s->io_bits &= ~bits;
pci20xxx_dio_config(dev, s);
return 1; /* XXX if the channel is configured for input, does this
do bad things? */
/* XXX it would be a good idea to only update the registers
that _need_ to be updated. This requires changes to
comedi, however. */
writeb((s->state >> 0) & 0xff, devpriv->ioaddr + PCI20000_DIO_0);
writeb((s->state >> 8) & 0xff, devpriv->ioaddr + PCI20000_DIO_1);
writeb((s->state >> 16) & 0xff, devpriv->ioaddr + PCI20000_DIO_2);
writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3);
} }
static int pci20xxx_dio_insn_bits(struct comedi_device *dev, static unsigned int pci20xxx_di(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s)
struct comedi_insn *insn, unsigned int *data)
{ {
struct pci20xxx_private *devpriv = dev->private; struct pci20xxx_private *devpriv = dev->private;
unsigned int mask = data[0]; unsigned int bits;
s->state &= ~mask;
s->state |= (mask & data[1]);
mask &= s->io_bits;
if (mask & 0x000000ff)
writeb((s->state >> 0) & 0xff,
devpriv->ioaddr + PCI20000_DIO_0);
if (mask & 0x0000ff00)
writeb((s->state >> 8) & 0xff,
devpriv->ioaddr + PCI20000_DIO_1);
if (mask & 0x00ff0000)
writeb((s->state >> 16) & 0xff,
devpriv->ioaddr + PCI20000_DIO_2);
if (mask & 0xff000000)
writeb((s->state >> 24) & 0xff,
devpriv->ioaddr + PCI20000_DIO_3);
data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0); /* XXX same note as above */
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; bits = readb(devpriv->ioaddr + PCI20000_DIO_0);
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
bits |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24;
return insn->n; return bits;
} }
#endif
static void pci20xxx_dio_config(struct comedi_device *dev, static void pci20xxx_dio_config(struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
...@@ -508,37 +450,81 @@ static void pci20xxx_dio_config(struct comedi_device *dev, ...@@ -508,37 +450,81 @@ static void pci20xxx_dio_config(struct comedi_device *dev,
writeb(buffer, devpriv->ioaddr + PCI20000_DIO_BUFFER); writeb(buffer, devpriv->ioaddr + PCI20000_DIO_BUFFER);
} }
#if 0 static int pci20xxx_dio_insn_config(struct comedi_device *dev,
static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
int mask, bits;
mask = 1 << CR_CHAN(insn->chanspec);
if (mask & 0x000000ff)
bits = 0x000000ff;
else if (mask & 0x0000ff00)
bits = 0x0000ff00;
else if (mask & 0x00ff0000)
bits = 0x00ff0000;
else
bits = 0xff000000;
if (data[0])
s->io_bits |= bits;
else
s->io_bits &= ~bits;
pci20xxx_dio_config(dev, s);
return 1;
}
static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{ {
struct pci20xxx_private *devpriv = dev->private; struct pci20xxx_private *devpriv = dev->private;
unsigned int mask = data[0];
/* XXX if the channel is configured for input, does this s->state &= ~mask;
do bad things? */ s->state |= (mask & data[1]);
/* XXX it would be a good idea to only update the registers
that _need_ to be updated. This requires changes to mask &= s->io_bits;
comedi, however. */ if (mask & 0x000000ff)
writeb((s->state >> 0) & 0xff, devpriv->ioaddr + PCI20000_DIO_0); writeb((s->state >> 0) & 0xff,
writeb((s->state >> 8) & 0xff, devpriv->ioaddr + PCI20000_DIO_1); devpriv->ioaddr + PCI20000_DIO_0);
writeb((s->state >> 16) & 0xff, devpriv->ioaddr + PCI20000_DIO_2); if (mask & 0x0000ff00)
writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3); writeb((s->state >> 8) & 0xff,
devpriv->ioaddr + PCI20000_DIO_1);
if (mask & 0x00ff0000)
writeb((s->state >> 16) & 0xff,
devpriv->ioaddr + PCI20000_DIO_2);
if (mask & 0xff000000)
writeb((s->state >> 24) & 0xff,
devpriv->ioaddr + PCI20000_DIO_3);
data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0);
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24;
return insn->n;
} }
static unsigned int pci20xxx_di(struct comedi_device *dev, static int pci20xxx_dio_init(struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
struct pci20xxx_private *devpriv = dev->private; s->type = COMEDI_SUBD_DIO;
unsigned int bits; s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 32;
s->insn_bits = pci20xxx_dio_insn_bits;
s->insn_config = pci20xxx_dio_insn_config;
s->maxdata = 1;
s->len_chanlist = 32;
s->range_table = &range_digital;
s->io_bits = 0;
/* XXX same note as above */ /* digital I/O lines default to input on board reset. */
bits = readb(devpriv->ioaddr + PCI20000_DIO_0); pci20xxx_dio_config(dev, s);
bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
bits |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24;
return bits; return 0;
} }
#endif
static int pci20xxx_attach(struct comedi_device *dev, static int pci20xxx_attach(struct comedi_device *dev,
struct comedi_devconfig *it) struct comedi_devconfig *it)
......
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