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

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

staging: comedi: ni_6527: introduce ni6527_reset()



Factor the board reset code out of the (*attach). Do the reset as
soon as possible to ensure the interrupts are disabled.

For convienence, use the ni6257_reset() during the (*detach) instead
of just disabling the interrupts.

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 42e705e9
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -334,6 +334,19 @@ static int ni6527_intr_insn_config(struct comedi_device *dev,
	return insn->n;
}

static void ni6527_reset(struct comedi_device *dev)
{
	struct ni6527_private *devpriv = dev->private;
	void __iomem *mmio = devpriv->mmio_base;

	/* disable deglitch filters on all channels */
	ni6527_set_filter_enable(dev, 0);

	writeb(NI6527_CLR_IRQS | NI6527_CLR_RESET_FILT,
	       mmio + NI6527_CLR_REG);
	writeb(NI6527_CTRL_DISABLE_IRQS, mmio + NI6527_CTRL_REG);
}

static int ni6527_auto_attach(struct comedi_device *dev,
			      unsigned long context)
{
@@ -366,6 +379,8 @@ static int ni6527_auto_attach(struct comedi_device *dev,
	if (readb(devpriv->mmio_base + NI6527_ID_REG) != 0x27)
		return -ENODEV;

	ni6527_reset(dev);

	ret = comedi_alloc_subdevices(dev, 3);
	if (ret)
		return ret;
@@ -400,13 +415,6 @@ static int ni6527_auto_attach(struct comedi_device *dev,
	s->insn_bits = ni6527_intr_insn_bits;
	s->insn_config = ni6527_intr_insn_config;

	ni6527_set_filter_enable(dev, 0);

	writeb(NI6527_CLR_IRQS | NI6527_CLR_RESET_FILT,
	       devpriv->mmio_base + NI6527_CLR_REG);
	writeb(NI6527_CTRL_DISABLE_IRQS,
	       devpriv->mmio_base + NI6527_CTRL_REG);

	ret = request_irq(pcidev->irq, ni6527_interrupt,
			  IRQF_SHARED, dev->board_name, dev);
	if (ret < 0)
@@ -422,8 +430,7 @@ static void ni6527_detach(struct comedi_device *dev)
	struct ni6527_private *devpriv = dev->private;

	if (devpriv && devpriv->mmio_base)
		writeb(NI6527_CTRL_DISABLE_IRQS,
		       devpriv->mmio_base + NI6527_CTRL_REG);
		ni6527_reset(dev);
	if (dev->irq)
		free_irq(dev->irq, dev);
	comedi_pci_disable(dev);