#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
+#include <linux/mutex.h>
#include <asm/mach-types.h>
#include <asm/mach/irq.h>
struct menelaus_chip {
unsigned long initialized;
- struct semaphore lock;
+ struct mutex lock;
struct i2c_client client;
struct work_struct work;
int irq;
/* Adds a handler for an interrupt. Does not run in interrupt context */
static int menelaus_add_irq_work(int irq, void * handler)
{
- down(&menelaus.lock);
+ mutex_lock(&menelaus.lock);
menelaus.handlers[irq] = handler;
menelaus_enable_irq(irq);
- up(&menelaus.lock);
+ mutex_unlock(&menelaus.lock);
return 0;
}
/* Removes handler for an interrupt */
static void menelaus_remove_irq_work(int irq)
{
- down(&menelaus.lock);
+ mutex_lock(&menelaus.lock);
menelaus_disable_irq(irq);
menelaus.handlers[irq] = NULL;
- up(&menelaus.lock);
+ mutex_unlock(&menelaus.lock);
}
/*-----------------------------------------------------------------------*/
for (i = 0; i < IH_MENELAUS_IRQS; i++) {
if (isr & (1 << i)) {
- down(&menelaus->lock);
+ mutex_lock(&menelaus->lock);
menelaus_disable_irq(i);
menelaus_ack_irq(i);
if (menelaus->handlers[i]) {
handler(menelaus);
}
menelaus_enable_irq(i);
- up(&menelaus->lock);
+ mutex_unlock(&menelaus->lock);
}
}
}
if (err)
printk(KERN_ERR "Could not get Menelaus IRQ\n");
- init_MUTEX(&menelaus.lock);
+ mutex_init(&menelaus.lock);
INIT_WORK(&menelaus.work, menelaus_work, &menelaus);
if (kind < 0)