提交 72ba9f0c 编写于 作者: I Ingo Molnar 提交者: Dmitry Torokhov

Input: joysticks - semaphore to mutex conversion

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Amijoy conversion was done by Arjan van de Ven.
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 33d3f07a
......@@ -36,6 +36,7 @@
#include <linux/init.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <asm/system.h>
#include <asm/amigahw.h>
......@@ -52,7 +53,7 @@ MODULE_PARM_DESC(map, "Map of attached joysticks in form of <a>,<b> (default is
__obsolete_setup("amijoy=");
static int amijoy_used;
static DECLARE_MUTEX(amijoy_sem);
static DEFINE_MUTEX(amijoy_mutex);
static struct input_dev *amijoy_dev[2];
static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" };
......@@ -85,7 +86,7 @@ static int amijoy_open(struct input_dev *dev)
{
int err;
err = down_interruptible(&amijoy_sem);
err = mutex_lock_interruptible(&amijoy_mutex);
if (err)
return err;
......@@ -97,16 +98,16 @@ static int amijoy_open(struct input_dev *dev)
amijoy_used++;
out:
up(&amijoy_sem);
mutex_unlock(&amijoy_mutex);
return err;
}
static void amijoy_close(struct input_dev *dev)
{
down(&amijoy_sem);
mutex_lock(&amijoy_mutex);
if (!--amijoy_used)
free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt);
up(&amijoy_sem);
mutex_unlock(&amijoy_mutex);
}
static int __init amijoy_init(void)
......
......@@ -38,6 +38,7 @@
#include <linux/init.h>
#include <linux/parport.h>
#include <linux/input.h>
#include <linux/mutex.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver");
......@@ -111,7 +112,7 @@ struct db9 {
struct pardevice *pd;
int mode;
int used;
struct semaphore sem;
struct mutex mutex;
char phys[DB9_MAX_DEVICES][32];
};
......@@ -525,7 +526,7 @@ static int db9_open(struct input_dev *dev)
struct parport *port = db9->pd->port;
int err;
err = down_interruptible(&db9->sem);
err = mutex_lock_interruptible(&db9->mutex);
if (err)
return err;
......@@ -539,7 +540,7 @@ static int db9_open(struct input_dev *dev)
mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME);
}
up(&db9->sem);
mutex_unlock(&db9->mutex);
return 0;
}
......@@ -548,14 +549,14 @@ static void db9_close(struct input_dev *dev)
struct db9 *db9 = dev->private;
struct parport *port = db9->pd->port;
down(&db9->sem);
mutex_lock(&db9->mutex);
if (!--db9->used) {
del_timer_sync(&db9->timer);
parport_write_control(port, 0x00);
parport_data_forward(port);
parport_release(db9->pd);
}
up(&db9->sem);
mutex_unlock(&db9->mutex);
}
static struct db9 __init *db9_probe(int parport, int mode)
......@@ -603,7 +604,7 @@ static struct db9 __init *db9_probe(int parport, int mode)
goto err_unreg_pardev;
}
init_MUTEX(&db9->sem);
mutex_init(&db9->mutex);
db9->pd = pd;
db9->mode = mode;
init_timer(&db9->timer);
......
......@@ -36,6 +36,7 @@
#include <linux/init.h>
#include <linux/parport.h>
#include <linux/input.h>
#include <linux/mutex.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver");
......@@ -83,7 +84,7 @@ struct gc {
struct timer_list timer;
unsigned char pads[GC_MAX + 1];
int used;
struct semaphore sem;
struct mutex mutex;
char phys[GC_MAX_DEVICES][32];
};
......@@ -552,7 +553,7 @@ static int gc_open(struct input_dev *dev)
struct gc *gc = dev->private;
int err;
err = down_interruptible(&gc->sem);
err = mutex_lock_interruptible(&gc->mutex);
if (err)
return err;
......@@ -562,7 +563,7 @@ static int gc_open(struct input_dev *dev)
mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
}
up(&gc->sem);
mutex_unlock(&gc->mutex);
return 0;
}
......@@ -570,13 +571,13 @@ static void gc_close(struct input_dev *dev)
{
struct gc *gc = dev->private;
down(&gc->sem);
mutex_lock(&gc->mutex);
if (!--gc->used) {
del_timer_sync(&gc->timer);
parport_write_control(gc->pd->port, 0x00);
parport_release(gc->pd);
}
up(&gc->sem);
mutex_unlock(&gc->mutex);
}
static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
......@@ -693,7 +694,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
goto err_unreg_pardev;
}
init_MUTEX(&gc->sem);
mutex_init(&gc->mutex);
gc->pd = pd;
init_timer(&gc->timer);
gc->timer.data = (long) gc;
......
......@@ -42,14 +42,14 @@ static int make_magnitude_modifier(struct iforce* iforce,
unsigned char data[3];
if (!no_alloc) {
down(&iforce->mem_mutex);
mutex_lock(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 2,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
return -ENOMEM;
}
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
}
data[0] = LO(mod_chunk->start);
......@@ -75,14 +75,14 @@ static int make_period_modifier(struct iforce* iforce,
period = TIME_SCALE(period);
if (!no_alloc) {
down(&iforce->mem_mutex);
mutex_lock(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
return -ENOMEM;
}
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
}
data[0] = LO(mod_chunk->start);
......@@ -115,14 +115,14 @@ static int make_envelope_modifier(struct iforce* iforce,
fade_duration = TIME_SCALE(fade_duration);
if (!no_alloc) {
down(&iforce->mem_mutex);
mutex_lock(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
return -ENOMEM;
}
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
}
data[0] = LO(mod_chunk->start);
......@@ -152,14 +152,14 @@ static int make_condition_modifier(struct iforce* iforce,
unsigned char data[10];
if (!no_alloc) {
down(&iforce->mem_mutex);
mutex_lock(&iforce->mem_mutex);
if (allocate_resource(&(iforce->device_memory), mod_chunk, 8,
iforce->device_memory.start, iforce->device_memory.end, 2L,
NULL, NULL)) {
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
return -ENOMEM;
}
up(&iforce->mem_mutex);
mutex_unlock(&iforce->mem_mutex);
}
data[0] = LO(mod_chunk->start);
......
......@@ -350,7 +350,7 @@ int iforce_init_device(struct iforce *iforce)
init_waitqueue_head(&iforce->wait);
spin_lock_init(&iforce->xmit_lock);
init_MUTEX(&iforce->mem_mutex);
mutex_init(&iforce->mem_mutex);
iforce->xmit.buf = iforce->xmit_data;
iforce->dev = input_dev;
......
......@@ -37,7 +37,7 @@
#include <linux/serio.h>
#include <linux/config.h>
#include <linux/circ_buf.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>
/* This module provides arbitrary resource management routines.
* I use it to manage the device's memory.
......@@ -45,6 +45,7 @@
*/
#include <linux/ioport.h>
#define IFORCE_MAX_LENGTH 16
/* iforce::bus */
......@@ -146,7 +147,7 @@ struct iforce {
wait_queue_head_t wait;
struct resource device_memory;
struct iforce_core_effect core_effects[FF_EFFECTS_MAX];
struct semaphore mem_mutex;
struct mutex mem_mutex;
};
/* Get hi and low bytes of a 16-bits int */
......
......@@ -37,6 +37,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/mutex.h>
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("TurboGraFX parallel port interface driver");
......@@ -86,7 +87,7 @@ static struct tgfx {
char phys[TGFX_MAX_DEVICES][32];
int sticks;
int used;
struct semaphore sem;
struct mutex sem;
} *tgfx_base[TGFX_MAX_PORTS];
/*
......@@ -128,7 +129,7 @@ static int tgfx_open(struct input_dev *dev)
struct tgfx *tgfx = dev->private;
int err;
err = down_interruptible(&tgfx->sem);
err = mutex_lock_interruptible(&tgfx->sem);
if (err)
return err;
......@@ -138,7 +139,7 @@ static int tgfx_open(struct input_dev *dev)
mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME);
}
up(&tgfx->sem);
mutex_unlock(&tgfx->sem);
return 0;
}
......@@ -146,13 +147,13 @@ static void tgfx_close(struct input_dev *dev)
{
struct tgfx *tgfx = dev->private;
down(&tgfx->sem);
mutex_lock(&tgfx->sem);
if (!--tgfx->used) {
del_timer_sync(&tgfx->timer);
parport_write_control(tgfx->pd->port, 0x00);
parport_release(tgfx->pd);
}
up(&tgfx->sem);
mutex_unlock(&tgfx->sem);
}
......@@ -191,7 +192,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
goto err_unreg_pardev;
}
init_MUTEX(&tgfx->sem);
mutex_init(&tgfx->sem);
tgfx->pd = pd;
init_timer(&tgfx->timer);
tgfx->timer.data = (long) tgfx;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册