[PATCH 09/17] staging: comedi: ni_65xx: hook up command support only if irq is available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Subdevice 3 is used in this driver to provide edge detection of the input
channels.

Move the reset/disable of the interrupts and the request_irq() so that
when subdevice 3 is setup we can conditionally hookup the async command
support only if the irq is available.

Also, remove the noise when the irq is not available.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregk@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_65xx.c | 50 +++++++++++++++++---------------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 74af6c7..3f8176a 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -562,7 +562,17 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
 	if (!devpriv->mmio)
 		return -ENOMEM;
 
-	dev->irq = pcidev->irq;
+	writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
+	       devpriv->mmio + NI_65XX_CLR_REG);
+	writeb(0x00, devpriv->mmio + NI_65XX_CTRL_REG);
+
+	if (pcidev->irq) {
+		ret = request_irq(pcidev->irq, ni_65xx_interrupt, IRQF_SHARED,
+				  dev->board_name, dev);
+		if (ret == 0)
+			dev->irq = pcidev->irq;
+	}
+
 	dev_info(dev->class_dev, "board: %s, ID=0x%02x", dev->board_name,
 	       readb(devpriv->mmio + NI_65XX_ID_REG));
 
@@ -627,36 +637,28 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
 	}
 
 	s = &dev->subdevices[3];
-	dev->read_subdev = s;
-	s->type = COMEDI_SUBD_DI;
-	s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
-	s->n_chan = 1;
-	s->range_table = &range_unknown;
-	s->maxdata = 1;
-	s->len_chanlist	= 1;
-	s->do_cmdtest = ni_65xx_intr_cmdtest;
-	s->do_cmd = ni_65xx_intr_cmd;
-	s->cancel = ni_65xx_intr_cancel;
-	s->insn_bits = ni_65xx_intr_insn_bits;
-	s->insn_config = ni_65xx_intr_insn_config;
+	s->type		= COMEDI_SUBD_DI;
+	s->subdev_flags	= SDF_READABLE;
+	s->n_chan	= 1;
+	s->maxdata	= 1;
+	s->range_table	= &range_digital;
+	s->insn_bits	= ni_65xx_intr_insn_bits;
+	if (dev->irq) {
+		dev->read_subdev = s;
+		s->subdev_flags	|= SDF_CMD_READ;
+		s->len_chanlist	= 1;
+		s->insn_config	= ni_65xx_intr_insn_config;
+		s->do_cmdtest	= ni_65xx_intr_cmdtest;
+		s->do_cmd	= ni_65xx_intr_cmd;
+		s->cancel	= ni_65xx_intr_cancel;
+	}
 
 	for (i = 0; i < ni_65xx_total_num_ports(board); ++i)
 		writeb(0x00, devpriv->mmio + NI_65XX_FILTER_ENA(i));
 
-	writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
-	       devpriv->mmio + NI_65XX_CLR_REG);
-	writeb(0x00, devpriv->mmio + NI_65XX_CTRL_REG);
-
 	/* Set filter interval to 0  (32bit reg) */
 	writel(0x00000000, devpriv->mmio + NI_65XX_FILTER_REG);
 
-	ret = request_irq(dev->irq, ni_65xx_interrupt, IRQF_SHARED,
-			  "ni_65xx", dev);
-	if (ret < 0) {
-		dev->irq = 0;
-		dev_warn(dev->class_dev, "irq not available\n");
-	}
-
 	return 0;
 }
 
-- 
1.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux