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

staging: comedi: ii_pci20kc.c: remove 'iobase' from the subdevice private data

The 'iobase' can be calculated when needed. Remove it from the
subdevice private data.
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 f0e32df3
...@@ -179,15 +179,12 @@ static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; ...@@ -179,15 +179,12 @@ static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 };
static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 };
union pci20xxx_subdev_private { union pci20xxx_subdev_private {
void __iomem *iobase;
struct { struct {
void __iomem *iobase;
const struct comedi_lrange *ao_range_list[2]; const struct comedi_lrange *ao_range_list[2];
/* range of channels of ao module */ /* range of channels of ao module */
unsigned int last_data[2]; unsigned int last_data[2];
} pci20006; } pci20006;
struct { struct {
void __iomem *iobase;
int timebase; int timebase;
int settling_time; int settling_time;
int ai_gain; int ai_gain;
...@@ -198,6 +195,14 @@ struct pci20xxx_private { ...@@ -198,6 +195,14 @@ struct pci20xxx_private {
void __iomem *ioaddr; void __iomem *ioaddr;
}; };
static void __iomem *ii20k_module_iobase(struct comedi_device *dev,
struct comedi_subdevice *s)
{
struct pci20xxx_private *devpriv = dev->private;
return devpriv->ioaddr + (s->index + 1) * II20K_MOD_OFFSET;
}
static int ii20k_ao_insn_read(struct comedi_device *dev, static int ii20k_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
...@@ -216,6 +221,7 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, ...@@ -216,6 +221,7 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
union pci20xxx_subdev_private *sdp = s->private; union pci20xxx_subdev_private *sdp = s->private;
void __iomem *iobase = ii20k_module_iobase(dev, s);
int hi, lo; int hi, lo;
unsigned int boarddata; unsigned int boarddata;
...@@ -227,14 +233,14 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, ...@@ -227,14 +233,14 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
switch (CR_CHAN(insn->chanspec)) { switch (CR_CHAN(insn->chanspec)) {
case 0: case 0:
writeb(lo, sdp->iobase + PCI20006_LCHAN0); writeb(lo, iobase + PCI20006_LCHAN0);
writeb(hi, sdp->iobase + PCI20006_LCHAN0 + 1); writeb(hi, iobase + PCI20006_LCHAN0 + 1);
writeb(0x00, sdp->iobase + PCI20006_STROBE0); writeb(0x00, iobase + PCI20006_STROBE0);
break; break;
case 1: case 1:
writeb(lo, sdp->iobase + PCI20006_LCHAN1); writeb(lo, iobase + PCI20006_LCHAN1);
writeb(hi, sdp->iobase + PCI20006_LCHAN1 + 1); writeb(hi, iobase + PCI20006_LCHAN1 + 1);
writeb(0x00, sdp->iobase + PCI20006_STROBE1); writeb(0x00, iobase + PCI20006_STROBE1);
break; break;
default: default:
dev_warn(dev->class_dev, "ao channel Error!\n"); dev_warn(dev->class_dev, "ao channel Error!\n");
...@@ -250,6 +256,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, ...@@ -250,6 +256,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
union pci20xxx_subdev_private *sdp = s->private; union pci20xxx_subdev_private *sdp = s->private;
void __iomem *iobase = ii20k_module_iobase(dev, s);
unsigned int i = 0, j = 0; unsigned int i = 0, j = 0;
int lo, hi; int lo, hi;
unsigned char eoc; /* end of conversion */ unsigned char eoc; /* end of conversion */
...@@ -257,15 +264,15 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, ...@@ -257,15 +264,15 @@ static int ii20k_ai_insn_read(struct comedi_device *dev,
unsigned int boarddata; unsigned int boarddata;
/* write number of input channels */ /* write number of input channels */
writeb(1, sdp->iobase + PCI20341_LCHAN_ADDR_REG); writeb(1, iobase + PCI20341_LCHAN_ADDR_REG);
clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3) clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3)
| CR_CHAN(insn->chanspec); | CR_CHAN(insn->chanspec);
writeb(clb, sdp->iobase + PCI20341_CHAN_LIST); writeb(clb, iobase + PCI20341_CHAN_LIST);
/* reset settling time counter and trigger delay counter */ /* reset settling time counter and trigger delay counter */
writeb(0x00, sdp->iobase + PCI20341_CC_RESET); writeb(0x00, iobase + PCI20341_CC_RESET);
writeb(0x00, sdp->iobase + PCI20341_CHAN_RESET); writeb(0x00, iobase + PCI20341_CHAN_RESET);
/* generate Pacer */ /* generate Pacer */
...@@ -276,21 +283,21 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, ...@@ -276,21 +283,21 @@ static int ii20k_ai_insn_read(struct comedi_device *dev,
*/ */
j = 0; j = 0;
/* generate Pacer */ /* generate Pacer */
readb(sdp->iobase + PCI20341_SOFT_PACER); readb(iobase + PCI20341_SOFT_PACER);
eoc = readb(sdp->iobase + PCI20341_STATUS_REG); eoc = readb(iobase + PCI20341_STATUS_REG);
/* poll Interrupt Flag */ /* poll Interrupt Flag */
while ((eoc < 0x80) && j < 100) { while ((eoc < 0x80) && j < 100) {
j++; j++;
eoc = readb(sdp->iobase + PCI20341_STATUS_REG); eoc = readb(iobase + PCI20341_STATUS_REG);
} }
if (j >= 100) { if (j >= 100) {
dev_warn(dev->class_dev, dev_warn(dev->class_dev,
"AI interrupt channel %i polling exit !\n", i); "AI interrupt channel %i polling exit !\n", i);
return -EINVAL; return -EINVAL;
} }
lo = readb(sdp->iobase + PCI20341_LDATA); lo = readb(iobase + PCI20341_LDATA);
hi = readb(sdp->iobase + PCI20341_LDATA + 1); hi = readb(iobase + PCI20341_LDATA + 1);
boarddata = lo + 0x100 * hi; boarddata = lo + 0x100 * hi;
/* board-data -> comedi-data */ /* board-data -> comedi-data */
...@@ -304,20 +311,21 @@ static void ii20k_ai_init(struct comedi_device *dev, ...@@ -304,20 +311,21 @@ static void ii20k_ai_init(struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
union pci20xxx_subdev_private *sdp = s->private; union pci20xxx_subdev_private *sdp = s->private;
void __iomem *iobase = ii20k_module_iobase(dev, s);
unsigned char option; unsigned char option;
/* depends on gain, trigger, repetition mode */ /* depends on gain, trigger, repetition mode */
option = sdp->pci20341.timebase | PCI20341_REPMODE; option = sdp->pci20341.timebase | PCI20341_REPMODE;
/* initialize Module */ /* initialize Module */
writeb(PCI20341_INIT, sdp->iobase + PCI20341_CONFIG_REG); writeb(PCI20341_INIT, iobase + PCI20341_CONFIG_REG);
/* set Pacer */ /* set Pacer */
writeb(PCI20341_PACER, sdp->iobase + PCI20341_MOD_STATUS); writeb(PCI20341_PACER, iobase + PCI20341_MOD_STATUS);
/* option register */ /* option register */
writeb(option, sdp->iobase + PCI20341_OPT_REG); writeb(option, iobase + PCI20341_OPT_REG);
/* settling time counter */ /* settling time counter */
writeb(sdp->pci20341.settling_time, writeb(sdp->pci20341.settling_time,
sdp->iobase + PCI20341_SET_TIME_REG); iobase + PCI20341_SET_TIME_REG);
/* trigger not implemented */ /* trigger not implemented */
} }
...@@ -461,18 +469,16 @@ static int ii20k_init_module(struct comedi_device *dev, ...@@ -461,18 +469,16 @@ static int ii20k_init_module(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_devconfig *it) struct comedi_devconfig *it)
{ {
struct pci20xxx_private *devpriv = dev->private;
union pci20xxx_subdev_private *sdp; union pci20xxx_subdev_private *sdp;
void __iomem *iobase = ii20k_module_iobase(dev, s);
unsigned int opt0 = it->options[(2 * s->index) + 2]; unsigned int opt0 = it->options[(2 * s->index) + 2];
unsigned int opt1 = it->options[(2 * s->index) + 3]; unsigned int opt1 = it->options[(2 * s->index) + 3];
void __iomem *iobase;
unsigned char id; unsigned char id;
sdp = comedi_alloc_spriv(s, sizeof(*sdp)); sdp = comedi_alloc_spriv(s, sizeof(*sdp));
if (!sdp) if (!sdp)
return -ENOMEM; return -ENOMEM;
iobase = devpriv->ioaddr + (s->index + 1) * II20K_MOD_OFFSET;
id = readb(iobase + II20K_ID_REG); id = readb(iobase + II20K_ID_REG);
switch (id) { switch (id) {
case PCI20006_ID: case PCI20006_ID:
...@@ -481,7 +487,6 @@ static int ii20k_init_module(struct comedi_device *dev, ...@@ -481,7 +487,6 @@ static int ii20k_init_module(struct comedi_device *dev,
if (opt1 < 0 || opt1 > 2) if (opt1 < 0 || opt1 > 2)
opt1 = 0; opt1 = 0;
sdp->pci20006.iobase = iobase;
sdp->pci20006.ao_range_list[0] = ii20k_ao_ranges[opt0]; sdp->pci20006.ao_range_list[0] = ii20k_ao_ranges[opt0];
sdp->pci20006.ao_range_list[1] = ii20k_ao_ranges[opt1]; sdp->pci20006.ao_range_list[1] = ii20k_ao_ranges[opt1];
...@@ -498,7 +503,6 @@ static int ii20k_init_module(struct comedi_device *dev, ...@@ -498,7 +503,6 @@ static int ii20k_init_module(struct comedi_device *dev,
if (opt0 < 0 || opt0 > 3) if (opt0 < 0 || opt0 > 3)
opt0 = 0; opt0 = 0;
sdp->pci20341.iobase = iobase;
sdp->pci20341.timebase = pci20341_timebase[opt0]; sdp->pci20341.timebase = pci20341_timebase[opt0];
sdp->pci20341.settling_time = pci20341_settling_time[opt0]; sdp->pci20341.settling_time = pci20341_settling_time[opt0];
......
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