Skip to content

Commit

Permalink
staging: comedi: me4000: remove dio context
Browse files Browse the repository at this point in the history
The dio context is a struct containing all the register addresses
used with the dio subdevice. These can easily be calculated when
needed. Remove the me4000_dio_context struct, its intialization
function, and it's variable in the private data.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Sep 8, 2012
1 parent 362bcbd commit da755d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 45 deletions.
50 changes: 15 additions & 35 deletions drivers/staging/comedi/drivers/me4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ static int init_board_info(struct comedi_device *dev,
struct pci_dev *pci_dev_p);
static int init_ao_context(struct comedi_device *dev);
static int init_ai_context(struct comedi_device *dev);
static int init_dio_context(struct comedi_device *dev);
static int xilinx_download(struct comedi_device *dev);
static int reset_board(struct comedi_device *dev);

Expand Down Expand Up @@ -325,10 +324,6 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
if (result)
return result;

result = init_dio_context(dev);
if (result)
return result;

result = xilinx_download(dev);
if (result)
return result;
Expand Down Expand Up @@ -483,22 +478,6 @@ static int init_ai_context(struct comedi_device *dev)
return 0;
}

static int init_dio_context(struct comedi_device *dev)
{
info->dio_context.dir_reg = dev->iobase + ME4000_DIO_DIR_REG;
info->dio_context.ctrl_reg = dev->iobase + ME4000_DIO_CTRL_REG;
info->dio_context.port_0_reg =
dev->iobase + ME4000_DIO_PORT_0_REG;
info->dio_context.port_1_reg =
dev->iobase + ME4000_DIO_PORT_1_REG;
info->dio_context.port_2_reg =
dev->iobase + ME4000_DIO_PORT_2_REG;
info->dio_context.port_3_reg =
dev->iobase + ME4000_DIO_PORT_3_REG;

return 0;
}

#define FIRMWARE_NOT_AVAILABLE 1
#if FIRMWARE_NOT_AVAILABLE
extern unsigned char *xilinx_firm;
Expand Down Expand Up @@ -1671,21 +1650,21 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,

/* Write out the new digital output lines */
outl((s->state >> 0) & 0xFF,
info->dio_context.port_0_reg);
dev->iobase + ME4000_DIO_PORT_0_REG);
outl((s->state >> 8) & 0xFF,
info->dio_context.port_1_reg);
dev->iobase + ME4000_DIO_PORT_1_REG);
outl((s->state >> 16) & 0xFF,
info->dio_context.port_2_reg);
dev->iobase + ME4000_DIO_PORT_2_REG);
outl((s->state >> 24) & 0xFF,
info->dio_context.port_3_reg);
dev->iobase + ME4000_DIO_PORT_3_REG);
}

/* On return, data[1] contains the value of
the digital input and output lines. */
data[1] = ((inl(info->dio_context.port_0_reg) & 0xFF) << 0) |
((inl(info->dio_context.port_1_reg) & 0xFF) << 8) |
((inl(info->dio_context.port_2_reg) & 0xFF) << 16) |
((inl(info->dio_context.port_3_reg) & 0xFF) << 24);
data[1] = ((inl(dev->iobase + ME4000_DIO_PORT_0_REG) & 0xFF) << 0) |
((inl(dev->iobase + ME4000_DIO_PORT_1_REG) & 0xFF) << 8) |
((inl(dev->iobase + ME4000_DIO_PORT_2_REG) & 0xFF) << 16) |
((inl(dev->iobase + ME4000_DIO_PORT_3_REG) & 0xFF) << 24);

return insn->n;
}
Expand Down Expand Up @@ -1717,7 +1696,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
* On the ME-4000 it is only possible to switch port wise (8 bit)
*/

tmp = inl(info->dio_context.ctrl_reg);
tmp = inl(dev->iobase + ME4000_DIO_CTRL_REG);

if (data[0] == INSN_CONFIG_DIO_OUTPUT) {
if (chan < 8) {
Expand All @@ -1731,7 +1710,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
* If one the first port is a fixed output
* port and the second is a fixed input port.
*/
if (!inl(info->dio_context.dir_reg))
if (!inl(dev->iobase + ME4000_DIO_DIR_REG))
return -ENODEV;

s->io_bits |= 0xFF00;
Expand All @@ -1758,7 +1737,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
* If one the first port is a fixed output
* port and the second is a fixed input port.
*/
if (!inl(info->dio_context.dir_reg))
if (!inl(dev->iobase + ME4000_DIO_DIR_REG))
return -ENODEV;

s->io_bits &= ~0xFF;
Expand All @@ -1781,7 +1760,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
}
}

outl(tmp, info->dio_context.ctrl_reg);
outl(tmp, dev->iobase + ME4000_DIO_CTRL_REG);

return 1;
}
Expand Down Expand Up @@ -2105,9 +2084,10 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* Check for optoisolated ME-4000 version. If one the first
* port is a fixed output port and the second is a fixed input port.
*/
if (!inl(info->dio_context.dir_reg)) {
if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) {
s->io_bits |= 0xFF;
outl(ME4000_DIO_CTRL_BIT_MODE_0, info->dio_context.dir_reg);
outl(ME4000_DIO_CTRL_BIT_MODE_0,
dev->iobase + ME4000_DIO_DIR_REG);
}

/*=========================================================================
Expand Down
10 changes: 0 additions & 10 deletions drivers/staging/comedi/drivers/me4000.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,6 @@ struct me4000_ai_context {
unsigned long sample_counter_reg;
};

struct me4000_dio_context {
unsigned long dir_reg;
unsigned long ctrl_reg;
unsigned long port_0_reg;
unsigned long port_1_reg;
unsigned long port_2_reg;
unsigned long port_3_reg;
};

struct me4000_info {
unsigned long plx_regbase; /* PLX configuration space base address */
unsigned long timer_regbase; /* Base address of the timer circuit */
Expand All @@ -290,7 +281,6 @@ struct me4000_info {

struct me4000_ai_context ai_context; /* Analog input specific context */
struct me4000_ao_context ao_context[4]; /* Vector with analog output specific context */
struct me4000_dio_context dio_context; /* Digital I/O specific context */
};

#define info ((struct me4000_info *)dev->private)
Expand Down

0 comments on commit da755d1

Please sign in to comment.