From 9091a714c07a97bf364d7252fdee66f591b55f04 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 30 Sep 2010 16:31:27 +0000 Subject: [PATCH] quatech_daqp_cs: Replace eos semaphore with a completion. Build tested only. Note: the wait_for_completion_interruptible() function needs 2.6.11 kernel or above, but I'm pretty sure this driver (and other PCMCIA drivers) is currently broken for those kernels anyway, so I'm not bothering to implement the function in compatibility headers just yet. --- comedi/drivers/quatech_daqp_cs.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/comedi/drivers/quatech_daqp_cs.c b/comedi/drivers/quatech_daqp_cs.c index c963ff41..1e5da6ff 100644 --- a/comedi/drivers/quatech_daqp_cs.c +++ b/comedi/drivers/quatech_daqp_cs.c @@ -57,6 +57,8 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308 #include #include +#include + /* All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If you do not define PCMCIA_DEBUG at all, all the debug code will be @@ -88,7 +90,7 @@ typedef struct local_info_t { enum { semaphore, buffer } interrupt_mode; - struct semaphore eos; + struct completion eos; comedi_device *dev; comedi_subdevice *s; @@ -259,7 +261,7 @@ static int daqp_ai_cancel(comedi_device * dev, comedi_subdevice * s) /* Interrupt handler * * Operates in one of two modes. If local->interrupt_mode is - * 'semaphore', just signal the local->eos semaphore and return + * 'semaphore', just signal the local->eos completion and return * (one-shot mode). Otherwise (continuous mode), read data in from * the card, transfer it to the buffer provided by the higher-level * comedi kernel module, and signal various comedi callback routines, @@ -320,7 +322,7 @@ static my_irqreturn_t daqp_interrupt(int irq, void *dev_id PT_REGS_ARG) case semaphore: - up(&local->eos); + complete(&local->eos); break; case buffer: @@ -433,8 +435,7 @@ static int daqp_ai_insn_read(comedi_device * dev, comedi_subdevice * s, return -1; } - /* Make sure semaphore is blocked */ - sema_init(&local->eos, 0); + init_completion(&local->eos); local->interrupt_mode = semaphore; local->dev = dev; local->s = s; @@ -445,9 +446,9 @@ static int daqp_ai_insn_read(comedi_device * dev, comedi_subdevice * s, outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA, dev->iobase + DAQP_COMMAND); - /* Wait for interrupt service routine to unblock semaphore */ + /* Wait for interrupt service routine to unblock completion */ /* Maybe could use a timeout here, but it's interruptible */ - if (down_interruptible(&local->eos)) + if (wait_for_completion_interruptible(&local->eos)) return -EINTR; data[i] = inb(dev->iobase + DAQP_FIFO); -- 2.26.2