diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-11-26 18:42:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-03 12:20:23 -0500 |
commit | ec9b2f4f4fe6012ea426206e6d4f79da8ac19113 (patch) | |
tree | e063938bd95c91921580aa1428291a81287a8681 | |
parent | d4bdba2f602e10ecad17e495ded089085cbd72f2 (diff) |
staging: comedi: ni_atmio16d: tidy up the irq support in atmio16d_attach()
Tidy up the code that does the request_irq().
Only hookup the commad support if the irq was sucessfully requested.
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>
-rw-r--r-- | drivers/staging/comedi/drivers/ni_atmio16d.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 95e98a8cb6a0..35cadc38b7fa 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c | |||
@@ -631,7 +631,6 @@ static int atmio16d_attach(struct comedi_device *dev, | |||
631 | const struct atmio16_board_t *board = comedi_board(dev); | 631 | const struct atmio16_board_t *board = comedi_board(dev); |
632 | struct atmio16d_private *devpriv; | 632 | struct atmio16d_private *devpriv; |
633 | struct comedi_subdevice *s; | 633 | struct comedi_subdevice *s; |
634 | unsigned int irq; | ||
635 | int ret; | 634 | int ret; |
636 | 635 | ||
637 | ret = comedi_request_region(dev, it->options[0], ATMIO16D_SIZE); | 636 | ret = comedi_request_region(dev, it->options[0], ATMIO16D_SIZE); |
@@ -649,19 +648,11 @@ static int atmio16d_attach(struct comedi_device *dev, | |||
649 | /* reset the atmio16d hardware */ | 648 | /* reset the atmio16d hardware */ |
650 | reset_atmio16d(dev); | 649 | reset_atmio16d(dev); |
651 | 650 | ||
652 | /* check if our interrupt is available and get it */ | 651 | if (it->options[1]) { |
653 | irq = it->options[1]; | 652 | ret = request_irq(it->options[1], atmio16d_interrupt, 0, |
654 | if (irq) { | 653 | dev->board_name, dev); |
655 | 654 | if (ret == 0) | |
656 | ret = request_irq(irq, atmio16d_interrupt, 0, "atmio16d", dev); | 655 | dev->irq = it->options[1]; |
657 | if (ret < 0) { | ||
658 | printk(KERN_INFO "failed to allocate irq %u\n", irq); | ||
659 | return ret; | ||
660 | } | ||
661 | dev->irq = irq; | ||
662 | printk(KERN_INFO "( irq = %u )\n", irq); | ||
663 | } else { | ||
664 | printk(KERN_INFO "( no irq )"); | ||
665 | } | 656 | } |
666 | 657 | ||
667 | /* set device options */ | 658 | /* set device options */ |
@@ -677,16 +668,11 @@ static int atmio16d_attach(struct comedi_device *dev, | |||
677 | 668 | ||
678 | /* setup sub-devices */ | 669 | /* setup sub-devices */ |
679 | s = &dev->subdevices[0]; | 670 | s = &dev->subdevices[0]; |
680 | dev->read_subdev = s; | ||
681 | /* ai subdevice */ | 671 | /* ai subdevice */ |
682 | s->type = COMEDI_SUBD_AI; | 672 | s->type = COMEDI_SUBD_AI; |
683 | s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; | 673 | s->subdev_flags = SDF_READABLE | SDF_GROUND; |
684 | s->n_chan = (devpriv->adc_mux ? 16 : 8); | 674 | s->n_chan = (devpriv->adc_mux ? 16 : 8); |
685 | s->len_chanlist = 16; | ||
686 | s->insn_read = atmio16d_ai_insn_read; | 675 | s->insn_read = atmio16d_ai_insn_read; |
687 | s->do_cmdtest = atmio16d_ai_cmdtest; | ||
688 | s->do_cmd = atmio16d_ai_cmd; | ||
689 | s->cancel = atmio16d_ai_cancel; | ||
690 | s->maxdata = 0xfff; /* 4095 decimal */ | 676 | s->maxdata = 0xfff; /* 4095 decimal */ |
691 | switch (devpriv->adc_range) { | 677 | switch (devpriv->adc_range) { |
692 | case adc_bipolar10: | 678 | case adc_bipolar10: |
@@ -699,6 +685,14 @@ static int atmio16d_attach(struct comedi_device *dev, | |||
699 | s->range_table = &range_atmio16d_ai_unipolar; | 685 | s->range_table = &range_atmio16d_ai_unipolar; |
700 | break; | 686 | break; |
701 | } | 687 | } |
688 | if (dev->irq) { | ||
689 | dev->read_subdev = s; | ||
690 | s->subdev_flags |= SDF_CMD_READ; | ||
691 | s->len_chanlist = 16; | ||
692 | s->do_cmdtest = atmio16d_ai_cmdtest; | ||
693 | s->do_cmd = atmio16d_ai_cmd; | ||
694 | s->cancel = atmio16d_ai_cancel; | ||
695 | } | ||
702 | 696 | ||
703 | /* ao subdevice */ | 697 | /* ao subdevice */ |
704 | s = &dev->subdevices[1]; | 698 | s = &dev->subdevices[1]; |