mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-12 16:15:05 -04:00
staging: comedi: addi_apci_3120: fix timer (*insn_read)
The timer subdevice in this driver does not follow the comedi API. Fix the (*insn_read) to work correctly. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dcb5e2c4df
commit
15cf0617c0
@@ -608,38 +608,3 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
|
||||
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the Timer value
|
||||
*
|
||||
* for Timer: data[0]= Timer constant
|
||||
*
|
||||
* for watchdog: data[0] = 0 (still running)
|
||||
* = 1 (run down)
|
||||
*/
|
||||
static int apci3120_read_insn_timer(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct apci3120_private *devpriv = dev->private;
|
||||
unsigned int status;
|
||||
|
||||
if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG)
|
||||
&& (devpriv->b_Timer2Mode != APCI3120_TIMER)) {
|
||||
dev_err(dev->class_dev, "timer2 not configured\n");
|
||||
}
|
||||
if (devpriv->b_Timer2Mode == APCI3120_TIMER) {
|
||||
data[0] = apci3120_timer_read(dev, 2);
|
||||
} else {
|
||||
/* Read watch dog status */
|
||||
status = inw(dev->iobase + APCI3120_STATUS_REG);
|
||||
if (status & APCI3120_STATUS_TIMER2_INT) {
|
||||
apci3120_clr_timer2_interrupt(dev);
|
||||
data[0] = 1;
|
||||
} else {
|
||||
data[0] = 0;
|
||||
}
|
||||
}
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
@@ -447,6 +447,19 @@ static int apci3120_do_insn_bits(struct comedi_device *dev,
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
static int apci3120_timer_insn_read(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < insn->n; i++)
|
||||
data[i] = apci3120_timer_read(dev, 2);
|
||||
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
static void apci3120_dma_alloc(struct comedi_device *dev)
|
||||
{
|
||||
struct apci3120_private *devpriv = dev->private;
|
||||
@@ -618,8 +631,8 @@ static int apci3120_auto_attach(struct comedi_device *dev,
|
||||
s->n_chan = 1;
|
||||
s->maxdata = 0x00ffffff;
|
||||
s->insn_write = apci3120_write_insn_timer;
|
||||
s->insn_read = apci3120_read_insn_timer;
|
||||
s->insn_config = apci3120_config_insn_timer;
|
||||
s->insn_read = apci3120_timer_insn_read;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user