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: 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:
parent
42e705e91f
commit
5dfbd5051c
@ -334,6 +334,19 @@ static int ni6527_intr_insn_config(struct comedi_device *dev,
|
|||||||
return insn->n;
|
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,
|
static int ni6527_auto_attach(struct comedi_device *dev,
|
||||||
unsigned long context)
|
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)
|
if (readb(devpriv->mmio_base + NI6527_ID_REG) != 0x27)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
ni6527_reset(dev);
|
||||||
|
|
||||||
ret = comedi_alloc_subdevices(dev, 3);
|
ret = comedi_alloc_subdevices(dev, 3);
|
||||||
if (ret)
|
if (ret)
|
||||||
return 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_bits = ni6527_intr_insn_bits;
|
||||||
s->insn_config = ni6527_intr_insn_config;
|
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,
|
ret = request_irq(pcidev->irq, ni6527_interrupt,
|
||||||
IRQF_SHARED, dev->board_name, dev);
|
IRQF_SHARED, dev->board_name, dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -422,8 +430,7 @@ static void ni6527_detach(struct comedi_device *dev)
|
|||||||
struct ni6527_private *devpriv = dev->private;
|
struct ni6527_private *devpriv = dev->private;
|
||||||
|
|
||||||
if (devpriv && devpriv->mmio_base)
|
if (devpriv && devpriv->mmio_base)
|
||||||
writeb(NI6527_CTRL_DISABLE_IRQS,
|
ni6527_reset(dev);
|
||||||
devpriv->mmio_base + NI6527_CTRL_REG);
|
|
||||||
if (dev->irq)
|
if (dev->irq)
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
comedi_pci_disable(dev);
|
comedi_pci_disable(dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user