Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a2cf2f9 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: addi_apci_1564: fix counter code in main driver source



The Rev 1.0 APCI-1564 boards do not have counters.

Fix the code in the main driver source so that the I/O accesses to the
counters do not happen if the devpriv->counters member is not initialized.

This does not fix the code in hwdrv_apci1564.c. That code violates the
comedi API and is currently broken.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6cf8ea2e
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -141,10 +141,12 @@ static int apci1564_reset(struct comedi_device *dev)
	outl(0x0, devpriv->timer + APCI1564_TIMER_CTRL_REG);
	outl(0x0, devpriv->timer + APCI1564_TIMER_RELOAD_REG);

	if (devpriv->counters) {
		/* Reset the counter registers */
		outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(0));
		outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(1));
		outl(0x0, devpriv->counters + APCI1564_COUNTER_CTRL_REG(2));
	}

	return 0;
}
@@ -186,6 +188,7 @@ static irqreturn_t apci1564_interrupt(int irq, void *d)
		outl(ctrl, devpriv->timer + APCI1564_TIMER_CTRL_REG);
	}

	if (devpriv->counters) {
		for (chan = 0; chan < 4; chan++) {
			status = inl(devpriv->counters +
				     APCI1564_COUNTER_IRQ_REG(chan));
@@ -204,6 +207,7 @@ static irqreturn_t apci1564_interrupt(int irq, void *d)
					   APCI1564_COUNTER_CTRL_REG(chan));
			}
		}
	}

	return IRQ_HANDLED;
}