diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-11-26 18:41:56 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-03 12:20:21 -0500 |
commit | c5a9595b2368eee2a4a92ffe30a57f3a45e478bf (patch) | |
tree | 3692efdbf5a3b6557741f0bc9ffd29ff0514fd8c | |
parent | 323cd3559f2443c3d5be511ea298cfadade71c17 (diff) |
staging: comedi: dt2814: tidy up the irq support in dt2814_attach()
An irq is only needed by this driver in order to support async commands.
Since it is optional, modify the attach so that if the request_irq() fails
the attach does not fail.
Remove the printk noise about the irq.
Only hookup the async command support if the request_irq() was successful.
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/dt2814.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index c3f82087ae10..e52d22e0ba63 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c | |||
@@ -235,9 +235,9 @@ static irqreturn_t dt2814_interrupt(int irq, void *d) | |||
235 | static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) | 235 | static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) |
236 | { | 236 | { |
237 | struct dt2814_private *devpriv; | 237 | struct dt2814_private *devpriv; |
238 | int i, irq; | ||
239 | int ret; | ||
240 | struct comedi_subdevice *s; | 238 | struct comedi_subdevice *s; |
239 | int ret; | ||
240 | int i; | ||
241 | 241 | ||
242 | ret = comedi_request_region(dev, it->options[0], DT2814_SIZE); | 242 | ret = comedi_request_region(dev, it->options[0], DT2814_SIZE); |
243 | if (ret) | 243 | if (ret) |
@@ -252,17 +252,11 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
252 | i = inb(dev->iobase + DT2814_DATA); | 252 | i = inb(dev->iobase + DT2814_DATA); |
253 | i = inb(dev->iobase + DT2814_DATA); | 253 | i = inb(dev->iobase + DT2814_DATA); |
254 | 254 | ||
255 | irq = it->options[1]; | 255 | if (it->options[1]) { |
256 | dev->irq = 0; | 256 | ret = request_irq(it->options[1], dt2814_interrupt, 0, |
257 | if (irq > 0) { | 257 | dev->board_name, dev); |
258 | if (request_irq(irq, dt2814_interrupt, 0, "dt2814", dev)) { | 258 | if (ret == 0) |
259 | printk(KERN_WARNING "(irq %d unavailable)\n", irq); | 259 | dev->irq = it->options[1]; |
260 | } else { | ||
261 | printk(KERN_INFO "( irq = %d )\n", irq); | ||
262 | dev->irq = irq; | ||
263 | } | ||
264 | } else if (irq == 0) { | ||
265 | printk(KERN_WARNING "(no irq)\n"); | ||
266 | } | 260 | } |
267 | 261 | ||
268 | ret = comedi_alloc_subdevices(dev, 1); | 262 | ret = comedi_alloc_subdevices(dev, 1); |
@@ -274,16 +268,19 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
274 | return -ENOMEM; | 268 | return -ENOMEM; |
275 | 269 | ||
276 | s = &dev->subdevices[0]; | 270 | s = &dev->subdevices[0]; |
277 | dev->read_subdev = s; | ||
278 | s->type = COMEDI_SUBD_AI; | 271 | s->type = COMEDI_SUBD_AI; |
279 | s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; | 272 | s->subdev_flags = SDF_READABLE | SDF_GROUND; |
280 | s->n_chan = 16; /* XXX */ | 273 | s->n_chan = 16; /* XXX */ |
281 | s->len_chanlist = 1; | ||
282 | s->insn_read = dt2814_ai_insn_read; | 274 | s->insn_read = dt2814_ai_insn_read; |
283 | s->do_cmd = dt2814_ai_cmd; | ||
284 | s->do_cmdtest = dt2814_ai_cmdtest; | ||
285 | s->maxdata = 0xfff; | 275 | s->maxdata = 0xfff; |
286 | s->range_table = &range_unknown; /* XXX */ | 276 | s->range_table = &range_unknown; /* XXX */ |
277 | if (dev->irq) { | ||
278 | dev->read_subdev = s; | ||
279 | s->subdev_flags |= SDF_CMD_READ; | ||
280 | s->len_chanlist = 1; | ||
281 | s->do_cmd = dt2814_ai_cmd; | ||
282 | s->do_cmdtest = dt2814_ai_cmdtest; | ||
283 | } | ||
287 | 284 | ||
288 | return 0; | 285 | return 0; |
289 | } | 286 | } |