aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-04-22 21:33:03 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-23 13:41:38 -0400
commitfe9b0850ab8f6f5a91a170cca07d24a2afb4ceb9 (patch)
tree93a224f5d1e5ac81b9a777e2282884b28dd3d23a
parent62c3b4bf66bfff62faf4556ee5ba251ba5e8b506 (diff)
staging: comedi: das800: remove forward declarations
Move the das800_cancel() and das800_interrupt() functions to remove the need for the remaining forward declarations. 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/das800.c225
1 files changed, 109 insertions, 116 deletions
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
index 596be5e991b6..18e2ac02aff1 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -228,122 +228,6 @@ struct das800_private {
228 volatile int do_bits; /* digital output bits */ 228 volatile int do_bits; /* digital output bits */
229}; 229};
230 230
231static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
232
233static irqreturn_t das800_interrupt(int irq, void *d);
234static void enable_das800(struct comedi_device *dev);
235static void disable_das800(struct comedi_device *dev);
236
237/* interrupt service routine */
238static irqreturn_t das800_interrupt(int irq, void *d)
239{
240 short i; /* loop index */
241 short dataPoint = 0;
242 struct comedi_device *dev = d;
243 const struct das800_board *thisboard = comedi_board(dev);
244 struct das800_private *devpriv = dev->private;
245 struct comedi_subdevice *s = dev->read_subdev; /* analog input subdevice */
246 struct comedi_async *async;
247 int status;
248 unsigned long irq_flags;
249 static const int max_loops = 128; /* half-fifo size for cio-das802/16 */
250 /* flags */
251 int fifo_empty = 0;
252 int fifo_overflow = 0;
253
254 status = inb(dev->iobase + DAS800_STATUS);
255 /* if interrupt was not generated by board or driver not attached, quit */
256 if (!(status & IRQ))
257 return IRQ_NONE;
258 if (!(dev->attached))
259 return IRQ_HANDLED;
260
261 /* wait until here to initialize async, since we will get null dereference
262 * if interrupt occurs before driver is fully attached!
263 */
264 async = s->async;
265
266 /* if hardware conversions are not enabled, then quit */
267 spin_lock_irqsave(&dev->spinlock, irq_flags);
268 outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */
269 status = inb(dev->iobase + DAS800_STATUS2) & STATUS2_HCEN;
270 /* don't release spinlock yet since we want to make sure no one else disables hardware conversions */
271 if (status == 0) {
272 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
273 return IRQ_HANDLED;
274 }
275
276 /* loop while card's fifo is not empty (and limit to half fifo for cio-das802/16) */
277 for (i = 0; i < max_loops; i++) {
278 /* read 16 bits from dev->iobase and dev->iobase + 1 */
279 dataPoint = inb(dev->iobase + DAS800_LSB);
280 dataPoint += inb(dev->iobase + DAS800_MSB) << 8;
281 if (thisboard->resolution == 12) {
282 fifo_empty = dataPoint & FIFO_EMPTY;
283 fifo_overflow = dataPoint & FIFO_OVF;
284 if (fifo_overflow)
285 break;
286 } else {
287 fifo_empty = 0; /* cio-das802/16 has no fifo empty status bit */
288 }
289 if (fifo_empty)
290 break;
291 /* strip off extraneous bits for 12 bit cards */
292 if (thisboard->resolution == 12)
293 dataPoint = (dataPoint >> 4) & 0xfff;
294 /* if there are more data points to collect */
295 if (devpriv->count > 0 || devpriv->forever == 1) {
296 /* write data point to buffer */
297 cfc_write_to_buffer(s, dataPoint);
298 if (devpriv->count > 0)
299 devpriv->count--;
300 }
301 }
302 async->events |= COMEDI_CB_BLOCK;
303 /* check for fifo overflow */
304 if (thisboard->resolution == 12) {
305 fifo_overflow = dataPoint & FIFO_OVF;
306 /* else cio-das802/16 */
307 } else {
308 fifo_overflow = inb(dev->iobase + DAS800_GAIN) & CIO_FFOV;
309 }
310 if (fifo_overflow) {
311 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
312 comedi_error(dev, "DAS800 FIFO overflow");
313 das800_cancel(dev, s);
314 async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
315 comedi_event(dev, s);
316 async->events = 0;
317 return IRQ_HANDLED;
318 }
319 if (devpriv->count > 0 || devpriv->forever == 1) {
320 /* Re-enable card's interrupt.
321 * We already have spinlock, so indirect addressing is safe */
322 outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
323 outb(CONTROL1_INTE | devpriv->do_bits,
324 dev->iobase + DAS800_CONTROL1);
325 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
326 /* otherwise, stop taking data */
327 } else {
328 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
329 disable_das800(dev); /* disable hardware triggered conversions */
330 async->events |= COMEDI_CB_EOA;
331 }
332 comedi_event(dev, s);
333 async->events = 0;
334 return IRQ_HANDLED;
335}
336
337static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
338{
339 struct das800_private *devpriv = dev->private;
340
341 devpriv->forever = 0;
342 devpriv->count = 0;
343 disable_das800(dev);
344 return 0;
345}
346
347/* enable_das800 makes the card start taking hardware triggered conversions */ 231/* enable_das800 makes the card start taking hardware triggered conversions */
348static void enable_das800(struct comedi_device *dev) 232static void enable_das800(struct comedi_device *dev)
349{ 233{
@@ -387,6 +271,16 @@ static int das800_set_frequency(struct comedi_device *dev)
387 return 0; 271 return 0;
388} 272}
389 273
274static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
275{
276 struct das800_private *devpriv = dev->private;
277
278 devpriv->forever = 0;
279 devpriv->count = 0;
280 disable_das800(dev);
281 return 0;
282}
283
390static int das800_ai_do_cmdtest(struct comedi_device *dev, 284static int das800_ai_do_cmdtest(struct comedi_device *dev,
391 struct comedi_subdevice *s, 285 struct comedi_subdevice *s,
392 struct comedi_cmd *cmd) 286 struct comedi_cmd *cmd)
@@ -564,6 +458,105 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
564 return 0; 458 return 0;
565} 459}
566 460
461static irqreturn_t das800_interrupt(int irq, void *d)
462{
463 short i; /* loop index */
464 short dataPoint = 0;
465 struct comedi_device *dev = d;
466 const struct das800_board *thisboard = comedi_board(dev);
467 struct das800_private *devpriv = dev->private;
468 struct comedi_subdevice *s = dev->read_subdev; /* analog input subdevice */
469 struct comedi_async *async;
470 int status;
471 unsigned long irq_flags;
472 static const int max_loops = 128; /* half-fifo size for cio-das802/16 */
473 /* flags */
474 int fifo_empty = 0;
475 int fifo_overflow = 0;
476
477 status = inb(dev->iobase + DAS800_STATUS);
478 /* if interrupt was not generated by board or driver not attached, quit */
479 if (!(status & IRQ))
480 return IRQ_NONE;
481 if (!(dev->attached))
482 return IRQ_HANDLED;
483
484 /* wait until here to initialize async, since we will get null dereference
485 * if interrupt occurs before driver is fully attached!
486 */
487 async = s->async;
488
489 /* if hardware conversions are not enabled, then quit */
490 spin_lock_irqsave(&dev->spinlock, irq_flags);
491 outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */
492 status = inb(dev->iobase + DAS800_STATUS2) & STATUS2_HCEN;
493 /* don't release spinlock yet since we want to make sure no one else disables hardware conversions */
494 if (status == 0) {
495 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
496 return IRQ_HANDLED;
497 }
498
499 /* loop while card's fifo is not empty (and limit to half fifo for cio-das802/16) */
500 for (i = 0; i < max_loops; i++) {
501 /* read 16 bits from dev->iobase and dev->iobase + 1 */
502 dataPoint = inb(dev->iobase + DAS800_LSB);
503 dataPoint += inb(dev->iobase + DAS800_MSB) << 8;
504 if (thisboard->resolution == 12) {
505 fifo_empty = dataPoint & FIFO_EMPTY;
506 fifo_overflow = dataPoint & FIFO_OVF;
507 if (fifo_overflow)
508 break;
509 } else {
510 fifo_empty = 0; /* cio-das802/16 has no fifo empty status bit */
511 }
512 if (fifo_empty)
513 break;
514 /* strip off extraneous bits for 12 bit cards */
515 if (thisboard->resolution == 12)
516 dataPoint = (dataPoint >> 4) & 0xfff;
517 /* if there are more data points to collect */
518 if (devpriv->count > 0 || devpriv->forever == 1) {
519 /* write data point to buffer */
520 cfc_write_to_buffer(s, dataPoint);
521 if (devpriv->count > 0)
522 devpriv->count--;
523 }
524 }
525 async->events |= COMEDI_CB_BLOCK;
526 /* check for fifo overflow */
527 if (thisboard->resolution == 12) {
528 fifo_overflow = dataPoint & FIFO_OVF;
529 /* else cio-das802/16 */
530 } else {
531 fifo_overflow = inb(dev->iobase + DAS800_GAIN) & CIO_FFOV;
532 }
533 if (fifo_overflow) {
534 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
535 comedi_error(dev, "DAS800 FIFO overflow");
536 das800_cancel(dev, s);
537 async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
538 comedi_event(dev, s);
539 async->events = 0;
540 return IRQ_HANDLED;
541 }
542 if (devpriv->count > 0 || devpriv->forever == 1) {
543 /* Re-enable card's interrupt.
544 * We already have spinlock, so indirect addressing is safe */
545 outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
546 outb(CONTROL1_INTE | devpriv->do_bits,
547 dev->iobase + DAS800_CONTROL1);
548 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
549 /* otherwise, stop taking data */
550 } else {
551 spin_unlock_irqrestore(&dev->spinlock, irq_flags);
552 disable_das800(dev); /* disable hardware triggered conversions */
553 async->events |= COMEDI_CB_EOA;
554 }
555 comedi_event(dev, s);
556 async->events = 0;
557 return IRQ_HANDLED;
558}
559
567static int das800_ai_rinsn(struct comedi_device *dev, 560static int das800_ai_rinsn(struct comedi_device *dev,
568 struct comedi_subdevice *s, struct comedi_insn *insn, 561 struct comedi_subdevice *s, struct comedi_insn *insn,
569 unsigned int *data) 562 unsigned int *data)