The control register for the parallel port is readable so there is no need to cache the current value in the private data.
Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com> Cc: Ian Abbott <abbo...@mev.co.uk> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- drivers/staging/comedi/drivers/comedi_parport.c | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 7180b0c..3944c19 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -92,7 +92,6 @@ pin, which can be used to wake up tasks. #define PARPORT_CTRL_BIDIR_ENA (1 << 5) struct parport_private { - unsigned int c_data; int enable_irq; }; @@ -114,18 +113,19 @@ static int parport_data_reg_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct parport_private *devpriv = dev->private; + unsigned int ctrl; int ret; ret = comedi_dio_insn_config(dev, s, insn, data, 0xff); if (ret) return ret; + ctrl = inb(dev->iobase + PARPORT_CTRL_REG); if (s->io_bits) - devpriv->c_data &= ~PARPORT_CTRL_BIDIR_ENA; + ctrl &= ~PARPORT_CTRL_BIDIR_ENA; else - devpriv->c_data |= PARPORT_CTRL_BIDIR_ENA; - outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG); + ctrl |= PARPORT_CTRL_BIDIR_ENA; + outb(ctrl, dev->iobase + PARPORT_CTRL_REG); return insn->n; } @@ -145,12 +145,13 @@ static int parport_ctrl_reg_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct parport_private *devpriv = dev->private; + unsigned int ctrl; if (comedi_dio_insn_bits(dev, s, insn, data)) { - devpriv->c_data &= ~((1 << s->n_chan) - 1); - devpriv->c_data |= s->state; - outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG); + ctrl = inb(dev->iobase + PARPORT_CTRL_REG); + ctrl &= (PARPORT_CTRL_IRQ_ENA | PARPORT_CTRL_BIDIR_ENA); + ctrl |= s->state; + outb(ctrl, dev->iobase + PARPORT_CTRL_REG); } data[1] = s->state; @@ -212,9 +213,11 @@ static int parport_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct parport_private *devpriv = dev->private; + unsigned int ctrl; - devpriv->c_data |= PARPORT_CTRL_IRQ_ENA; - outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG); + ctrl = inb(dev->iobase + PARPORT_CTRL_REG); + ctrl |= PARPORT_CTRL_IRQ_ENA; + outb(ctrl, dev->iobase + PARPORT_CTRL_REG); devpriv->enable_irq = 1; @@ -225,9 +228,11 @@ static int parport_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct parport_private *devpriv = dev->private; + unsigned int ctrl; - devpriv->c_data &= ~PARPORT_CTRL_IRQ_ENA; - outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG); + ctrl = inb(dev->iobase + PARPORT_CTRL_REG); + ctrl &= ~PARPORT_CTRL_IRQ_ENA; + outb(ctrl, dev->iobase + PARPORT_CTRL_REG); devpriv->enable_irq = 0; @@ -323,8 +328,7 @@ static int parport_attach(struct comedi_device *dev, } outb(0, dev->iobase + PARPORT_DATA_REG); - devpriv->c_data = 0; - outb(devpriv->c_data, dev->iobase + PARPORT_CTRL_REG); + outb(0, dev->iobase + PARPORT_CTRL_REG); return 0; } -- 1.8.3.2 _______________________________________________ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel