* [PATCH] Staging: quatech_usb2: Convert eos semaphore to mutex
@ 2010-05-15 21:40 Alessio Igor Bogani
2010-05-15 21:55 ` Oliver Neukum
0 siblings, 1 reply; 5+ messages in thread
From: Alessio Igor Bogani @ 2010-05-15 21:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dominik Brodowski, Bill Pemberton,
Jiri Kosina, Javier Martinez Canillas
Cc: devel, linux-kernel, Alessio Igor Bogani
The eos semaphore is used as a mutex so replace it with a real mutex.
Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
drivers/staging/comedi/drivers/quatech_daqp_cs.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 6e9f482..3076666 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -67,7 +67,7 @@ struct local_info_t {
enum { semaphore, buffer } interrupt_mode;
- struct semaphore eos;
+ struct mutex eos;
struct comedi_device *dev;
struct comedi_subdevice *s;
@@ -238,7 +238,7 @@ static int daqp_ai_cancel(struct comedi_device *dev, struct 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 mutex 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,
@@ -287,7 +287,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
case semaphore:
- up(&local->eos);
+ mutex_unlock(&local->eos);
break;
case buffer:
@@ -401,8 +401,9 @@ static int daqp_ai_insn_read(struct comedi_device *dev,
return -1;
}
- /* Make sure semaphore is blocked */
- sema_init(&local->eos, 0);
+ mutex_init(&local->eos);
+ /* Make sure mutex is blocked */
+ mutex_lock(&local->eos);
local->interrupt_mode = semaphore;
local->dev = dev;
local->s = s;
@@ -413,9 +414,9 @@ static int daqp_ai_insn_read(struct comedi_device *dev,
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 mutex */
/* Maybe could use a timeout here, but it's interruptible */
- if (down_interruptible(&local->eos))
+ if (mutex_lock_interruptible(&local->eos))
return -EINTR;
data[i] = inb(dev->iobase + DAQP_FIFO);
--
1.7.0.4
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] Staging: quatech_usb2: Convert eos semaphore to mutex
2010-05-15 21:40 [PATCH] Staging: quatech_usb2: Convert eos semaphore to mutex Alessio Igor Bogani
@ 2010-05-15 21:55 ` Oliver Neukum
2010-05-15 22:08 ` Alessio Igor Bogani
0 siblings, 1 reply; 5+ messages in thread
From: Oliver Neukum @ 2010-05-15 21:55 UTC (permalink / raw)
To: Alessio Igor Bogani
Cc: Greg Kroah-Hartman, Dominik Brodowski, Bill Pemberton,
Jiri Kosina, Javier Martinez Canillas, devel, linux-kernel
Am Samstag, 15. Mai 2010 23:40:02 schrieb Alessio Igor Bogani:
> The eos semaphore is used as a mutex so replace it with a real mutex.
Documentation/mutex-design.txt states that a mutex must not be used
from within an interrupt handler. Is this outdated?
Regards
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Staging: quatech_usb2: Convert eos semaphore to mutex
2010-05-15 21:55 ` Oliver Neukum
@ 2010-05-15 22:08 ` Alessio Igor Bogani
2010-05-16 20:45 ` Arjan van de Ven
0 siblings, 1 reply; 5+ messages in thread
From: Alessio Igor Bogani @ 2010-05-15 22:08 UTC (permalink / raw)
To: Oliver Neukum
Cc: Greg Kroah-Hartman, Dominik Brodowski, Bill Pemberton,
Jiri Kosina, Javier Martinez Canillas, devel, linux-kernel
Hi Oliver,
2010/5/15 Oliver Neukum <oliver@neukum.org>:
> Am Samstag, 15. Mai 2010 23:40:02 schrieb Alessio Igor Bogani:
>> The eos semaphore is used as a mutex so replace it with a real mutex.
>
> Documentation/mutex-design.txt states that a mutex must not be used
> from within an interrupt handler. Is this outdated?
You are right. Simply I didn't see irqreturn_t return type in function
prototype.
Sorry for my mistake.
Ciao,
Alessio
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Staging: quatech_usb2: Convert eos semaphore to mutex
2010-05-15 22:08 ` Alessio Igor Bogani
@ 2010-05-16 20:45 ` Arjan van de Ven
2010-05-18 11:12 ` [PATCH] Staging: comedi: quatech_daqp_cs.c Replace eos semaphore with a completion Alessio Igor Bogani
0 siblings, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2010-05-16 20:45 UTC (permalink / raw)
To: Alessio Igor Bogani
Cc: Oliver Neukum, Greg Kroah-Hartman, Dominik Brodowski,
Bill Pemberton, Jiri Kosina, Javier Martinez Canillas, devel,
linux-kernel
On Sun, 16 May 2010 00:08:30 +0200
Alessio Igor Bogani <abogani@texware.it> wrote:
> Hi Oliver,
>
> 2010/5/15 Oliver Neukum <oliver@neukum.org>:
> > Am Samstag, 15. Mai 2010 23:40:02 schrieb Alessio Igor Bogani:
> >> The eos semaphore is used as a mutex so replace it with a real
> >> mutex.
> >
> > Documentation/mutex-design.txt states that a mutex must not be used
> > from within an interrupt handler. Is this outdated?
>
> You are right. Simply I didn't see irqreturn_t return type in function
> prototype.
>
> Sorry for my mistake.
>
you might want to convert it to a completion....
that sounds more the usage model that the driver here is doing
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Staging: comedi: quatech_daqp_cs.c Replace eos semaphore with a completion.
2010-05-16 20:45 ` Arjan van de Ven
@ 2010-05-18 11:12 ` Alessio Igor Bogani
0 siblings, 0 replies; 5+ messages in thread
From: Alessio Igor Bogani @ 2010-05-18 11:12 UTC (permalink / raw)
To: Greg Kroah-Hartman, Oliver Neukum, Arjan van de Ven,
Dominik Brodowski, Bill Pemberton, Jiri Kosina,
Javier Martinez Canillas, Alexander Kurz
Cc: linux-kernel, Alessio Igor Bogani
Build tested only.
Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
drivers/staging/comedi/drivers/quatech_daqp_cs.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 197c302..a91db6c 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -56,6 +56,8 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308
#include <pcmcia/cisreg.h>
#include <pcmcia/ds.h>
+#include <linux/completion.h>
+
/* Maximum number of separate DAQP devices we'll allow */
#define MAX_DEV 4
@@ -67,7 +69,7 @@ struct local_info_t {
enum { semaphore, buffer } interrupt_mode;
- struct semaphore eos;
+ struct completion eos;
struct comedi_device *dev;
struct comedi_subdevice *s;
@@ -238,7 +240,7 @@ static int daqp_ai_cancel(struct comedi_device *dev, struct 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,
@@ -287,7 +289,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
case semaphore:
- up(&local->eos);
+ complete(&local->eos);
break;
case buffer:
@@ -401,8 +403,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev,
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;
@@ -413,9 +414,9 @@ static int daqp_ai_insn_read(struct comedi_device *dev,
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);
--
1.7.0.4
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-18 11:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-15 21:40 [PATCH] Staging: quatech_usb2: Convert eos semaphore to mutex Alessio Igor Bogani
2010-05-15 21:55 ` Oliver Neukum
2010-05-15 22:08 ` Alessio Igor Bogani
2010-05-16 20:45 ` Arjan van de Ven
2010-05-18 11:12 ` [PATCH] Staging: comedi: quatech_daqp_cs.c Replace eos semaphore with a completion Alessio Igor Bogani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®